Пример #1
0
    def test_reduce(self):
        """Reduce test"""
        if self.local: self.log.add('Loading PDB...')

        self.m1 = PDBModel(T.testRoot('lig/1A19_dry.model'))

        rec = T.load(T.testRoot('com/rec.model'))
        lig = T.load(T.testRoot('com/lig.model'))

        self.m2 = rec.concat(lig)

        if self.local: self.log.add('Starting Reduce')
        self.x = Reduce(self.m1, debug=self.DEBUG, verbose=self.local)
        if self.local:
            self.log.add('Running')
        self.r = self.x.run()

        if self.local:
            self.log.add("Result: ")
            self.log.add(self.r.report(prnt=False))

        if self.local:
            self.log.add('Reduce protein complex')
        self.x = Reduce(self.m2,
                        debug=self.DEBUG,
                        verbose=self.local,
                        autocap=True)
        self.r2 = self.x.run()
Пример #2
0
    def loadResContacts( self ):
        """
        Uncompress residue contact matrix if necessary.
        
        @return: dict with contact matrix and parameters OR None
        @rtype: dict OR None
        """
        ## Backwards compatibility
        if self.contacts is not None and type( self.contacts ) == str:
            self.contacts = t.load( self.contacts )
            EHandler.warning("loading old-style pickled contacts.") 
            return self.contacts

        ## New, uncompression from list of indices into raveled array
        if self.contacts is not None and \
           len( N0.shape( self.contacts['result'])) == 1:

            try:
                lenRec, lenLig = self.contacts['shape']
            except:
                EHandler.warning("uncompressing contacts without shape")
                lenRec = self.rec().lenResidues()
                lenLig = self.lig().lenResidues()

            m = N0.zeros( lenRec * lenLig )
            N0.put( m, self.contacts['result'], 1 )

            self.contacts['result'] = N0.reshape( m, (lenRec, lenLig) )

        return self.contacts
Пример #3
0
    def load_locked(self, fname):
        """
        wait with unpickling until another Entropist has finished.

        :param fname: file name
        :type  fname: str

        :return: trajectroy
        :rtype: Trajectroy
        """
        flock = fname + '__locked'

        while os.path.exists(flock):
            if self.verbose: self.log.write('~')
            time.sleep(random.random() * 10)
        if self.verbose: self.log.add('')

        try:
            f = open(flock, 'w')
            f.write('1')
            f.close()

            r = t.load(fname)

        finally:
            t.tryRemove(flock)

        return r
Пример #4
0
    def test_Ramachandran(self):
        """Ramachandran test"""
        import numpy as N

        self.traj = T.load(T.testRoot('/lig_pcr_00/traj.dat'))

        self.traj.ref.atoms.set('mass', self.traj.ref.masses())

        self.mdls = [self.traj[0], self.traj[11]]
        self.mdls = [m.compress(m.maskProtein()) for m in self.mdls]

        self.rama = Ramachandran(self.mdls,
                                 name='test',
                                 profileName='mass',
                                 verbose=self.local)

        self.psi = N.array(self.rama.psi)

        if self.local:
            self.rama.show()

        ## remove NaN or None
        self.psi = N.compress(N.logical_not(N.equal(self.psi, None)), self.psi)
        r = round(N.sum(N.round(N.array(self.psi, float), 3)), 2)

        self.assertAlmostEqual(r, -11718.22, 2)
Пример #5
0
    def loadResContacts(self):
        """
        Uncompress residue contact matrix if necessary.
        
        @return: dict with contact matrix and parameters OR None
        @rtype: dict OR None
        """
        ## Backwards compatibility
        if self.contacts is not None and type(self.contacts) == str:
            self.contacts = t.load(self.contacts)
            EHandler.warning("loading old-style pickled contacts.")
            return self.contacts

        ## New, uncompression from list of indices into raveled array
        if self.contacts is not None and \
           len( N0.shape( self.contacts['result'])) == 1:

            try:
                lenRec, lenLig = self.contacts['shape']
            except:
                EHandler.warning("uncompressing contacts without shape")
                lenRec = self.rec().lenResidues()
                lenLig = self.lig().lenResidues()

            m = N0.zeros(lenRec * lenLig)
            N0.put(m, self.contacts['result'], 1)

            self.contacts['result'] = N0.reshape(m, (lenRec, lenLig))

        return self.contacts
Пример #6
0
    def test_TrajCluster(self):
        """TrajCluster test"""
        from biskit.md import traj2ensemble

        traj = T.load( T.testRoot()+'/lig_pcr_00/traj.dat')

        traj = traj2ensemble( traj )

        aMask = traj.ref.mask( lambda a: a['name'] in ['CA','CB','CG'] )

        traj = traj.thin( 1 )

        traj.fit( aMask, verbose=self.local )
        self.tc = TrajCluster( traj, verbose=self.local )

        ## check how many clusters that are needed with the given criteria
        n_clusters = self.tc.calcClusterNumber( min_clst=3, max_clst=15,
                                                rmsLimit=0.7, aMask=aMask )

        ## cluster
        self.tc.cluster( n_clusters, aMask=aMask )

        if self.local:
            member_frames = self.tc.memberFrames()

            print('There are %i clusters where the members are:'%n_clusters)
            for i in range(n_clusters):
                print('Cluster %i (%i members): %s'%( i+1,
                                                      len(member_frames[i]),
                                                      member_frames[i] ))
Пример #7
0
    def update( self, model, source, skipRes=None, updateMissing=0, force=0,
                headPatterns=[] ):
        """
        Update empty or missing fields of model from the source. The
        model will be connected to the source via model.source.
        Profiles that are taken from the source are labeled 'changed'=0.
        The same holds for coordinates (xyzChanged=0).
        However, existing profiles or coordinates or fields remain untouched.

        :param model: existing model
        :type  model: PDBModel
        :param source: source PDB file or pickled PDBModel or PDBModel object
        :type  source: str || file || PDBModel
        :param skipRes: list residue names that should not be parsed
        :type  skipRes: [ str ]
        :param updateMissing: check source for additional profiles [0] 
        :type  updateMissing: 1|0
        """
        try:
            if force or updateMissing or self.needsUpdate( model ):

                s = T.load( source )

                super( PDBParsePickle, self ).update(
                    model, s, skipRes=skipRes, updateMissing=updateMissing,
                    force=force )
                              
        except Exception as why:
            raise PDBParserError("Cannot unpickle source model from %s, "\
                   % str(source) + "Reason:\n" + str(why))

        model.setSource( source )
Пример #8
0
    def load_locked( self, fname ):
        """
        wait with unpickling until another Entropist has finished.

        :param fname: file name
        :type  fname: str

        :return: trajectroy
        :rtype: Trajectroy
        """
        flock = fname + '__locked'

        while os.path.exists( flock ):
            if self.verbose: self.log.write('~')
            time.sleep( random.random() * 10 )
        if self.verbose: self.log.add('')

        try:
            f = open( flock, 'w' )
            f.write('1')
            f.close()

            r = t.load(fname)

        finally:
            t.tryRemove( flock )

        return r
Пример #9
0
    def test_ComplexVC(self):
        """Dock.ComplexVC test"""
        import time
        import biskit.tools as T

        c = T.load(T.testRoot() + '/com/ref.complex')

        self.ce = ComplexVC(c.rec_model, c.lig(), c, info={'comment': 'test'})

        time.sleep(2)

        lig = self.ce.lig().transform(MU.randomRotation(), [0, 0, 0])
        self.ce2 = ComplexVC(self.ce.rec_model,
                             lig,
                             self.ce,
                             info={'comment': 'test2'})

        if self.local:
            print('\nFound %i versions of the complex: ' % len(self.ce2))
            for x in self.ce2:
                print('\t* ' + x['date'])

            print('Comments: ', self.ce2.valuesOf('comment'))

        self.assertEqual(self.ce2.valuesOf('comment'), [None, 'test', 'test2'])
