From 2f5dc713e8952c7820c35988d030c249ad52eb97 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt <tobias.schmidt@unibas.ch> Date: Fri, 14 Jan 2011 16:50:26 +0100 Subject: [PATCH] added ChainView::GetBondCount --- modules/mol/base/src/chain_handle.hh | 9 +++++---- modules/mol/base/src/chain_view.cc | 14 ++++++++++++++ modules/mol/base/src/chain_view.hh | 8 ++++++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/modules/mol/base/src/chain_handle.hh b/modules/mol/base/src/chain_handle.hh index 57f52ce75..461176925 100644 --- a/modules/mol/base/src/chain_handle.hh +++ b/modules/mol/base/src/chain_handle.hh @@ -118,11 +118,12 @@ public: // \c ResidueHandle::GetResidueCount(). int GetAtomCount() const; - //! \brief Get number of bonds of this chain. This method might NOT work as expected (see warning below). + /// \brief Get number of all inclusive bonds of this chain. + /// /// \warning For a bond between two different chains, it is not clearly - /// defined to which chain it belongs. Therefore, this method - /// works only correctly if the chain has NO bonds to any other - /// chains! + /// defined to which chain it belongs. Therefore, this method will + /// only return the number of bonds where both bonded atoms are + /// within the same chain (all inclusive bonds). int GetBondCount() const; /// \brief Get number of residues of this chain. diff --git a/modules/mol/base/src/chain_view.cc b/modules/mol/base/src/chain_view.cc index e5d7e0549..beac66cbe 100644 --- a/modules/mol/base/src/chain_view.cc +++ b/modules/mol/base/src/chain_view.cc @@ -138,6 +138,20 @@ int ChainView::GetAtomCount() const { return count; } +int ChainView::GetBondCount() const { + this->CheckValidity(); + int count=0; + EntityView ev = this->GetEntity(); + const BondHandleList& bhl = ev.GetBondList(); + for (BondHandleList::const_iterator i=bhl.begin(); i!=bhl.end(); ++i) { + if (i->GetFirst().GetResidue().GetChain().GetName()==this->GetName() && + i->GetSecond().GetResidue().GetChain().GetName()==this->GetName()) { + count++; + } + } + return count; +} + ResidueView ChainView::FindResidue(const ResNum& number) const { this->CheckValidity(); const ResidueViewList& l=data_->residues; diff --git a/modules/mol/base/src/chain_view.hh b/modules/mol/base/src/chain_view.hh index d2552a65c..fbade4518 100644 --- a/modules/mol/base/src/chain_view.hh +++ b/modules/mol/base/src/chain_view.hh @@ -71,6 +71,14 @@ public: /// \brief Get number of atoms in this chain view int GetAtomCount() const; + /// \brief Get number of all inclusive bonds of this chain. + /// + /// \warning For a bond between two different chains, it is not clearly + /// defined to which chain it belongs. Therefore, this method will + /// only return the number of bonds where both bonded atoms are + /// within the same chain (all inclusive bonds). + int GetBondCount() const; + public: /// \brief Add residue to view /// -- GitLab