From 6e0ec856190258edc372526a0c47bf8ad77ea31f Mon Sep 17 00:00:00 2001 From: even1024 Date: Tue, 10 Oct 2023 15:01:44 +0200 Subject: [PATCH] #1300 Stereobond is not preserved after pasting a SMILES structure (#1314) --- api/tests/integration/ref/formats/smiles.py.out | 5 +++++ api/tests/integration/tests/formats/smiles.py | 13 +++++++++++++ .../molecule/src/molecule_stereocenters.cpp | 6 ++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/api/tests/integration/ref/formats/smiles.py.out b/api/tests/integration/ref/formats/smiles.py.out index 27d92a67c4..8fa030b498 100644 --- a/api/tests/integration/ref/formats/smiles.py.out +++ b/api/tests/integration/ref/formats/smiles.py.out @@ -81,3 +81,8 @@ C1C(O)=C(C2C=CC(C)=CC=2N)C(C)=CC=1 |wU:3.12,wD:3.3,(-2.40,1.39,;-0.80,1.39,;-0.0 atropisomer: C1C(O)=C(C2C=CC(C)=CC=2N)C(C)=CC=1 |w:3.3,3.12| C1C(O)=C(C2C=CC(C)=CC=2N)C(C)=CC=1 |w:3.3,3.12,(-2.40,1.39,;-0.80,1.39,;-0.00,2.77,;0.00,0.00,;1.60,0.00,;2.40,1.39,;4.00,1.39,;4.80,0.00,;6.40,0.00,;4.00,-1.39,;2.40,-1.39,;1.60,-2.77,;-0.80,-1.39,;0.00,-2.77,;-2.40,-1.39,;-3.20,-0.00,)| +*** Suffoxides *** +suffoxide: +C1[S@](=O)CC(=O)C=1C +C1[S@](=O)CC(=O)C=1C +bond:5 stereo:6 diff --git a/api/tests/integration/tests/formats/smiles.py b/api/tests/integration/tests/formats/smiles.py index e650df5a2c..c110a93bae 100644 --- a/api/tests/integration/tests/formats/smiles.py +++ b/api/tests/integration/tests/formats/smiles.py @@ -128,3 +128,16 @@ print(mol.smiles()) mol.layout() print(mol.smiles()) + +print("*** Suffoxides ***") +mols_smiles = ["C1=C(C)C(=O)C[S@]1=O"] +for sm in mols_smiles: + print("suffoxide:") + mol = indigo.loadMolecule(sm) + print(mol.smiles()) + mol.layout() + print(mol.smiles()) + for i in range(mol.countBonds()): + bs = mol.getBond(i).bondStereo() + if bs > 0: + print("bond:%d stereo:%d" % (i, bs)) diff --git a/core/indigo-core/molecule/src/molecule_stereocenters.cpp b/core/indigo-core/molecule/src/molecule_stereocenters.cpp index 072751255d..a0267e66db 100644 --- a/core/indigo-core/molecule/src/molecule_stereocenters.cpp +++ b/core/indigo-core/molecule/src/molecule_stereocenters.cpp @@ -1771,7 +1771,8 @@ void MoleculeStereocenters::markBond(BaseMolecule& baseMolecule, int atom_idx) for (j = 0; j < size; j++) { edge_idx = baseMolecule.findEdgeIndex(atom_idx, pyramid[size - 1]); - if (baseMolecule.getBondDirection(edge_idx) == 0 && baseMolecule.getVertex(pyramid[size - 1]).degree() == 1) + if (baseMolecule.getBondDirection(edge_idx) == 0 && baseMolecule.getBondOrder(edge_idx) == BOND_SINGLE && + baseMolecule.getVertex(pyramid[size - 1]).degree() == 1) break; rotatePyramid(pyramid); if (size == 4) @@ -1783,7 +1784,8 @@ void MoleculeStereocenters::markBond(BaseMolecule& baseMolecule, int atom_idx) for (j = 0; j < size; j++) { edge_idx = baseMolecule.findEdgeIndex(atom_idx, pyramid[size - 1]); - if (baseMolecule.getBondDirection(edge_idx) == 0 && baseMolecule.getBondTopology(edge_idx) == TOPOLOGY_CHAIN && getType(pyramid[size - 1]) == 0) + if (baseMolecule.getBondDirection(edge_idx) == 0 && baseMolecule.getBondOrder(edge_idx) == BOND_SINGLE && + baseMolecule.getBondTopology(edge_idx) == TOPOLOGY_CHAIN && getType(pyramid[size - 1]) == 0) break; rotatePyramid(pyramid); if (size == 4)