Пример #10
0
    def test_ComplexVC(self):
        """Dock.ComplexVC test"""
        import time
        import biskit.tools as T

        c = T.load( T.testRoot() + '/com/ref.complex' )

        self.ce= ComplexVC( c.rec_model, c.lig(), c,
                                  info={'comment':'test'} )

        time.sleep( 2 )

        lig = self.ce.lig().transform( MU.randomRotation(), [0,0,0] )
        self.ce2 = ComplexVC( self.ce.rec_model, lig, self.ce,
                                    info={'comment':'test2'})

        if self.local:
            print('\nFound %i versions of the complex: ' % len(self.ce2))
            for x in self.ce2:
                print('\t* ' + x['date'])

            print('Comments: ', self.ce2.valuesOf('comment'))

        self.assertEqual( self.ce2.valuesOf('comment'),
                          [None, 'test', 'test2'])
Пример #11
0
    def test_ComplexVCList(self):
        """Dock.ComplexVCList test"""

        import biskit.tools as T
        from biskit.dock import ComplexVC
        from biskit.dock import ComplexVCList

        ## original complex
        cl = T.load(  T.testRoot() + "/dock/hex/complexes.cl" )

        ## first evolution step
        c = ComplexVC( cl[0].rec(), cl[0].lig(), cl[0],
                             info={'comment':'test1'})

        ## second evolution step
        c = ComplexVC( c.rec(), c.lig(), c,
                             info={'comment':'test2'})

        ## create an evolving complex list
        cl = ComplexVCList( [c, c] )

        if self.local:
            ## last version of all complexes in list
            print(cl.valuesOf('comment'))

            ## version 1
            print(cl.valuesOf('comment', version=1))

            ## the first complex in the list
            print(cl[0].valuesOf('comment'))

            globals().update( locals() )

        self.assertEqual( (cl.valuesOf('comment'), cl[0].valuesOf('comment')),
                          (['test2', 'test2'], [None, 'test1', 'test2']) )
Пример #12
0
    def test_tmalignTransform( self ):
        """TMAlign.applyTransformation test"""
        m = T.load( T.testRoot( 'tmalign/1huy_citrine.model' ) )
        ref = T.load( T.testRoot( 'tmalign/1zgp_dsred_dimer.model' ) )
        ref = ref.takeChains( [0] )

        tm = TMAlign( m, ref, debug=self.DEBUG, verbose=self.local )
        tm.run()

        self.maligned = tm.applyTransformation()

        diff = self.maligned.centerOfMass() - ref.centerOfMass()

        if self.VERBOSITY > 2 or self.local:
            print('center of mass deviation: \n%r' % diff)
            self.maligned.concat( ref ).plot()

        self.assertTrue( N.all( N.absolute(diff) < 1 ),
                      'superposition failed: \n%r' % diff)
Пример #13
0
    def test_tmalignTransform(self):
        """TMAlign.applyTransformation test"""
        m = T.load(T.testRoot('tmalign/1huy_citrine.model'))
        ref = T.load(T.testRoot('tmalign/1zgp_dsred_dimer.model'))
        ref = ref.takeChains([0])

        tm = TMAlign(m, ref, debug=self.DEBUG, verbose=self.local)
        tm.run()

        self.maligned = tm.applyTransformation()

        diff = self.maligned.centerOfMass() - ref.centerOfMass()

        if self.VERBOSITY > 2 or self.local:
            print('center of mass deviation: \n%r' % diff)
            self.maligned.concat(ref).plot()

        self.assertTrue(N.all(N.absolute(diff) < 1),
                        'superposition failed: \n%r' % diff)
Пример #14
0
    def dry_or_wet_run( self, run=True ):
        """ """
        import time, os
        import os.path

        ligDic = t.load(t.testRoot('/dock/lig/1A19_model.dic'))
        recDic = t.load(t.testRoot('/dock/rec/1A2P_model.dic'))

        self.d = Docker( recDic, ligDic, out=self.out_folder,
                         verbose=self.local  )

        # dock rec 1 vs. lig 2 on localhost
        fmac1, fout = self.d.createHexInp( 1, 1 )
        if run:
            self.d.runHex( fmac1, log=1, ncpu=6 )
            if self.local: print("ALL jobs submitted.")

            self.d.waitForLastHex()
            
            self.assertEqual(self.d.hexFailed, 0, 'Hex exited with error')
            self.assertTrue(len(self.d.result) > 1, 'no results collected')
Пример #15
0
    def test_hexParser(self):
        """Dock.hexParser test"""

        rec_dic = t.load(t.testRoot() + "/dock/rec/1A2P_model.dic")
        lig_dic = t.load(t.testRoot() + "/dock/lig/1A19_model.dic")

        self.h = HexParser(t.testRoot() + "/dock/hex/1A2P-1A19_hex8.out",
                           rec_dic, lig_dic)

        c_lst = self.h.parseHex()

        if self.local:
            print(c_lst[1].info)

            globals().update(locals())

        self.assertSetEqual(
            set(c_lst[1].info.keys()),
            set([
                'soln', 'rms', 'hex_clst', 'hex_eshape', 'model2', 'model1',
                'hex_etotal', 'hex_eair', 'date'
            ]))
Пример #16
0
    def test_bindingE( self ):
        """bindingEnergyDelphi test (Barnase:Barstar)"""
        self.com = T.load( T.testRoot() + '/com/ref.complex' )
        self.dG = DelphiBindingEnergy( self.com, log=self.log, scale=1.2,
                                       verbose=self.local )
        self.r = self.dG.run()

##        self.assertAlmostEqual( self.r['dG_kt'], 21., 0 )
        self.assertTrue( abs(self.r['dG_kt'] - 24.6) < 4 )

        if self.local:
            self.log.add(
                '\nFinal result: dG = %3.2f kcal/mol'%self.r['dG_kcal'])
Пример #17
0
 def load( self ):
     """
     Try to unpickle an object from the currently valid path.
     
     :return: unpickled object 
     :rtype: any
     
     :raise IOError: if file can not be found
     """
     try:
         return T.load( self.local( existing=1 ) )
     except LocalPathError as why:
         raise IOError("Cannot find file %s (constructed from %s)" %\
               self.local()).with_traceback(str( self ))
Пример #18
0
    def dry_or_wet_run(self, run=True):
        """ """
        import time, os
        import os.path

        ligDic = t.load(t.testRoot('/dock/lig/1A19_model.dic'))
        recDic = t.load(t.testRoot('/dock/rec/1A2P_model.dic'))

        self.d = Docker(recDic,
                        ligDic,
                        out=self.out_folder,
                        verbose=self.local)

        # dock rec 1 vs. lig 2 on localhost
        fmac1, fout = self.d.createHexInp(1, 1)
        if run:
            self.d.runHex(fmac1, log=1, ncpu=6)
            if self.local: print("ALL jobs submitted.")

            self.d.waitForLastHex()

            self.assertEqual(self.d.hexFailed, 0, 'Hex exited with error')
            self.assertTrue(len(self.d.result) > 1, 'no results collected')
Пример #19
0
 def load(self):
     """
     Try to unpickle an object from the currently valid path.
     
     :return: unpickled object 
     :rtype: any
     
     :raise IOError: if file can not be found
     """
     try:
         return T.load(self.local(existing=1))
     except LocalPathError as why:
         raise IOError("Cannot find file %s (constructed from %s)" %\
               self.local()).with_traceback(str( self ))
Пример #20
0
    def test_ComplexList(self):
        """Dock.ComplexList test"""
        self.cl = t.load( t.testRoot() + "/dock/hex/complexes.cl" )

        ## number of clusters among the 100 best (lowest rmsd) solutions
        self.cl_sorted = self.cl.sortBy( 'rms' )
        self.hex_clst = self.cl_sorted.valuesOf( 'hex_clst',
                                                 indices=list(range(100)),
                                                 unique=1 )

        if self.local:
            self.p = self.cl.plot( 'rms', 'hex_eshape', 'hex_etotal' )
            self.p.show()

        self.assertEqual( len( self.hex_clst ), 36)
