Example #1
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
Example #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 = AutoDock41Scorer()
    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[:-1]
        if o in ('-h', '--'):
            usage()
            sys.exit()


    if not receptorfilename:
        print 'compute_AutoDock41_score: receptorfilename must be specified.'
        usage()
        sys.exit()

    if not ligandfilename:
        print 'compute_AutoDock41_score: ligandfilename must be specified.'
        usage()
        sys.exit()

    ad_scorer = AutoDock41Scorer(exclude_torsFreeEnergy=exclude_torsFreeEnergy)
    if parameter_library_filename is not None:
        ad_scorer.read_parameter_file(parameter_library_filename)
    supported_types = ad_scorer.supported_types
    receptor = Read(receptorfilename)[0]
    assert os.path.splitext(receptor.parser.filename)[-1]=='.pdbqt',"receptor file not in required '.pdbqt' format"
    if verbose: print 'read ', receptorfilename
    receptor.buildBondsByDistance()
    rec_non_std = ""
    non_std_types = check_types(receptor, supported_types)
    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
    #check format of receptor
Example #4
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()
Example #5
0
        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')

    #5. score the docked pose outputting individual terms for each atom:
    all_estat = []
    all_VHD = []
    for i in range(len(lig.allAtoms)):