Skip to content

Commit

Permalink
Backmerge #1362 Valence is not added to the SMARTS file (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliaksandrDziarkach committed Oct 26, 2023
1 parent af912fb commit ced8aeb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
6 changes: 6 additions & 0 deletions api/tests/integration/ref/formats/smarts.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,18 @@ Ok expected smarts generated
[#6,#7;a]:[o] is ok. expected string found in json
[c,n,o]:[o] is ok. json_in==json_out
[c,n,o]:[o] is ok. expected string found in json
[c,C,c] is ok. smarts_in==smarts_out
[c,C,c] is ok. json_in==json_out
[c,C,c] is ok. expected string found in json
[C,c] is ok. smarts_in==smarts_out
[C,c] is ok. json_in==json_out
[C,c] is ok. expected string found in json
[C,c,n,o] is ok. smarts_in==smarts_out
[C,c,n,o] is ok. json_in==json_out
[C,c,n,o] is ok. expected string found in json
[#7;v4]-[#6] is ok. smarts_in==smarts_out
[#7;v4]-[#6] is ok. json_in==json_out
[#7;v4]-[#6] is ok. expected string found in json
*** SMARTS specific ***
Smarts [C,N] loaded as smarts - OK.
Smarts [C;N] loaded as smarts - OK.
Expand Down
9 changes: 6 additions & 3 deletions api/tests/integration/tests/formats/smarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,16 @@ def test_smarts_load_save_through_ket(
test_smarts_load_save_through_ket(smarts, expected, False)
smarts = "[c,C,c]"
expected = '"atoms":[{"label":"C","location":[0.0,0.0,0.0],"queryProperties":{"customQuery":"c,C,c"}}]'
test_smarts_load_save_through_ket(smarts, expected, False)
test_smarts_load_save_through_ket(smarts, expected)
smarts = "[C,c]"
expected = '"atoms":[{"label":"C","location":[0.0,0.0,0.0],"queryProperties":{"customQuery":"C,c"}}]'
test_smarts_load_save_through_ket(smarts, expected, False)
test_smarts_load_save_through_ket(smarts, expected)
smarts = "[C,c,n,o]"
expected = '"atoms":[{"label":"","location":[0.0,0.0,0.0],"queryProperties":{"customQuery":"C,c,n,o"}}]'
test_smarts_load_save_through_ket(smarts, expected, False)
test_smarts_load_save_through_ket(smarts, expected)
smarts = "[#7;v4]-[#6]"
expected = '"atoms":[{"label":"N","location":[0.0,0.0,0.0],"explicitValence":4},{"label":"C","location":[1.0,0.0,0.0]}]'
test_smarts_load_save_through_ket(smarts, expected)
print(" *** SMARTS specific ***")
smarts_list = [
"[C,N]",
Expand Down
2 changes: 1 addition & 1 deletion core/indigo-core/molecule/src/molecule_json_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ int MoleculeJsonLoader::addAtomToMoleculeQuery(const char* label, int element, i
{
if (valence == 15)
valence = 0;
atom.reset(QueryMolecule::Atom::und(atom.release(), new QueryMolecule::Atom(QueryMolecule::ATOM_VALENCE, valence)));
atom.reset(QueryMolecule::Atom::und(atom.release(), new QueryMolecule::Atom(QueryMolecule::ATOM_TOTAL_BOND_ORDER, valence)));
}

if (isotope != 0)
Expand Down
8 changes: 7 additions & 1 deletion core/indigo-core/molecule/src/molecule_json_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,13 @@ void MoleculeJsonSaver::saveAtoms(BaseMolecule& mol, JsonWriter& writer)
writer.Int(charge);
}

if (evalence > 0)
int total_bond_count = 0;
if (_pqmol && _pqmol->getAtom(i).sureValue(QueryMolecule::ATOM_TOTAL_BOND_ORDER, total_bond_count))
{
writer.Key("explicitValence");
writer.Int(total_bond_count);
}
else if (evalence > 0)
{
writer.Key("explicitValence");
writer.Int(evalence);
Expand Down

0 comments on commit ced8aeb

Please sign in to comment.