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

H atoms in SGroups cause RDKit to clear SGroups after parsing #2716

Closed
ricrogz opened this issue Oct 14, 2019 · 0 comments · Fixed by #5399
Closed

H atoms in SGroups cause RDKit to clear SGroups after parsing #2716

ricrogz opened this issue Oct 14, 2019 · 0 comments · Fixed by #5399
Labels
Milestone

Comments

@ricrogz
Copy link
Contributor

ricrogz commented Oct 14, 2019

A simple example (in this case, the H atom is not directly in the SGroup, but in the crossing bond):

from rdkit import Chem
mol = Chem.MolFromMolBlock("""
                    3D

  2  1  0  0  0  0            999 V2000
   -2.3620   -1.8090    1.7866 C   0  0  0  0  0  0
   -2.9887   -1.8667    2.6766 H   0  0  0  0  0  0
  1  2  1  0  0  0
M  STY  1   1 SRU
M  SAL   1  1   1
M  SBL   1  1   1
M  SCN  1   1 HT
M  END""")
print(len(Chem.GetMolSubstanceGroups(mol)))

This will print "0". Looked a bit at it in the debugger, and checked that the SGroup does actually get parsed, but is deleted before asking for the SGroups again. I'm suspecting it has to do with the H atom being turned "explicitH", so I changed it in the input to be an F atom, and in this case, the SGroup is not deleted:

In [9]: mol2 = Chem.MolFromMolBlock("""
   ...:                     3D
   ...: 
   ...:   2  1  0  0  0  0            999 V2000
   ...:    -2.3620   -1.8090    1.7866 C   0  0  0  0  0  0
   ...:    -2.9887   -1.8667    2.6766 F   0  0  0  0  0  0
   ...:   1  2  1  0  0  0
   ...: M  STY  1   1 SRU
   ...: M  SAL   1  1   1
   ...: M  SBL   1  1   1
   ...: M  SCN  1   1 HT
   ...: M  END""")
   ...: print(len(Chem.GetMolSubstanceGroups(mol2)))
   ...: 
   ...: 
1

I'm planning on submitting a patch to keep these H atoms as explicit nodes if they are included in any SGroups atoms, patoms, or bonds list (and possibly other SGroup features, if required).

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