diff --git a/modules/mol/base/src/impl/atom_impl.cc b/modules/mol/base/src/impl/atom_impl.cc index 60a6ac1f5a75e05e643b191a219471a2ba6a18cf..6d71e54d0de92685931225de16bcbb356e3b5ac2 100644 --- a/modules/mol/base/src/impl/atom_impl.cc +++ b/modules/mol/base/src/impl/atom_impl.cc @@ -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); } diff --git a/modules/mol/base/src/impl/query_impl.cc b/modules/mol/base/src/impl/query_impl.cc index 314c05ae93af5c21c2af908e538d699af5bc3004..cc5f80240bd1ddaff070ea42d518891c84419772 100644 --- a/modules/mol/base/src/impl/query_impl.cc +++ b/modules/mol/base/src/impl/query_impl.cc @@ -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())); diff --git a/modules/mol/base/src/property_id.cc b/modules/mol/base/src/property_id.cc index 8a7d5a49d7918b18e0b35b7d28eb195dd8e68661..2f80a94cf0b6f3c80dff7c6974461581d906b999 100644 --- a/modules/mol/base/src/property_id.cc +++ b/modules/mol/base/src/property_id.cc @@ -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)) diff --git a/modules/mol/base/src/property_id.hh b/modules/mol/base/src/property_id.hh index 6bb64b30fd0f31b1490770fb0ee559e3534ee24d..3632f996ac468a9891139a69a107d87aa2f8d711 100644 --- a/modules/mol/base/src/property_id.hh +++ b/modules/mol/base/src/property_id.hh @@ -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; diff --git a/modules/mol/base/src/query_state.cc b/modules/mol/base/src/query_state.cc index 38562c580105c8dbb1d3f53229ff5dfec567f87b..b90767a7e20de61fad90328283940bbc9e0da2f2 100644 --- a/modules/mol/base/src/query_state.cc +++ b/modules/mol/base/src/query_state.cc @@ -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, diff --git a/modules/mol/base/tests/test_query.cc b/modules/mol/base/tests/test_query.cc index bf94f913e618241e8f34be8677bdc3fdce93dff6..815e597f7bf0e68b7d94ba0396b901988daa1d02 100644 --- a/modules/mol/base/tests/test_query.cc +++ b/modules/mol/base/tests/test_query.cc @@ -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);