Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drawing mol with a non zero confID results in bad confID error #7409

Closed
kekulai-fredchang opened this issue May 1, 2024 · 2 comments · Fixed by #7415
Closed

drawing mol with a non zero confID results in bad confID error #7409

kekulai-fredchang opened this issue May 1, 2024 · 2 comments · Fixed by #7415
Labels
Milestone

Comments

@kekulai-fredchang
Copy link

Describe the bug
Goal is to make a new Chem.Mol of a given conformer in the application of using o3a align to get the best scoring conformer. I followed the description outlined in the rdkit blog post https://greglandrum.github.io/rdkit-blog/posts/2023-02-04-working-with-conformers.html and encountered a bug (or misunderstanding) in the visualization of the mol for the different conformers that do not have id=0.

To Reproduce
notebook as done in and go to last line to render a new molecule with the conformer of interest:
https://greglandrum.github.io/rdkit-blog/posts/2023-02-04-working-with-conformers.html

cp = Chem.Mol(esomeprazole,confId=5)
cp

results in
ValueError: Bad Conformer Id in Chem.Draw

Expected behavior

The draw mol function does a hard assumption that it must be confId=0, but when plucking conformers out of a set, it would be nice to keep its ID so as to maintain its id origin. Could the drawing function take the first conformer to draw?

Alternative drawing tools such as py3dmol will render the conformer correctly since the confId does not seem to be referenced,

@greglandrum
Copy link
Member

Confirmed. Thanks for the bug report @kekulai-fredchang
Here's a short reproducible

from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem import rdDistGeom
m = Chem.AddHs(Chem.MolFromSmiles('CCCCCCC'))
rdDistGeom.EmbedMolecule(m)
m.GetConformer().SetId(5)
d2d = Draw.MolDraw2DCairo(200,200)
d2d.DrawMolecule(m)

@greglandrum greglandrum changed the title plotting mol with a non zero confID results in bad confID error drawing mol with a non zero confID results in bad confID error May 2, 2024
@greglandrum
Copy link
Member

greglandrum commented May 2, 2024

FWIW: this doesn't happen with the SVG molecule renderer. It seems to be specific to MolDraw2DCairo, which means that if you do IPythonConsole.ipython_useSVG=True things should work.

I'll fix the bug in the Cairo rendering code too.

@greglandrum greglandrum added this to the 2024_03_3 milestone May 2, 2024
greglandrum added a commit to greglandrum/rdkit that referenced this issue May 2, 2024
greglandrum added a commit that referenced this issue May 9, 2024
* Fixes #7414
Fixes #7409

* skip that test if cairo is not enabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants