class Test(BT.BiskitTest): """Test case""" TAGS = [ BT.OLD, BT.EXE ] ## msms is superseeded by SurfaceRacer def test_msms(self): """msms test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel( T.testRoot() + '/lig/1A19.pdb' ) self.m = self.m.compress( self.m.maskProtein() ) if self.local: print 'Getting surfaces via the MSMS executable' self.ms = MSMS( self.m, debug=self.DEBUG, verbose=self.local ) if self.local: print 'Running' out, sesList, sasList, atmList = self.ms.run() if self.local: print out print '\nResult from MSMS (first 5 lines): ' print 'SES \tSAS \tAtom name' for i in range(5): print '%.2f \t%.2f \t%s'%(sesList[i], sasList[i], atmList[i]) print 'MSMS done' globals().update( locals() ) self.assertAlmostEqual( out['sas'] + out['ses'], 5085.1580000000004 + 4208.7389999999996, 8 )
class Test(BT.BiskitTest): """Test class""" TAGS = [ BT.EXE, BT.LONG ] 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 ) if self.local: self.log.add( '\nFinal result: dG = %3.2f kcal/mol'%self.r['dG_kcal']) def test_errorcase1( self ): """bindinEnergyDelphi test (error case 01)""" self.m = PDBModel( T.testRoot() + '/delphi/case01.pdb' ) rec = self.m.takeChains( [0,1] ) lig = self.m.takeChains( [2] ) self.com = Complex( rec, lig ) self.dG = DelphiBindingEnergy( self.com, log = self.log, scale=0.5, verbose=self.local ) self.r = self.dG.run() if self.local: self.log.add( '\nFinal result: dG = %3.2f kcal/mol'%self.r['dG_kcal'])
def generic_test(self, pdb, expected=None, proteinonly=False): """generic DSSP test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel(pdb) if proteinonly: self.m = self.m.compress( self.m.maskProtein() ) if self.local: print 'Starting DSSP' self.dssp = Dssp( self.m, verbose=self.local, debug=self.DEBUG ) if self.local: print 'Running DSSP' self.result = self.dssp.run() ## returns modified PDBModel self.result = self.result.compress( self.result.maskProtein() ) self.result = ''.join(self.result['dssp']) if self.local: print "Sequence :", self.m.sequence() print "Secondary:", self.result if expected: self.assertEquals( self.result, expected)
class Test(BT.BiskitTest): """DSSP test""" TAGS = [BT.EXE] def prepare(self): self.f = T.testRoot() + "/com/1BGS.pdb" def test_DSSP(self): """DSSP test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel(self.f) self.m = self.m.compress(self.m.maskProtein()) if self.local: print 'Starting DSSP' self.dssp = Dssp(self.m, verbose=self.local, debug=self.DEBUG) if self.local: print 'Running DSSP' self.result = self.dssp.run() if self.local: print "Sequence :", self.m.sequence() print "Secondary:", self.result self.assertEquals(self.result, self.EXPECTED) EXPECTED = '.....SHHHHHHHHHHHSS..TTEE.HHHHHHHT..GGGT.HHHHSTT.EEEEEEE..TT..S...TT..EEEEE.S..SSS..S.EEEEETT..EEEESSSSSS.EE...EEEEETTT..SHHHHHHHHHHHHT..TT..SSHHHHHHHHHHT..SSEEEEEE.HHHHHHHTTTTHHHHHHHHHHHHHHT..EEEEE.'
def test_SurfaceRacer(self): """SurfaceRacer test""" from Biskit import PDBModel import Biskit.mathUtils as MA if self.local: print 'Loading PDB...' f = T.testRoot()+'/lig/1A19.pdb' m = PDBModel(f) m = m.compress( m.maskProtein() ) if self.local: print 'Starting SurfaceRacer' self.x = SurfaceRacer( m, 1.4, vdw_set=1, debug=self.DEBUG, verbose=0 ) if self.local: print 'Running ...' self.r = self.x.run() c= self.r['curvature'] ms= self.r['MS'] if self.local: print "Curvature: weighted mean %.6f and standard deviation %.3f"\ %(MA.wMean(c,ms), MA.wSD(c,ms)) print 'Relative MS of atoms 10 to 20:',self.r['relMS'][10:20] print 'Relative AS of atoms 10 to 20:',self.r['relAS'][10:20] self.e = ( N.sum(self.r['relMS'][10:20]), N.sum(self.r['relAS'][10:20]), N.sum(self.r['curvature'][10:20]) ) self.assertAlmostEqual( self.e, self.EXPECT )
class Test(BT.BiskitTest): """DSSP test""" TAGS = [BT.EXE] def prepare(self): self.f = T.testRoot()+"/com/1BGS.pdb" def test_DSSP( self ): """DSSP test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel(self.f) self.m = self.m.compress( self.m.maskProtein() ) if self.local: print 'Starting DSSP' self.dssp = Dssp( self.m ) if self.local: print 'Running DSSP' self.result = self.dssp.run() if self.local: print "Sequence :", self.m.sequence() print "Secondary:", self.result self.assertEquals( self.result, self.EXPECTED) EXPECTED = '.....SHHHHHHHHHHHSS..TTEE.HHHHHHHT..GGGT.HHHHSTT.EEEEEEE..TT..S...TT..EEEEE.S..SSS..S.EEEEETT..EEEESSSSSS.EE...EEEEETTT..SHHHHHHHHHHHHT..TT..SSHHHHHHHHHHT..SSEEEEEE.HHHHHHHTTTTHHHHHHHHHHHHHHT..EEEEE.'
def test_tmalign(self): """TMAlign test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m1 = PDBModel(T.testRoot('tmalign/1huy_citrine.model')) self.m2 = PDBModel(T.testRoot('tmalign/1zgp_dsred_dimer.model')) if self.local: print 'Starting TMAlign' self.x = TMAlign(self.m1, self.m2, debug=self.DEBUG, verbose=self.local) if self.local: print 'Running' self.r = self.x.run() if self.local: print "Result: " for key, value in self.r.items(): print '\t', key, ':\t', value self.assertEqual(self.r['rmsd'], 1.76)
class Test(BT.BiskitTest): """Test case""" def test_molTools(self): """molTools test""" from Biskit import PDBModel ## Loading PDB... self.m = PDBModel( T.testRoot() + '/lig/1A19.pdb' ) self.m = self.m.compress( self.m.maskProtein() ) hb = hbonds( self.m ) xyz = xyzOfNearestCovalentNeighbour( 40, self.m ) if self.local: print '\nThe nearest covalently attached atom to the' print ' atom with index 40 has the coordinates:' print xyz print 'Potential h-bonds in model:' print '(donor index, acceptor index, distance and angle)' for h in hb: print h globals().update( locals() ) self.r = N0.sum(N0.ravel(hb[3:5])) + N0.sum(xyz) self.assertAlmostEqual( self.r, self.EXPECT, 3 ) EXPECT = 2025.8997840075292 + 152.687011719
def test_hexTools(self): """Dock.hexTools test""" from Biskit import PDBModel self.m = PDBModel(t.testRoot() + '/com/1BGS.pdb') dist = centerSurfDist(self.m, self.m.maskCA()) self.assertAlmostEqual(dist[0], 26.880979538, 7)
def test_model(self): """PDBDope test final model""" from Biskit import PDBModel if self.local: print '\nData added to info record of model (key -- value):' for k in self.d.m.info.keys(): print '%s -- %s'%(k, self.d.m.info[k]) print '\nAdded atom profiles:' print self.M.atoms print '\nAdded residue profiles:' print self.M.residues ## check that nothing has changed print '\nChecking that models are unchanged by doping ...' m_ref = PDBModel( self.f ) m_ref = m_ref.compress( m_ref.maskProtein() ) for k in m_ref.atoms.keys(): #ref = [ m_ref.atoms[i][k] for i in m_ref.atomRange() ] #mod = [ self.M.atoms[i][k] for i in self.M.atomRange() ] self.assert_( N.all( m_ref[k] == self.M[k]) ) ## display in Pymol if self.local: print "Starting PyMol..." from Biskit.Pymoler import Pymoler pm = Pymoler() pm.addPdb( self.M, 'm' ) pm.colorAtoms( 'm', N.clip(self.M.profile('relAS'), 0.0, 100.0) ) pm.show()
def test_molTools(self): """molTools test""" from Biskit import PDBModel ## Loading PDB... self.m = PDBModel(T.testRoot() + '/lig/1A19.pdb') self.m = self.m.compress(self.m.maskProtein()) hb = hbonds(self.m) xyz = xyzOfNearestCovalentNeighbour(40, self.m) if self.local: print '\nThe nearest covalently attached atom to the' print ' atom with index 40 has the coordinates:' print xyz print 'Potential h-bonds in model:' print '(donor index, acceptor index, distance and angle)' for h in hb: print h globals().update(locals()) self.r = N0.sum(N0.ravel(hb[3:5])) + N0.sum(xyz) self.assertAlmostEqual(self.r, self.EXPECT, 3)
class Test(BT.BiskitTest): """Test""" TAGS = [BT.EXE] def test_Prosa2003(self): """Prosa2003 test""" from Biskit import PDBModel ## Loading PDB... self.ml = PDBModel(T.testRoot() + '/lig/1A19.pdb') self.ml = self.ml.compress(self.ml.maskProtein()) self.mr = PDBModel(T.testRoot() + '/rec/1A2P.pdb') self.mr = self.mr.compress(self.mr.maskProtein()) ## Starting Prosa2003 self.prosa = Prosa2003([self.ml, self.mr], debug=0, verbose=0) ## Running self.ene = self.prosa.run() self.result = self.prosa.prosaEnergy() if self.local: print "Result: ", self.result self.assert_( N0.sum(self.result - [ -94.568, -64.903, -159.463 ] ) \ < 0.0000001 )
def test_IcmCad(self): """IcmCad test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.f = T.testRoot() + '/lig/1A19.pdb' self.m1 = PDBModel(self.f) self.m1 = self.m1.compress(self.m1.maskProtein()) self.ms = [] self.lig_traj = T.load(T.testRoot() + '/lig_pcr_00/traj.dat') for m in self.lig_traj[:3]: m = m.compress(m.maskProtein()) self.ms.append(m) if self.local: print 'Starting ICM' self.x = IcmCad(self.m1, self.ms, debug=self.DEBUG, verbose=self.local) if self.local: print 'Running' self.r = self.x.run() if self.local: print "Result: ", self.r self.assertEqual( self.r, [8.8603529999999999, 9.0315890000000003, 8.5055429999999994])
class Test(BT.BiskitTest): """Test""" TAGS = [ BT.EXE ] def test_Prosa2003(self): """Prosa2003 test""" from Biskit import PDBModel ## Loading PDB... self.ml = PDBModel( T.testRoot()+'/lig/1A19.pdb' ) self.ml = self.ml.compress( self.ml.maskProtein() ) self.mr = PDBModel( T.testRoot()+'/rec/1A2P.pdb' ) self.mr = self.mr.compress( self.mr.maskProtein() ) ## Starting Prosa2003 self.prosa = Prosa2003( [self.ml, self.mr], debug=0, verbose=0 ) ## Running self.ene = self.prosa.run() self.result = self.prosa.prosaEnergy() if self.local: print "Result: ", self.result self.assert_( N.sum(self.result - [ -94.568, -64.903, -159.463 ] ) \ < 0.0000001 )
def test_msms(self): """msms test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel( T.testRoot() + '/lig/1A19.pdb' ) self.m = self.m.compress( self.m.maskProtein() ) if self.local: print 'Getting surfaces via the MSMS executable' self.ms = MSMS( self.m, debug=self.DEBUG, verbose=self.local ) if self.local: print 'Running' out, sesList, sasList, atmList = self.ms.run() if self.local: print out print '\nResult from MSMS (first 5 lines): ' print 'SES \tSAS \tAtom name' for i in range(5): print '%.2f \t%.2f \t%s'%(sesList[i], sasList[i], atmList[i]) print 'MSMS done' globals().update( locals() ) self.assertAlmostEqual( out['sas'] + out['ses'], 5085.1580000000004 + 4208.7389999999996, 8 )
def test_SurfaceRacer(self): """SurfaceRacer test""" from Biskit import PDBModel import Biskit.mathUtils as MA if self.local: print 'Loading PDB...' f = T.testRoot() + '/lig/1A19.pdb' m = PDBModel(f) m = m.compress(m.maskProtein()) if self.local: print 'Starting SurfaceRacer' self.x = SurfaceRacer(m, 1.4, vdw_set=1, debug=self.DEBUG, verbose=0) if self.local: print 'Running ...' self.r = self.x.run() c = self.r['curvature'] ms = self.r['MS'] if self.local: print "Curvature: weighted mean %.6f and standard deviation %.3f"\ %(MA.wMean(c,ms), MA.wSD(c,ms)) print 'Relative MS of atoms 10 to 20:', self.r['relMS'][10:20] print 'Relative AS of atoms 10 to 20:', self.r['relAS'][10:20] self.e = (N.sum(self.r['relMS'][10:20]), N.sum(self.r['relAS'][10:20]), N.sum(self.r['curvature'][10:20])) self.assertAlmostEqual(self.e, self.EXPECT)
def test_model(self): """PDBDope test final model""" from Biskit import PDBModel if self.local: print '\nData added to info record of model (key -- value):' for k in self.d.m.info.keys(): print '%s -- %s' % (k, self.d.m.info[k]) print '\nAdded atom profiles:' print self.M.atoms print '\nAdded residue profiles:' print self.M.residues ## check that nothing has changed print '\nChecking that models are unchanged by doping ...' m_ref = PDBModel(self.f) m_ref = m_ref.compress(m_ref.maskProtein()) for k in m_ref.atoms.keys(): #ref = [ m_ref.atoms[i][k] for i in m_ref.atomRange() ] #mod = [ self.M.atoms[i][k] for i in self.M.atomRange() ] self.assert_(N.all(m_ref[k] == self.M[k])) ## display in Pymol if self.local: print "Starting PyMol..." from Biskit.Pymoler import Pymoler pm = Pymoler() pm.addPdb(self.M, 'm') pm.colorAtoms('m', N0.clip(self.M.profile('relAS'), 0.0, 100.0)) pm.show()
class Test(BT.BiskitTest): """Fold_X test""" TAGS = [ BT.EXE ] def test_Fold_X( self): """Fold_X test""" from Biskit import PDBModel ## Loading PDB... self.m = PDBModel( T.testRoot() + '/rec/1A2P.pdb' ) self.m = self.m.compress( self.m.maskProtein() ) ## Starting fold_X self.x = Fold_X( self.m, debug=self.DEBUG, verbose=(self.VERBOSITY>2) ) ## Running self.r = self.x.run() if self.local: print "Result: ", self.r for k, v in self.r.items(): self.assertAlmostEqual( v, self.EXPECTED[k], 6 ) EXPECTED = {'el': -13.766400000000001, 'wtbr': -4.8059700000000003, 'ene': -18.475000000000001, 'mc': 160.28800000000001, 'sloop': 0.0, 'dip': 0.00177626, 'sol_p': 167.71100000000001, 'disu': 0.0, 'tcl': 0.72696700000000003, 'cis': 0.0, 'p_cov': 0.0, 'sol_h': -134.613, 'bb_hb': -87.362499999999997, 'sc_hb': -48.350000000000001, 'vw': -116.67100000000001, 'sc': 58.089300000000001, 'el_kon': 0.0, 'mloop': 0.0, 'vwcl': 0.27728599999999998, 'bbcl': 0.37019200000000002}
def prepare(self): from Biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' self.M = PDBModel(self.f) self.M = self.M.compress(self.M.maskProtein()) self.d = PDBDope(self.M)
def test_addSecondaryNonFiltered(self): from Biskit import PDBModel m = PDBModel('1R4Q') d = PDBDope(m) d.addSecondaryStructure() r = m.compress(m.maskProtein())['secondary'] self.assertEqual(''.join(r), self.EXPECT_1RQ4)
def prepare(self): from Biskit import PDBModel import Biskit.tools as T if not self.M: if self.local: print "Loading PDB...", self.M = PDBModel(T.testRoot() + '/lig/1A19.pdb') self.M = self.M.compress(self.M.maskProtein()) if self.local: print "Done"
class Test(BT.BiskitTest): """Test class""" def test_reduce(self): """AtomCharger test""" if self.local: self.log.add('\nLoading PDB...') self.m1 = PDBModel(T.testRoot('lig/1A19_dry.model')) self.m2 = T.load(T.testRoot('com/ref.complex')) self.m2 = self.m2.model() if self.local: self.log.add('\nRunning Reduce...') self.x = Reduce(self.m1, debug=self.DEBUG, verbose=self.local, log=self.log, autocap=True) self.m1 = self.x.run() if self.local: self.log.add('\nReduce protein complex') self.x = Reduce(self.m2, debug=self.DEBUG, verbose=self.local, log=self.log, autocap=True) self.m2 = self.x.run() if self.local: self.log.add('\nSetup Residue Library\n') ac = AtomCharger(log=self.log, verbose=self.local) if self.local: self.log.add('match residues to Amber topology') ac.charge(self.m1) ac.charge(self.m2) self.assertAlmostEqual(N.sum(self.m1['partial_charge']), -6, 2) self.assertAlmostEqual(N.sum(self.m2['partial_charge']), -4, 2) self.assert_(N.all(self.m1['partial_charge'] != 0), 'unmatched atoms 1') self.assert_(N.all(self.m2['partial_charge'] != 0), 'unmatched atoms 2') if self.local: self.log.add('\nNow test handling of atom miss-matches:\n') self.m3 = PDBModel(self.m1.clone()) self.m3.remove([0, 3, 100, 101, 102, 200]) ac.charge(self.m3) self.assertAlmostEqual(N.sum(self.m3['partial_charge']), -8.21, 2)
def parseReference(self, fpdb, dry_out=None): flushPrint("parsing " + fpdb + "...") m = PDBModel(fpdb) solute_res = m.atom2resMask(logical_not(m.maskSolvent())) self.lenres = self.lenres or sum(solute_res) self.lenatoms = len(m) - sum(m.maskH2O()) if dry_out: m.remove(m.maskH2O()) m.writePdb(dry_out) flushPrint('done.\n')
class Test(BT.BiskitTest): """DSSP test""" TAGS = [BT.EXE] def prepare(self): self.f = T.testRoot() + "/com/1BGS.pdb" def generic_test(self, pdb, expected=None, proteinonly=False): """generic DSSP test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel(pdb) if proteinonly: self.m = self.m.compress(self.m.maskProtein()) if self.local: print 'Starting DSSP' self.dssp = Dssp(self.m, verbose=self.local, debug=self.DEBUG) if self.local: print 'Running DSSP' self.result = self.dssp.run() if self.local: print "Sequence :", self.m.sequence() print "Secondary:", self.result if expected: self.assertEquals(self.result, expected) EXPECTED = '.....SHHHHHHHHHHHSS..TTEE.HHHHHHHT..GGGT.HHHHSTT.EEEEEEE..TT..S...TT..EEEEE.S..SSS..S.EEEEETT..EEEESSSSSS.EE...EEEEETTT..SHHHHHHHHHHHHT..TT..SSHHHHHHHHHHT..SSEEEEEE.HHHHHHHTTTTHHHHHHHHHHHHHHT..EEEEE.' def test_DSSP(self): """DSSP test""" self.generic_test(self.f, expected=self.EXPECTED, proteinonly=True) def test_DSSP_2W3A(self): """DSSP test 2W3A""" self.generic_test('2W3A', proteinonly=True) def test_DSSP_1R4Q(self): """DSSP test""" self.generic_test('1R4Q', proteinonly=True) def test_DSSP_1AM7(self): self.generic_test('1AM7') def test_DSSP_5FB8(self): self.generic_test('5fb8')
class LongTest(BT.BiskitTest): TAGS = [BT.EXE, BT.LONG] def prepare(self): from Biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' self.M = PDBModel(self.f) self.M = self.M.compress(self.M.maskProtein()) self.d = PDBDope(self.M) def test_conservation(self): """PDBDope.addConservation (Hmmer) test""" if self.local: print "Adding conservation data...", self.d.addConservation() if self.local: print 'Done.' ## display in Pymol if self.local: print "Starting PyMol..." from Biskit.Pymoler import Pymoler pm = Pymoler() pm.addPdb(self.M, 'm') pm.colorAtoms('m', N0.clip(self.M.profile('cons_ent'), 0.0, 100.0)) pm.show() def test_delphi(self): """PDBDope.addDelphi test""" if self.local: self.log.add('Calculating Delphi electrostatic potential') self.log.add('') self.d.addDelphi(scale=1.2) self.assertAlmostEqual(self.M['delphi']['scharge'], 0.95, 1) ## EXPECT_1RQ4 = '.EEEEE.SSHHHHHHHHHHHHHHHEEEEEEEE.SS.EEEEE..SS...EEEEEEE.SSTTT.....EEEEEESSS..EEEEEETTTTEEEE.GGGTT...TT.EEEE.SS.SSHHHHHHHHTS.STT.EE.HHHHHHHHHHHHT..SS...HHHHHHHHHHHHHTHHHHH.HHHHHHHHGGGT.TT...EE..HHHHHHHTTHHHHHHHGGG.SS.SEEEETTEEESSHHHHHTT..EE.......SS.SSSS..EEEETTEEEEHHHHHHH.....EEEEE.SSHHHHHHHHHHHHHHHEEEEEEEEETTEEEEEE...S...EEEEEEE.SSSSS.....EEEEEETTT..EEEEEETTTTEEEE.GGGTT...TT.EEEE.SS..SHHHHHHHS...TTT.EE.TTHHHHHHHHHHT..SS...HHHHHHHHHHHHHHHHHHH.HHHHHHHGGGSS.TT...EE..HHHHHHHHTHHHHHHHGGG.SS.SEEEETTEEE.SHHHHHTT..EE........S.STTSS.EEESSSEEEEHHHHHHH.......EEEEE.EEEEEE.TTS.EEEEESS.EEEE..HHHHHHHHHHHHHT..EEEE.S..STT.B..EEEE...EEEEE...EEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHTT..EEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHHT.EEEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHTT.EEEEE.S..STT.B..EEEE...EEEEE.EEEEEE.SSS.EEEEETTEEEEE..HHHHHHHHHHHHHT..EEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..HHHHHHHHHHHHTT.EEEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHTT.EEEEE.S..STT.B..EEEE...EEEEE.EEEEEE.TTS.EEEEETTB..EE..TTHHHHHHHHHHHT..EEEE.SS.STT.B..EEEE.....EEE.EEEEEE.TTS.EEEEETTEEEEE..THHHHHHHHHHHHT..EEEE.S..STT.B..EEEE...EEEEE.EEEEEE.SSS.EEEEETTEEEEE..TTHHHHHHHHHTTT..EEEE.S..STT.B..EEEE.' EXPECT_1RQ4 = '.EEEEE.SSHHHHHHHHHHHHHHHEEEEEEEE.SS.EEEEE..SS...EEEEEEE.SSTTT.....EEEEEESSS..EEEEEETTTTEEEE.GGGTT...TT.EEEE.SS.SSHHHHHHHHTS.STT.EE.HHHHHHHHHHHHT..SS...HHHHHHHHHHHIIIIIHHH.HHHHHHHHGGGT.TT...EE..HHHHHHHTTHHHHHHHGGG.SS.SEEEETTEEESSHHHHHTT..EE.......SS.SSSS..EEEETTEEEEHHHHHHH.....EEEEE.SSHHHHHHHHHHHHHHHEEEEEEEEETTEEEEEE...S...EEEEEEE.SSSSS.....EEEEEETTT..EEEEEETTTTEEEE.GGGTT...TT.EEEE.SS..SHHHHHHHS...TTT.EE.TTHHHHHHHHHHT..SS...HHHHHHHHHHHIIIIIHHH.HHHHHHHGGGSS.TT...EE..HHHHHHHHTHHHHHHHGGG.SS.SEEEETTEEE.SHHHHHTT..EE........S.STTSS.EEESSSEEEEHHHHHHH.......EEEEE.EEEEEE.TTS.EEEEESS.EEEE..HHHHHHHHHHHHHT..EEEE.S..STT.B..EEEE...EEEEE...EEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHTT..EEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHHT.EEEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHTT.EEEEE.S..STT.B..EEEE...EEEEE.EEEEEE.SSS.EEEEETTEEEEE..HHHHHHHHHHHHHT..EEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..HHHHHHHHHHHHTT.EEEEE.S..STT.B..EEEE...EEEEEEEEEEEE.TTS.EEEEETTEEEEE..TTHHHHHHHHHHTT.EEEEE.S..STT.B..EEEE...EEEEE.EEEEEE.TTS.EEEEETTB..EE..TTHHHHHHHHHHHT..EEEE.SS.STT.B..EEEE.....EEE.EEEEEE.TTS.EEEEETTEEEEE..THHHHHHHHHHHHT..EEEE.S..STT.B..EEEE...EEEEE.EEEEEE.SSS.EEEEETTEEEEE..TTHHHHHHHHHTTT..EEEE.S..STT.B..EEEE.' def test_addSecondaryNonFiltered(self): from Biskit import PDBModel m = PDBModel('1R4Q') d = PDBDope(m) d.addSecondaryStructure() r = m.compress(m.maskProtein())['secondary'] self.assertEqual(''.join(r), self.EXPECT_1RQ4)
class Test(BT.BiskitTest): """Test class""" def test_reduce( self ): """AtomCharger test""" if self.local: self.log.add('\nLoading PDB...') self.m1 = PDBModel( T.testRoot( 'lig/1A19_dry.model' ) ) self.m2 = T.load( T.testRoot( 'com/ref.complex' ) ) self.m2 = self.m2.model() if self.local: self.log.add('\nRunning Reduce...') self.x = Reduce( self.m1, debug=self.DEBUG, verbose=self.local, log=self.log, autocap=True ) self.m1 = self.x.run() if self.local: self.log.add('\nReduce protein complex') self.x = Reduce( self.m2, debug=self.DEBUG, verbose=self.local, log=self.log, autocap=True ) self.m2 = self.x.run() if self.local: self.log.add('\nSetup Residue Library\n') ac = AtomCharger(log=self.log, verbose=self.local) if self.local: self.log.add('match residues to Amber topology') ac.charge( self.m1 ) ac.charge( self.m2 ) self.assertAlmostEqual( N.sum(self.m1['partial_charge']), -6, 2 ) self.assertAlmostEqual( N.sum(self.m2['partial_charge']), -4, 2 ) self.assert_(N.all(self.m1['partial_charge'] != 0),'unmatched atoms 1') self.assert_(N.all(self.m2['partial_charge'] != 0),'unmatched atoms 2') if self.local: self.log.add('\nNow test handling of atom miss-matches:\n') self.m3 = PDBModel(self.m1.clone()) self.m3.remove( [0,3,100,101,102,200] ) ac.charge( self.m3 ) self.assertAlmostEqual( N.sum(self.m3['partial_charge']),-8.21, 2)
def parseReference(self, fpdb, dry_out=None ): flushPrint("parsing "+fpdb+"...") m = PDBModel( fpdb ) solute_res = m.atom2resMask( logical_not( m.maskSolvent() ) ) self.lenres = self.lenres or sum( solute_res ) self.lenatoms = len( m ) - sum( m.maskH2O() ) if dry_out: m.remove( m.maskH2O() ) m.writePdb( dry_out ) flushPrint('done.\n')
def test_delphiCharges2(self): """ PDB2DelphiCharges test """ if self.local: T.errWrite('loading PDB...') self.m1 = self.MODEL or PDBModel(T.testRoot('lig/1A19_dry.model')) Test.MODEL = self.m1 if self.local: T.errWriteln('Done.') if self.local: T.errWrite('Adding hydrogens to model (reduce)...') self.rmodel = Reduce(self.m1, verbose=self.local).run() self.rmodel.xplor2amber() if self.local: T.errWriteln('Done.') ac = AtomCharger() ac.charge(self.rmodel) self.rmodel.addChainFromSegid() self.dc = PDB2DelphiCharges(self.rmodel) self.dc.prepare() self.assertEqual(len(self.dc.resmap['LYS']), 2) # normal and N' self.assertEqual(len(self.dc.resmap['SER']), 2) # normal and C' if self.local: T.errWriteln('writing delphi charge file to %s' % self.fcrg) self.dc.tofile(self.fcrg) self.assert_(os.path.exists(self.fcrg))
def test_hexTools(self): """Dock.hexTools test""" from Biskit import PDBModel self.m = PDBModel( t.testRoot() + '/com/1BGS.pdb' ) dist = centerSurfDist( self.m , self.m.maskCA() ) self.assertAlmostEqual( dist[0], 26.880979538, 7)
def test_reduce(self): """Reduce test""" if self.local: self.log.add('Loading PDB...') self.m1 = PDBModel(T.testRoot('lig/1A19_dry.model')) self.m2 = T.load(T.testRoot('com/ref.complex')) self.m2 = self.m2.model() 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()
class OldTest(BT.BiskitTest): TAGS = [BT.EXE, BT.OLD] def prepare(self): from Biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' self.M = PDBModel(self.f) self.M = self.M.compress(self.M.maskProtein()) self.d = PDBDope(self.M) def _test_addAsa(self): """PDBDope.addAsa (Whatif, obsolete) test""" self.d.addASA()
def test_surfaceRacerBug(self): """PDBDope.addSurfaceRacer mask handling bugfix""" import os from Biskit import PDBModel m = PDBModel(os.path.join(T.testRoot(), 'lig/1A19.pdb')) d = PDBDope(m) d.addSurfaceRacer()
class OldTest( BT.BiskitTest ): TAGS = [ BT.EXE, BT.OLD ] def prepare(self): from Biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' self.M = PDBModel( self.f ) self.M = self.M.compress( self.M.maskProtein() ) self.d = PDBDope( self.M ) def _test_addAsa(self): """PDBDope.addAsa (Whatif, obsolete) test""" self.d.addASA()
def inputComplex(options): if 'c' in options: return T.load(T.absfile(options['c'])) m = PDBModel(T.absfile(options['i'])) ## extract rec and lig chains rec_chains = T.toIntList(options['r']) lig_chains = T.toIntList(options['l']) rec = m.takeChains(rec_chains) lig = m.takeChains(lig_chains) ## create Protein complex com = Complex(rec, lig) return com
def test_IcmCad( self ): """IcmCad test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.f = T.testRoot() + '/lig/1A19.pdb' self.m1 = PDBModel(self.f) self.m1 = self.m1.compress( self.m1.maskProtein() ) self.ms = [] self.lig_traj = T.load( T.testRoot() + '/lig_pcr_00/traj.dat' ) for m in self.lig_traj[:3]: m = m.compress( m.maskProtein() ) self.ms.append(m) if self.local: print 'Starting ICM' self.x = IcmCad( self.m1, self.ms, debug=self.DEBUG, verbose=self.local ) if self.local: print 'Running' self.r = self.x.run() if self.local: print "Result: ", self.r self.assertEqual( self.r, [8.8603529999999999, 9.0315890000000003, 8.5055429999999994] )
def test_DSSP_alltroublemakers(self): from Biskit import PDBModel lst = '''1c48.pdb 3rlg.pdb 4gv5.pdb 4tsp.pdb 1p9g.pdb 3v03.pdb 4i0n.pdb 4tsq.pdb 1rd9.pdb 3v09.pdb 4idj.pdb 4wdc.pdb 1rdp.pdb 3vwi.pdb 4iw1.pdb 4whn.pdb 2anv.pdb 3w9p.pdb 4iya.pdb 4wvp.pdb 2anx.pdb 3weu.pdb 4j0l.pdb 4wx3.pdb 2f9r.pdb 3wev.pdb 4j2v.pdb 4wx5.pdb 2j8f.pdb 3wmu.pdb 4jk4.pdb 4zbq.pdb 2wc8.pdb 3wmv.pdb 4nzl.pdb 4zbr.pdb 2wcb.pdb 4bct.pdb 4ot2.pdb 5abw.pdb 2wce.pdb 4e99.pdb 4pho.pdb 5bpg.pdb 2xrs.pdb 4emx.pdb 4phq.pdb 5cr6.pdb 2xsc.pdb 4f5s.pdb 4po0.pdb 5dby.pdb 3a57.pdb 4f5t.pdb 4q7g.pdb 5elc.pdb 3hdf.pdb 4f5u.pdb 4rw3.pdb 5ele.pdb 3kve.pdb 4f5v.pdb 4rw5.pdb 5elf.pdb 3lu6.pdb 4fba.pdb 4tsl.pdb 5id7.pdb 3lu8.pdb 4fzm.pdb 4tsn.pdb 5id9.pdb 3mxg.pdb 4fzn.pdb 4tso.pdb'''.split() for s in lst: dssp = Dssp(PDBModel(s[:4])) r = dssp.run() if self.local: print s, ':' print r.sequence() print ''.join( r.compress(r.maskProtein())['dssp'] ) print
def test_errorcase1(self): """bindinEnergyDelphi test (error case 01)""" self.m = PDBModel(T.testRoot() + '/delphi/case01.pdb') rec = self.m.takeChains([0, 1]) lig = self.m.takeChains([2]) self.com = Complex(rec, lig) self.dG = DelphiBindingEnergy(self.com, log=self.log, scale=0.5, verbose=self.local) self.r = self.dG.run() if self.local: self.log.add('\nFinal result: dG = %3.2f kcal/mol' % self.r['dG_kcal'])
def test_molUtils(self): """molUtils test""" from Biskit import PDBModel S = self ## load a structure S.m = PDBModel(t.testRoot() + '/lig/1A19.pdb') S.model_1 = S.m.compress(S.m.maskProtein()) ## now sort in standard order S.model_2 = sortAtomsOfModel(S.model_1) ## compare the atom order cmp = [] for a in S.model_1.atomRange(): cmp += [cmpAtoms(S.model_1.atoms[a], S.model_2.atoms[a])] self.assertEqual(N0.sum(cmp), 159) ## get the primaty sequence as a string S.seq = S.model_1.sequence() ## convert it to a list of three letter code S.seq = single2longAA(S.seq) ## convert it to a list in one letter code S.seq = singleAA(S.seq) self.assertEqual(''.join(S.seq), S.model_1.sequence())
def inputComplex( options ): if 'c' in options: return T.load( T.absfile( options['c'] ) ) m = PDBModel( T.absfile( options['i'] ) ) ## extract rec and lig chains rec_chains = T.toIntList( options['r'] ) lig_chains = T.toIntList( options['l'] ) rec = m.takeChains( rec_chains ) lig = m.takeChains( lig_chains ) ## create Protein complex com = Complex( rec, lig ) return com
def prepare(self): from Biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' self.M = PDBModel( self.f ) self.M = self.M.compress( self.M.maskProtein() ) self.d = PDBDope( self.M )
def prepare( self ): from Biskit import PDBModel import Biskit.tools as T if not self.M: if self.local: print "Loading PDB...", self.M = PDBModel( T.testRoot()+'/lig/1A19.pdb') self.M = self.M.compress( self.M.maskProtein() ) if self.local: print "Done"
def test_DSSP_2W3A( self ): """DSSP test 2W3A""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel('2W3A') if self.local: print 'Starting DSSP' self.dssp = Dssp( self.m, verbose=self.local, debug=self.DEBUG ) if self.local: print 'Running DSSP' self.result = self.dssp.run() if self.local: print "Sequence :", self.m.sequence() print "Secondary:", self.result
def test_surfaceRacerTools(self): """surfaceRacerTools test""" from Biskit import PDBModel import Biskit.tools as T ## load a structure self.m = PDBModel(T.testRoot() + '/lig/1A19.pdb') self.m = self.m.compress(self.m.maskProtein()) self.m = self.m.compress(self.m.maskHeavy()) ## some fake surface data surf = N0.ones(self.m.lenAtoms()) * 10.0 relExp = relExposure(self.m, surf) ## if self.local: ## globals().update( locals() ) self.assertAlmostEqual(N0.sum(relExp), 44276.86085222386, 8)
def test_Fold_X(self): """Fold_X test""" from Biskit import PDBModel ## Loading PDB... self.m = PDBModel(T.testRoot() + '/rec/1A2P.pdb') self.m = self.m.compress(self.m.maskProtein()) ## Starting fold_X self.x = Fold_X(self.m, debug=self.DEBUG, verbose=(self.VERBOSITY > 2)) ## Running self.r = self.x.run() if self.local: print "Result: ", self.r for k, v in self.r.items(): self.assertAlmostEqual(v, self.EXPECTED[k], 6)
def test_DSSP(self): """DSSP test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel(self.f) self.m = self.m.compress(self.m.maskProtein()) if self.local: print 'Starting DSSP' self.dssp = Dssp(self.m, verbose=self.local, debug=self.DEBUG) if self.local: print 'Running DSSP' self.result = self.dssp.run() if self.local: print "Sequence :", self.m.sequence() print "Secondary:", self.result self.assertEquals(self.result, self.EXPECTED)
def test_Hmmer( self): """Hmmer test """ from Biskit import PDBModel import Biskit.tools as T if self.local: print "Loading PDB...", self.m = PDBModel( T.testRoot()+'/lig/1A19.pdb') self.model = self.m.compress( self.m.maskProtein() ) if self.local: print "Done" ## initiate and check database status self.hmmer = Hmmer( hmmdb=settings.hmm_db, verbose=self.local, log=self.log ) self.hmmer.checkHmmdbIndex() ## scoring methods to use method = [ 'emmScore', 'ent', 'maxAll', 'absSum', 'maxAllScale' ] ## search searchMatches, searchHits = self.hmmer.searchHmmdb( self.model ) hmmNames = self.hmmer.selectMatches( searchMatches, searchHits ) ## hmmNames = {'Barstar': [[1, 89]]} self.cons = [] self.result = None for name in hmmNames.keys(): ## retrieve hmm model hmmDic = self.hmmer.getHmmProfile( name ) ## align sequence with model fastaSeq, hmmSeq, repete, hmmGap = \ self.hmmer.align( self.model, hmmNames[ name ] ) ## cast hmm model hmmDic_cast = \ self.hmmer.castHmmDic( hmmDic, repete, hmmGap, method[0] ) ## Hmmer profile match scores for sequence self.cons = self.hmmer.matchScore( fastaSeq, hmmSeq, hmmDic_cast, method[0] ) ## If there are more than one profile in the model, merge to one. if self.result: self.result = self.hmmer.mergeProfiles( self.result, self.cons ) else: self.result = self.cons self.hmmer.cleanup() self.assertEqual( self.result, self.EXPECTED )
class Test(BT.BiskitTest): """Test case""" def test_surfaceRacerTools(self): """surfaceRacerTools test""" from Biskit import PDBModel import Biskit.tools as T ## load a structure self.m = PDBModel( T.testRoot()+'/lig/1A19.pdb' ) self.m = self.m.compress( self.m.maskProtein() ) self.m = self.m.compress( self.m.maskHeavy() ) ## some fake surface data surf = Numeric.ones( self.m.lenAtoms()) * 10.0 relExp = relExposure( self.m, surf ) ## if self.local: ## globals().update( locals() ) self.assertEqual( Numeric.sum(relExp), 44276.860852223857 )
class LongTest( BT.BiskitTest ): TAGS = [ BT.EXE, BT.LONG ] def prepare(self): from Biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' self.M = PDBModel( self.f ) self.M = self.M.compress( self.M.maskProtein() ) self.d = PDBDope( self.M ) def test_conservation(self): """PDBDope.addConservation (Hmmer) test""" if self.local: print "Adding conservation data...", self.d.addConservation() if self.local: print 'Done.' ## display in Pymol if self.local: print "Starting PyMol..." from Biskit.Pymoler import Pymoler pm = Pymoler() pm.addPdb( self.M, 'm' ) pm.colorAtoms( 'm', N.clip(self.M.profile('cons_ent'), 0.0, 100.0) ) pm.show() def test_delphi(self): """PDBDope.addDelphi test""" if self.local: self.log.add( 'Calculating Delphi electrostatic potential' ) self.log.add( '' ) self.d.addDelphi( scale=1.2 ) self.assertAlmostEqual( self.M['delphi']['scharge'], 0.95, 1 )
def test_errorcase1( self ): """bindinEnergyDelphi test (error case 01)""" self.m = PDBModel( T.testRoot() + '/delphi/case01.pdb' ) rec = self.m.takeChains( [0,1] ) lig = self.m.takeChains( [2] ) self.com = Complex( rec, lig ) self.dG = DelphiBindingEnergy( self.com, log = self.log, scale=0.5, verbose=self.local ) self.r = self.dG.run() if self.local: self.log.add( '\nFinal result: dG = %3.2f kcal/mol'%self.r['dG_kcal'])
def test_Whatif(self): """Whatif test""" from Biskit import PDBModel ## Loading PDB... f = T.testRoot()+"/com/1BGS.pdb" m = PDBModel(f) m = m.compress( m.maskProtein() ) m = m.compress( m.maskHeavy() ) ## Starting WhatIf x = WhatIf( m, debug=0, verbose=0 ) ## Running atomAcc, resAcc, resMask = x.run() if self.local: ## check that model hasn't changed m_ref = PDBModel(f) m_ref = m.compress( m.maskProtein() ) for k in m_ref.atoms.keys(): if not N0.all(m_ref[k] == m[k]): print 'Not equal ', k else: print 'Equal ', k ## display exposed residues in PyMol from Pymoler import Pymoler pm = Pymoler() model = pm.addPdb( m, '1' ) pm.colorRes( '1', resAcc[:,0] ) pm.show() print "\nResult for first 10 atoms/residues: " print '\nAccessability (A^2):\n', atomAcc[:10] print '\nResidue accessability (A^2)' print '[total, backbone, sidechain]:\n', resAcc[:10] print '\nExposed residue mask:\n',resMask[:10] print '\nTotal atom accessability (A^2): %.2f'%sum(atomAcc) print ' residue accessability (A^2): %.2f'%sum(resAcc)[0] self.assertAlmostEqual( N0.sum(resAcc[:,0]), 2814.6903, 7 )
def test_Fold_X( self): """Fold_X test""" from Biskit import PDBModel ## Loading PDB... self.m = PDBModel( T.testRoot() + '/rec/1A2P.pdb' ) self.m = self.m.compress( self.m.maskProtein() ) ## Starting fold_X self.x = Fold_X( self.m, debug=self.DEBUG, verbose=(self.VERBOSITY>2) ) ## Running self.r = self.x.run() if self.local: print "Result: ", self.r for k, v in self.r.items(): self.assertAlmostEqual( v, self.EXPECTED[k], 6 )
def test_DSSP( self ): """DSSP test""" from Biskit import PDBModel if self.local: print 'Loading PDB...' self.m = PDBModel(self.f) self.m = self.m.compress( self.m.maskProtein() ) if self.local: print 'Starting DSSP' self.dssp = Dssp( self.m ) if self.local: print 'Running DSSP' self.result = self.dssp.run() if self.local: print "Sequence :", self.m.sequence() print "Secondary:", self.result self.assertEquals( self.result, self.EXPECTED)
if __name__ == '__main__': options = cmdDict( {'ter':1} ) if len( options ) < 2: _use( options ) skip = None if options.has_key('wat'): skip = ['TIP3', 'WAT', 'HOH', 'H2O', 'Na+', 'Cl-'] fin = [ absfile(f) for f in toList( options['i'] ) ] ter = int( options['ter'] ) codeprefix = options.has_key( 'codeprefix' ) for f in fin: fout= options.get('o', None) or stripSuffix( f ) + '.pdb' m = PDBModel( f ) if codeprefix: code = m.pdbCode or '' fpath, fname = osp.split( fout ) fout = osp.join( fpath, code + fname ) m.writePdb( fout, ter=ter ) errWriteln('dumped ' + fout )
Syntax pdb2seq.py |pdb_file| """ def printSequence( header, s ): n_chunks = len( s ) / 80 print ">%s" % header for i in range(0, n_chunks+1): if i * 80 + 80 < len( s ): chunk = s[i * 80 : i * 80 + 80] else: chunk = s[i * 80 :] print chunk if __name__ == '__main__': if len( sys.argv ) < 1: _use() m = PDBModel( sys.argv[1] ) seq = m.sequence() printSequence( m.pdbCode, seq )
def process_all( self, file_dic, keep_hetatoms=0 ): """ Process PDB files in file_dic. The PDB is read from: - L{TemplateSearcher.F_NR} and cleaned files are written to: - L{F_CLEANED} - L{F_COFFEE} - L{F_MODELLER} If the file L{F_CLEANED} already exists, this file is used to write modeller and t-coffee pdbs. @param file_dic: dictionary mapping filenames of pdb files to the chains of interest, e.g. { fname : chain_id, } @type file_dic: {str:str} @param keep_hetatoms: keep hetatoms (default: 0) @type keep_hetatoms: 0|1 """ fasta = "" c = None for f, id in file_dic.items(): self.logWrite( '\nCLEANING ' + f + '...') try: code = string.split(f, '/')[-1][:4] ## clean to standard PDB c = PDBCleaner( f, self.log ) ## if /templates/nr_cleaned/pfb-file exists if os.path.exists( self.outFolder+self.F_CLEANED + code + '.pdb' ): model = PDBModel( self.outFolder+self.F_CLEANED \ + code + '.pdb' ) ## read pdb from /templates/nr else: model = c.process( keep_hetatoms=keep_hetatoms ) ## write complete cleaned PDB model.writePdb( self.outFolder+self.F_CLEANED \ + code + '.pdb') code = model.pdbCode title = code + '_' + id ## extract needed chain if len( id ) > 0: model = self.__chain_by_id( model, id ) fname = "%s%s.pdb" % (self.outFolder + self.F_MODELLER, title) self.write_modeller_pdb( model, fname ) ## write T_coffee CA trace with res sequence fname = "%s%s.alpha"%(self.outFolder + self.F_COFFEE, title) self.write_tcoffee_pdb( model, fname ) ## append fasta fasta += self.fasta_sequence( title, model.sequence() ) except: self.logWrite( 'Error cleaning ' + f) self.logWrite( T.lastError() ) self.err_cleaner = c self.err_file = f fasta_out = open( self.outFolder + self.F_FASTA, 'w' ) fasta_out.write( fasta ) fasta_out.close()
class Test(BT.BiskitTest): """Hmmer test""" TAGS = [ BT.EXE ] M = None def prepare( self ): from Biskit import PDBModel import Biskit.tools as T if not self.M: if self.local: print "Loading PDB...", self.M = PDBModel( T.testRoot()+'/lig/1A19.pdb') self.M = self.M.compress( self.M.maskProtein() ) if self.local: print "Done" def test_HmmSearch( self ): """HmmSearch test""" self.searcher = HmmerSearch( self.M, verbose=self.local, log=self.log ) self.matches, self.hits = self.searcher.run() def test_HmmProfile( self ): """HmmerProfile test""" profile = HmmerProfile( 'FH2', verbose=self.local, log=self.log) self.profileDic = profile.run() def test_HmmerFasta( self ): """Hmmer test (search from fasta)""" h = Hmmer(hmmdb=settings.hmm_db) h.checkHmmdbIndex() self.searchMatches, self.searchHits = h.searchHmmdb( T.testRoot()+'/Mod/project/target.fasta' ) self.assertTrue( len( self.searchHits ) > 3 ) def test_HmmerModel( self): """Hmmer test (search from model)""" ## initiate and check database status self.hmmer = Hmmer( hmmdb=settings.hmm_db, verbose=self.local, log=self.log ) self.hmmer.checkHmmdbIndex() ## scoring methods to use method = [ 'emmScore', 'ent', 'maxAll', 'absSum', 'maxAllScale' ] ## search searchMatches, searchHits = self.hmmer.searchHmmdb( self.M ) hmmNames = self.hmmer.selectMatches( searchMatches, searchHits ) ## hmmNames = {'Barstar': [[1, 89]]} self.cons = [] self.result = None for name in hmmNames.keys(): ## retrieve hmm model hmmDic = self.hmmer.getHmmProfile( name ) ## align sequence with model fastaSeq, hmmSeq, repete, hmmGap = \ self.hmmer.align( self.M, hmmNames[ name ] ) ## cast hmm model hmmDic_cast = \ self.hmmer.castHmmDic( hmmDic, repete, hmmGap, method[0] ) ## Hmmer profile match scores for sequence self.cons = self.hmmer.matchScore( fastaSeq, hmmSeq, hmmDic_cast, method[0] ) ## If there are more than one profile in the model, merge to one. ## Note: this can be problematic as scores depend on family size if self.result: self.result = self.hmmer.mergeProfiles( self.result, self.cons ) else: self.result = self.cons self.hmmer.cleanup() self.assertEqual( self.result, self.EXPECTED ) #: Hmmer emission scores EXPECTED = [2581.0, 3583.0, 1804.0, 2596.0, 3474.0, 2699.0, 3650.0, 2087.0, 2729.0, 2450.0, 2412.0, 2041.0, 3474.0, 1861.0, 2342.0, 2976.0, 5124.0, 2729.0, 2202.0, 2976.0, 3583.0, 2202.0, 2103.0, 2976.0, 1922.0, 2132.0, 4122.0, 2403.0, 4561.0, 4561.0, 3650.0, 2087.0, 4001.0, 2976.0, 3860.0, 3260.0, 2976.0, 6081.0, 3860.0, 5611.0, 2976.0, 3609.0, 3650.0, 6081.0, 3343.0, 2403.0, 3288.0, 4122.0, 2976.0, 2322.0, 2976.0, 1995.0, 4378.0, 2706.0, 2665.0, 4186.0, 3539.0, 2692.0, 3270.0, 2302.0, 2604.0, 2132.0, 2118.0, 2380.0, 2614.0, 2170.0, 3260.0, 2403.0, 1964.0, 3343.0, 2976.0, 2643.0, 3343.0, 2714.0, 2591.0, 3539.0, 3260.0, 2410.0, 1809.0, 3539.0, 2111.0, -774.0, 3860.0, 2450.0, 2063.0, 3474.0, 3474.0, 2057.0, 1861.0]
import Biskit.mathUtils as MU def getSS( model, cutoff=4.0 ): cys_mask = model.mask( lambda a: a['residue_name'] in ['CYS', 'CYX']\ and a['name'] == 'SG') model = model.compress( cys_mask ) diff = MU.pairwiseDistances( model.xyz, model.xyz ) count = N.sum( N.sum( N.less( diff, cutoff ) ) ) - model.lenAtoms() return count / 2 if __name__ == '__main__': if len( sys.argv ) < 2: print """Count number of SS bonds in protein. Syntax: getSS.py |input1.pdb| |input_2.pdb| .. """ sys.exit(0) for f in sys.argv[1:]: m = PDBModel( f ) flushPrint( '%s : %2i\n' % (m.sourceFile(),getSS( m )) )
if __name__ == '__main__': if len( sys.argv ) < 4: _use() options = cmdDict( {} ) f1 = absfile( options['i1'] ) f2 = absfile( options['i2'] ) o1 = absfile( options['o1'] ) o2 = absfile( options['o2'] ) errWriteln("loading pdbs...") m1 = PDBModel( f1 ) m2 = PDBModel( f2 ) if options.has_key('c1'): m1 = m1.takeChains( toIntList( options['c1'] ) ) if options.has_key('c2'): m2 = m2.takeChains( toIntList( options['c2'] ) ) m1.removeRes( 'TIP3' ) m2.removeRes( 'TIP3' ) m1.sort() m2.sort() errWriteln("compare atoms of pdbs...")
def main(options): ################## ## files and names receptorName = absfile(options['r']) receptorCode = stripFilename(receptorName)[0:4] ligandName = absfile(options['l']) ligandCode = stripFilename(ligandName)[0:4] complexName = absfile(options['c']) rm = options['rm'] lm = options['lm'] if rm or lm: rn = rm or '1' ln = lm or '1' baseName = receptorCode + '_' + rn + '-' + ligandCode + '_' + ln else: baseName = receptorCode + '-' + ligandCode ## hex macro name macName = baseName + '_hex.mac' ## hex rotation matrix output name outName_all = baseName + '_hex.out' outName_clust = baseName + '_hex_cluster.out' ## load model dictionaries, if they exist in the same directory ## as the corresponding pdb-file and start with the same pdb-code ## and ends with '_model.dic' try: rec_dic = stripFilename(options['r'])[:4] + '_model.dic' rec_path = options['r'][:options['r'].rfind('/')] lig_dic = stripFilename(options['l'])[:4] + '_model.dic' lig_path = options['l'][:options['l'].rfind('/')] rec = load( absfile(rec_path + '/' + rec_dic) ) lig = load( absfile(lig_path + '/' + lig_dic) ) print 'Loading dictionaries' if type(rec) is dict: rec = rec[1] if type(lig) is dict: lig = lig[1] ## could not load dictionaty, will load pdb-file insted except: print 'Loading pdb files' rec = PDBModel(receptorName) lig = PDBModel(ligandName) ############################# ## get structural information ## add surface profiles if not there if not rec.atoms.has_key('relASA'): flushPrint('\nCalculating receptor surface profile') rec_asa = PDBDope( rec ) rec_asa.addASA() if not lig.atoms.has_key('relASA'): flushPrint('\nCalculating ligand surface profile') lig_asa = PDBDope( lig ) lig_asa.addASA() ## surface masks, > 95% exposed rec_surf_mask = greater( rec.profile('relASA'), 95 ) lig_surf_mask = greater( lig.profile('relASA'), 95 ) ## maximun and medisn distance from centre of mass to any surface atom recMax, recMin = centerSurfDist( rec, rec_surf_mask ) ligMax, ligMin = centerSurfDist( lig, lig_surf_mask ) ## approxinate max and min center to centre distance maxDist = recMax + ligMax minDist = recMin + ligMin print '\n\nReceptor and ligand max radius are %i and %i A, respectively.'\ %( recMax, ligMax ) print 'Receptor and ligand min radius are %i and %i A, respectively.'\ %( recMin, ligMin ) ## molecular separation and search range to be used in the docking molSep = ( maxDist + minDist ) / 2 molRange = 2 * ( maxDist - molSep ) print 'A molecular separation of %i A and a search range of +-%i will be used.'\ %( molSep, molRange ) ## determine docking mode to use macroDocking = 0 if recMax > 30 and ligMax > 30: print '\nWARNING! Both the receptor and ligand radius is greater than 30 A.\n' if recMax > 30: print '\nReceptor has a radius that exceeds 30 A -> Macro docking will be used' macroDocking = 1 ##################### ## write macro file macOpen= open(macName, 'w') macOpen.write('# ------------------- ' + macName + ' -----------------------\n') macOpen.write(' \n') macOpen.write('open_receptor '+receptorName+'\n') macOpen.write('open_ligand '+ligandName+'\n') if complexName[-4:] == '.pdb': macOpen.write('open_complex '+complexName+'\n') macOpen.write('\n') head = """ # -------------- general settings ---------------- disc_cache 1 # disc cache on (0 off) docking_sort_mode 1 # Sort solutions by cluster (0 by energy) docking_cluster_mode 1 # Display all clusters (0 display best) docking_cluster_threshold 2.00 # docking_cluster_bumps number # ------------ molecule orientation -------------- molecule_separation %(separation)i commit_view """%({'separation': round(molSep)} ) macro =""" # -------------- macro docking ------------------- macro_min_coverage 25 macro_sphere_radius 15 macro_docking_separation 25 activate_macro_model""" tail = """ # -------------- docking setup ------------------- docking_search_mode 0 # full rotational search receptor_range_angle 180 # 0, 15, 30, 45, 60, 75, 90, 180 docking_receptor_samples 720 # 362, 492, 642, 720, 980, 1280 ligand_range_angle 180 docking_ligand_samples 720 twist_range_angle 360 # 0, 15, 30, 60, 90, 180, 360 docking_alpha_samples 128 # 64, 128, 256 r12_step 0.500000 # 0.1, 0.2, 0.25, 0.5, 0.75, 1, 1.5, 2 r12_range %(range)i docking_radial_filter 0 # Radial Envelope Filter - None # docking_radial_filter 0 # Radial Envelope Filter - Re-entrant # docking_radial_filter 0 # Radial Envelope Filter - Starlike grid_size 0.600 # 0.4, 0.5, 0.6, 0.75, 1.0 # docking_electrostatics 0 # use only surface complimentarity docking_electrostatics 1 # use electrostatic term for scoring clusters docking_main_scan 16 # docking_main_search 26 max_docking_solutions %(nr_sol)i # number of solutions to save # -------------- post-processing ---------------- docking_refine 0 # None # docking_refine 1 # Backbone Bumps and volumes # docking_refine 2 # MM energies # docking_refine 3 # MM minimization # ---------------- run docking ------------------ activate_docking save_docking %(output_clust)s # save_range 1 512 ./ dock .pdb # ------------ also save all solutions ---------- docking_sort_mode 0 # Sort solutions by energy (1 by cluster) save_docking %(output_all)s""" \ %({'range':round(molRange), 'output_all':outName_all, 'nr_sol':int(options['sol']), 'output_clust':outName_clust} ) macOpen.writelines( head ) ## select certain models if rm or lm: macOpen.write('\n') macOpen.write('\n# -------------- select models -------------------\n') if rm: select_rec_model = 'dock_receptor_model %s'%rm macOpen.write( select_rec_model + '\n') if lm: select_lig_model = 'dock_ligand_model %s'%lm macOpen.write( select_lig_model + '\n') ## macro docking will not work with multiple models, if both are added to ## the hex macro file - macrodocking will be skipped during the docking run if macroDocking: macOpen.writelines( macro ) macOpen.writelines( tail ) macOpen.close()