connorcoley / rdchiral

Wrapper for RDKit's RunReactants to improve stereochemistry handling
MIT License
151 stars 50 forks source link

Pre-condition Violation: attempt to add self-bond #22

Open robertdavidburbidgephd opened 3 years ago

robertdavidburbidgephd commented 3 years ago

With the following code:

from rdchiral import main as rdc reaction = rdc.rdchiralReaction('[C:1]-[N;H0;D3;+0:2](-[C:3])-[O;H0;D2;+0:6]-[C:5]=[O;D1;H0:4]>>[C:1]-[NH;D2;+0:2]-[C:3].[O;D1;H0:4]=[C:5]-[O;H0;D2;+0:6]-[O;H0;D2;+0:6]-[C:5]=[O;D1;H0:4]') rct = rdc.rdchiralReactants('O=C(ON1C(=O)CCC1=O)c1ccc2c(c1)OCO2') reactants = rdc.rdchiralRun(reaction, rct)

I get the following error:

Traceback (most recent call last): File "test.py", line 6, in reactants = rdc.rdchiralRun(reaction, rct) File "xx/lib/python3.6/site-packages/rdchiral/main.py", line 242, in rdchiralRun merged_map_to_id[bj], b.GetBondType()) RuntimeError: Pre-condition Violation attempt to add self-bond Violation occurred on line 300 in file Code/GraphMol/RWMol.cpp Failed Expression: atomIdx1 != atomIdx2 RDKIT: 2020.03.3 BOOST: 1_67

The SMARTS was generated with RDChiral from the reverse of various reaction SMILES from Reaxys, e.g.:

[NH:1]([CH2:6][CH2:7][O:8][CH3:9])[CH2:2][CH2:3][O:4][CH3:5].[c:10]1([C:16]([O:18][O:18][C:16]([c:10]2[cH:15][cH:14][cH:13][cH:12][cH:11]2)=[O:17])=[O:17])[cH:15][cH:14][cH:13][cH:12][cH:11]1>>[C:16]([c:10]1[cH:15][cH:14][cH:13][cH:12][cH:11]1)([O:18][N:1]([CH2:6][CH2:7][O:8][CH3:9])[CH2:2][CH2:3][O:4][CH3:5])=[O:17]

In my data there are 122 reaction SMILES that when reversed lead to the above SMARTS.

ljn917 commented 3 years ago

Reproducible on RDKit 2019.03.3, caused by https://github.com/connorcoley/rdchiral/blob/246e17133f70565b851fa3fbb10152dc2afa884a/rdchiral/main.py#L259

Seem to be a bad template because reactants have non-unique atom mapping numbers.