Пример #21
0
    def test_bindingE(self):
        """bindingEnergyDelphi test (Barnase:Barstar)"""
        self.com = T.load(T.testRoot() + '/com/ref.complex')
        self.dG = DelphiBindingEnergy(self.com,
                                      log=self.log,
                                      scale=1.2,
                                      verbose=self.local)
        self.r = self.dG.run()

        ##        self.assertAlmostEqual( self.r['dG_kt'], 21., 0 )
        self.assertTrue(abs(self.r['dG_kt'] - 24.6) < 4)

        if self.local:
            self.log.add('\nFinal result: dG = %3.2f kcal/mol' %
                         self.r['dG_kcal'])
Пример #22
0
    def test_ComplexModelRegistry(self):
        """Dock.ComplexModelRegistry test"""
        from biskit.dock import ComplexList
        
        self.cl = T.load( T.testRoot() +'/dock/hex/complexes.cl' )
        self.cl = self.cl.toList()
        
        self.r = ComplexModelRegistry()

        for c in self.cl[:500]:
            self.r.addComplex( c )

        check = self.r.getLigComplexes( self.r.ligModels()[0] )

        self.assertEqual( len(check), 500 )
Пример #23
0
    def test_ComplexModelRegistry(self):
        """Dock.ComplexModelRegistry test"""
        from biskit.dock import ComplexList

        self.cl = T.load(T.testRoot() + '/dock/hex/complexes.cl')
        self.cl = self.cl.toList()

        self.r = ComplexModelRegistry()

        for c in self.cl[:500]:
            self.r.addComplex(c)

        check = self.r.getLigComplexes(self.r.ligModels()[0])

        self.assertEqual(len(check), 500)
Пример #24
0
def loadTraj(f, trajIndex, start=0, end=None, step=1, prot=False):
    """Load traj from file, add frame names, extract portion if requested"""

    t = T.load(T.absfile(f))
    addFrameNames(t, trajIndex)

    e = end or len(t)

    if start or end or (step != 1):
        t = t.takeFrames(list(range(start, e, step)))

    if prot:
        t.keepAtoms(N0.nonzero(t.ref.maskProtein()))

    return t
Пример #25
0
    def test_ComplexList(self):
        """Dock.ComplexList test"""
        self.cl = t.load(t.testRoot() + "/dock/hex/complexes.cl")

        ## number of clusters among the 100 best (lowest rmsd) solutions
        self.cl_sorted = self.cl.sortBy('rms')
        self.hex_clst = self.cl_sorted.valuesOf('hex_clst',
                                                indices=list(range(100)),
                                                unique=1)

        if self.local:
            self.p = self.cl.plot('rms', 'hex_eshape', 'hex_etotal')
            self.p.show()

        self.assertEqual(len(self.hex_clst), 36)
Пример #26
0
    def test_Pymoler(self):
        """Pymoler test"""
        self.traj = T.load( T.testRoot() + '/lig_pcr_00/traj.dat' )

        self.pm = Pymoler( full=0, verbose=self.local )
        
        mname = self.pm.addMovie( [ self.traj[i] for i in range(0,100,20) ] )

        sel = self.pm.makeSel({'residue':29})
##         self.pm.add('show stick, %s' % sel)
        self.pm.add('show surface, %s' % sel)

        self.pm.add('mplay')
        
        if not self.local:
            self.pm.add('quit')
            
        self.pm.run() ## old style call "pm.show()" also works
    
        self.assertTrue( self.pm.pid is not None )
