From 958c5ac75514535875bef6fbd613bc556b896662 Mon Sep 17 00:00:00 2001 From: even1024 Date: Sat, 9 Dec 2023 23:03:39 +0100 Subject: [PATCH 1/2] query crash --- .../ref/formats/mol_features.py.out | 2 + .../integration/tests/formats/mol_features.py | 7 ++++ .../formats/molecules/query_crash_1431.mol | 38 +++++++++++++++++++ .../molecule/src/query_molecule.cpp | 3 +- 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 api/tests/integration/tests/formats/molecules/query_crash_1431.mol diff --git a/api/tests/integration/ref/formats/mol_features.py.out b/api/tests/integration/ref/formats/mol_features.py.out index adde2a4d47..af0b7d5236 100644 --- a/api/tests/integration/ref/formats/mol_features.py.out +++ b/api/tests/integration/ref/formats/mol_features.py.out @@ -13075,3 +13075,5 @@ M V30 END SGROUP M V30 END CTAB M END +*** 1431 Query explicit valency crash *** +[#6;+2;v;D0;$([*,#1]=,#,:[*,#1]);x0]1=[#6]-[#6]=[#6]-[#6]=[#6]-1.[#6]-[#6]-[#6@@](-[#6])-[#6]-[#6] diff --git a/api/tests/integration/tests/formats/mol_features.py b/api/tests/integration/tests/formats/mol_features.py index d1ece98bce..06b9ad7463 100644 --- a/api/tests/integration/tests/formats/mol_features.py +++ b/api/tests/integration/tests/formats/mol_features.py @@ -176,3 +176,10 @@ def printGroupsInfo(m): print(smiles) indigo.setOption("molfile-saving-mode", "3000") print(mol.molfile()) + +print("*** 1431 Query explicit valency crash ***") +qmol = indigo.loadQueryMoleculeFromFile( + joinPathPy("molecules/query_crash_1431.mol", __file__) +) + +print(qmol.smarts()) \ No newline at end of file diff --git a/api/tests/integration/tests/formats/molecules/query_crash_1431.mol b/api/tests/integration/tests/formats/molecules/query_crash_1431.mol new file mode 100644 index 0000000000..7ccf95082f --- /dev/null +++ b/api/tests/integration/tests/formats/molecules/query_crash_1431.mol @@ -0,0 +1,38 @@ + + SMMXDraw07231311392D + + 0 0 0 0 0 999 V3000 +M V30 BEGIN CTAB +M V30 COUNTS 12 11 0 0 0 +M V30 BEGIN ATOM +M V30 1 C 12.4156 -5.7104 0 0 CHG=2 VAL=1 INVRET=2 SUBST=-1 UNSAT=1 RBCNT=-2 +M V30 2 C 13.7493 -6.4805 0 0 +M V30 3 C 13.7493 -8.0205 0 0 +M V30 4 C 12.4156 -8.7905 0 0 +M V30 5 C 11.082 -8.0205 0 0 +M V30 6 C 11.082 -6.4805 0 0 +M V30 7 C 3.8438 -5.3438 0 0 +M V30 8 C 4.703 -5.8398 0 0 +M V30 9 C 5.5622 -5.3438 0 0 CFG=2 +M V30 10 C 6.4214 -5.8398 0 0 +M V30 11 C 7.2806 -5.3438 0 0 +M V30 12 C 5.5622 -4.3516 0 0 +M V30 END ATOM +M V30 BEGIN BOND +M V30 1 1 1 2 +M V30 2 2 2 3 +M V30 3 1 3 4 +M V30 4 2 4 5 +M V30 5 1 5 6 +M V30 6 2 6 1 +M V30 7 1 7 8 +M V30 8 1 8 9 +M V30 9 1 9 10 +M V30 10 1 10 11 +M V30 11 1 9 12 CFG=1 +M V30 END BOND +M V30 BEGIN COLLECTION +M V30 MDLV30/STEREL1 ATOMS=(1 9) +M V30 END COLLECTION +M V30 END CTAB +M END diff --git a/core/indigo-core/molecule/src/query_molecule.cpp b/core/indigo-core/molecule/src/query_molecule.cpp index 34f8a3411c..4d5c8074b9 100644 --- a/core/indigo-core/molecule/src/query_molecule.cpp +++ b/core/indigo-core/molecule/src/query_molecule.cpp @@ -1855,7 +1855,8 @@ QueryMolecule::Atom* QueryMolecule::releaseAtom(int idx) void QueryMolecule::resetAtom(int idx, QueryMolecule::Atom* atom) { - _atoms.reset(idx); + if (atom != _atoms[idx]) + _atoms.reset(idx); _atoms[idx] = atom; updateEditRevision(); } From d710f645d550f9581ea9a7962e42bfd860372c9c Mon Sep 17 00:00:00 2001 From: Roman Porozhnetov Date: Sat, 9 Dec 2023 23:18:01 +0100 Subject: [PATCH 2/2] fix python formatting --- api/tests/integration/tests/formats/mol_features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/tests/integration/tests/formats/mol_features.py b/api/tests/integration/tests/formats/mol_features.py index 06b9ad7463..46fd17d922 100644 --- a/api/tests/integration/tests/formats/mol_features.py +++ b/api/tests/integration/tests/formats/mol_features.py @@ -182,4 +182,4 @@ def printGroupsInfo(m): joinPathPy("molecules/query_crash_1431.mol", __file__) ) -print(qmol.smarts()) \ No newline at end of file +print(qmol.smarts())