diff --git a/modules/base/tests/test_generic_property.cc b/modules/base/tests/test_generic_property.cc index 754d5ead4438d6c8a9c5780170e625bf65983c72..48fa0d63addd1ff12f5e446a1f0a2e8586a7fcbd 100644 --- a/modules/base/tests/test_generic_property.cc +++ b/modules/base/tests/test_generic_property.cc @@ -53,8 +53,8 @@ BOOST_AUTO_TEST_CASE( test_generic_property ) EntityView ev = eh.CreateFullView(); ChainView chv = ev.FindChain("A"); - ResidueView resv = ev.FindResidue(res); - AtomView atomv = ev.FindAtom(atom); + ResidueView resv = ev.ViewForHandle(res); + AtomView atomv = ev.ViewForHandle(atom); BOOST_CHECK(ev.GetStringProp("a")=="123"); BOOST_CHECK(chv.GetFloatProp("b")==1.5); diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc index 0154907216fc4940b726707307db806981cb7a2f..7920cd4eb8fdad036d4bed302dbbf9e845afadd0 100644 --- a/modules/gfx/src/entity.cc +++ b/modules/gfx/src/entity.cc @@ -443,7 +443,7 @@ bool Entity::OnSelect(const geom::Line3& line, geom::Vec3& result, return true; } if(smode==1) { - AtomView av = sel_.FindAtom(sel.GetHandle()); + AtomView av = sel_.ViewForHandle(sel.GetHandle()); if(av.IsValid()) { LOG_DEBUG("de-selected atom: " << sel); sel_.RemoveAtom(av); @@ -456,8 +456,8 @@ bool Entity::OnSelect(const geom::Line3& line, geom::Vec3& result, } result = sel.GetPos(); } else if(smode==2) { - AtomView av=sel_.FindAtom(sel); - ResidueView rv=sel_.FindResidue(sel.GetResidue()); + AtomView av=sel_.ViewForHandle(sel); + ResidueView rv=sel_.ViewForHandle(sel.GetResidue()); if(av.IsValid() && rv.IsValid()) { LOG_DEBUG("de-selected residue: " << sel.GetResidue()); sel_.RemoveResidue(rv); @@ -472,7 +472,7 @@ bool Entity::OnSelect(const geom::Line3& line, geom::Vec3& result, return false; } ChainHandle chain=sel.GetHandle().GetResidue().GetChain(); - ChainView cv = sel_.FindChain(chain); + ChainView cv = sel_.ViewForHandle(chain); if(cv.IsValid()) { LOG_DEBUG("de-selected chain: " << chain); sel_.RemoveChain(cv); diff --git a/modules/gfx/src/impl/backbone_trace.cc b/modules/gfx/src/impl/backbone_trace.cc index ad9e8c961b0cedea3073cdd8183fc636662b5397..9ff14e1f45280f6e9be0ccac54c1a7507586cee1 100644 --- a/modules/gfx/src/impl/backbone_trace.cc +++ b/modules/gfx/src/impl/backbone_trace.cc @@ -253,7 +253,7 @@ BackboneTrace BackboneTrace::CreateSubset(const mol::EntityView& subview) NodeEntryList new_nlist; const NodeEntryList& nlist=*nitnit; for(NodeEntryList::const_iterator nit=nlist.begin();nit!=nlist.end();++nit) { - if(subview.FindAtom(nit->atom).IsValid()) { + if(subview.ViewForHandle(nit->atom).IsValid()) { if(!new_nlist.empty()) { if(!in_sequence(new_nlist.back().atom.GetResidue(),nit->atom.GetResidue(),seq_hack_)) { if(new_nlist.size()>1) { diff --git a/modules/gfx/src/impl/connect_renderer_base.cc b/modules/gfx/src/impl/connect_renderer_base.cc index fd70d9968b67270d14c837de128fcbce9a003460..5f0ed4a6b8f821866eb587ac7110a0df28a307d4 100644 --- a/modules/gfx/src/impl/connect_renderer_base.cc +++ b/modules/gfx/src/impl/connect_renderer_base.cc @@ -145,7 +145,7 @@ inline void apply_color_op(ConnectRendererBase* rend, GfxView* v, T1 get_col, co view = op.GetView(); } for(AtomEntryMap::iterator it=v->atom_map.begin();it!=v->atom_map.end();++it){ - if(view.FindAtom(it->second.atom)){ + if(view.ViewForHandle(it->second.atom)){ it->second.color=get_col.ColorOfAtom(it->second.atom).second; } } diff --git a/modules/gfx/src/impl/line_trace_renderer.cc b/modules/gfx/src/impl/line_trace_renderer.cc index 8e650b9876e4ee1d065bde84962bd75a7377702f..bb6622ac84e6de1d5138c3810760975d2744dffb 100644 --- a/modules/gfx/src/impl/line_trace_renderer.cc +++ b/modules/gfx/src/impl/line_trace_renderer.cc @@ -92,7 +92,7 @@ void LineTraceRenderer::PrepareRendering(const BackboneTrace& trace_subset, if(nl.size()<1) continue; for(unsigned int i=0;i<nl.size();++i) { const NodeEntry& entry=nl[i]; - if(sel_.FindAtom(entry.atom).IsValid()) { + if(sel_.ViewForHandle(entry.atom).IsValid()) { geom::Vec3 apos = entry.atom.GetPos(); VertexID p0=va.Add(apos, geom::Vec3(),sel_clr); if(i>0) { diff --git a/modules/gfx/src/impl/trace_renderer.cc b/modules/gfx/src/impl/trace_renderer.cc index 49ee1c7ab258f9b51aa2432d019b78f809a3fd43..f901c77cdf7fa93424bcf6557e02557fd67377f3 100644 --- a/modules/gfx/src/impl/trace_renderer.cc +++ b/modules/gfx/src/impl/trace_renderer.cc @@ -64,7 +64,7 @@ void TraceRenderer::PrepareRendering(BackboneTrace& trace_subset, const NodeEntryList& nl=trace_subset.GetList(node_list); for(unsigned int i=0;i<nl.size();++i) { mol::AtomHandle ah=nl[i].atom; - if(sel_.FindAtom(ah).IsValid()) { + if(sel_.ViewForHandle(ah).IsValid()) { geom::Vec3 apos = ah.GetPos(); va.AddSphere(SpherePrim(apos, options_->GetTubeRadius()+0.05, diff --git a/modules/gfx/src/impl/trace_renderer_base.cc b/modules/gfx/src/impl/trace_renderer_base.cc index b77b426913f5aaab3628371554d842e0d31932c6..1b4c47fe5320f3a118d8ffff66a26412640b9201 100644 --- a/modules/gfx/src/impl/trace_renderer_base.cc +++ b/modules/gfx/src/impl/trace_renderer_base.cc @@ -63,7 +63,7 @@ inline void apply_color_op(TraceRendererBase* rend, BackboneTrace& trace_subset, for (int node_list=0; node_list<trace_subset.GetListCount(); ++node_list) { NodeEntryList& nl=trace_subset.GetList(node_list); for (unsigned int i=0; i<nl.size();++i) { - if(view.FindAtom(nl[i].atom)){ + if(view.ViewForHandle(nl[i].atom)){ std::pair<bool,Color> clr =get_col.ColorOfAtom(nl[i].atom); if(clr.first) { set_node_entry_color(nl[i],mask,clr.second); diff --git a/modules/gui/src/gl_canvas.cc b/modules/gui/src/gl_canvas.cc index 2d631931bafc912c9137587f28df24c1b9a0b9c0..f94bff0458c4fbfe746c489e424ebc467c9137d2 100644 --- a/modules/gui/src/gl_canvas.cc +++ b/modules/gui/src/gl_canvas.cc @@ -369,7 +369,7 @@ void GLCanvas::CopySelectionToClipboard() if (!rv.IsPeptideLinking() || rv.GetOneLetterCode()=='?') continue; seq1 << rv.GetOneLetterCode(); - if (sel.FindResidue(rv.GetHandle()).IsValid()) { + if (sel.ViewForHandle(rv.GetHandle()).IsValid()) { seq2 << rv.GetOneLetterCode(); } else { seq2 << '-'; diff --git a/modules/gui/src/sequence_viewer/sequence_view_object.cc b/modules/gui/src/sequence_viewer/sequence_view_object.cc index f9303f8ddce335f16dbf4fd4f48cef5eb3bfaa16..97993f0cdf11d45967377249f0793cf01e37ea50 100644 --- a/modules/gui/src/sequence_viewer/sequence_view_object.cc +++ b/modules/gui/src/sequence_viewer/sequence_view_object.cc @@ -168,7 +168,7 @@ QMap<int, QList<int> > SequenceViewObject::GetIndexesForView(const mol::EntityVi // for each residue in the selection deduce index in sequence for (mol::ResidueViewList::const_iterator j=src_chain.GetResidueList().begin(), e2=src_chain.GetResidueList().end(); j!=e2; ++j) { - mol::ResidueView dst_res=dst_chain.FindResidue(j->GetHandle()); + mol::ResidueView dst_res=dst_chain.ViewForHandle(j->GetHandle()); assert(dst_res.IsValid()); int p=dst_res.GetIndex()+1; assert(p>=0 && p<=seq.GetLength()); diff --git a/modules/mol/base/pymod/export_chain_view.cc b/modules/mol/base/pymod/export_chain_view.cc index e8c54c9a4a9436585531da168bdcbeab4130d3b2..70ee5d1d1a216c56ad6757ffa681094141d85b41 100644 --- a/modules/mol/base/pymod/export_chain_view.cc +++ b/modules/mol/base/pymod/export_chain_view.cc @@ -34,7 +34,8 @@ typedef ResidueView (ChainView::*RnumMethod)(const ResNum&) const; typedef ResidueView (ChainView::*HandleMethod)(const ResidueHandle&) const; RnumMethod rnum_find_residue=&ChainView::FindResidue; -HandleMethod handle_find_residue=&ChainView::FindResidue; +HandleMethod handle_find_residue=&ChainView::FindResidue; +HandleMethod view_for_rh=&ChainView::ViewForHandle; typedef ResidueView (ChainView::*HM)(const ResidueHandle&, ViewAddFlags); typedef ResidueView (ChainView::*VM)(const ResidueView&, ViewAddFlags); @@ -48,9 +49,11 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_add_atom_overloads, ChainView::AddAtom, 1, 2) AtomView (ChainView::*find_atom_a)(const ResNum&, const String&) const=&ChainView::FindAtom; -AtomView (ChainView::*find_atom_b)(const AtomHandle&) const=&ChainView::FindAtom; +AtomView (ChainView::*find_atom_b)(const AtomHandle&) const=&ChainView::FindAtom; +AtomView (ChainView::*view_for_ah)(const AtomHandle&) const=&ChainView::ViewForHandle; typedef EntityView (ChainView::*QueryMethod)(const Query&, uint) const; typedef EntityView (ChainView::*StringMethod)(const String&, uint) const; + QueryMethod select_query=&ChainView::Select; StringMethod select_string=&ChainView::Select; } @@ -71,8 +74,10 @@ void export_ChainView() .def("GetEntity", &ChainView::GetEntity) .def("FindResidue",rnum_find_residue, arg("residue_number")) .def("FindResidue", handle_find_residue, arg("residue_handle")) + .def("ViewForHandle", view_for_rh, arg("residue_handle")) .def("FindAtom", find_atom_a) - .def("FindAtom", find_atom_b) + .def("FindAtom", find_atom_b) + .def("ViewForHandle", view_for_ah) .def("AddAtom", &ChainView::AddAtom, X_add_atom_overloads(args("atom_handle", "view_add_flags"))) .def("AddResidue", hm, diff --git a/modules/mol/base/pymod/export_entity_view.cc b/modules/mol/base/pymod/export_entity_view.cc index e0b4c9b097097d4dbfd7dcf50ae7b6f8c8d9c184..9d724a57982f024103e2949ad56b7eda5e57eea4 100644 --- a/modules/mol/base/pymod/export_entity_view.cc +++ b/modules/mol/base/pymod/export_entity_view.cc @@ -54,6 +54,7 @@ VM vm=&EntityView::AddChain; HM hm=&EntityView::AddChain; HandleMethod find_chain_hnd=&EntityView::FindChain; +HandleMethod view_for_ch=&EntityView::ViewForHandle; StringMethod find_chain_str=&EntityView::FindChain; QSMethod select_string=&EntityView::Select; QueryMethod select_query=&EntityView::Select; @@ -91,8 +92,16 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_add_chain_overloads, BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_add_atom_overloads, EntityView::AddAtom, 1, 2) -AtomView (EntityView::*find_atom_a)(const String&, const ResNum&, const String&) const=&EntityView::FindAtom; +AtomView (EntityView::*find_atom_a)(const String&, const ResNum&, + const String&) const=&EntityView::FindAtom; AtomView (EntityView::*find_atom_b)(const AtomHandle&) const=&EntityView::FindAtom; +AtomView (EntityView::*view_for_ah)(const AtomHandle&) const=&EntityView::ViewForHandle; + +ResidueView (EntityView::*find_res_a)(const ResidueHandle&) const=&EntityView::FindResidue; +ResidueView (EntityView::*find_res_b)(const String&, + const ResNum&) const=&EntityView::FindResidue; + +ResidueView (EntityView::*view_for_rh)(const ResidueHandle&) const=&EntityView::ViewForHandle; } @@ -115,9 +124,15 @@ void export_EntityView() .def("ExtendViewToResidues", &EntityView::ExtendViewToResidues) .def("ExtendViewToSurrounding", &EntityView::ExtendViewToSurrounding) .def("FindChain", find_chain_str) - .def("FindResidue", &EntityView::FindResidue) + .def("FindChain", find_chain_hnd) + .def("ViewForHandle", view_for_rh) + .def("ViewForHandle", view_for_ch) .def("FindAtom", find_atom_a) - .def("FindAtom", find_atom_b) + .def("FindAtom", find_atom_b) + .def("FindResidue", find_res_a) + .def("FindResidue", find_res_b) + + .def("ViewForHandle", view_for_ah) .def("GetAtomCount", &EntityView::GetAtomCount) .def("GetGeometricStart", geom_start<EntityView>) .def("GetGeometricEnd", geom_end<EntityView>) diff --git a/modules/mol/base/pymod/export_residue_view.cc b/modules/mol/base/pymod/export_residue_view.cc index 89c6eddc428833b3dfe3d019b109b0e558c95ed7..79d167996ed18eb6d53d0ae57e66df3f8c2c695a 100644 --- a/modules/mol/base/pymod/export_residue_view.cc +++ b/modules/mol/base/pymod/export_residue_view.cc @@ -35,6 +35,7 @@ typedef AtomView (ResidueView::*HandleMethodNonConst)(const AtomHandle&, ViewAdd StringMethod string_find_atom=&ResidueView::FindAtom; HandleMethod handle_find_atom=&ResidueView::FindAtom; +HandleMethod view_for_ah=&ResidueView::ViewForHandle; HandleMethodNonConst add_atom_handle=&ResidueView::AddAtom; ViewMethod add_atom_view=&ResidueView::AddAtom; BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_add_atom_overloads, @@ -67,6 +68,7 @@ void export_ResidueView() .def("AddAtom", add_atom_handle, X_add_atom_overloads(args("atom_handle", "flags"))) .def("AddAtom", add_atom_view, X_add_atom_overloads(args("atom_view", "flags"))) .def("FindAtom", handle_find_atom, args("atom_handle")) + .def("ViewForHandle", view_for_ah, arg("atom_handle")) .def("IsAtomIncluded", &ResidueView::IsAtomIncluded, args("atom_handle")) .def("GetIndex", &ResidueView::GetIndex) .add_property("index", &ResidueView::GetIndex) diff --git a/modules/mol/base/src/atom_view.cc b/modules/mol/base/src/atom_view.cc index 2d81e4aec04be48a8310209fc05250139e71709e..ed16ac0f82f314a452cddbc8b35fd8fe5842b2ab 100644 --- a/modules/mol/base/src/atom_view.cc +++ b/modules/mol/base/src/atom_view.cc @@ -120,9 +120,9 @@ mol::AtomViewList AtomView::GetBondPartners() const mol::BondHandleList::const_iterator i; for (i=data_->bonds.begin();i!=data_->bonds.end();++i) { if (i->GetFirst().GetHandle()!=this->GetHandle()) { - avl.push_back(this->GetEntity().FindAtom(i->GetFirst())); + avl.push_back(this->GetEntity().ViewForHandle(i->GetFirst())); } else { - avl.push_back(this->GetEntity().FindAtom(i->GetSecond())); + avl.push_back(this->GetEntity().ViewForHandle(i->GetSecond())); } } return avl; @@ -138,9 +138,9 @@ void AtomView::RemoveBonds() BondHandle b=*i; AtomView av; if (b.GetFirst()==this->GetHandle()) { - av=ent.FindAtom(b.GetSecond()); + av=ent.ViewForHandle(b.GetSecond()); } else { - av=ent.FindAtom(b.GetFirst()); + av=ent.ViewForHandle(b.GetFirst()); } ent.RemoveBond(b); } diff --git a/modules/mol/base/src/chain_view.cc b/modules/mol/base/src/chain_view.cc index 4727e31ddce6764bcdfc0e78bb5e7c3c31e0d83f..355bd6cf5963f68a3a42fdf587c7ec60f2ed9c80 100644 --- a/modules/mol/base/src/chain_view.cc +++ b/modules/mol/base/src/chain_view.cc @@ -18,8 +18,8 @@ //------------------------------------------------------------------------------ #include <algorithm> #include <limits> - #include <boost/bind.hpp> +#include <ost/log.hh> #include <ost/mol/bond_handle.hh> #include <ost/mol/residue_handle.hh> #include <ost/mol/chain_view.hh> @@ -176,7 +176,13 @@ ResidueView ChainView::FindResidue(const ResNum& number) const { } } -ResidueView ChainView::FindResidue(const ResidueHandle& handle) const { +ResidueView ChainView::FindResidue(const ResidueHandle& residue) const { + LOG_WARNING("ChainView::FindResidue(handle) is deprecated. " + "Use ChainView::ViewForHandle instead."); + return this->ViewForHandle(residue); +} + +ResidueView ChainView::ViewForHandle(const ResidueHandle& handle) const { this->CheckValidity(); const ResidueViewList& l=data_->residues; ResidueViewList::const_iterator i; @@ -187,7 +193,7 @@ ResidueView ChainView::FindResidue(const ResidueHandle& handle) const { bool ChainView::IsResidueIncluded(const ResidueHandle& handle) const { this->CheckValidity(); - return this->FindResidue(handle).IsValid(); + return this->ViewForHandle(handle).IsValid(); } ResidueView ChainView::AddResidue(const ResidueHandle& residue_handle, @@ -195,7 +201,7 @@ ResidueView ChainView::AddResidue(const ResidueHandle& residue_handle, this->CheckValidity(); ResidueView rv; if ((flags & ViewAddFlag::CHECK_DUPLICATES) && - (rv=this->FindResidue(residue_handle))) + (rv=this->ViewForHandle(residue_handle))) return rv; rv=ResidueView(*this, residue_handle); if (!data_->residues.empty()) { @@ -213,12 +219,18 @@ ResidueView ChainView::AddResidue(const ResidueHandle& residue_handle, } AtomView ChainView::FindAtom(const AtomHandle& atom) const { + LOG_WARNING("ChainView::FindAtom(handle) is deprecated. " + "Use ChainView::ViewForHandle instead."); + return this->ViewForHandle(atom); +} + +AtomView ChainView::ViewForHandle(const AtomHandle& atom) const { ResidueHandle residue=atom.GetResidue(); if (atom.GetEntity()!=this->GetEntity().GetHandle()) return AtomView(); ResidueView v=this->FindResidue(residue.GetNumber()); - return v.IsValid() ? v.FindAtom(atom) : AtomView(); + return v.IsValid() ? v.ViewForHandle(atom) : AtomView(); } AtomView ChainView::AddAtom(const AtomHandle& atom_handle, @@ -262,7 +274,7 @@ ResidueView ChainView::AddResidue(const ResidueView& residue_view, this->CheckValidity(); ResidueView rv; if ((flags & ViewAddFlag::CHECK_DUPLICATES) && - (rv=this->FindResidue(residue_view.GetHandle()))) { + (rv=this->ViewForHandle(residue_view.GetHandle()))) { if (!(flags & ViewAddFlag::INCLUDE_ATOMS)) { return rv; } diff --git a/modules/mol/base/src/chain_view.hh b/modules/mol/base/src/chain_view.hh index 72ed7a72e47877f485931994c2d4f501bc95a925..70bd305aa1c17884f062a2b0721c97cb1cea7340 100644 --- a/modules/mol/base/src/chain_view.hh +++ b/modules/mol/base/src/chain_view.hh @@ -125,12 +125,15 @@ public: ResidueView FindResidue(const ResNum& number) const; /// \brief Find view for given atom handle - AtomView FindAtom(const AtomHandle& atom) const; + /// Deprecated: Use ViewForHandle instead + AtomView FindAtom(const AtomHandle& atom) const; + AtomView ViewForHandle(const AtomHandle& atom) const; AtomView FindAtom(const ResNum& num, const String& name) const; /// \brief Find residue by residue handle - ResidueView FindResidue(const ResidueHandle& handle) const; + ResidueView ViewForHandle(const ResidueHandle& handle) const; + ResidueView FindResidue(const ResidueHandle& handle) const; /// \brief Check whether the view includes the given residue. bool IsResidueIncluded(const ResidueHandle& handle) const; diff --git a/modules/mol/base/src/entity_view.cc b/modules/mol/base/src/entity_view.cc index a88f0b39553a438c0d51359fee91cacf9d85a7a1..d81940ee1bfc89228a9db78163ac410b95a96738 100644 --- a/modules/mol/base/src/entity_view.cc +++ b/modules/mol/base/src/entity_view.cc @@ -1,4 +1,5 @@ //------------------------------------------------------------------------------ +// // This file is part of the OpenStructure project <www.openstructure.org> // // Copyright (C) 2008-2011 by the OpenStructure authors @@ -207,7 +208,7 @@ ChainView EntityView::AddChain(const ChainHandle& chain_handle, this->CheckValidity(); ChainView cv; if (flags & ViewAddFlag::CHECK_DUPLICATES && - (cv=this->FindChain(chain_handle))) + (cv=this->ViewForHandle(chain_handle))) return cv; cv=ChainView(*this, chain_handle); data_->chains.push_back(cv); @@ -256,14 +257,14 @@ ChainView EntityView::FindChain(const String& chain_name) const{ } -ResidueView EntityView::FindResidue(const ResidueHandle& residue) const { +ResidueView EntityView::ViewForHandle(const ResidueHandle& residue) const { ChainHandle chain=residue.GetChain(); - ChainView v=this->FindChain(chain); - return v.IsValid() ? v.FindResidue(residue) : ResidueView(); + ChainView v=this->ViewForHandle(chain); + return v.IsValid() ? v.ViewForHandle(residue) : ResidueView(); } -AtomView EntityView::FindAtom(const AtomHandle& atom) const +AtomView EntityView::ViewForHandle(const AtomHandle& atom) const { this->CheckValidity(); return data_->ViewForHandle(atom); @@ -409,7 +410,7 @@ EntityView EntityView::Select(const Query& query, QueryFlags flags) const return view; } -ChainView EntityView::FindChain(const ChainHandle& chain) const { +ChainView EntityView::ViewForHandle(const ChainHandle& chain) const { this->CheckValidity(); ChainViewList::const_iterator i; i=std::find_if(data_->chains.begin(), data_->chains.end(), @@ -421,7 +422,7 @@ ChainView EntityView::FindChain(const ChainHandle& chain) const { bool EntityView::IsChainIncluded(const ChainHandle& chain) const { this->CheckValidity(); - return this->FindChain(chain).IsValid(); + return this->ViewForHandle(chain).IsValid(); } @@ -584,7 +585,7 @@ ChainView EntityView::AddChain(const ChainView& chain_view, this->CheckValidity(); ChainView cv; if (flags & ViewAddFlag::CHECK_DUPLICATES && - (cv=this->FindChain(chain_view.GetHandle()))) { + (cv=this->ViewForHandle(chain_view.GetHandle()))) { if (!(flags & ViewAddFlag::INCLUDE_RESIDUES)) { return cv; } @@ -627,7 +628,7 @@ AtomViewList EntityView::FindWithin(const geom::Vec3& center, Real radius) const AtomHandleList ahl=this->GetHandle().FindWithin(center, radius); AtomViewList avl; for (AtomHandleList::iterator i=ahl.begin(), e=ahl.end(); i!=e; ++i) { - if (AtomView v=this->FindAtom(*i)) { + if (AtomView v=this->ViewForHandle(*i)) { avl.push_back(v); } } @@ -721,7 +722,7 @@ AtomView EntityView::AddXAtom(const AtomHandle& ah, ViewAddFlags flags) } AtomView EntityView::FindXAtom(const AtomHandle& ah) { - return this->FindAtom(ah); + return this->ViewForHandle(ah); } #endif @@ -737,6 +738,18 @@ AtomView EntityView::FindAtom(const String& chain_name, } return AtomView(); } + +ResidueView EntityView::FindResidue(const String& chain, + const ResNum& num) const +{ + this->CheckValidity(); + ChainView ch=this->FindChain(chain); + if (ch.IsValid()) { + return ch.FindResidue(num); + } + return ResidueView(); +} + geom::AlignedCuboid EntityView::GetBounds() const { this->CheckValidity(); @@ -878,5 +891,26 @@ String EntityView::Dump() const return stream.str(); } +ChainView EntityView::FindChain(const ChainHandle& chain) const +{ + LOG_WARNING("EntityView::FindChain is deprecated. " + "Use EntityView::ViewForHandle instead"); + return this->ViewForHandle(chain); +} + +ResidueView EntityView::FindResidue(const ResidueHandle& residue) const +{ + LOG_WARNING("EntityView::FindResidue is deprecated. " + "Use EntityView::ViewForHandle instead"); + return this->ViewForHandle(residue); +} + +AtomView EntityView::FindAtom(const AtomHandle& atom) const +{ + LOG_WARNING("EntityView::FindAtom(handle) is deprecated. " + "Use EntityView::ViewForHandle instead"); + return this->ViewForHandle(atom); +} + }} // ns diff --git a/modules/mol/base/src/entity_view.hh b/modules/mol/base/src/entity_view.hh index 6e5b2371695064033bfa4637d7a5e533e6c9957b..56136733b06abfca2abc5bf12c3f299f6de9e002 100644 --- a/modules/mol/base/src/entity_view.hh +++ b/modules/mol/base/src/entity_view.hh @@ -221,16 +221,39 @@ public: ChainView FindChain(const String& chain_name) const; /// \brief Find atom for given residue handle + /// + /// deprecated. Use ViewForHandle instead ResidueView FindResidue(const ResidueHandle& residue) const; + ResidueView FindResidue(const String& chain, const ResNum& num) const; + + /// \brief locate residue view for given residue handle + /// + /// returns an invalid ResidueView if the residue could not be + /// located in the structure + ResidueView ViewForHandle(const ResidueHandle& residue) const; /// \brief Find view for given atom handle + /// + /// deprecated. Use ViewForHandle instead AtomView FindAtom(const AtomHandle& atom) const; + AtomView ViewForHandle(const AtomHandle& atom) const; + /// \brief locate atom view for given atom handle + /// + /// returns an invalid AtomView if the residue could not be + /// located in the structure AtomView FindAtom(const String& chain_name, const ResNum& num, const String& atom_name) const; /// \brief Find chain for given chain handle - ChainView FindChain(const ChainHandle& chain) const; + /// + /// deprecated: Use ViewForHandle instead + ChainView FindChain(const ChainHandle& chain) const; + /// \brief locate chain view for given chain handle + /// + /// returns an invalid AtomView if the residue could not be + /// located in the structure + ChainView ViewForHandle(const ChainHandle& chain) const; /// \brief Check whether the view includes the given chain /// \return True, if the chain is included in the view, false if not. bool IsChainIncluded(const ChainHandle& chain) const; diff --git a/modules/mol/base/src/residue_view.cc b/modules/mol/base/src/residue_view.cc index 4bd75ba32e1701750d89a28a04ab9169c5ce9dc2..406854a1f0f077c61080c320320e82577765e625 100644 --- a/modules/mol/base/src/residue_view.cc +++ b/modules/mol/base/src/residue_view.cc @@ -20,7 +20,7 @@ #include <limits> #include <boost/bind.hpp> - +#include <ost/log.hh> #include <ost/mol/bond_handle.hh> #include <ost/mol/chain_view.hh> #include <ost/mol/atom_view.hh> @@ -96,7 +96,7 @@ AtomView ResidueView::AddAtom(const AtomHandle& atom_handle, this->CheckValidity(); AtomView v; if ((flags & ViewAddFlag::CHECK_DUPLICATES) && - (v=this->FindAtom(atom_handle))) { + (v=this->ViewForHandle(atom_handle))) { return v; } v=AtomView(*this, atom_handle); @@ -118,7 +118,7 @@ AtomView ResidueView::FindAtom(const String& atom_name) const { return i==data_->atoms.end() ? AtomView() : *i; } -AtomView ResidueView::FindAtom(const AtomHandle& handle) const { +AtomView ResidueView::ViewForHandle(const AtomHandle& handle) const { this->CheckValidity(); const AtomViewList& l=data_->atoms; AtomViewList::const_iterator i; @@ -128,7 +128,7 @@ AtomView ResidueView::FindAtom(const AtomHandle& handle) const { bool ResidueView::IsAtomIncluded(const AtomHandle& handle) const { // validity is checked by FindAtom - return this->FindAtom(handle).IsValid(); + return this->ViewForHandle(handle).IsValid(); } @@ -274,4 +274,11 @@ EntityView ResidueView::Select(const String& q, QueryFlags flags) const { return this->GetEntity().Select(Query(s.str()), flags); } +AtomView ResidueView::FindAtom(const AtomHandle& handle) const +{ + LOG_WARNING("ResidueView::FindAtom(handle) is deprecated. " + "Use ResidueView::ViewForHandle instead."); + return this->ViewForHandle(handle); +} + }} //ns diff --git a/modules/mol/base/src/residue_view.hh b/modules/mol/base/src/residue_view.hh index 8efe0c97f8739a5e8c64a1d1f84f3db357e94835..1727e87719c93b1d437352d861e8674c6cd72963 100644 --- a/modules/mol/base/src/residue_view.hh +++ b/modules/mol/base/src/residue_view.hh @@ -118,6 +118,7 @@ public: AtomView FindAtom(const String& atom_name) const; /// \brief Find residue by residue handle + AtomView ViewForHandle(const AtomHandle& handle) const; AtomView FindAtom(const AtomHandle& handle) const; /// \brief Check whether the view includes the the given atom. diff --git a/modules/mol/base/src/view_op.cc b/modules/mol/base/src/view_op.cc index 973fa768662d38a4992874bf40917a768810d19a..6e4227e741d0faa02d5b1a902b1d63be0050aee2 100644 --- a/modules/mol/base/src/view_op.cc +++ b/modules/mol/base/src/view_op.cc @@ -64,14 +64,14 @@ mol::EntityView Union(const mol::EntityView& ev1, const mol::EntityView& ev2) mol::ChainViewList::const_iterator c_it=ev2.GetChainList().begin(); for ( ; c_it!=ev2.GetChainList().end(); ++c_it) { mol::ChainView cv=*c_it; - mol::ChainView cv2=merge.FindChain(cv.GetHandle()); + mol::ChainView cv2=merge.ViewForHandle(cv.GetHandle()); if (!cv2) { cv2=merge.AddChain(cv, mol::ViewAddFlag::INCLUDE_ALL); } else { mol::ResidueViewList::const_iterator r_it=cv.GetResidueList().begin(); for (; r_it!=cv.GetResidueList().end(); ++r_it) { mol::ResidueView rv=*r_it; - mol::ResidueView rv2=cv2.FindResidue(rv.GetHandle()); + mol::ResidueView rv2=cv2.ViewForHandle(rv.GetHandle()); if (!rv2) { rv2=cv2.AddResidue(rv, mol::ViewAddFlag::INCLUDE_ALL); } else { @@ -115,7 +115,7 @@ mol::EntityView Difference(const mol::EntityView& ev1, mol::ChainViewList::const_iterator c_it=ev1.GetChainList().begin(); for ( ; c_it!=ev1.GetChainList().end(); ++c_it) { mol::ChainView cv=*c_it; - mol::ChainView cv2=ev2.FindChain(cv.GetHandle()); + mol::ChainView cv2=ev2.ViewForHandle(cv.GetHandle()); if (!cv2) { diff.AddChain(cv,mol::ViewAddFlag::INCLUDE_ALL); } else { @@ -123,7 +123,7 @@ mol::EntityView Difference(const mol::EntityView& ev1, mol::ResidueViewList::const_iterator r_it=cv.GetResidueList().begin(); for (; r_it!=cv.GetResidueList().end(); ++r_it) { mol::ResidueView rv=*r_it; - mol::ResidueView rv2=cv2.FindResidue(rv.GetHandle()); + mol::ResidueView rv2=cv2.ViewForHandle(rv.GetHandle()); if (!rv2) { if(!chain_added){ diff.AddChain(cv); @@ -134,7 +134,7 @@ mol::EntityView Difference(const mol::EntityView& ev1, bool residue_added = false; mol::AtomViewList::const_iterator a_it=rv.GetAtomList().begin(); for (; a_it!=rv.GetAtomList().end(); ++a_it) { - if (!rv2.FindAtom((*a_it).GetHandle())) { + if (!rv2.ViewForHandle((*a_it).GetHandle())) { if(!residue_added){ diff.AddResidue(rv); residue_added = true; @@ -182,7 +182,7 @@ mol::EntityView Intersection(const mol::EntityView& ev1, BondHandleList bonds_to_add; for (AtomViewIter a=ev1.AtomsBegin(),e=ev1.AtomsEnd(); a!=e; ++a) { AtomView av=*a; - AtomView av2=ev2.FindAtom(av.GetHandle()); + AtomView av2=ev2.ViewForHandle(av.GetHandle()); if (av2.IsValid()) { intersection.AddAtom(av.GetHandle()); bl=av.GetBondList(); diff --git a/modules/mol/base/tests/test_view_op.cc b/modules/mol/base/tests/test_view_op.cc index 7d084e6fbb2816a8e49b73727160e79b4c6e845a..61fff1ff0955baac7eaa11e775d42e19f35179c5 100644 --- a/modules/mol/base/tests/test_view_op.cc +++ b/modules/mol/base/tests/test_view_op.cc @@ -81,20 +81,20 @@ BOOST_AUTO_TEST_CASE(test_difference) BOOST_CHECK(diff_view.FindChain("B")); // check residues - BOOST_CHECK(!diff_view.FindResidue(ent.FindResidue("A", mol::ResNum(1)))); - BOOST_CHECK(diff_view.FindResidue(ent.FindResidue("A", mol::ResNum(2)))); - BOOST_CHECK(diff_view.FindResidue(ent.FindResidue("B", mol::ResNum(1)))); - BOOST_CHECK(diff_view.FindResidue(ent.FindResidue("B", mol::ResNum(2)))); + BOOST_CHECK(!diff_view.ViewForHandle(ent.FindResidue("A", mol::ResNum(1)))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindResidue("A", mol::ResNum(2)))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindResidue("B", mol::ResNum(1)))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindResidue("B", mol::ResNum(2)))); // check atoms - BOOST_CHECK(!diff_view.FindAtom(ent.FindAtom("A", mol::ResNum(1), "A"))); - BOOST_CHECK(!diff_view.FindAtom(ent.FindAtom("A", mol::ResNum(1), "B"))); - BOOST_CHECK(!diff_view.FindAtom(ent.FindAtom("A", mol::ResNum(2), "C"))); - BOOST_CHECK(diff_view.FindAtom(ent.FindAtom("A", mol::ResNum(2), "D"))); - BOOST_CHECK(diff_view.FindAtom(ent.FindAtom("B", mol::ResNum(1), "E"))); - BOOST_CHECK(diff_view.FindAtom(ent.FindAtom("B", mol::ResNum(1), "F"))); - BOOST_CHECK(diff_view.FindAtom(ent.FindAtom("B", mol::ResNum(2), "G"))); - BOOST_CHECK(diff_view.FindAtom(ent.FindAtom("B", mol::ResNum(2), "H"))); + BOOST_CHECK(!diff_view.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "A"))); + BOOST_CHECK(!diff_view.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "B"))); + BOOST_CHECK(!diff_view.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "C"))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "D"))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "E"))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "F"))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "G"))); + BOOST_CHECK(diff_view.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "H"))); // check bonds BondHandleList bonds=diff_view.GetBondList(); @@ -132,21 +132,21 @@ BOOST_AUTO_TEST_CASE(test_union_a) BOOST_CHECK(un.FindChain("B")); // test residues - BOOST_CHECK(un.FindResidue(ent.FindResidue("A", mol::ResNum(1)))); - BOOST_CHECK(un.FindResidue(ent.FindResidue("A", mol::ResNum(2)))); - BOOST_CHECK(un.FindResidue(ent.FindResidue("B", mol::ResNum(1)))); - BOOST_CHECK(un.FindResidue(ent.FindResidue("B", mol::ResNum(2)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("A", mol::ResNum(1)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("A", mol::ResNum(2)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("B", mol::ResNum(1)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("B", mol::ResNum(2)))); // test atoms - BOOST_CHECK(!un.FindAtom(ent.FindAtom("A", mol::ResNum(1), "A"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("A", mol::ResNum(1), "B"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("A", mol::ResNum(2), "C"))); - BOOST_CHECK(!un.FindAtom(ent.FindAtom("A", mol::ResNum(2), "D"))); + BOOST_CHECK(!un.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "A"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "B"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "C"))); + BOOST_CHECK(!un.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "D"))); - BOOST_CHECK(!un.FindAtom(ent.FindAtom("B", mol::ResNum(1), "E"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("B", mol::ResNum(1), "F"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("B", mol::ResNum(2), "G"))); - BOOST_CHECK(!un.FindAtom(ent.FindAtom("B", mol::ResNum(2), "H"))); + BOOST_CHECK(!un.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "E"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "F"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "G"))); + BOOST_CHECK(!un.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "H"))); // bonds BondHandleList bonds=un.GetBondList(); @@ -186,21 +186,21 @@ BOOST_AUTO_TEST_CASE(test_union_b) BOOST_CHECK(un.FindChain("B")); // test residues - BOOST_CHECK(un.FindResidue(ent.FindResidue("A", mol::ResNum(1)))); - BOOST_CHECK(un.FindResidue(ent.FindResidue("A", mol::ResNum(2)))); - BOOST_CHECK(un.FindResidue(ent.FindResidue("B", mol::ResNum(1)))); - BOOST_CHECK(un.FindResidue(ent.FindResidue("B", mol::ResNum(2)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("A", mol::ResNum(1)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("A", mol::ResNum(2)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("B", mol::ResNum(1)))); + BOOST_CHECK(un.ViewForHandle(ent.FindResidue("B", mol::ResNum(2)))); // test atoms - BOOST_CHECK(un.FindAtom(ent.FindAtom("A", mol::ResNum(1), "A"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("A", mol::ResNum(1), "B"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("A", mol::ResNum(2), "C"))); - BOOST_CHECK(!un.FindAtom(ent.FindAtom("A", mol::ResNum(2), "D"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "A"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "B"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "C"))); + BOOST_CHECK(!un.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "D"))); - BOOST_CHECK(!un.FindAtom(ent.FindAtom("B", mol::ResNum(1), "E"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("B", mol::ResNum(1), "F"))); - BOOST_CHECK(un.FindAtom(ent.FindAtom("B", mol::ResNum(2), "G"))); - BOOST_CHECK(!un.FindAtom(ent.FindAtom("B", mol::ResNum(2), "H"))); + BOOST_CHECK(!un.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "E"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "F"))); + BOOST_CHECK(un.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "G"))); + BOOST_CHECK(!un.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "H"))); // bonds BondHandleList bonds=un.GetBondList(); @@ -240,22 +240,22 @@ BOOST_AUTO_TEST_CASE(test_intersection_a) BOOST_CHECK(is.FindChain("B")); // test residues - BOOST_CHECK(!is.FindResidue(ent.FindResidue("A", mol::ResNum(1)))); - BOOST_CHECK(is.FindResidue(ent.FindResidue("A", mol::ResNum(2)))); - BOOST_CHECK(is.FindResidue(ent.FindResidue("B", mol::ResNum(1)))); - BOOST_CHECK(is.FindResidue(ent.FindResidue("B", mol::ResNum(2)))); + BOOST_CHECK(!is.ViewForHandle(ent.FindResidue("A", mol::ResNum(1)))); + BOOST_CHECK(is.ViewForHandle(ent.FindResidue("A", mol::ResNum(2)))); + BOOST_CHECK(is.ViewForHandle(ent.FindResidue("B", mol::ResNum(1)))); + BOOST_CHECK(is.ViewForHandle(ent.FindResidue("B", mol::ResNum(2)))); // test atoms - BOOST_CHECK(!is.FindAtom(ent.FindAtom("A", mol::ResNum(1), "A"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("A", mol::ResNum(1), "B"))); - BOOST_CHECK(is.FindAtom(ent.FindAtom("A", mol::ResNum(2), "C"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("A", mol::ResNum(2), "D"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "A"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "B"))); + BOOST_CHECK(is.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "C"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "D"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("B", mol::ResNum(1), "E"))); - BOOST_CHECK(is.FindAtom(ent.FindAtom("B", mol::ResNum(1), "F"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "E"))); + BOOST_CHECK(is.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "F"))); - BOOST_CHECK(is.FindAtom(ent.FindAtom("B", mol::ResNum(2), "G"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("B", mol::ResNum(2), "H"))); + BOOST_CHECK(is.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "G"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "H"))); // bonds BondHandleList bonds=is.GetBondList(); @@ -295,22 +295,22 @@ BOOST_AUTO_TEST_CASE(test_intersection_b) BOOST_CHECK(is.FindChain("B")); // test residues - BOOST_CHECK(!is.FindResidue(ent.FindResidue("A", mol::ResNum(1)))); - BOOST_CHECK(!is.FindResidue(ent.FindResidue("A", mol::ResNum(2)))); - BOOST_CHECK(is.FindResidue(ent.FindResidue("B", mol::ResNum(1)))); - BOOST_CHECK(is.FindResidue(ent.FindResidue("B", mol::ResNum(2)))); + BOOST_CHECK(!is.ViewForHandle(ent.FindResidue("A", mol::ResNum(1)))); + BOOST_CHECK(!is.ViewForHandle(ent.FindResidue("A", mol::ResNum(2)))); + BOOST_CHECK(is.ViewForHandle(ent.FindResidue("B", mol::ResNum(1)))); + BOOST_CHECK(is.ViewForHandle(ent.FindResidue("B", mol::ResNum(2)))); // test atoms - BOOST_CHECK(!is.FindAtom(ent.FindAtom("A", mol::ResNum(1), "A"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("A", mol::ResNum(1), "B"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("A", mol::ResNum(2), "C"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("A", mol::ResNum(2), "D"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "A"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("A", mol::ResNum(1), "B"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "C"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("A", mol::ResNum(2), "D"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("B", mol::ResNum(1), "E"))); - BOOST_CHECK(is.FindAtom(ent.FindAtom("B", mol::ResNum(1), "F"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "E"))); + BOOST_CHECK(is.ViewForHandle(ent.FindAtom("B", mol::ResNum(1), "F"))); - BOOST_CHECK(is.FindAtom(ent.FindAtom("B", mol::ResNum(2), "G"))); - BOOST_CHECK(!is.FindAtom(ent.FindAtom("B", mol::ResNum(2), "H"))); + BOOST_CHECK(is.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "G"))); + BOOST_CHECK(!is.ViewForHandle(ent.FindAtom("B", mol::ResNum(2), "H"))); // bonds BondHandleList bonds=is.GetBondList();