예제 #1
0
def readDockingResults(resFile):
	fHandle = open(resFile)
	result= {}
	try:
		header = fHandle.next().strip().split()
		if "Ligand" not in header or "1_Energy" not in header:
			raise
	except:
		errorMsg("Docking result file is in bad format")
		return {}
	for line in fHandle:
		entry = dict(zip(header, line.strip().split()))
		result[entry["Ligand"]] = float(entry["1_Energy"].replace(',','.'))
	fHandle.close()
	return result
예제 #2
0
		for x in contactsBaseSet:
			if x in chemBaseMolsDict:
				baseSubset.append(chemBaseMolsDict[x])
		for chemTrainSet, chemBaseSet in chemTreeWalkGenerator(contactsTrainSet, trainSubset, contactsBaseSet, baseSubset, minYesThreshold = args.yesPersChem, topPercent = args.chemTreshold):
			for cName in chemBaseSet:
				bestCompounds.add(cName)
		#print('Best compounds')
		#print(bestCompounds)
		bestCompoundsList = list(bestCompounds)
		bestCompoundsList.sort(key = lambda x: baseDockingResults[x])
		for cName in bestCompoundsList[:args.maxcluster]:
			#print('  ', cName, baseDockingResults[cName])
			finalResult.add(cName)
		#print("*******************")
else:
	errorMsg('Methods are not implemented')
	sys.exit(1)

finalResultList = list(finalResult)
finalResultList.sort(key = lambda x: baseDockingResults[x])
results = []
trainCompNames=getLongNames(chemTrainMolsDict)

for cName in finalResultList:
	print('  ', cName, baseDockingResults[cName])
	results.append({"id":cName.replace('ZINC', ''), "energy":baseDockingResults[cName], "score":scoreS[cName], "similarChem":getBestSimilarToMolset(chemBaseMolsDict[cName], chemTrainMolsDict, trainCompNames), "similarContacts":getBestSimilarToMolset(contactsBaseMolsDict[cName], contactsTrainMolsDict, trainCompNames)})

saveResults(args.outJson, results)
createHtmlReport(args.htmlreport, results, maxsimil=min(max(args.maxsimilar, 3), 10), maxOutComp = args.maxtop)