diff --git a/api/tests/integration/ref/arom/basic.py.out b/api/tests/integration/ref/arom/basic.py.out index ee19b2d997..456e2bc0be 100644 --- a/api/tests/integration/ref/arom/basic.py.out +++ b/api/tests/integration/ref/arom/basic.py.out @@ -465,3 +465,7 @@ M END M END {"root":{"nodes":[{"$ref":"mol0"}]},"mol0":{"type":"molecule","atoms":[{"label":"C","location":[0.0,0.0,0.0]},{"label":"C","location":[1.0,0.0,0.0]}],"bonds":[{"type":7,"atoms":[0,1]}]}} +***** Dearomatize molecule with custom query without label ***** +[#6](=[$([#7]-[#8]-[#6](-[#1])(-[#1])-[#6](-[#1])(-[#1])-[#6](-[#1])(-[#1])-[#7](-[#6](-[#1])-[#1])-[#6](-[#1])-[#1]),$([#7]-[#8]-[#6](-[#1])(-[#1])-[#6](-[#1])(-[#1])-[#7](-[#6](-[#1])-[#1])-[#6](-[#1])-[#1]),$([#7]-[#7](-[#1])-[#6](=[#7]-[#1])-[#7](-[#1])-[#1]),$([#6](-[#1])-[#7])])(-[#6]1-[#6](-[H])=[#6](-[H])-[#6](-[$([#1]),$([#17])])=[#6](-[H])-[#6]=1-[H])-[#6]1-[#6](-[H])=[#6]-[#6](-[$([#6;X4]),$([#1])])=[#6](-[H])-[#6]=1-[H] +***** Dearomatize molecule with atom_aromatic_connectivity < 0 should not cause exception ***** +c1ccccc1 diff --git a/api/tests/integration/tests/arom/basic.py b/api/tests/integration/tests/arom/basic.py index 678c2a65c7..62f39bc3b2 100644 --- a/api/tests/integration/tests/arom/basic.py +++ b/api/tests/integration/tests/arom/basic.py @@ -352,3 +352,19 @@ def printMoleculeWithRGroups(m): indigo.setOption("dearomatize-on-load", "true") q = indigo.loadQueryMolecule("[#6]=,:[#6]") print(q.json()) + +print("***** Dearomatize molecule with custom query without label *****") +m = indigo.loadQueryMoleculeFromFile( + joinPathPy("molecules/issue_1524.ket", __file__) +) +m.dearomatize() +print(m.smarts()) + +print( + "***** Dearomatize molecule with atom_aromatic_connectivity < 0 should not cause exception *****" +) +m = indigo.loadMoleculeFromFile( + joinPathPy("molecules/issue_1478.ket", __file__) +) +m.dearomatize() +print(m.smiles()) diff --git a/api/tests/integration/tests/arom/molecules/issue_1478.ket b/api/tests/integration/tests/arom/molecules/issue_1478.ket new file mode 100644 index 0000000000..ac87eca35d --- /dev/null +++ b/api/tests/integration/tests/arom/molecules/issue_1478.ket @@ -0,0 +1,114 @@ +{ + "root": { + "nodes": [ + { + "$ref": "mol0" + } + ], + "connections": [], + "templates": [] + }, + "mol0": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 14.059849222125079, + -9.825074473618729, + 0 + ] + }, + { + "label": "C", + "location": [ + 15.790150777932888, + -9.824589053476172, + 0 + ] + }, + { + "label": "C", + "location": [ + 14.926637935382303, + -9.324966795472761, + 0 + ], + "implicitHCount": 4 + }, + { + "label": "C", + "location": [ + 15.790150777932888, + -10.825532063144866, + 0 + ] + }, + { + "label": "C", + "location": [ + 14.059849222125079, + -10.830020053696668, + 0 + ] + }, + { + "label": "C", + "location": [ + 14.928820895512578, + -11.325033204531177, + 0 + ] + } + ], + "bonds": [ + { + "type": 4, + "atoms": [ + 2, + 0 + ] + }, + { + "type": 4, + "atoms": [ + 0, + 4 + ] + }, + { + "type": 4, + "atoms": [ + 4, + 5 + ] + }, + { + "type": 4, + "atoms": [ + 5, + 3 + ] + }, + { + "type": 4, + "atoms": [ + 3, + 1 + ] + }, + { + "type": 4, + "atoms": [ + 1, + 2 + ] + } + ], + "stereoFlagPosition": { + "x": 15.790153526462133, + "y": 8.324968418632889, + "z": 0 + } + } +} diff --git a/core/indigo-core/molecule/src/molecule_dearom.cpp b/core/indigo-core/molecule/src/molecule_dearom.cpp index 750e39a4ce..8aa4ad1617 100644 --- a/core/indigo-core/molecule/src/molecule_dearom.cpp +++ b/core/indigo-core/molecule/src/molecule_dearom.cpp @@ -971,20 +971,24 @@ void DearomatizationsGroups::_detectAromaticGroups(int v_idx, const int* atom_ex atom_aromatic_connectivity = max_connectivity - non_aromatic_conn; if (atom_aromatic_connectivity < 0) - throw Error("atom_aromatic_connectivity < 0 on %s having %d drawn bonds, charge %d, and %d radical electrons", Element::toString(label), - non_aromatic_conn, charge, radical); - - _vertexIsAcceptSingleEdge[v_idx] = true; - if (atom_aromatic_connectivity > 0) { - _vertexIsAcceptDoubleEdge[v_idx] = true; - // If number of implicit hydrogens are fixed and double bond is possible then - // double bond must exist - if (impl_h_fixed) - _vertexIsAcceptSingleEdge[v_idx] = false; + _vertexIsAcceptSingleEdge[v_idx] = false; + _vertexIsAcceptDoubleEdge[v_idx] = false; } else - _vertexIsAcceptDoubleEdge[v_idx] = false; + { + _vertexIsAcceptSingleEdge[v_idx] = true; + if (atom_aromatic_connectivity > 0) + { + _vertexIsAcceptDoubleEdge[v_idx] = true; + // If number of implicit hydrogens are fixed and double bond is possible then + // double bond must exist + if (impl_h_fixed) + _vertexIsAcceptSingleEdge[v_idx] = false; + } + else + _vertexIsAcceptDoubleEdge[v_idx] = false; + } } bool* DearomatizationsGroups::getAcceptDoubleBonds(void)