Re: [Rdkit-discuss] Ligand conversion problem from 2D to 3D

2024-01-10 Thread He, Amy
Hi Emre!

You can get more detailed info on failed conformer generations through 
rdDistGeom.EmbedFailureCauses, see:
https://greglandrum.github.io/rdkit-blog/posts/2023-05-17-understanding-confgen-errors.html

Bests,


--
Amy He
Hadad Lab @ OSU
he.1...@osu.edu

From: Emre Apaydın 
Date: Wednesday, January 10, 2024 at 8:47 AM
To: rdkit-discuss@lists.sourceforge.net 
Subject: [Rdkit-discuss] Ligand conversion problem from 2D to 3D
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; ZINC08214373, ZINC01530666, ZINC85545180. 208 ligands are 
not converted

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; ZINC08214373, ZINC01530666, ZINC85545180. 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 
"ZINC08214373.sdf : rdDistGeom.EmbedMolecule(mol, etkdgv3) = Failed
ZINC08214373.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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] Ligand conversion problem from 2D to 3D

2024-01-10 Thread Emre Apaydın
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; ZINC08214373, ZINC01530666, ZINC85545180. 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 "ZINC08214373.sdf : rdDistGeom.EmbedMolecule(mol,
etkdgv3) = Failed
ZINC08214373.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
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss


[Rdkit-discuss] mmpdb 3.1

2024-01-10 Thread Andrew Dalke
Hi everyone,

  We have released mmpdb 3.1, which you can get from 
https://github.com/rdkit/mmpdb .

mmpdb 3.0, released May 2023, merged three development tracks:

- create and query 1-cut med chem transformations as described in Awale et al., 
The Playbooks of Medicinal Chemistry Design Moves, J. Chem. Inf. Model. 2021, 
61, 2, 729–742

- support indexing large datasets on a distributed cluster

- replace the hash-based fingerprint environment with a SMARTS/pseudo-SMILES 
description

Version 3.1 adds support for the 2- and 3-cut med chem transformations 
described by Awale et al.

There are also a few feature improvements, some performance tuning, and bug 
fixes. See the CHANGELOG for details.


Andrew
da...@dalkescientific.com



___
Rdkit-discuss mailing list
Rdkit-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss