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

Zero & coordinate bonds are being taken into account for chirality #5196

Closed
ricrogz opened this issue Apr 13, 2022 · 2 comments
Closed

Zero & coordinate bonds are being taken into account for chirality #5196

ricrogz opened this issue Apr 13, 2022 · 2 comments
Labels
Milestone

Comments

@ricrogz
Copy link
Contributor

ricrogz commented Apr 13, 2022

I'm seeing the following using current master:

Consider this input mol. It has to be a mol block because of the zero bonds, which are not supported on SMILES. They are actually non standard on mol blocks too!

from rdkit import Chem

m = Chem.MolFromMolBlock("""
     RDKit          3D

  0  0  0  0  0  0  0  0  0  0999 V3000
M  V30 BEGIN CTAB
M  V30 COUNTS 15 18 0 0 0
M  V30 BEGIN ATOM
M  V30 1 C -0.136359 0.025241 -0.986870 0
M  V30 2 C 0.211183 -0.810922 0.138318 0
M  V30 3 C -0.446638 -0.713741 1.305561 0
M  V30 4 C -1.141107 0.914647 -0.916429 0
M  V30 5 R -1.628248 -0.983190 -0.411960 0
M  V30 6 H 0.392055 -0.106505 -1.920607 0
M  V30 7 H 0.974038 -1.568492 0.017171 0
M  V30 8 H -0.209921 -1.406535 2.084966 0
M  V30 9 H -1.378909 1.482059 -1.807349 0
M  V30 10 C -1.544607 0.306162 1.588191 0
M  V30 11 C -1.946856 1.186683 0.358271 0
M  V30 12 H -1.207983 0.944410 2.407927 0
M  V30 13 H -2.419549 -0.225146 1.965589 0
M  V30 14 H -3.006492 1.040978 0.144313 0
M  V30 15 H -1.830875 2.240146 0.620809 0
M  V30 END ATOM
M  V30 BEGIN BOND
M  V30 1 1 2 1
M  V30 2 2 3 2
M  V30 3 2 4 1
M  V30 4 0 5 1
M  V30 5 0 5 2
M  V30 6 0 5 3
M  V30 7 0 5 4
M  V30 8 1 1 6
M  V30 9 1 2 7
M  V30 10 1 3 8
M  V30 11 1 4 9
M  V30 12 1 10 3
M  V30 13 1 11 4
M  V30 14 1 11 10
M  V30 15 1 12 10
M  V30 16 1 13 10
M  V30 17 1 14 11
M  V30 18 1 15 11
M  V30 END BOND
M  V30 END CTAB
M  END
""")

----
[12:13:04] bond with order 0 found on line 28. This is not part of the MDL specification.
[12:13:04] bond with order 0 found on line 29. This is not part of the MDL specification.
[12:13:04] bond with order 0 found on line 30. This is not part of the MDL specification.
[12:13:04] bond with order 0 found on line 31. This is not part of the MDL specification.

Up to this point, things are fine:

m.Debug()                                                                                                                                           
Atoms:
	0 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 0
	1 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 0
	2 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 0
	3 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 0
	4 0 * chg: 0  deg: 4 exp: 0 imp: 0 hyb: 0 arom?: 0 chi: 0
	5 6 C chg: 0  deg: 2 exp: 2 imp: 2 hyb: 4 arom?: 0 chi: 0
	6 6 C chg: 0  deg: 2 exp: 2 imp: 2 hyb: 4 arom?: 0 chi: 0
Bonds:
	0 1->0 order: 1 conj?: 0 aromatic?: 0
	1 2->1 order: 2 conj?: 0 aromatic?: 0
	2 3->0 order: 2 conj?: 0 aromatic?: 0
	3 4->0 order: 0 conj?: 0 aromatic?: 0
	4 4->1 order: 0 conj?: 0 aromatic?: 0
	5 4->2 order: 0 conj?: 0 aromatic?: 0
	6 4->3 order: 0 conj?: 0 aromatic?: 0
	7 5->2 order: 1 conj?: 0 aromatic?: 0
	8 6->3 order: 1 conj?: 0 aromatic?: 0
	9 6->5 order: 1 conj?: 0 aromatic?: 0

But if we assign stereo, we start seeing weird things:

Chem.AssignStereochemistryFrom3D(m)                                                                                                                 
m.Debug()                                                                                                                                           
Atoms:
	0 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 2
	1 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 1
	2 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 2
	3 6 C chg: 0  deg: 3 exp: 3 imp: 1 hyb: 4 arom?: 0 chi: 1
	4 0 * chg: 0  deg: 4 exp: 0 imp: 0 hyb: 0 arom?: 0 chi: 1
	5 6 C chg: 0  deg: 2 exp: 2 imp: 2 hyb: 4 arom?: 0 chi: 0
	6 6 C chg: 0  deg: 2 exp: 2 imp: 2 hyb: 4 arom?: 0 chi: 0
Bonds:
	0 1->0 order: 1 conj?: 0 aromatic?: 0
	1 2->1 order: 2 conj?: 0 aromatic?: 0
	2 3->0 order: 2 conj?: 0 aromatic?: 0
	3 4->0 order: 0 conj?: 0 aromatic?: 0
	4 4->1 order: 0 conj?: 0 aromatic?: 0
	5 4->2 order: 0 conj?: 0 aromatic?: 0
	6 4->3 order: 0 conj?: 0 aromatic?: 0
	7 5->2 order: 1 conj?: 0 aromatic?: 0
	8 6->3 order: 1 conj?: 0 aromatic?: 0
	9 6->5 order: 1 conj?: 0 aromatic?: 0

RDkit found 5 chiral atoms: 4 C atoms with 1 implicit H + 1 single + 1 double + 1 zero bonds, and the dummy atom, with 4 zero bonds (!!!!).

And here is where things explode:

Chem.MolToMolBlock(m)                                                                                                                               
[12:19:02] 

****
Invariant Violation
no eligible neighbors for chiral center
Violation occurred on line 240 in file /rdkit_builder/rdkit/Code/GraphMol/FileParsers/MolFileStereochem.cpp
Failed Expression: nbrScores.size()
****

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Input In [6], in <cell line: 1>()
----> 1 Chem.MolToMolBlock(m)

RuntimeError: Invariant Violation
	no eligible neighbors for chiral center
	Violation occurred on line 240 in file Code/GraphMol/FileParsers/MolFileStereochem.cpp
	Failed Expression: nbrScores.size()
	RDKIT: 2022.09.1pre
	BOOST: 1_76

This is happening inside WedgeMolBonds(), when we try to find a bond to wedge for the dummy atom: as it only has zero bonds, of course, we can't find a single bond we can wedge to encode the parity in the mol block.

@ricrogz ricrogz added the bug label Apr 13, 2022
greglandrum added a commit to greglandrum/rdkit that referenced this issue Apr 14, 2022
This fixes the bug as reported, but there's more work to do in order to get the other cases
@greglandrum greglandrum added this to the 2022_03_2 milestone Apr 14, 2022
greglandrum added a commit that referenced this issue Apr 25, 2022
* Fixes #5196

This fixes the bug as reported, but there's more work to do in order to get the other cases

* cleanup

* fix assignStereochemistry()

* Fixes #5200

* move those functions to the public API

* fix assignStereochemistry

* cleanup

* refactoring in response to review
@lonngxiang
Copy link

The same error, how to solve?
image

@greglandrum
Copy link
Member

@lonngxiang : we can't help if you don't provide the sample input which caused the problem you are seeing.

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

3 participants