def autodock_scoring(receptor, ligand): receptorfilename = receptor ligandfilename = ligand write_file_mode = False parameter_library_filename = None exclude_torsFreeEnergy = False verbose = None ad_scorer = AutoDock41Scorer(exclude_torsFreeEnergy=exclude_torsFreeEnergy) supported_types = ad_scorer.supported_types receptor = Read(receptorfilename)[0] receptor.buildBondsByDistance() ligand = Read(ligandfilename)[0] ligand.buildBondsByDistance() ms = MolecularSystem() ms.add_entities(receptor.allAtoms) ms.add_entities(ligand.allAtoms) ad_scorer.set_molecular_system(ms) #get the scores, score per term: [estat, hb, vdw, dsolv] = ad_scorer.get_score_per_term() torsEnrg = ligand.TORSDOF * ad_scorer.tors_weight score = estat + hb + vdw + dsolv + torsEnrg output_score = { 'score': score, 'estat': estat, 'hb': hb, 'vdw': vdw, 'dsolv,': dsolv, 'torsEnrg': torsEnrg } return output_score
def get_energy_breakdown(receptor_atoms, ligand_atoms, coords_to_use): ms = MolecularSystem() ms.add_entities(receptor_atoms) ms.add_entities(ligand_atoms) ms.set_coords(1, coords_to_use) #ms.set_coords(1, c.getCoords()[:]) ad_scorer = AutoDock305Scorer() ad_scorer.set_molecular_system(ms) score_list = ad_scorer.get_score_per_term() ostr = "" for score in score_list: ostr = ostr + "% 8.4f," % score return ostr
def __init__(self,atomset1,atomset2,func=None): self.atomset1 =atomset1 self.atomset2 =atomset2 # save molecule instance of parent molecule self.mol1 = self.atomset1.top.uniq()[0] self.mol2 = self.atomset2.top.uniq()[0] # dictionary to save the state of each molecule when the # energy is calculated, will allow to retrieve the conformation # use for the energy calculation # keys are score,values is a list a 2 set of coords (mol1,mol2) self.confcoords = {} self.ms = ms = MolecularSystem() self.cutoff = 1.0 self.score = 0.0
first = True if verbose: print 'first is ', first optr = open(outputfilename, mode) if first: tstr = " Receptor Ligand AutoDock4.1Score estat hb vdw dsolv tors\n" optr.write(tstr) #setup the molecular system ostr = "" if len(lig_non_std): ostr = 'ERROR: unable to score ligand "%s" due to presence of non-standard atom type(s): %s\n' %(ligand.name, lig_non_std) optr.write(ostr) elif len(rec_non_std): ostr = 'ERROR: unable to score receptor "%s" due to non-standard atom type(s): %s\n' %(receptor.name, rec_non_std) optr.write(ostr) else: ms = MolecularSystem() ms.add_entities(receptor.allAtoms) ms.add_entities(ligand.allAtoms) ad_scorer.set_molecular_system(ms) #get the scores #score per term estat, hb,vdw,dsolv = ad_scorer.get_score_per_term() torsEnrg = ligand.TORSDOF * ad_scorer.tors_weight score = estat + hb + vdw + dsolv + torsEnrg ostr = "%12s%12s % 8.4f % 6.4f % 6.4f % 6.4f % 6.4f % 6.4f\n" %(receptor.name,ligand.name, score, estat, hb, vdw, dsolv, torsEnrg) optr.write(ostr) if verbose: print 'wrote %s' %outputfilename optr.close() # To execute this command type:
def autodock_scoring(receptor, ligand): receptorfilename = receptor ligandfilename = ligand write_file_mode = False outputfilename = dirname + '/Alanine_Scanning_Binding_Energies_Result.csv' parameter_library_filename = None exclude_torsFreeEnergy = False verbose = None ad_scorer = AutoDock41Scorer(exclude_torsFreeEnergy=exclude_torsFreeEnergy) supported_types = ad_scorer.supported_types receptor = Read(receptorfilename)[0] receptor.buildBondsByDistance() rec_non_std = "" non_std_types = check_types(receptor, supported_types) #Checking the format of receptor if len(non_std_types): rec_non_std = non_std_types[0] if len(non_std_types) > 1: for t in non_std_types[1:]: rec_non_std = rec_non_std + '_' + t ligand = Read(ligandfilename)[0] ligand.buildBondsByDistance() lig_non_std = "" non_std_types = check_types(ligand, supported_types) #Checking the format of ligand if len(non_std_types): lig_non_std = non_std_types[0] if len(non_std_types) > 1: for t in non_std_types[1:]: lig_non_std = lig_non_std + '_' + t mode = 'a' first = not os.path.exists(outputfilename) if write_file_mode: mode = 'w' first = True optr = open(outputfilename, mode) if first: tstr = "Receptor,Ligand,AutoDock4.1Score,estat,hb,vdw,dsolv,tors\n" optr.write(tstr) #setup the molecular system ostr = "" if len(lig_non_std): ostr = 'ERROR: unable to score ligand "%s" due to presence of non-standard atom type(s): %s\n' % ( ligand.name, lig_non_std) optr.write(ostr) elif len(rec_non_std): ostr = 'ERROR: unable to score receptor "%s" due to non-standard atom type(s): %s\n' % ( receptor.name, rec_non_std) optr.write(ostr) else: ms = MolecularSystem() ms.add_entities(receptor.allAtoms) ms.add_entities(ligand.allAtoms) ad_scorer.set_molecular_system(ms) #get the scores #score per term estat, hb, vdw, dsolv = ad_scorer.get_score_per_term() torsEnrg = ligand.TORSDOF * ad_scorer.tors_weight score = estat + hb + vdw + dsolv + torsEnrg ostr = "%19s,%3s,%8.4f,%6.4f,%6.4f,%6.4f,%6.4f,%6.4f\n" % ( receptor.name, uniq_ligand[0], score, estat, hb, vdw, dsolv, torsEnrg) optr.write(ostr) optr.close()