Пример #27
0
    def update(self,
               model,
               source,
               skipRes=None,
               updateMissing=0,
               force=0,
               headPatterns=[]):
        """
        Update empty or missing fields of model from the source. The
        model will be connected to the source via model.source.
        Profiles that are taken from the source are labeled 'changed'=0.
        The same holds for coordinates (xyzChanged=0).
        However, existing profiles or coordinates or fields remain untouched.

        :param model: existing model
        :type  model: PDBModel
        :param source: source PDB file or pickled PDBModel or PDBModel object
        :type  source: str || file || PDBModel
        :param skipRes: list residue names that should not be parsed
        :type  skipRes: [ str ]
        :param updateMissing: check source for additional profiles [0] 
        :type  updateMissing: 1|0
        """
        try:
            if force or updateMissing or self.needsUpdate(model):

                s = T.load(source)

                super(PDBParsePickle, self).update(model,
                                                   s,
                                                   skipRes=skipRes,
                                                   updateMissing=updateMissing,
                                                   force=force)

        except Exception as why:
            raise PDBParserError("Cannot unpickle source model from %s, "\
                   % str(source) + "Reason:\n" + str(why))

        model.setSource(source)
Пример #28
0
    def prepareRef( self, fname ):
        """
        Prepare reference model.
        
        :param fname: file name 
        :type  fname: str

        :return: reference structure
        :rtype: PDBModel|Complex        

        :raise EntropistError: if unknown reference type
        """
        if not fname:
            return None

        if self.__splitFilenames( fname ):
            f1, f2 = self.__splitFilenames( fname )
            m1, m2 = PDBModel( self.__getModel(f1) ), \
                     PDBModel( self.__getModel(f2) )

            ref = Complex( m1, m2 )
        else:
            ref = t.load( fname )

        if isinstance( ref, Trajectory ):
            ref = ref.ref

        if isinstance( ref, PDBModel ):
            return self.__cleanAtoms( ref )

        if isinstance( ref, Complex ):
            self.__cleanAtoms( ref.rec_model )
            self.__cleanAtoms( ref.lig_model )
            ref.lig_model_transformed = None
            return ref

        raise EntropistError('unknown reference type')
Пример #29
0
    def test_Trajectory(self):
        """Trajectory test"""
##         f = T.testRoot() + '/lig_pc2_00/pdb/'
##         allfiles = os.listdir( f )
##         pdbs = []
##         for fn in allfiles:
##             try:
##                 if (fn[-7:].upper() == '.PDB.GZ'):
##                     pdbs += [f + fn]
##             except:
##                 pass

##         ref = pdbs[0]
##         traj = Trajectory( pdbs[:3], ref, rmwat=0 )

        ## Loading
        self.traj = T.load(T.testRoot() + '/lig_pcr_00/traj.dat')

        ## sort frames after frameNames
        self.traj.sortFrames()

        ## sort atoms 
        self.traj.sortAtoms()

        ## remove waters
        self.traj = self.traj.compressAtoms(
            N0.logical_not( self.traj.ref.maskH2O()) )

        ## get fluctuation on a residue level
        r1 = self.traj.getFluct_local( verbose=self.local )

        ## fit backbone of frames to reference structure
        self.traj.fit( ref=self.traj.ref,
                       mask=self.traj.ref.maskBB(), verbose=self.local )

        self.assertAlmostEqual( N0.sum( self.traj.profile('rms') ),
                                58.101235746353879, 2 )
Пример #30
0
    def prepareRef(self, fname):
        """
        Prepare reference model.
        
        :param fname: file name 
        :type  fname: str

        :return: reference structure
        :rtype: PDBModel|Complex        

        :raise EntropistError: if unknown reference type
        """
        if not fname:
            return None

        if self.__splitFilenames(fname):
            f1, f2 = self.__splitFilenames(fname)
            m1, m2 = PDBModel( self.__getModel(f1) ), \
                     PDBModel( self.__getModel(f2) )

            ref = Complex(m1, m2)
        else:
            ref = t.load(fname)

        if isinstance(ref, Trajectory):
            ref = ref.ref

        if isinstance(ref, PDBModel):
            return self.__cleanAtoms(ref)

        if isinstance(ref, Complex):
            self.__cleanAtoms(ref.rec_model)
            self.__cleanAtoms(ref.lig_model)
            ref.lig_model_transformed = None
            return ref

        raise EntropistError('unknown reference type')
