print("error extracting energy from xml. {}".format(line))
raise
returnNone
defgrep_all(f,*keys):
out=dict((k,[])forkinkeys)
forlineinf:
line=line.decode('utf8')
forkinkeys:
ifkinline:
out[k].append(line)
returnout
defparse_dlg(f):
#dlg = grep_all(f, "DOCKED:", "Estimated", "Number of atoms", "Number of rotat")
dlg=grep_all(f,"DOCKED:")
confs=dlg_to_confs(dlg['DOCKED:'])
# truncate to max 5
#confs = confs[:min(5,len(confs))]
returnconfs[0]# en, pdbqt
# inputstrings are all containing "DOCKED:"
defdlg_to_confs(lines):
confs=[]
conf=""
en=None
forsinlines:
conf+=s[8:]+"\n"
# DOCKED: USER Estimated Free Energy of Binding = -7.85 kcal/mol
if"Estimated Free Energy of Binding"ins:
tok=s.replace('=','').split()
en=float(tok[7])
elifs[8:14]=="ENDMDL":
confs.append((en,conf))
assertenisnotNone
conf=""
en=None
confs.sort()
returnconfs
# Basically, autodock will spit out -nruns number of poses, which I chose to output to a .pdb file so I could load them in typical molecular visualization tools. This also means that you'd need to get the energies for all the models, and sort them. This is what I was doing on a much smaller set:
# lines that contain "Estimated"
defdlg_to_energy(lines):
en=[]
forlineinlines[:-1]:
en.append(line.replace('=','').split()[7])
returnen
# You can also get ligand data from the dlg if you like.