if verbose: print('set parameter_library_filename to ', a)
        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:]:
예제 #2
0
    if append_to_outputfile:
        mode = 'a'
        first = not os.path.exists(outputfilename)
    if verbose: print 'first is ', first
    optr = open(outputfilename, mode)
    if first:
        tstr = "RECEPTOR_LIGAND         #ESTAT       #HB      #VDW    #DSOLV  #TORSDOF #ATS #TORS\n"
        optr.write(tstr)
    #get the scores
    ms = MolecularSystem()
    ms.add_entities(receptor.allAtoms)
    ms.add_entities(ligand.allAtoms)
    if use_autodock40_weights:
        ad_scorer = AutoDock4Scorer()
    else:
        ad_scorer = AutoDock41Scorer()
    ad_scorer.set_molecular_system(ms)
    score_list = ad_scorer.get_score_per_term()
    ostr = "%8s_%6s," % (receptor.name, ligand.name)
    for score in score_list:
        ostr = ostr + " % 8.4f," % score
    ostr = ostr + " % 8d," % ligand.TORSDOF
    ostr = ostr + " % 8d," % len(ligand.allAtoms)
    ostr = ostr + " % 8d," % len(ligand.torTree.torsionMap)
    ostr = ostr + "\n"
    optr.write(ostr)
    optr.close()
    if verbose:
        print 'wrote %s' % outputfilename

# To execute this command type:
예제 #3
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()