You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When MolDrawOptions.prepareMolsBeforeDrawing is set to false the code hits a PRECONDITION.
The problem arises when DrawMol::getAtomSymbol() calls Atom::getTotalNumHs() as implicit valence has not been computed yet.
The fix is simple: it is sufficient to move mol.updatePropertyCache(false) out of the if (drawOptions().prepareMolsBeforeDrawing) {} clause in MolDraw2D::makeReactionDrawMol()`.
To Reproduce
from rdkit import Chem
from rdkit.Chem import rdChemReactions
from rdkit.Chem.Draw import rdMolDraw2D, IPythonConsole
rxn = rdChemReactions.ReactionFromSmarts('[CH3:1]-[OH:2]>>[CH2:1]=[OH0:2]')
d2d = rdMolDraw2D.MolDraw2DSVG(800, 300)
d2d.drawOptions().prepareMolsBeforeDrawing = False
d2d.DrawReaction(rxn)
[09:39:33]
****
Pre-condition Violation
getNumImplicitHs() called without preceding call to calcImplicitValence()
Violation occurred on line 297 in file /scratch/toscopa1/src/rdkit/Code/GraphMol/Atom.cpp
Failed Expression: d_implicitValence > -1
****
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/tmp/ipykernel_242993/2731136680.py in <module>
2 d2d = rdMolDraw2D.MolDraw2DSVG(800, 300)
3 d2d.drawOptions().prepareMolsBeforeDrawing = False
----> 4 d2d.DrawReaction(rxn)
5 #d2d.FinishDrawing()
6 #svg = d2d.GetDrawingText()
RuntimeError: Pre-condition Violation
getNumImplicitHs() called without preceding call to calcImplicitValence()
Violation occurred on line 297 in file Code/GraphMol/Atom.cpp
Failed Expression: d_implicitValence > -1
RDKIT: 2022.09.1pre
BOOST: 1_74
Expected behavior drawReaction() should not fail because a PRECONDITION is hit.
The text was updated successfully, but these errors were encountered:
Describe the bug
When
MolDrawOptions.prepareMolsBeforeDrawing
is set tofalse
the code hits aPRECONDITION
.The problem arises when
DrawMol::getAtomSymbol()
callsAtom::getTotalNumHs()
as implicit valence has not been computed yet.The fix is simple: it is sufficient to move
mol.updatePropertyCache(false)
out of theif (drawOptions().prepareMolsBeforeDrawing) {}
clause in MolDraw2D::makeReactionDrawMol()`.To Reproduce
Expected behavior
drawReaction()
should not fail because aPRECONDITION
is hit.The text was updated successfully, but these errors were encountered: