Skip to content

Commit

Permalink
#1331 Ring bond count 'As drawn' saved wrong (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliaksandrDziarkach authored Oct 19, 2023
1 parent 7f62e4e commit 08d5650
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/tests/integration/ref/formats/custom_query.py.out
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
**** #1310 error at opening SMARTS with comma ****
[#6]1-[#6]=[#6]-[#6]=[#6]-[b;r;3;s&2,X3]=1 OK. Expected string found.
**** #1331 wrong smarts for ring bond count as drawn ****
ket_with_rb_as_drawn.ket OK. Smarts equals expected string '[#6](-[#6])(-[#6;x0])-[#6]'
19 changes: 19 additions & 0 deletions api/tests/integration/tests/formats/custom_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

indigo = Indigo()

ref_path = joinPathPy("ref/", __file__)


def test_smarts_to_ket(smarts_in, expected_str):
mol = indigo.loadSmarts(smarts_in)
Expand All @@ -21,8 +23,25 @@ def test_smarts_to_ket(smarts_in, expected_str):
print("%s FAILED. Expected string not found." % smarts_in)


def test_ket_to_smarts(filename, expected_str):
mol = indigo.loadQueryMoleculeFromFile(os.path.join(ref_path, filename))
smarts = mol.smarts()
if smarts == expected_str:
print(
"%s OK. Smarts equals expected string '%s'"
% (filename, expected_str)
)
else:
print(
"%s FAILED. Expected '%s', generated smarts '%s'"
% (filename, expected_str, smarts)
)


print("**** #1310 error at opening SMARTS with comma ****")
test_smarts_to_ket(
"[#6]1-[#6]=[#6]-[#6]=[#6]-[b;r;3;s&2,X3]=1",
'"queryProperties":{"customQuery":"b;r;3;s&2,X3"}',
)
print("**** #1331 wrong smarts for ring bond count as drawn ****")
test_ket_to_smarts("ket_with_rb_as_drawn.ket", "[#6](-[#6])(-[#6;x0])-[#6]")
70 changes: 70 additions & 0 deletions api/tests/integration/tests/formats/ref/ket_with_rb_as_drawn.ket
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"root": {
"nodes": [
{
"$ref": "mol0"
}
]
},
"mol0": {
"type": "molecule",
"atoms": [
{
"label": "C",
"location": [
10.366987298107782,
-9.325000000000001,
0
]
},
{
"label": "C",
"location": [
11.23301270189222,
-8.825000000000001,
0
]
},
{
"label": "C",
"location": [
9.500961894323343,
-8.825000000000001,
0
],
"ringBondCount": -2
},
{
"label": "C",
"location": [
10.366987298107782,
-10.325000000000001,
0
]
}
],
"bonds": [
{
"type": 1,
"atoms": [
0,
1
]
},
{
"type": 1,
"atoms": [
0,
2
]
},
{
"type": 1,
"atoms": [
0,
3
]
}
]
}
}
2 changes: 1 addition & 1 deletion core/indigo-core/molecule/src/query_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ void QueryMolecule::writeSmartsAtom(Output& output, Atom* atom, int aam, int chi
}

case ATOM_RING_BONDS_AS_DRAWN: {
output.printf("x:%d", atom->value_min);
output.printf("x0"); // exact value should be writed in extended part
break;
}

Expand Down

0 comments on commit 08d5650

Please sign in to comment.