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

Atropisomer CX Smiles generation is not canonical #7427

Open
ricrogz opened this issue May 8, 2024 · 1 comment
Open

Atropisomer CX Smiles generation is not canonical #7427

ricrogz opened this issue May 8, 2024 · 1 comment
Labels

Comments

@ricrogz
Copy link
Contributor

ricrogz commented May 8, 2024

I hit this while working on the failed test in #7426:

from rdkit import Chem

atropTestFile = '../Code/GraphMol/FileParsers/test_data/atropisomers/RP-6306_atrop1.sdf'
mol = Chem.MolFromMolFile(atropTestFile)

# Strip conformers so that we can't accicentally use them
mol.RemoveAllConformers()

# This is the atrop bond
bond = mol.GetBondWithIdx(3)
assert bond.GetStereo() ==  Chem.BondStereo.STEREOATROPCW

ps = Chem.SmilesWriteParams()

cxsmi1 = Chem.MolToCXSmiles(mol, ps, Chem.CXSmilesFields.CX_ALL_BUT_COORDS)
print(f'{cxsmi1=}')  # cxsmi1='Cc1cc2c(C(N)=O)c(N)n(-c3c(C)ccc(O)c3C)c2nc1C |wD:11.11|'

mol2 = Chem.MolFromSmiles(cxsmi1)
cxsmi2 = Chem.MolToCXSmiles(mol2, ps, Chem.CXSmilesFields.CX_ALL_BUT_COORDS)
print(f'{cxsmi2=}')  # cxsmi2='Cc1cc2c(C(N)=O)c(N)n(-c3c(C)ccc(O)c3C)c2nc1C |wU:10.9|'

# Smiles canonicalization should be stable
assert cxsmi1 == cxsmi2, 'canonicalization is not stable!'  # AssertionError: canonicalization is not stable!

@ricrogz ricrogz added the bug label May 8, 2024
@greglandrum
Copy link
Member

Yeah, we're going to have to take either the canonical atom ranks or the atom/bond output orders into account when selecting which bonds to wedge.

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