Ghost/make_figs.py
def load_calcghosts(self,options,loadfile=None): 
        """Load the calculated ghosts from a single file or a directory"""
        if options.loaddir:
            # Load all files in the directory specified
            import os
            if os.path.isdir(options.loaddir):
                files=os.listdir(options.loaddir)
                okfiles=[]
                for fn in files:
                    txt='_H.pdb.pickle'
                    size=len(txt)
                    if fn[-size:]!=txt:
                        continue
                    okfiles.append(fn)
                
                print 'Found %3d files with calculated ghosts' %len(okfiles)
                C=False
                count=1
                for fn in sorted(okfiles):
                    print 'Reading # %3d with name: %s' %(count,fn)
                    count=count+1
                    realfile=os.path.join(options.loaddir,fn)
                    fd=open(realfile)
                    import pickle
                    data=pickle.load(fd)
                    fd.close()
                    if not C:
                        C=data.copy()
                    #
                    for datatype in data.keys():
                        for diel in data[datatype].keys():
                            if not C[datatype].has_key(diel):
                                C[datatype][diel]={}
                            for TG in data[datatype][diel].keys():
                                if not C[datatype][diel].has_key(TG):
                                    C[datatype][diel][TG]={}
                                for residue in data[datatype][diel][TG].keys():
                                    if not C[datatype][diel][TG].has_key(residue):
                                        C[datatype][diel][TG][residue]={}
                                    for nucleus in data[datatype][diel][TG][residue].keys():
                                        if not C[datatype][diel][TG][residue].has_key(nucleus):
                                            C[datatype][diel][TG][residue][nucleus]=[]
                                        #
                                        value=data[datatype][diel][TG][residue][nucleus]
                                        
                                        if not type(C[datatype][diel][TG][residue][nucleus]) is type([]):
                                            C[datatype][diel][TG][residue][nucleus]=[]
                                        C[datatype][diel][TG][residue][nucleus].append(value)
                #
                # Get the averages and standard deviations    
                #
                calc_ghosts=self.calculate_average(C)
                avgfile=options.avgfile
                print 'Saving average ghosts to %s' %avgfile
                fd=open(avgfile,'w')
                import pickle
                pickle.dump(calc_ghosts,fd)
                fd.close()
            else:
                raise Exception('Not a directory: %s' %options.loaddir)
        else:
            # 
            # Load just a single file
            #
            filename=options.calcghosts
            if loadfile:
                filename=loadfile 
            fd=open(filename)
            import pickle
            print 'Reading calculated ghosts from %s' %filename
            calc_ghosts=pickle.load(fd)
            fd.close()
        return calc_ghosts
Load the calculated ghosts from a single file or a directory
Load the calculated ghosts from a single file or a directory
Load the calculated ghosts from a single file or a directory
def load_calcghosts(self,options,loadfile=None): 
        if options.loaddir:
            import os
            if os.path.isdir(options.loaddir):
                files=os.listdir(options.loaddir)
                okfiles=[]
                for fn in files:
                    txt='_H.pdb.pickle'
                    size=len(txt)
                    if fn[-size:]!=txt:
                        continue
                    okfiles.append(fn)
                print 'Found %3d files with calculated ghosts' %len(okfiles)
                C=False
                count=1
                for fn in sorted(okfiles):
                    print 'Reading  %3d with name: %s' %(count,fn)
                    count=count+1
                    realfile=os.path.join(options.loaddir,fn)
                    fd=open(realfile)
                    import pickle
                    data=pickle.load(fd)
                    fd.close()
                    if not C:
                        C=data.copy()
                    for datatype in data.keys():
                        for diel in data[datatype].keys():
                            if not C[datatype].has_key(diel):
                                C[datatype][diel]={}
                            for TG in data[datatype][diel].keys():
                                if not C[datatype][diel].has_key(TG):
                                    C[datatype][diel][TG]={}
                                for residue in data[datatype][diel][TG].keys():
                                    if not C[datatype][diel][TG].has_key(residue):
                                        C[datatype][diel][TG][residue]={}
                                    for nucleus in data[datatype][diel][TG][residue].keys():
                                        if not C[datatype][diel][TG][residue].has_key(nucleus):
                                            C[datatype][diel][TG][residue][nucleus]=[]
                                        value=data[datatype][diel][TG][residue][nucleus]
                                        if not type(C[datatype][diel][TG][residue][nucleus]) is type([]):
                                            C[datatype][diel][TG][residue][nucleus]=[]
                                        C[datatype][diel][TG][residue][nucleus].append(value)
                 Get the averages and standard deviations    
                calc_ghosts=self.calculate_average(C)
                avgfile=options.avgfile
                print 'Saving average ghosts to %s' %avgfile
                fd=open(avgfile,'w')
                import pickle
                pickle.dump(calc_ghosts,fd)
                fd.close()
            else:
                raise Exception('Not a directory: %s' %options.loaddir)
        else:
             Load just a single file
            filename=options.calcghosts
            if loadfile:
                filename=loadfile 
            fd=open(filename)
            import pickle
            print 'Reading calculated ghosts from %s' %filename
            calc_ghosts=pickle.load(fd)
            fd.close()
        return calc_ghosts