Пример #31
0
    def test_Trajectory(self):
        """Trajectory test"""
        ## Loading
        self.traj = T.load(T.testRoot() + '/lig_pcr_00/traj.dat')

        ## sort frames after frameNames
        self.traj.sortFrames()

        ## sort atoms 
        self.traj.sortAtoms()

        ## remove waters
        self.traj = self.traj.compressAtoms(
            N0.logical_not( self.traj.ref.maskH2O()) )

        ## get fluctuation on a residue level
        r1 = self.traj.getFluct_local( verbose=self.local )

        ## fit backbone of frames to reference structure
        self.traj.fit( ref=self.traj.ref,
                       mask=self.traj.ref.maskBB(), verbose=self.local )

        self.assertAlmostEqual( N0.sum( self.traj.profile('rms') ),
                                58.101235746353879, 2 )
Пример #32
0
    def test_Ramachandran(self):
        """Ramachandran test"""
        import numpy as N
        
        self.traj = T.load( T.testRoot('/lig_pcr_00/traj.dat') )

        self.traj.ref.atoms.set('mass', self.traj.ref.masses() ) 

        self.mdls = [ self.traj[0], self.traj[11] ]
        self.mdls = [ m.compress( m.maskProtein() ) for m in self.mdls ]

        self.rama = Ramachandran( self.mdls , name='test', profileName='mass',
                                  verbose=self.local)

        self.psi = N.array( self.rama.psi )

        if self.local:
            self.rama.show()
            
        ## remove NaN or None
        self.psi = N.compress( N.logical_not(N.equal(self.psi, None)),self.psi)
        r = round( N.sum( N.round(N.array(self.psi, float), 3) ), 2)
        
        self.assertAlmostEqual( r, -11718.22, 2 )
Пример #33
0
    def test_ComplexVCList(self):
        """Dock.ComplexVCList test"""

        import biskit.tools as T
        from biskit.dock import ComplexVC
        from biskit.dock import ComplexVCList

        ## original complex
        cl = T.load(T.testRoot() + "/dock/hex/complexes.cl")

        ## first evolution step
        c = ComplexVC(cl[0].rec(),
                      cl[0].lig(),
                      cl[0],
                      info={'comment': 'test1'})

        ## second evolution step
        c = ComplexVC(c.rec(), c.lig(), c, info={'comment': 'test2'})

        ## create an evolving complex list
        cl = ComplexVCList([c, c])

        if self.local:
            ## last version of all complexes in list
            print(cl.valuesOf('comment'))

            ## version 1
            print(cl.valuesOf('comment', version=1))

            ## the first complex in the list
            print(cl[0].valuesOf('comment'))

            globals().update(locals())

        self.assertEqual((cl.valuesOf('comment'), cl[0].valuesOf('comment')),
                         (['test2', 'test2'], [None, 'test1', 'test2']))
Пример #34
0
import biskit.tools as T

t = T.load( 'com_fake.etraj' )

x = t.takeFrames( range(0, t.n_members * 5) )

x.ref.disconnect()

T.dump( x, 'extract.etraj' )
Пример #35
0
#!/usr/bin/env python
## re-generate binary test data in this folder

import biskit as B
import biskit.tools as T
from biskit.md import AmberCrdParser, EnsembleTraj, traj2ensemble

p = AmberCrdParser('raw/traj.crd', 'raw/traj_ref.pdb')

## create standard trajectory object
t = p.crd2traj()
t.frameNames = T.load('raw/traj_framenames.list')

te = traj2ensemble(t, members=10)
te.fit(
    fit=0)  ## re-calculate profile 'rms' (all-atom fit to average structure)

T.dump(te, 'traj.dat')
Пример #36
0
 def prepare(self):
     self.tr = T.load( T.testRoot() + '/lig_pcr_00/traj.dat')
     self.t50 = T.load( T.testRoot() + 'md/traj_ens50_peptide.dat')
Пример #37
0
    def prepare( self ):
        import biskit as B
        import biskit.tools as T

        self.M = self.M or T.load( T.testRoot() + '/lig/1A19_dry.model' )
