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

SubstanceGroup labels sometimes overlap with atoms in image generation #4508

Closed
rachelnwalker opened this issue Sep 13, 2021 · 0 comments
Closed
Assignees
Labels

Comments

@rachelnwalker
Copy link
Contributor

Describe the bug
When depicting a molecule with a data substance group, the substance group label will sometimes overlap with an atom/atom label.

To Reproduce
Read a molblock with a data substance group:

from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
IPythonConsole.ipython_useSVG=True 
IPythonConsole.molSize = 400,400

mol = Chem.MolFromMolBlock("""
  Mrv2114 09132120172D          

  0  0  0     0  0            999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 8 8 1 0 1
M  V30 BEGIN ATOM
M  V30 1 C -0.5878 0.8085 0 0
M  V30 2 C -1.9434 0.078 0 0
M  V30 3 C -1.9884 -1.4614 0 0
M  V30 4 C -0.6778 -2.2702 0 0
M  V30 5 C 0.6778 -1.5394 0 0
M  V30 6 C 0.7228 -0.0001 0 0
M  V30 7 N -0.5428 2.3478 0 0
M  V30 8 O 1.9884 -2.3479 0 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 2 1 2
M  V30 2 1 2 3
M  V30 3 2 3 4
M  V30 4 1 4 5
M  V30 5 2 5 6
M  V30 6 1 6 1
M  V30 7 1 1 7
M  V30 8 1 5 8
M  V30 END BOND
M  V30 BEGIN SGROUP
M  V30 1 DAT 0 ATOMS=(1 7) FIELDNAME=UV FIELDINFO=nm -
M  V30 FIELDDISP="    0.0000    0.0000    DRU   ALL  0       0" -
M  V30 MRV_FIELDDISP=0 FIELDDATA=340
M  V30 END SGROUP
M  V30 END CTAB
M  END
""")
mol

Result:
drawing

A similar issue occurs when reading from cxsmiles -- here are a few examples:

from IPython.display import SVG
mol1 = Chem.MolFromSmiles("NC1=CC=CC(O)=C1 |c:3,6,t:1,lp:0:1,6:2,SgD:0:UV:340::nm::|")
mol2 = Chem.MolFromSmiles("C/C=C/C |SgD:2:Stereo:Cis::::|")
mol3 = Chem.MolFromSmiles("CC(=C)C=C |SgD:1,3,4,2,0:Lambda Max:222::nm::|")
Draw.MolsToGridImage([mol1,mol2,mol3], molsPerRow=3, subImgSize=(300,200), useSVG=True)

Screen Shot 2021-09-13 at 1 43 13 PM

Expected behavior
The substance group labels should not overlap with atoms. Here is an example of what that could look like:

Screen Shot 2021-09-13 at 3 00 47 PM Screen Shot 2021-09-13 at 3 05 48 PM Screen Shot 2021-09-13 at 3 06 02 PM

Additional context
I believe this issue is happening because the location of the sgroup label relative to an atom in the sgroup is determined by the FIELDDISP property (see here), which is often looks something like 0.0000 0.0000 DR ALL 0 0 if the molecule was generated by CXSmiles or an sdf exported from marvin. If that property is removed (which I think can't be done in python), RDKit will default to calculating the placement of the label and we will get something like the images above.

Configuration (please complete the following information):

  • RDKit version: 2021_09
  • OS: MacOS Big Sur 11.5
  • Are you using conda? No
@greglandrum greglandrum self-assigned this Sep 14, 2021
greglandrum added a commit to greglandrum/rdkit that referenced this issue Sep 14, 2021
@greglandrum greglandrum added this to the 2021_03_6 milestone Sep 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants