Skip to content

Commit

Permalink
#1292 valid SMARTS with cycles cause error in loader (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliaksandrDziarkach authored Oct 20, 2023
1 parent 2e0b7ae commit 6a5ff1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/tests/integration/ref/formats/smarts.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ CC[C+5]CCCCC
[#6]-;!@[#6] is ok. smarts_in==smarts_out
[#6]-;!@[#6] is ok. json_in==json_out
[#6]-;!@[#6] is ok. expected string found in json
#1292 test smarts c:1-2:c(:c:c:c:c:1)-[#6](=[#8])-[#6;X4]-[#6]-2=[#8]
smarts loaded OK
3 changes: 3 additions & 0 deletions api/tests/integration/tests/formats/smarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,6 @@ def test_smarts_load_save_through_ket(smarts_in, expected_str):
test_smarts_load_save_through_ket(
"[#6]-;!@[#6]", '"bonds":[{"type":1,"topology":2,"atoms":[0,1]}]'
)
print("#1292 test smarts c:1-2:c(:c:c:c:c:1)-[#6](=[#8])-[#6;X4]-[#6]-2=[#8]")
indigo.loadSmarts("c:1-2:c(:c:c:c:c:1)-[#6](=[#8])-[#6;X4]-[#6]-2=[#8]")
print("smarts loaded OK")
3 changes: 3 additions & 0 deletions core/indigo-core/molecule/src/smiles_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1643,6 +1643,9 @@ void SmilesLoader::_parseMolecule()
// Without this shift the 9th bond in the second structure is not double
_bonds.top() = pending_bond;
_bonds.remove(pending_bond_idx);
for (int i = 0; i < _cycles.size(); i++)
if (_cycles[i].pending_bond >= pending_bond_idx)
--_cycles[i].pending_bond;

_cycles[number].clear();
continue;
Expand Down

0 comments on commit 6a5ff1e

Please sign in to comment.