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()
def test_Xplorer(self): """Xplorer test""" ## input template variables param = T.dataRoot() + '/xplor/toppar/param19.pro' pdb_out = self.dir_out + '/lig.pdb' log_out = self.dir_out + '/test.out' pdb_in = T.testRoot() + '/lig/1A19.pdb' psf_in = T.testRoot() + '/lig/1A19.psf' self.x = Xplorer(self.dir_out + '/test.inp', xout=log_out, verbose=self.local, lig_psf=psf_in, lig_pdb=pdb_in, param19=param, lig_out=pdb_out) self.x.run() if self.local: print(""" The minimized structure and the X-Plor log file have been written to %s and %s, respectively """ % (pdb_out, log_out)) print("""See x.logLines for the complete xplor log file!""")
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)
def test_Xplorer( self ): """Xplorer test""" ## input template variables param = T.dataRoot() + '/xplor/toppar/param19.pro' pdb_out = self.dir_out +'/lig.pdb' log_out = self.dir_out +'/test.out' pdb_in = T.testRoot() + '/lig/1A19.pdb' psf_in = T.testRoot() + '/lig/1A19.psf' self.x = Xplorer( self.dir_out +'/test.inp', xout = log_out, verbose = self.local, lig_psf = psf_in, lig_pdb = pdb_in, param19 = param, lig_out = pdb_out ) self.x.run() if self.local: print(""" The minimized structure and the X-Plor log file have been written to %s and %s, respectively """ % (pdb_out, log_out)) print("""See x.logLines for the complete xplor log file!""")
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 )
def test_atomcharger( self ): """AtomCharger test""" import biskit.tools as T if self.local: self.log.add('\nLoading PDB...') self.m1 = PDBModel( T.testRoot('delphi/1A19_reduced.model')) self.m2 = PDBModel( T.testRoot('delphi/complex_reduced.model')) 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.assertTrue(N.all(self.m1['partial_charge'] != 0),'unmatched atoms 1') self.assertTrue(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 test_atomcharger(self): """AtomCharger test""" import biskit.tools as T if self.local: self.log.add('\nLoading PDB...') self.m1 = PDBModel(T.testRoot('delphi/1A19_reduced.model')) self.m2 = PDBModel(T.testRoot('delphi/complex_reduced.model')) 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.assertTrue(N.all(self.m1['partial_charge'] != 0), 'unmatched atoms 1') self.assertTrue(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 test_ComplexRandomizer(self): """Dock.ComplexRandomizer test""" from biskit.md import Trajectory if self.local: print("\nLoading Rec and Lig files ...", end=' ') rec_pdb = t.testRoot() + '/rec/1A2P.pdb' lig_pdb = t.testRoot() + '/lig/1A19.pdb' rec_psf = t.testRoot() + '/rec/1A2P.psf' lig_psf = t.testRoot() + '/lig/1A19.psf' rec = XplorModel( rec_psf, rec_pdb ) lig = XplorModel( lig_psf, lig_pdb ) if self.local: print("Initializing Randomizer...") self.cr = ComplexRandomizer( rec, lig, debug=self.DEBUG ) if self.local: print("Creating 3 random complexes...") cs = [ self.cr.random_complex() for i in range(3) ] self.traj = Trajectory( [ c.model() for c in cs ], verbose=self.local ) if self.local: self.display( self.traj ) globals().update( locals() ) self.assertEqual( len(self.traj), 3 )
def test_XplorModel(self): """XplorModel test""" ## Loading PDB... self.m_com = XplorModel(t.testRoot() + "/com/1BGS.psf", t.testRoot() + "/com/1BGS.pdb") self.m_rec = XplorModel(t.testRoot() + "/rec/1A2P.psf", t.testRoot() + "/rec/1A2P.pdb") ## remove waters self.m_com = self.m_com.compress(self.m_com.maskProtein()) self.m_rec = self.m_rec.compress(self.m_rec.maskProtein()) ## fit the complex structure to the free receptor m_com_fit = self.m_com.magicFit(self.m_rec) ## calculate the rmsd between the original complex and the ## one fitted to the free receptor rms = m_com_fit.rms(self.m_com, fit=0) if self.local: print('Rmsd between the two complex structures: %.2f Angstrom' % rms) self.assertAlmostEqual(rms, 58.7844130314, 4)
def test_TrajParserNetCDF(self): """TrajParserNetCDF test""" fcrd = T.testRoot('amber/md_netcdf/heat.ncdf') fpdb = T.testRoot('amber/md_netcdf/0.pdb') self.assertTrue(TrajParseNetCDF.supports(fcrd)) p = TrajParseNetCDF() t = p.parse2new(fcrd, fpdb) self.assertEqual(t.lenAtoms(), 365) self.assertEqual(len(t), 6)
def test_TrajParserAmberCrd(self): """TrajParserNetCDF test""" fcrd = T.testRoot('lig_pcr_00/raw/traj.crd') fpdb = T.testRoot('lig_pcr_00/raw/traj_ref.pdb') self.assertTrue( TrajParseAmberCrd.supports(fcrd)) p = TrajParseAmberCrd(hasbox=False) t = p.parse2new( fcrd, fpdb) self.assertEqual(t.lenAtoms(),876) self.assertEqual(len(t),100)
def prepare(self): root = T.testRoot('amber/leap/') self.ref = PDBModel( T.testRoot('amber/leap/1HPT_solvated.pdb')) self.refdry = root + '1HPT_dry.pdb' self.dryparm = tempfile.mktemp('.parm', 'dry_') self.drycrd = tempfile.mktemp('.crd', 'dry_') self.drypdb = tempfile.mktemp('.pdb', 'dry_') self.wetparm = tempfile.mktemp('.parm', 'wet_') self.wetcrd = tempfile.mktemp('.crd', 'wet_') self.wetpdb = tempfile.mktemp('.pdb', 'wet_') self.leapout = tempfile.mktemp('.out', 'leap_')
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'])
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 test_ComplexTraj(self): """Dock.ComplexTraj test""" import biskit.tools as T ## there is no complex trajectory in the test folder so will have ## to create a fake trajectory with a complex f = [T.testRoot() + '/com/1BGS.pdb'] * 5 t = Trajectory(f, verbose=self.local) t = ComplexTraj(t, recChains=[0]) #if self.local: #print 'plotting contact density...' #t.plotContactDensity( step=2 ) ## create a fake second chain in the ligand for i in range(1093 + 98, 1968): t.ref.atoms['chain_id'][i] = 'B' t.ref.chainIndex(force=1, cache=1) t.cl = [1, 2] r = N0.concatenate( (list(range(1093, 1191)), list(range(0, 1093)), list(range(1191, 1968)))) tt = t.takeAtoms(r) contactMat = tt.atomContacts(1) if self.local: print('Receptor chains: %s Ligand chains: %s' % (t.cr, t.cl)) self.assertEqual(N0.sum(N0.ravel(contactMat)), 308)
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'])
def test_Capping(self): """PDBCleaner.capTerminals test""" ## Loading PDB... self.model = PDBModel(t.testRoot() + '/rec/1A2P_rec_original.pdb') self.c = PDBCleaner(self.model, log=self.log, verbose=self.local) self.m2 = self.c.capTerminals(breaks=True) self.assertTrue(self.m2.atomNames() == self.model.atomNames()) self.m3 = self.model.clone() self.m3.removeRes([10, 11, 12, 13, 14, 15]) self.m4 = self.m3.clone() self.c = PDBCleaner(self.m3, log=self.log, verbose=self.local) self.m3 = self.c.capTerminals(breaks=True, capC=[0], capN=[0, 1]) self.assertEqual( self.m3.takeChains([0]).sequence()[:18], 'XVINTFDGVADXXKLPDN') if self.local: self.log.add('\nTesting automatic chain capping...\n') self.c = PDBCleaner(self.m4, log=self.log, verbose=self.local) self.m4 = self.c.capTerminals(auto=True) self.assertEqual( self.m4.takeChains([0]).sequence()[:18], 'XVINTFDGVADXXKLPDN')
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.assertTrue( os.path.exists( self.fcrg ) )
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()
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']) )
def test_Capping( self ): """PDBCleaner.capTerminals test""" ## Loading PDB... self.model = PDBModel(t.testRoot() + '/rec/1A2P_rec_original.pdb') self.c = PDBCleaner( self.model, log=self.log, verbose=self.local ) self.m2 = self.c.capTerminals( breaks=True ) self.assertTrue( self.m2.atomNames() == self.model.atomNames() ) self.m3 = self.model.clone() self.m3.removeRes( [10,11,12,13,14,15] ) self.m4 = self.m3.clone() self.c = PDBCleaner( self.m3, log=self.log, verbose=self.local ) self.m3 = self.c.capTerminals( breaks=True, capC=[0], capN=[0,1]) self.assertEqual( self.m3.takeChains([0]).sequence()[:18], 'XVINTFDGVADXXKLPDN' ) if self.local: self.log.add( '\nTesting automatic chain capping...\n' ) self.c = PDBCleaner( self.m4, log=self.log, verbose=self.local ) self.m4 = self.c.capTerminals( auto=True ) self.assertEqual( self.m4.takeChains([0]).sequence()[:18], 'XVINTFDGVADXXKLPDN' )
def setUpClass(cls): cls.filepath = tools.testRoot() + "consScore" with open((cls.filepath + os.sep + 'CDC48Aseq.txt'), 'r') as file: arabidopsisCDC48A = file.read() cls.CDC48A = oma.OrthologFinder(arabidopsisCDC48A) with open((cls.filepath + os.sep + 'OMA_get_id.txt'), 'r') as file: OMA_id_response = file.read() cls.response = bytes(OMA_id_response, 'utf-8') with open((cls.filepath + os.sep + 'orhtolog_response.txt'), 'r') as file: ortho_response = file.read() cls.oresponse = bytes(ortho_response, 'utf-8') with open((cls.filepath + os.sep + 'fasta_response.txt'), 'r') as file: fasta_response = file.read() cls.fresponse = bytes(fasta_response, 'utf-8') with open((cls.filepath + os.sep + 'ATN1_HOGS.txt'), 'r') as file: HOG_response = file.read() cls.hresponse = bytes(HOG_response, 'utf-8') with open((cls.filepath + os.sep + 'hog_content.txt'), 'r') as file: level_response = file.read() cls.lvlresponse = bytes(level_response, 'utf-8')
def test_ComplexTraj(self): """Dock.ComplexTraj test""" import biskit.tools as T ## there is no complex trajectory in the test folder so will have ## to create a fake trajectory with a complex f = [ T.testRoot()+ '/com/1BGS.pdb' ] * 5 t = Trajectory( f, verbose=self.local ) t = ComplexTraj( t, recChains=[0] ) #if self.local: #print 'plotting contact density...' #t.plotContactDensity( step=2 ) ## create a fake second chain in the ligand for i in range( 1093+98, 1968 ): t.ref.atoms['chain_id'][i] = 'B' t.ref.chainIndex( force=1, cache=1 ) t.cl = [1,2] r = N0.concatenate((list(range(1093,1191)), list(range(0,1093)), list(range(1191,1968)))) tt = t.takeAtoms( r ) contactMat = tt.atomContacts( 1 ) if self.local: print('Receptor chains: %s Ligand chains: %s'%(t.cr, t.cl)) self.assertEqual( N0.sum(N0.ravel(contactMat)), 308 )
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)
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.assertTrue(os.path.exists(self.fcrg))
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] ))
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()
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 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 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_DNACleaning( self ): """PDBCleaner DNA test""" ## Loading PDB... self.c = PDBCleaner( t.testRoot() + 'amber/entropy/0_com.pdb', log=self.log, verbose=self.local ) self.dna = self.c.process(amber=True) self.assertAlmostEqual( self.dna.mass(), 26953.26, 1 )
def test_capping_extra( self ): """PDBCleaner.capTerminals extra challenge""" self.m2 = PDBModel( t.testRoot() + '/pdbclean/foldx_citche.pdb' ) self.c = PDBCleaner( self.m2, verbose=self.local, log=self.log) self.assertRaises(CappingError, self.c.capTerminals, auto=True) if self.local: self.log.add('OK: CappingError has been raised indicating clash.' ) self.assertEqual( len(self.m2.takeChains([1]).chainBreaks()), 1 )
def test_capping_internal(self): self.m3 = PDBModel(t.testRoot('pdbclean/foldx_citche.pdb')) self.m3 = self.m3.takeChains([1]) # pick second chain; has chain break self.c3 = PDBCleaner(self.m3, verbose=self.local, log=self.log) m = self.c3.capACE(self.m3, 1, checkgap=False) self.assertEqual( m.lenChains(breaks=True) - 1, self.m3.lenChains(breaks=True))
def test_ExeConfig_externalPath(self): """ExeConfig using external path""" x = ExeConfig('ls',configpath=[T.testRoot('exe')]) x.validate() if self.local: print(x.bin) self.assertTrue('ls' in x.bin)
def test_capping_internal(self): self.m3 = PDBModel(t.testRoot('pdbclean/foldx_citche.pdb')) self.m3 = self.m3.takeChains([1]) # pick second chain; has chain break self.c3 = PDBCleaner(self.m3, verbose=self.local, log=self.log) m = self.c3.capACE(self.m3, 1, checkgap=False) self.assertEqual(m.lenChains(breaks=True) -1, self.m3.lenChains(breaks=True))
def test_capping_extra(self): """PDBCleaner.capTerminals extra challenge""" self.m2 = PDBModel(t.testRoot() + '/pdbclean/foldx_citche.pdb') self.c = PDBCleaner(self.m2, verbose=self.local, log=self.log) self.assertRaises(CappingError, self.c.capTerminals, auto=True) if self.local: self.log.add('OK: CappingError has been raised indicating clash.') self.assertEqual(len(self.m2.takeChains([1]).chainBreaks()), 1)
def test_DNACleaning(self): """PDBCleaner DNA test""" ## Loading PDB... self.c = PDBCleaner(t.testRoot() + 'amber/entropy/0_com.pdb', log=self.log, verbose=self.local) self.dna = self.c.process(amber=True) self.assertAlmostEqual(self.dna.mass(), 26953.26, 1)
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)
def setUpClass(cls): cls.filepath = tools.testRoot() + "consScore" with open((cls.filepath + os.sep + 'CDC48Aseq.txt'), 'r') as file: arabidopsisCDC48A = file.read() cls.CDC48A = seq2conservation.ConservationPipe(arabidopsisCDC48A, cache=False) with open((cls.filepath + os.sep + 'multiFasta.fasta'), 'r') as file: cls.ex_seq = file.read()
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)
def test_PDBCleaner(self): """PDBCleaner general test""" ## Loading PDB... self.c = PDBCleaner(t.testRoot() + '/rec/1A2P_rec_original.pdb', log=self.log, verbose=self.local) self.m = self.c.process() self.assertAlmostEqual(self.m.mass(), 34029.0115499993, 7)
def test_PDBParseModel(self): """PDBParseModel test""" ## loading output file from X-plor if self.local: print('Loading pdb file ..') self.p = PDBParseModel() self.m = self.p.parse2new(B.PDBModel(T.testRoot() + '/rec/1A2P.pdb')) self.assertAlmostEqual(N0.sum(self.m.centerOfMass()), 113.682601929, 2)
def test_PDBCleaner( self ): """PDBCleaner general test""" ## Loading PDB... self.c = PDBCleaner( t.testRoot() + '/rec/1A2P_rec_original.pdb', log=self.log, verbose=self.local) self.m = self.c.process() self.assertAlmostEqual( self.m.mass(), 34029.0115499993, 7 )
def test_PDBParseModel( self ): """PDBParseModel test""" ## loading output file from X-plor if self.local: print('Loading pdb file ..') self.p = PDBParseModel() self.m = self.p.parse2new( B.PDBModel(T.testRoot()+'/rec/1A2P.pdb') ) self.assertAlmostEqual( N0.sum( self.m.centerOfMass() ), 113.682601929, 2 )
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')
def prepare(self): from biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' if not Test.M: if self.local: print("Loading PDB...", end=' ') Test.M = PDBModel( self.f ) Test.M = self.M.compress( Test.M.maskProtein() ) if self.local: print("Done") self.d = PDBDope( self.M )
def test_amberEntropist( self ): """AmberEntropist test""" import biskit.tools as T self.a = AmberEntropist( T.testRoot('/amber/entropy/com_fake.etraj'), verbose=self.local, debug=self.DEBUG, log=self.log) self.r = self.a.run() self.assertTrue( abs(int(self.r['S_total']) - 398) < 2 ) self.assertAlmostEqual( self.r['mass'], 3254, 0 ) self.assertAlmostEqual( self.r['S_vibes'], 298, 0 ) self.assertEqual( int(self.r['S_rot']), 50 ) self.assertEqual( int(self.r['nframes']), 44 )
def prepare(self): from biskit import PDBModel self.f = T.testRoot() + '/com/1BGS.pdb' if not Test.M: if self.local: print("Loading PDB...", end=' ') Test.M = PDBModel(self.f) Test.M = self.M.compress(Test.M.maskProtein()) if self.local: print("Done") self.d = PDBDope(self.M)
def test_delphi(self): """Delphi test""" if self.local: print('Loading PDB...') self.m1 = self.MODEL or PDBModel(T.testRoot('lig/1A19_dry.model')) Test.MODEL = self.m1 self.m1.addChainFromSegid() if self.local: print('Starting Delphi') self.x = Delphi(self.m1, scale=1.2, debug=self.DEBUG, verbose=self.local, f_map=self.fmap) if self.local: print('Running') self.r = self.x.run() if self.local: print("Result: ") print(self.r) expect_delphi_v5 = { 'scharge': 1.427, 'egrid': 9091., 'ecoul': -9870, 'eself': -20420, 'erxn': -666.7 } expect_delphi_v6 = { 'scharge': 1.426, 'egrid': 8765., 'ecoul': -10335., 'eself': -20420., 'erxn': -664. } ## 'erxnt': -21083. } expect = expect_delphi_v6 if self.local: print("verifying results... ") print("Note: numeric values can differ on different hardware.") for k, v in list(expect.items()): self.assertAlmostEqual(expect[k], self.r[k], -1) self.assertTrue(os.path.exists(self.fmap), 'Potential map not found') self.assertTrue( os.path.getsize(self.fmap) > 1000, 'empty potential map')
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'])
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' ]))
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_PDBParsePickle( self ): """PDBParsePickle test""" import biskit.core.oldnumeric as N0 ## loading output file from X-plor if self.local: print('Loading pickled model ..') self.p = PDBParsePickle() self.m = self.p.parse2new( T.testRoot('rec/1A2P_dry.model')) self.assertAlmostEqual( N0.sum( self.m.centerOfMass() ), 114.18037, 5)
def test_XplorModel( self ): """XplorModel test""" ## Loading PDB... self.m_com = XplorModel( t.testRoot() + "/com/1BGS.psf", t.testRoot() + "/com/1BGS.pdb" ) self.m_rec = XplorModel( t.testRoot() + "/rec/1A2P.psf", t.testRoot() + "/rec/1A2P.pdb" ) ## remove waters self.m_com = self.m_com.compress( self.m_com.maskProtein() ) self.m_rec = self.m_rec.compress( self.m_rec.maskProtein() ) ## fit the complex structure to the free receptor m_com_fit = self.m_com.magicFit( self.m_rec ) ## calculate the rmsd between the original complex and the ## one fitted to the free receptor rms = m_com_fit.rms(self.m_com, fit=0) if self.local: print('Rmsd between the two complex structures: %.2f Angstrom'%rms) self.assertAlmostEqual(rms, 58.7844130314, 4)
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)
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 )