def load_calcghosts ( self , options , loadfile = None ) : if options . loaddir : import os if os . path . isdir ( options . loaddir ) : files = os . listdir ( options . loaddir ) okfiles = [ ] for fn in files : txt = '_H.pdb.pickle' size = len ( txt ) if fn [ - size : ] != txt : continue okfiles . append ( fn ) print 'Found %3d files with calculated ghosts' % len ( okfiles ) C = False count = 1 for fn in sorted ( okfiles ) : print 'Reading # %3d with name: %s' % ( count , fn ) count = count + 1 realfile = os . path . join ( options . loaddir , fn ) fd = open ( realfile ) import pickle data = pickle . load ( fd ) fd . close ( ) if not C : C = data . copy ( ) for datatype in data . keys ( ) : for diel in data [ datatype ] . keys ( ) : if not C [ datatype ] . has_key ( diel ) : C [ datatype ] [ diel ] = { } for TG in data [ datatype ] [ diel ] . keys ( ) : if not C [ datatype ] [ diel ] . has_key ( TG ) : C [ datatype ] [ diel ] [ TG ] = { } for residue in data [ datatype ] [ diel ] [ TG ] . keys ( ) : if not C [ datatype ] [ diel ] [ TG ] . has_key ( residue ) : C [ datatype ] [ diel ] [ TG ] [ residue ] = { } for nucleus in data [ datatype ] [ diel ] [ TG ] [ residue ] . keys ( ) : if not C [ datatype ] [ diel ] [ TG ] [ residue ] . has_key ( nucleus ) : C [ datatype ] [ diel ] [ TG ] [ residue ] [ nucleus ] = [ ] value = data [ datatype ] [ diel ] [ TG ] [ residue ] [ nucleus ] if not type ( C [ datatype ] [ diel ] [ TG ] [ residue ] [ nucleus ] ) is type ( [ ] ) : C [ datatype ] [ diel ] [ TG ] [ residue ] [ nucleus ] = [ ] C [ datatype ] [ diel ] [ TG ] [ residue ] [ nucleus ] . append ( value ) calc_ghosts = self . calculate_average ( C ) avgfile = options . avgfile print 'Saving average ghosts to %s' % avgfile fd = open ( avgfile , 'w' ) import pickle pickle . dump ( calc_ghosts , fd ) fd . close ( ) else : raise Exception ( 'Not a directory: %s' % options . loaddir ) else : filename = options . calcghosts if loadfile : filename = loadfile fd = open ( filename ) import pickle print 'Reading calculated ghosts from %s' % filename calc_ghosts = pickle . load ( fd ) fd . close ( ) return calc_ghosts
Load the calculated ghosts from a single file or a directory
Load the calculated ghosts from a single file or a directory
"""Load the calculated ghosts from a single file or a directory""" # Load all files in the directory specified # # # # Get the averages and standard deviations     # #  # Load just a single file #
self
options
loadfile