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
Beispiel #2
0
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
Beispiel #3
0
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, c):
    ms = MolecularSystem()
    ms.add_entities(receptor_atoms)
    ms.add_entities(ligand_atoms)
    ms.set_coords(1, c.getCoords()[:])
    ad_scorer = AutoDock4Scorer()
    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
Beispiel #5
0
    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:
Beispiel #7
0
    cl = Clusterer(d.ch.conformations)
    d.clusterer = cl
    cl.make_clustering(rms_tolerance)
    ref_coords = cl.clustering_dict[rms_tolerance][0][0].getCoords()[:]

    # for building hydrogen bonds or reporting energy breakdown
    # setup receptor:
    if build_hydrogen_bonds or report_energy_breakdown:
        ligMol.buildBondsByDistance()
        receptor = Read(receptor_filename)[0]
        receptor.buildBondsByDistance()
    if build_hydrogen_bonds:
        hbondBuilder = HydrogenBondBuilder()
    if report_energy_breakdown:
        ms = MolecularSystem()
        ms.add_entities(receptor.allAtoms)
        ms.add_entities(ligMol.allAtoms)
        adscorer = AutoDock4Scorer()
        adscorer.set_molecular_system(ms)

    mode = 'w'
    if append_to_outputfile:
        mode = 'a'
    fptr = open(outputfilename, mode)
    if mode=='w':
        if build_hydrogen_bonds and report_energy_breakdown:
            titles = "#clust  binding_nrg rmsd_v_0          Ki    int_nrg  hbnds sum_py_nrg estat_nrg     hbnd_nrg       vdw_nrg dsolv_nrg#ats #t\n"
        elif build_hydrogen_bonds:
            titles = "#clust  binding_nrg rmsd_v_0          Ki    int_nrg  hbnds #ats #t\n"
        elif report_energy_breakdown:
Beispiel #8
0
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()
Beispiel #9
0
        sys.exit()

    if not ligand_file:
        print(
            'score_docked_atoms_by_component: ligand file must be specified.')
        usage()
        sys.exit()

    #1: create the python molecules
    rec = Read(receptor_file)[0]
    recbnds = rec.buildBondsByDistance()
    lig = Read(ligand_file)[0]
    ligbnds = lig.buildBondsByDistance()

    #2: setup python scorers for your molecules:
    ms = MolecularSystem()
    ms.add_entities(rec.allAtoms)
    ms.add_entities(lig.allAtoms)

    #3: setup python scorers
    scorer = AutoDock41Scorer()
    scorer.set_molecular_system(ms)
    estat_scores = numpy.add.reduce(scorer.terms[0][0].get_score_array())
    dsolv_scores = numpy.add.reduce(scorer.terms[1][0].get_score_array())
    vdw_scores = numpy.add.reduce(scorer.terms[2][0].get_score_array())
    hbond_scores = numpy.add.reduce(scorer.terms[3][0].get_score_array())
    wts = AutoDockTermWeights41()

    #4: open outputfile for writing scores
    if output_file is not None:
        fptr = open(output_file, 'w')
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()
        ##debug only## m += p1u * p0v * p0w * at_data[ w1 ][ v1 ][ u0 ]
        m += p1u * p0v * p0w * at_data[ w1 ][ v1 ][ u0 ]
        ##d += p1u * p0v * p0w * map[ w1 ][ v1 ][ u0 ][DesolvMap];
        #d += p1u * p0v * p0w * d_data[ w1 ][ v1 ][ u0 ]

        ##d += p0u * p0v * p0w * map[ w1 ][ v1 ][ u1 ][DesolvMap];
        #d += p0u * p0v * p0w * d_data[ w1 ][ v1 ][ u1 ]
        #m += p0u * p0v * p0w * map[ w1 ][ v1 ][ u1 ][AtomType];
        ##debug only##m += p0u * p0v * p0w * at_data[ w1 ][ v1 ][ u1 ]
        m += p0u * p0v * p0w * at_data[ w1 ][ v1 ][ u1 ]
        #e += p0u * p0v * p0w * map[ w1 ][ v1 ][ u1 ][ElecMap];
        e += p0u * p0v * p0w * e_data[ w1 ][ v1 ][ u1 ]
        
        charge = at1.charge
        #return e*charge + m + d*abs(charge)
        return e*charge + m
        


if __name__ == '__main__':
    print 'in main'
    tls = TrilinterpScorer('test', ['C'])
    from MolKit import Read
    m = Read("test.pdb")[0]
    #crds= [4.083,6.527,-3.152], [2.737,6.793,-3.728], [1.900,5.679,-4.323]
    ms = MolecularSystem()
    ms.add_entities(m.allAtoms)
    tls.set_molecular_system(ms)