:param mol_mol2: Should contain all the conformers for evaluation
:param prody_protein:
:param protein_pdb:
:return:
Source code in ties/utils/score.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59 | def extract_best_conformer(
mol: Chem.Mol, prody_protein, protein_pdb="fe_rec_final.pdb"
):
"""
:param mol_mol2: Should contain all the conformers for evaluation
:param prody_protein:
:param protein_pdb:
:return:
"""
# convert to FEgrow RMol
rmol = fegrow.RMol(mol)
rmol.remove_clashing_confs(prody_protein, min_dst_allowed=0.5)
if rmol.GetNumConformers() == 0:
print("Warning: no conformers for energy minimisation: ", rmol.GetProp("_Name"))
return
# extract the mcs mapping
# we will freeze the MCS area in the ligand before optimisation
mcs = literal_eval(rmol.GetProp("MCS(ref,lig)"))
# extract
ligand_atoms_to_freeze = [idx for _, idx in mcs]
energies = rmol.optimise_in_receptor(
receptor_file=protein_pdb,
ligand_force_field="openff",
use_ani=False,
sigma_scale_factor=0.8,
relative_permittivity=4,
water_model=None,
platform_name="CPU", # or e.g. 'CUDA'
ligand_freeze=ligand_atoms_to_freeze,
)
# save the lowest energy conformer
best = energies[energies.Energy == energies.Energy.min()]
best_conf_id = int(best.index.values[0])
# print(f"Optimised, {time.time() - start:.2f}s")
# keep the lowest energy conformer
for conf in list(rmol.GetConformers()):
if conf.GetId() != best_conf_id:
rmol.RemoveConformer(conf.GetId())
return rmol
|