Skip to content

Commit

Permalink
#1478 Dearomatization causes exception in case of Implicit H count q…
Browse files Browse the repository at this point in the history
…uery feature set to 4 (i.e. more than 2) (#1570)
  • Loading branch information
AliaksandrDziarkach authored Jan 17, 2024
1 parent 49c01cc commit c661f9d
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 11 deletions.
2 changes: 2 additions & 0 deletions api/tests/integration/ref/arom/basic.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,5 @@ 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
9 changes: 9 additions & 0 deletions api/tests/integration/tests/arom/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,3 +359,12 @@ def printMoleculeWithRGroups(m):
)
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())
114 changes: 114 additions & 0 deletions api/tests/integration/tests/arom/molecules/issue_1478.ket
Original file line number Diff line number Diff line change
@@ -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
}
}
}
26 changes: 15 additions & 11 deletions core/indigo-core/molecule/src/molecule_dearom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c661f9d

Please sign in to comment.