def soap_score(): import modeller from modeller.scripts import complete_pdb from modeller import soap_protein_od env = modeller.environ() env.libs.topology.read(file='$(LIB)/top_heav.lib') env.libs.parameters.read(file='$(LIB)/par.lib') # Set up SOAP-Protein-OD scoring (we create the scorer once and keep it # around, since reading in the potential from disk can take a long time). sp = soap_protein_od.Scorer() out = open('SnapList.txt', 'w') cnt = 0 files = [ i for i in glob.glob('pm.pdb*.pdb') if 'pm.pdb.B10010002.pdb' not in i ] for fil in files: try: cnt += 1 # Read a model previously generated by Modeller's automodel class mdl = complete_pdb(env, fil) # Select all atoms atmsel = modeller.selection(mdl) # Assess with the above Scorer try: score = atmsel.assess(sp) out.write(fil + '\t' + str(score) + '\n') except modeller.ModellerError: print("The SOAP-Protein-OD library file is not included " "with MODELLER.") print("Please get it from https://salilab.org/SOAP/.") # Was 'except: pass' but this will hide genuine errors. Replace with # a more specific list of exceptions (and test) except: raise out.close()
def calc_score(self,runnumber,reportstatus=True): """Methods to benchmark the statistical potential, run on current directory""" ddbfile='pdbs'+str(runnumber) tmpdir=scratchdir bm=self.bm env = environ() if self.atompairclustering and self.decomposition: dnlist=pir(ddbfile).get_codelist() idist=self.calc_individual_sp(ddbfile,dnlist,'apdecompscore') np.save(str(runnumber)+'.score.npy',idist) if reportstatus: report_job_runstatus(self.runpath, True, runnumber, '.score.npy',inputname='runme.py') return idist elif self.atompairclustering: dnlist=pir(ddbfile).get_codelist() idist=self.calc_individual_sp(ddbfile,dnlist,'apscore') np.save(str(runnumber)+'.score.npy',idist) if reportstatus: report_job_runstatus(self.runpath, True, runnumber, '.score.npy',inputname='runme.py') return idist elif self.decomposition: dnlist=pir(ddbfile).get_codelist() idist=self.calc_individual_sp(ddbfile,dnlist,'decompscore') np.save(str(runnumber)+'.score.npy',idist) if reportstatus: report_job_runstatus(self.runpath, True, runnumber, '.score.npy',inputname='runme.py') return idist if self.features=='soap_loop': from modeller import soap_loop pair = soap_loop.Scorer() env.edat.sphere_stdv=-1 env.edat.contact_shell=6 env.edat.dynamic_sphere=False env.edat.energy_terms.append(pair) elif self.features=='soap_pep': from modeller import soap_peptide pair = soap_peptide.Scorer('soap_pep.hdf5') env.edat.sphere_stdv=-1 env.edat.contact_shell=6 env.edat.dynamic_sphere=False env.edat.energy_terms.append(pair) elif self.features=='soap_pp': from modeller import soap_pp atom = soap_pp.AtomScorer() pair = soap_pp.PairScorer() env.edat.sphere_stdv=-1 env.edat.contact_shell=15 env.edat.dynamic_sphere=False env.edat.energy_terms.append(atom) env.edat.energy_terms.append(pair) elif self.features=='soap_protein_od': from modeller import soap_protein_od pair = soap_protein_od.Scorer() env.edat.sphere_stdv=-1 env.edat.contact_shell=7 env.edat.dynamic_sphere=False env.edat.energy_terms.append(pair) features=self.features mdtfile=self.ssppath+'.hdf5' print 'Benchmarking: '+ ddbfile log.minimal() io=env.io mlib=mdt.Library(env) mlib.bond_classes.read('${LIB}/bndgrp.lib') featurelist=feature(self.features,mlib).get_featurelist() if self.pdbset!='Otherpot': m=mdt.Table(mlib,features=featurelist,shape=[-1]*len(featurelist)) print mdtfile m.read_hdf5(mdtfile) a=alignment(env) f=modfile.File(self.runpath+ddbfile,'r') csmin, csmax,kcut, kcut1, bs,bsm, errsv,ssp=decode_genmethod(bm) fp=0; tn=0; xp=0 scorestr='' aln=alignment(env) tmml=[] fdl=[] while aln.read_one(f): tn=tn+1 try: sr=0; alncode=aln[0].code codelist=alncode.split('.') spdbdir=runenv.ddbdir+codelist[0]+'/'+codelist[1]+'/' if self.features in ['firedock','zrank','rdock','dfire','epad','rosetta','plop','posescore','rankscore']: naln=aln fd=spdbdir if len(fdl)==0 or fd!=fdl[-1]: fdl.append(fd) tmml.append([]) if self.features in ['dfire','epad']: if not os.path.isfile('.'.join(alncode.split('.')[:2])+'.seq'): aln.write(file='.'.join(alncode.split('.')[:2])+'.seq', alignment_format='FASTA') tmml[-1].append(alncode) else: tmml[-1].append(alncode) else: errcount=1 while errcount<10: try: fd,naln=self.get_pdbfile(spdbdir,codelist,alncode,env,aln,tmpdir) io.atom_files_directory=[fd] if self.features=='dope' or self.features.startswith('soap'): score=self.calc_special_score(env,fd,naln) else: sr=m.open_alignment(naln,io=io) score=sr.sum(chain_span_range=(-csmax,-csmin,csmin,csmax),residue_span_range=(-kcut1,-kcut,kcut,kcut1),bond_span_range=(bs,bsm),disulfide=ssp) print score scorestr=scorestr+'>'+aln[0].code+' score: '+str(score)+'\n' fp+=1 print alncode break except Exception,e: time.sleep(0.1) print open(os.path.join(tmpdir,alncode+'.pdb')).read() print os.system('rm -f '+os.path.join(tmpdir,'*')) errcount+=1 if errcount>=10: raise e except Exception,e: traceback.print_exc() xp=1 if re.search('fork failure',str(e)): raise Exception('fork failure, quiting') else: if not self.test: raise e aln=0 aln=alignment(env)
import os import sys from modeller import * from modeller.scripts import complete_pdb from modeller import soap_protein_od import os.path log.verbose() # request verbose output env = environ() env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters # Set up SOAP-Protein-OD scoring (note: if assessing multiple models, it is # best to create 'sp' just once and keep it around, since reading in the # potential from disk can take a long time). sp = soap_protein_od.Scorer() # only calculate for single chains, because ga341 and dope only calculate first chains models = [ 'model_dimer.pdb', 'model_locked_dimer.pdb', 'model_fragment_dimer.pdb' ] templates = ['template_dimer_all.pdb', 'template_fragment_dimer_all.pdb'] files = models + templates for f in files: if (not os.path.isfile(f)): continue print("; FILE " + f) # read model file mdl = complete_pdb(env, f)