Skip to content

Commit

Permalink
Updating files that didn't merge correctly, so that they are identical
Browse files Browse the repository at this point in the history
to the versions in devel
  • Loading branch information
chryswoods committed Oct 10, 2023
1 parent 421a665 commit b20865a
Show file tree
Hide file tree
Showing 16 changed files with 775 additions and 8 deletions.
68 changes: 66 additions & 2 deletions corelib/src/libs/SireSearch/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ namespace AST
struct IDWith;
struct IDWhere;
struct IDCount;
struct IDClosest;
struct IDNot;
struct IDSubscript;
struct IDWithin;
Expand Down Expand Up @@ -232,8 +233,8 @@ namespace AST
boost::recursive_wrapper<IDProtein>, boost::recursive_wrapper<IDPerturbable>, boost::recursive_wrapper<IDMass>,
boost::recursive_wrapper<IDCharge>, boost::recursive_wrapper<IDCmpMass>, boost::recursive_wrapper<IDCmpCharge>,
boost::recursive_wrapper<IDObjMass>, boost::recursive_wrapper<IDObjCharge>, boost::recursive_wrapper<IDObjCmpMass>,
boost::recursive_wrapper<IDObjCmpCharge>, boost::recursive_wrapper<IDSmarts>, boost::recursive_wrapper<ExpressionPart>,
boost::recursive_wrapper<Expression>>;
boost::recursive_wrapper<IDObjCmpCharge>, boost::recursive_wrapper<IDSmarts>, boost::recursive_wrapper<IDClosest>,
boost::recursive_wrapper<ExpressionPart>, boost::recursive_wrapper<Expression>>;

QString expression_to_string(const ExpressionVariant &expression);

Expand Down Expand Up @@ -303,6 +304,11 @@ namespace AST
double value;
SireUnits::Dimension::Length unit;

SireUnits::Dimension::Length toLength() const
{
return value * unit;
}

QString toString() const;
};

Expand Down Expand Up @@ -343,6 +349,13 @@ namespace AST
return *this;
}

SireMaths::Vector toVector() const
{
return SireMaths::Vector(x.toLength().to(SireUnits::angstrom),
y.toLength().to(SireUnits::angstrom),
z.toLength().to(SireUnits::angstrom));
}

QString toString() const;

private:
Expand Down Expand Up @@ -460,6 +473,11 @@ namespace AST

QString toString() const;

bool isNull() const
{
return this->toEngine() == SelectEnginePtr();
}

SelectEnginePtr toEngine() const;
};

Expand Down Expand Up @@ -871,6 +889,52 @@ namespace AST
SelectEnginePtr toEngine() const;
};

/** Struct that holds "closest N X to Y" and "further N X from Y"
* expressions
*/
struct IDClosest
{
Expression search_set;
bool is_closest;
int n;
Expression reference_set;
SireMaths::Vector point;

IDClosest &operator+=(const Expression &s)
{
search_set = s;
return *this;
}

IDClosest &operator+=(int number)
{
n = number;
return *this;
}

IDClosest &operator*=(const Expression &r)
{
reference_set = r;
return *this;
}

IDClosest &operator*=(const VectorValue &v)
{
point = v.toVector();
return *this;
}

IDClosest &operator-=(bool c)
{
is_closest = c;
return *this;
}

QString toString() const;

SelectEnginePtr toEngine() const;
};

/** Struct that holds a "where within"
expression, e.g. residues where center is within 5 A of resname /lig/i */
struct IDWhereWithin
Expand Down
44 changes: 43 additions & 1 deletion corelib/src/libs/SireSearch/grammar.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class Grammar : public qi::grammar<IteratorT, AST::Node(), SkipperT>
expressionPartRule = idNameRule | idNumberRule | idElementRule | propertyRule | bondRule | water_token |
pert_token | protein_token | notRule | joinRule | massRule | massCmpRule | chargeRule |
chargeCmpRule | massObjRule | massObjCmpRule | chargeObjRule | chargeObjCmpRule |
all_token | countRule | smartsRule | user_token;
all_token | countRule | closestRule | smartsRule | user_token;

// grammar that specifies a list of names (comma-separated)
nameValuesRule = (nameValueRule % qi::lit(','));
Expand Down Expand Up @@ -356,6 +356,46 @@ class Grammar : public qi::grammar<IteratorT, AST::Node(), SkipperT>
countRule = eps[_val = AST::IDCount()] >> (qi::lit("count(") >> expressionRule[_val += _1] >> qi::lit(")") >>
cmp_token[_val += _1] >> qi::int_[_val += _1]);

// grammar for a closest or furthest expression, e.g.
// closest 5 waters to ligand, furthest 10 ions from protein
closestRule = eps[_val = AST::IDClosest()] >>
(qi::lit("closest")[_val -= true] >>
qi::int_[_val += _1] >>
expressionRule[_val += _1] >>
qi::lit("to") >>
expressionRule[_val *= _1]) |
(qi::lit("closest")[_val -= true] >>
expressionRule[_val += _1] >>
qi::lit("to")[_val += 1] >>
expressionRule[_val *= _1]) |
(qi::lit("furthest")[_val -= false] >>
qi::int_[_val += _1] >>
expressionRule[_val += _1] >>
qi::lit("from") >>
expressionRule[_val *= _1]) |
(qi::lit("furthest")[_val -= false] >>
expressionRule[_val += _1] >>
qi::lit("from")[_val += 1] >>
expressionRule[_val *= _1]) |
(qi::lit("closest")[_val -= true] >>
qi::int_[_val += _1] >>
expressionRule[_val += _1] >>
qi::lit("to") >>
vectorValueRule[_val *= _1]) |
(qi::lit("closest")[_val -= true] >>
expressionRule[_val += _1] >>
qi::lit("to")[_val += 1] >>
vectorValueRule[_val *= _1]) |
(qi::lit("furthest")[_val -= false] >>
qi::int_[_val += _1] >>
expressionRule[_val += _1] >>
qi::lit("from") >>
vectorValueRule[_val *= _1]) |
(qi::lit("furthest")[_val -= false] >>
expressionRule[_val += _1] >>
qi::lit("from")[_val += 1] >>
vectorValueRule[_val *= _1]);

/////
///// name all of the rules to simplify error messages
/////
Expand All @@ -374,6 +414,7 @@ class Grammar : public qi::grammar<IteratorT, AST::Node(), SkipperT>
whereWithinRule.name("Where Within");
whereCompareRule.name("Where Compare");
countRule.name("Count Rule");
closestRule.name("Closest Rule");
lhsRule.name("LHS");
rhsRule.name("RHS");
expressionRule.name("Expression");
Expand Down Expand Up @@ -435,6 +476,7 @@ class Grammar : public qi::grammar<IteratorT, AST::Node(), SkipperT>
qi::rule<IteratorT, AST::IDWhereWithin(), SkipperT> whereWithinRule;
qi::rule<IteratorT, AST::IDWhereCompare(), SkipperT> whereCompareRule;
qi::rule<IteratorT, AST::IDCount(), SkipperT> countRule;
qi::rule<IteratorT, AST::IDClosest(), SkipperT> closestRule;

qi::rule<IteratorT, AST::Expression(), SkipperT> lhsRule;
qi::rule<IteratorT, AST::Expression(), SkipperT> rhsRule;
Expand Down
Loading

0 comments on commit b20865a

Please sign in to comment.