Пример #38
0
        print("Reducing traj...")
        t1 = traj.takeAtoms(self.from_atoms)
        t2 = traj.takeAtoms(self.to_atoms)

        distances = N.sqrt(N.sum((t1.frames - t2.frames)**2, axis=2))

        return distances, N.array([self.from_atoms, self.to_atoms])


if __name__ == '__main__':

    import biskit.tools as T
    from biskit.md import FuzzyCluster

    ftraj = '~/data/input/traj_step20.dat'
    t = T.load(ftraj)  ## Trajectory
    t = t.compressAtoms(t.ref.maskHeavy())

    d = DistanceTrajectory(n_points=10, refmodel=t.ref)

    v = d.reduce(t)

    fz = FuzzyCluster(v[0:-1:5], n_cluster=10, weight=1.13)

    centers = fz.go(1e-10)

    ## get representative structure for each cluster center:
    msm = fz.getMembershipMatrix()
    i_frames = N.argmax(msm, axis=1)
    ## models = [ t[i] for i in i_frames ]
    tcenters = t.takeFrames(i_frames)
Пример #39
0
    def prepare(self):
        import biskit as B
        import biskit.tools as T

        self.M = self.M or T.load(T.testRoot() + '/lig/1A19_dry.model')
Пример #40
0
########
## MAIN
########

syntax()

## get and clean up options
o = options()
o['step'] = int( o['step'] )
o['i'] = T.absfile( o['i'] )
o['o'] = o.get('o',
              '%s/%s_rms.eps' % (osp.dirname(o['i']), T.stripFilename(o['i'])))
o['show'] = 'show' in o

T.flushPrint( "Loading..." )
t = T.load( o['i'] )
T.flushPrint( "done loading trajectory with %i frames." % len(t) )

if o['step'] != 1:
    t = t.thin( o['step'] ) 

T.flushPrint( "Fitting ...")
calcRmsd( t )
T.flushPrint( "done." )

p = plot( t, o.get( 'title', T.stripFilename(o['i']) ) )

if o['show']:
    p.show()

T.flushPrint( "Saving plot to %s" % o['o'] )
Пример #41
0
 def prepare(self):
     self.tr = T.load(T.testRoot() + '/lig_pcr_00/traj.dat')
Пример #42
0
#!/usr/bin/env python
## re-generate binary test data in this folder

import biskit as B
import biskit.tools as T
from biskit.md import AmberCrdParser, EnsembleTraj, traj2ensemble

p = AmberCrdParser('raw/traj.crd', 'raw/traj_ref.pdb' )

## create standard trajectory object
t = p.crd2traj()
t.frameNames = T.load('raw/traj_framenames.list')

te = traj2ensemble(t, members=10)
te.fit(fit=0)  ## re-calculate profile 'rms' (all-atom fit to average structure)

T.dump(te, 'traj.dat')


Пример #43
0
 def prepare(self):
     self.tr = T.load( T.testRoot() + '/lig_pcr_00/traj.dat')
Пример #44
0
""")
        sys.exit(0)

##########
## MAIN ##

use()

o = T.cmdDict( {'n':10} )

f_in  = T.absfile( o['i'] )
f_out = T.absfile( o.get('o', f_in) )
n = int( o['n'] )

T.flushPrint("Loading...")
t = T.load( f_in )

T.flushPrint("Converting %i frames..." % len(t) )

if isinstance(t, EnsembleTraj ):
    T.flushPrint( "Nothing to be done!\n")
    sys.exit(0)
    
t = traj2ensemble( t, n )
if 'pdb' in o:
    t.ref.pdbCode = o['pdb']

if f_in == f_out:
    os.rename( f_in, f_in + '_backup')

T.flushPrint("Saving...")
Пример #45
0
import biskit.tools as T

t = T.load('com_fake.etraj')

x = t.takeFrames(range(0, t.n_members * 5))

x.ref.disconnect()

T.dump(x, 'extract.etraj')