예제 #1
0
 def __init__(self,target,usegrp=None,nstruct=10000,pid=10,**kwargs):
     if os.path.isdir(target):
         #the target is a valid population structure directory
         if usegrp==None:
             raise RuntimeError, "group key is not specified!"
         firststr    = files.modelstructures(os.path.join(target,"copy0.hms"),[usegrp])
         self.idx    = firststr.idx
         self.genome = firststr.genome
         self.usegrp = usegrp
         self.nbead  = len(self.idx)
         self.nstruct = nstruct
         self.radius  = firststr[-1].r
         print("reading %d structures info in %s,%s"%(nstruct,target,usegrp))
         self._readStructures(target,pid,**kwargs)
     elif os.path.isfile(target) and os.path.splitext(target)[1] == '.hss':
         h5f = h5py.File(target,'r')
         self.idx                   = h5f['idx'][:]
         self.genome                = pickle.loads(h5f['genome'].value)
         self.usegrp                = pickle.loads(h5f['usegrp'].value)
         self.nbead                 = pickle.loads(h5f['nbead'].value)
         self.nstruct               = pickle.loads(h5f['nstruct'].value)
         self.radius                = h5f['radius'][:]
         self.coordinates           = h5f['coordinates'][:]
         self.score                 = h5f['score'][:]
         self.consecutiveViolations = h5f['consecutiveViolations'][:]
         self.contactViolations     = h5f['contactViolations'][:]
         self.intraRestraints       = h5f['intraRestraints'][:]
         self.interRestraints       = h5f['interRestraints'][:]
     else:
         raise RuntimeError, "Invalid filename or file directory!"
     #-
     return None
예제 #2
0
 def __init__(self,target,usegrp=None,nstruct=10000,pid=10,**kwargs):
     if os.path.isdir(target):
         #the target is a valid population structure directory
         if usegrp==None:
             raise RuntimeError, "group key is not specified!"
         firststr    = files.modelstructures(os.path.join(target,"copy0.hms"),[usegrp])
         self.idx    = firststr.idx
         self.genome = firststr.genome
         self.usegrp = usegrp
         self.nbead  = len(self.idx)
         self.nstruct = nstruct
         self.radius  = firststr[-1].r
         print("reading %d structures info in %s,%s"%(nstruct,target,usegrp))
         while nstruct%pid != 0:
             pid = int(pid/2)
         self._readStructures(target,pid,**kwargs)
     elif os.path.isfile(target) and os.path.splitext(target)[1] == '.hss':
         h5f = h5py.File(target,'r')
         self.idx                   = h5f['idx'][:]
         self.genome                = pickle.loads(h5f['genome'].value)
         self.usegrp                = pickle.loads(h5f['usegrp'].value)
         self.nbead                 = pickle.loads(h5f['nbead'].value)
         self.nstruct               = pickle.loads(h5f['nstruct'].value)
         self.radius                = h5f['radius'][:]
         self.coordinates           = h5f['coordinates'][:]
         self.score                 = h5f['score'][:]
         self.consecutiveViolations = h5f['consecutiveViolations'][:]
         self.contactViolations     = h5f['contactViolations'][:]
         self.intraRestraints       = h5f['intraRestraints'][:]
         self.interRestraints       = h5f['interRestraints'][:]
     else:
         raise RuntimeError, "Invalid filename or file directory!"
     #-
     return None
예제 #3
0
 def _readInfo(self,target,start,end,usegrp,
               coor_shared,
               consecVio_shared,contactVio_shared,
               score_shared,
               intrares_shared,interres_shared,silence=True):
     """
     Read in all information
     """
     arr = np.frombuffer(coor_shared.get_obj())
     modelcoor = arr.reshape((self.nstruct,self.nbead*2,3)) #10000 * 4640 * 3
     for i in range(start,end):
         try:
             if not silence:
                 print(i)
             sts = files.modelstructures(os.path.join(target,'copy'+str(i)+'.hms'),[usegrp])
             
             modelcoor[i][:] = sts[0].xyz
             score_shared[i] = sts[0].score
             
             try:
                 consecVio_shared[i]  = sts[0].consecutiveViolations
                 contactVio_shared[i] = sts[0].contactViolations
             except:
                 consecVio_shared[i]  = np.nan
                 contactVio_shared[i] = np.nan
             try:
                 intrares_shared[i] = sts[0].intraRestraints
                 interres_shared[i] = sts[0].interRestraints
             except:
                 intrares_shared[i] = np.nan
                 interres_shared[i] = np.nan
             
         except RuntimeError:
             print("Can't find result for copy %s , %s at %s" %(str(i),usegrp,os.path.join(target,'copy'+str(i)+'.hms')))
     return 0
예제 #4
0
 def _readInfo(self,target,start,end,usegrp,
               coor_shared,
               consecVio_shared,contactVio_shared,
               score_shared,
               intrares_shared,interres_shared,silence=True):
     """
     Read in all information
     """
     arr = np.frombuffer(coor_shared.get_obj())
     modelcoor = arr.reshape((self.nstruct,self.nbead*2,3)) #10000 * 4640 * 3
     for i in range(start,end):
         try:
             if not silence:
                 print(i)
             sts = files.modelstructures(os.path.join(target,'copy'+str(i)+'.hms'),[usegrp])
             
             modelcoor[i][:] = sts[0].xyz
             score_shared[i] = sts[0].score
             
             try:
                 consecVio_shared[i]  = sts[0].consecutiveViolations
                 contactVio_shared[i] = sts[0].contactViolations
             except:
                 consecVio_shared[i]  = np.nan
                 contactVio_shared[i] = np.nan
             try:
                 intrares_shared[i] = sts[0].intraRestraints
                 interres_shared[i] = sts[0].interRestraints
             except:
                 intrares_shared[i] = np.nan
                 interres_shared[i] = np.nan
             
         except RuntimeError:
             print("Can't find result for copy %s , %s at %s" %(str(i),usegrp,os.path.join(target,'copy'+str(i)+'.hms')))
     return 0