Skip to content

Commit

Permalink
#1355 Error appears when pressing 'Layout" (#1364)
Browse files Browse the repository at this point in the history
  • Loading branch information
AliaksandrDziarkach authored Oct 23, 2023
1 parent e6374ee commit 73a99f4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 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 @@ -61,3 +61,5 @@ smarts loaded OK
[!#6!#7!#8] is ok. smarts_in==smarts_out
[!#6!#7!#8] is ok. json_in==json_out
[!#6!#7!#8] is ok. expected string found in json
#1355 Error appeared at save query molecule with RSite as smarts
Ok expected smarts generated
12 changes: 12 additions & 0 deletions api/tests/integration/tests/formats/smarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,15 @@ def test_smarts_load_save_through_ket(smarts_in, expected_str):
"[!#6!#7!#8]",
'"atoms":[{"type":"atom-list","notList":true,"elements":["C","N","O"],"location":[0.0,0.0,0.0]}]',
)
print("#1355 Error appeared at save query molecule with RSite as smarts")
m = indigo.loadQueryMolecule(
"S=CC(F)CCCCC[C@@](CCO)/C=C/[C@@](N)CCC[C]C([13C]CC([C+2]CC(CC%91)CC(C)CCC)CCC)CC%92.[*:2]%92.[*:1]%91 |$;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;_R2;_R1$,rb:32:*,u:3|"
)
smarts = m.smarts()
expected = "[#16]=[#6]-[#6](-[#6]-[#6]-[#6]-[#6]-[#6]-[#6@](-[#6]=[#6]-[#6@](-[#6]-[#6]-[#6]-[#6]-[#6](-[#6]-[#6]%91)-[13;#6]-[#6]-[#6](-[#6]-[#6]-[#6])-[#6;+2]-[#6]-[#6](-[#6]-[#6](-[#6]-[#6]-[#6])-[#6;x0])-[#6]-[#6]%92)-[#7])-[#6]-[#6]-[#8])-[#9;$([*,#1]=,#,:[*,#1])].[*:2]-%91.[*:1]-%92"
if smarts == expected:
print("Ok expected smarts generated")
else:
print(
"Fail. Expected smarts is\n%s\nbut generated\n%s" % (expected, smarts)
)
7 changes: 4 additions & 3 deletions core/indigo-core/molecule/src/molecule_json_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,8 @@ void MoleculeJsonSaver::saveAtoms(BaseMolecule& mol, JsonWriter& writer)
int radical = 0;
int query_atom_type = QueryMolecule::QUERY_ATOM_UNKNOWN;
std::map<int, const QueryMolecule::Atom*> query_atom_properties;
if (mol.isRSite(i))
bool is_rSite = mol.isRSite(i);
if (is_rSite)
{
mol.getAllowedRGroups(i, rg_list);
writer.Key("type");
Expand Down Expand Up @@ -810,7 +811,7 @@ void MoleculeJsonSaver::saveAtoms(BaseMolecule& mol, JsonWriter& writer)
bool ecflag = mol.reaction_atom_exact_change[i];
int hcount = MoleculeSavers::getHCount(mol, i, anum, charge);

if (_pqmol)
if (_pqmol && !is_rSite) // No custom query for RSite
{
bool needCustomQuery = query_atom_type == QueryMolecule::QUERY_ATOM_UNKNOWN;
std::map<int, const char*> qprops{{QueryMolecule::ATOM_SSSR_RINGS, "ringMembership"},
Expand Down Expand Up @@ -908,7 +909,7 @@ void MoleculeJsonSaver::saveAtoms(BaseMolecule& mol, JsonWriter& writer)
writer.Int(query_atom_properties[QueryMolecule::ATOM_IMPLICIT_H]->value_min);
}
}
else
else if (_pmol)
{
if (Molecule::shouldWriteHCount(mol.asMolecule(), i) && hcount > 0)
{
Expand Down
3 changes: 3 additions & 0 deletions core/indigo-core/molecule/src/query_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,9 @@ void QueryMolecule::writeSmartsAtom(Output& output, Atom* atom, int aam, int chi
}
break;
}
case ATOM_RSITE:
output.printf("*:%d", atom->value_min);
break;

default: {
throw Error("Unknown atom attribute %d", atom->type);
Expand Down

0 comments on commit 73a99f4

Please sign in to comment.