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

Dummy atoms next to aromatic are always kekulized even when they should not #4721

Closed
ptosco opened this issue Nov 21, 2021 Discussed in #4716 · 0 comments · Fixed by #4722
Closed

Dummy atoms next to aromatic are always kekulized even when they should not #4721

ptosco opened this issue Nov 21, 2021 Discussed in #4716 · 0 comments · Fixed by #4722

Comments

@ptosco
Copy link
Contributor

ptosco commented Nov 21, 2021

Discussed in #4716

Originally posted by laurenreid1 November 19, 2021
Hi everyone,

I'd like to depict a benzocyclohexane-like compound containing 2 dummy atoms within the cyclohexane ring (e.g c12ccccc1*-*CC2). Using the following code:

from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import rdMolDraw2D

mol = Chem.MolFromSmiles("c12ccccc1*-*CC2")
dm = Draw.PrepareMolForDrawing(mol)
d2d = rdMolDraw2D.MolDraw2DCairo(240, 135)
d2d.DrawMolecule(dm)
d2d.FinishDrawing()
draw_text = d2d.GetDrawingText()

with open("test.png", "wb") as f:
    f.write(draw_text)

I receive this depicition that adds a double bond between the 2 dummies:
image

I believe this is happening during kekulization, where the conjugation of the dummy atoms to the benzene ring is interpreted as aromaticity? I can turn off the behaviour using the following:

from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import rdMolDraw2D

mol = Chem.MolFromSmiles("c12ccccc1*-*CC2", sanitize=False)
mol.UpdatePropertyCache()
dm = Draw.PrepareMolForDrawing(mol, kekulize=False)
d2d = rdMolDraw2D.MolDraw2DCairo(240, 135)
d2d.drawOptions().prepareMolsBeforeDrawing = False
d2d.DrawMolecule(dm)
d2d.FinishDrawing()
draw_text = d2d.GetDrawingText()

with open("test.png", "wb") as f:
    f.write(draw_text)

But this leaves me with the following depiction:

image

Does anyone know if there's a way I can depict the benzene ring in its kekulized form while keeping the bond between the dummy atoms as a single aliphatic bond? I've been playing around with the santizeflags but haven't found a combination that will allow only the benzene bonds to be kekulized.

Thanks,
Lauren

EDIT: My RDKit version is 2020.03.3

ptosco pushed a commit to ptosco/rdkit that referenced this issue Nov 21, 2021
@ptosco ptosco mentioned this issue Nov 21, 2021
@greglandrum greglandrum added this to the 2022_03_1 milestone Jan 28, 2022
greglandrum pushed a commit that referenced this issue Jan 28, 2022
* fixes #4721

* - store in RingInfo the index of the ring(s) each atom and bond belongs to rather tham just their size
- expand the RingInfo API with a few useful methods
- identify rings that are certainly aliphatic upfront
- avoid unnecessary copying atomRings when RingInfo is already initialized

* - code modernization and cleanup
- better handling of dummies in aromatic rings
- exposed atomMembers() and bondMembers()
- added several tests

* - avoid order dependency on rings
- added test for the above

* changes in response to review

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants