Skip to content

Commit

Permalink
#1440 Add support for query features in MOL
Browse files Browse the repository at this point in the history
Fix UT
  • Loading branch information
AliaksandrDziarkach committed Dec 28, 2023
1 parent a391844 commit fa626ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 5 additions & 3 deletions api/tests/integration/ref/basic/check_query.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -645,17 +645,19 @@ Check query for bond 21 returns 0
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 C 0 0 0 2 0 3 0 0 0 0 0 0
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 A 0 0 0 2 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 A 0 0 0 2 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 L 0 0 0 2 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 L 0 0 0 2 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 6 0 0 0 0
2 3 6 0 0 0 0
3 4 6 0 0 0 0
4 5 6 0 0 0 0
5 6 6 0 0 0 0
6 1 6 0 0 0 0
M ALS 4 3 T Cl Br I
M ALS 5 3 F C N F
M MRV SMA 2 [#6;Hh1X3R1r6a]
M MRV SMA 4 [!Cl;!Br;!I;a;R1;h1;H]
M MRV SMA 4 [!#17;!#35;!#53;Hh1R1a]
M MRV SMA 5 [#6,#7,#9;Hh1R1r6a]
M END

2 changes: 2 additions & 0 deletions core/indigo-core/molecule/query_molecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ namespace indigo
Atom* releaseAtom(int idx);
void resetAtom(int idx, Atom* atom);

static bool isAtomProperty(OpType type);

Bond& getBond(int idx);
Bond* releaseBond(int idx);
void resetBond(int idx, Bond* bond);
Expand Down
12 changes: 11 additions & 1 deletion core/indigo-core/molecule/src/query_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

using namespace indigo;

bool QueryMolecule::isAtomProperty(OpType type)
{
return (type > ATOM_PSEUDO && type <= ATOM_CHIRALITY);
}

QueryMolecule::QueryMolecule() : spatial_constraints(*this)
{
}
Expand Down Expand Up @@ -2654,7 +2659,7 @@ bool QueryMolecule::_isAtomOrListAndProps(Atom* p_query_atom, std::vector<std::u
neg = is_neg;
return true;
}
else if (!is_neg && p_query_atom_child->type > ATOM_NUMBER && p_query_atom_child->type <= ATOM_CHIRALITY) // atom property, no negative props here
else if (!is_neg && isAtomProperty(p_query_atom_child->type)) // atom property, no negative props here
{
properties[p_query_atom_child->type] = std::unique_ptr<Atom>(p_query_atom_child->clone());
return true;
Expand Down Expand Up @@ -2686,6 +2691,11 @@ bool QueryMolecule::_isAtomOrListAndProps(Atom* p_query_atom, std::vector<std::u
std::map<int, std::unique_ptr<Atom>> collected_properties;
if (_isAtomOrListAndProps(p_query_atom_child, collected, is_neg, collected_properties))
{
if (isAtomProperty(p_query_atom_child->type))
{
properties[p_query_atom_child->type] = std::unique_ptr<Atom>(p_query_atom_child->clone());
continue;
}
if (list.size() > 0 && is_neg != neg) // allowed only one list type in set - positive or negative
return false;
neg = is_neg;
Expand Down

0 comments on commit fa626ac

Please sign in to comment.