From 4a8f2b26a2542f36488ed47803e64387d45beb07 Mon Sep 17 00:00:00 2001 From: Marco Biasini <marco.biasini@unibas.ch> Date: Tue, 8 Mar 2011 11:32:55 +0100 Subject: [PATCH] fix for BZDNG-219 (bracketed-within query ignores not) --- modules/mol/base/src/impl/query_impl.cc | 6 ++++-- modules/mol/base/src/query_state.cc | 2 +- modules/mol/base/tests/test_query.cc | 9 ++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/mol/base/src/impl/query_impl.cc b/modules/mol/base/src/impl/query_impl.cc index d2297c5cd..314c05ae9 100644 --- a/modules/mol/base/src/impl/query_impl.cc +++ b/modules/mol/base/src/impl/query_impl.cc @@ -1042,7 +1042,7 @@ Node* QueryImpl::ParseWithinExpr(QueryLexer& lexer) { geom::Vec3 point; if (this->ParsePoint(lexer, point)) { ParamType pt(WithinParam(point, rv*rv)); - CompOP comp_op= COP_LE; + CompOP comp_op=COP_LE; if (inversion_stack_.back()) comp_op=COP_GE; SelNode* within_node=new SelNode(Prop(Prop::WITHIN, Prop::VEC_DIST, @@ -1082,8 +1082,10 @@ Node* QueryImpl::ParseWithinExpr(QueryLexer& lexer) { ParamType pt(WithinParam(bracketed_expr_.size()-1, rv*rv)); inversion_stack_.pop_back(); CompOP comp_op= COP_LE; - if (inversion_stack_.back()) + if (inversion_stack_.back()) { comp_op=COP_GE; + } + SelNode* within_node=new SelNode(Prop(Prop::WITHIN, Prop::VEC_DIST, Prop::ATOM), comp_op, pt); diff --git a/modules/mol/base/src/query_state.cc b/modules/mol/base/src/query_state.cc index 1e5c8d3a2..38562c580 100644 --- a/modules/mol/base/src/query_state.cc +++ b/modules/mol/base/src/query_state.cc @@ -73,7 +73,7 @@ bool QueryState::do_within(const geom::Vec3& pos, const WithinParam& p, if (geom::Dot(d, d) <= p.GetRadiusSquare()) { return true; } - } else if (geom::Dot(d, d) > p.GetRadiusSquare()) { + } else if (geom::Dot(d, d) < p.GetRadiusSquare()) { return false; } } diff --git a/modules/mol/base/tests/test_query.cc b/modules/mol/base/tests/test_query.cc index f868c468a..bf94f913e 100644 --- a/modules/mol/base/tests/test_query.cc +++ b/modules/mol/base/tests/test_query.cc @@ -76,13 +76,13 @@ void ensure_counts(EntityHandle e, const String& qs, int cc, int rc, int ac) { BOOST_CHECK_NO_THROW(v=e.Select(qs)); BOOST_CHECK_MESSAGE(v.GetChainCount()==cc, "wrong chain count " << v.GetChainCount() - << " for query String " << qs); + << " for query string " << qs); BOOST_CHECK_MESSAGE(v.GetResidueCount()==rc, "wrong residue count " << v.GetResidueCount() << - " for query String " << qs); + " for query string " << qs); BOOST_CHECK_MESSAGE(v.GetAtomCount()==ac, "wrong atom count " << v.GetAtomCount() << - " for query String " << qs); + " for query string " << qs); } @@ -211,6 +211,9 @@ BOOST_AUTO_TEST_CASE(test_query_eval) ensure_counts(e, "rtype=C", 1, 3, 27); ensure_counts(e, "not (aname=CA and not aname=CA)", 1, 3, 27); ensure_counts(e, "3 <> {21.5,35,57.0}", 1, 2, 5); + ensure_counts(e, "not 3 <> {21.5,35,57.0}", 1, 3, 22); + ensure_counts(e, "3 <> {21.5,35,57} and not 0.5 <> {21.5,35,57} ", 1, 2, 4); + ensure_counts(e, "not 0.5 <> [rnum=3]", 1, 2, 19); ensure_counts(e, "1 <> {0,0,0}", 0, 0, 0); ensure_counts(e, "gatestpropa:0=1", 1, 1, 1); ensure_counts(e, "gatestpropa:1.0=1", 1, 3, 27); -- GitLab