Skip to content
Snippets Groups Projects
Commit b79cf5e0 authored by Ansgar Philippsen's avatar Ansgar Philippsen
Browse files

fixed missing aindex selection property

parent c32098a0
Branches
Tags
No related merge requests found
......@@ -316,6 +316,10 @@ void AtomImpl::DeleteConnector(const ConnectorImplP& conn,
int AtomImpl::GetIntProperty(Prop::ID prop_id) const
{
switch (prop_id) {
case Prop::AINDEX:
return index_;
}
throw PropertyError(prop_id);
}
......
......@@ -650,12 +650,12 @@ Node* QueryImpl::ParsePropValueExpr(QueryLexer& lexer) {
LogicOP lop=inversion_stack_.back() ? LOP_OR : LOP_AND;
CompOP cop=inversion_stack_.back() ? COP_NEQ : COP_EQ;
ParamType cname_val(StringOrRegexParam(query_string_.substr(cname.GetValueRange().Loc,
cname.GetValueRange().Length).c_str()));
cname.GetValueRange().Length).c_str()));
Prop cname_prop(Prop::CNAME, Prop::STRING, Prop::CHAIN);
SelNode* cname_node=new SelNode(cname_prop, cop, cname_val);
ParamType aname_val(StringOrRegexParam(query_string_.substr(aname.GetValueRange().Loc,
aname.GetValueRange().Length).c_str()));
Prop aname_prop(Prop::ANAME, Prop::STRING, Prop::ATOM);
aname.GetValueRange().Length).c_str()));
Prop aname_prop(Prop::ANAME, Prop::STRING, Prop::ATOM);
SelNode* aname_node=new SelNode(aname_prop, cop, aname_val);
ParamType rnum_val(atoi(query_string_.substr(rnum.GetValueRange().Loc,
rnum.GetValueRange().Length).c_str()));
......
......@@ -39,6 +39,7 @@ struct Properties : public boost::spirit::symbols<Prop> {
("rtype", Prop(Prop::RTYPE, Prop::STRING, Prop::RESIDUE))
("ele", Prop(Prop::ELE, Prop::STRING, Prop::ATOM))
("anum", Prop(Prop::ANUM, Prop::INT, Prop::ATOM))
("aindex", Prop(Prop::AINDEX, Prop::INT, Prop::ATOM))
("x",Prop(Prop::AX, Prop::FLOAT, Prop::ATOM))
("y",Prop(Prop::AY, Prop::FLOAT, Prop::ATOM))
("z",Prop(Prop::AZ, Prop::FLOAT, Prop::ATOM))
......
......@@ -39,7 +39,7 @@ public:
/// the GenericProp 'propname' at the atom, residue and chain level
/// respectively.
typedef enum {
RNAME, ANAME, CNAME, ELE, RNUM, ANUM, AX, AY, AZ, OCC, RTYPE, ISHETATM,
RNAME, ANAME, CNAME, ELE, RNUM, ANUM, AX, AY, AZ, OCC, AINDEX, RTYPE, ISHETATM,
RBFAC, ABFAC, PEPTIDE, ACHARGE, RINDEX, PROTEIN, LIGAND, WATER, WITHIN,
UNDEF, CUSTOM
} ID;
......
......@@ -323,6 +323,10 @@ boost::logic::tribool QueryState::EvalAtom(const AtomImplPtr& a) {
s_[*i] = cmp_string(ss.comp_op,str_value,
boost::get<StringOrRegexParam>(ss.param));
break;
case Prop::AINDEX:
int_value=(a->GetIndex());
s_[*i]=cmp_num<int>(ss.comp_op, int_value,boost::get<int>(ss.param));
break;
case Prop::AX:
float_value=(a->GetPos())[0];
s_[*i]=cmp_num<Real>(ss.comp_op, float_value,
......
......@@ -116,6 +116,7 @@ BOOST_AUTO_TEST_CASE(test_query_parse_properties)
BOOST_CHECK(Query("x=3").IsValid());
BOOST_CHECK(Query("y=4").IsValid());
BOOST_CHECK(Query("z=6").IsValid());
BOOST_CHECK(Query("aindex=1").IsValid());
BOOST_CHECK(Query("gatest=7").IsValid());
BOOST_CHECK(Query("grtest=8").IsValid());
BOOST_CHECK(Query("gctest=9").IsValid());
......@@ -151,6 +152,10 @@ BOOST_AUTO_TEST_CASE(test_query_parse_value_type)
BOOST_CHECK(Query("rnum=WTF").IsValid()==false);
BOOST_CHECK(Query("rnum=3.0").IsValid()==false);
BOOST_CHECK(Query("ele>=XXX").IsValid()==false);
BOOST_CHECK(Query("aindex=1,2").IsValid());
BOOST_CHECK(Query("aindex=1:10,12:20").IsValid());
BOOST_CHECK(Query("aindex>7").IsValid());
}
BOOST_AUTO_TEST_CASE(test_query_parse_logical_op)
......@@ -198,6 +203,7 @@ BOOST_AUTO_TEST_CASE(test_query_eval)
ensure_counts(e, "cname=A", 1, 3, 27);
ensure_counts(e, "aname=CA", 1, 3, 3);
ensure_counts(e, "aname=SD", 1, 1, 1);
ensure_counts(e, "aindex=1,3,99", 1, 1, 2);
ensure_counts(e, "rnum=1:2", 1, 2, 19);
ensure_counts(e, "rnum=1,2", 1, 2, 19);
ensure_counts(e, "rnum>3", 0, 0, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment