Hello,
I want to convert the 2D ligands I downloaded as sdf format from the ZINC
library to 3D, but almost half of them are not converted to 3D. Some of
them are; ZINC000008214373, ZINC000001530666, ZINC000085545180. 208 ligands
are not converted to 3D in this way. When I run the script, I do not get
any warning or error in IDE. When I look at the output of my Try, Except
commands, I see "ZINC000008214373.sdf : rdDistGeom.EmbedMolecule(mol,
etkdgv3) = Failed
ZINC000008214373.sdf : rdForceFieldHelpers.UFFOptimizeMolecule(mol) =
Failed" It outputs like this for ligands that are not translated to 3D.
When I try different methods, the ligands are converted to 3D. I wonder if
there is something missing or wrong with my script. I would be grateful if
you can help me.
Thank you!
```
from rdkit import Chem
from rdkit.Chem import rdDistGeom
from rdkit.Chem import rdForceFieldHelpers
from rdkit.Chem import rdPartialCharges
import os
ligands_dir = "ligands"
output_dir = "new_ligands"
status_file = "process_status.txt"
if not os.path.exists(output_dir):
os.makedirs(output_dir)
sdf_files = [f for f in os.listdir(ligands_dir) if f.endswith(".sdf")]
with open(status_file, 'w') as status:
for sdf_file in sdf_files:
input_path = os.path.join(ligands_dir, sdf_file)
output_path = os.path.join(output_dir, sdf_file)
mol = Chem.MolFromMolFile(input_path)
# Add hydrogens
try:
mol = Chem.AddHs(mol, addCoords=True)
except:
status.write(f"{sdf_file} : Chem.AddHs(mol) = Failed\\n")
continue
# 3D embedding
etkdgv3 = rdDistGeom.ETKDGv3()
embed_status = rdDistGeom.EmbedMolecule(mol, etkdgv3)
if embed_status == -1:
status.write(f"{sdf_file} : rdDistGeom.EmbedMolecule(mol,
etkdgv3) = Failed\\n")
# Compute Gasteiger charges
try:
rdPartialCharges.ComputeGasteigerCharges(mol)
except:
status.write(f"{sdf_file} :
rdPartialCharges.ComputeGasteigerCharges(mol) = Failed\\n")
# UFF energy minimization
try:
rdForceFieldHelpers.UFFOptimizeMolecule(mol)
except:
status.write(f"{sdf_file} :
rdForceFieldHelpers.UFFOptimizeMolecule(mol) = Failed\\n")
Chem.MolToMolFile(mol, output_path)
```
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss