diff --git a/modules/mol/base/src/chain_handle.hh b/modules/mol/base/src/chain_handle.hh index 57f52ce75e71e5f7859e83e191d3d5be119575b1..461176925141b0c327d7facebf412f3e984d3890 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 e5d7e05499460fa1d76468f313774a67e353d438..beac66cbedc73343e38cf81d9acb473523df6b3c 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 d2552a65c25f8be3079aad36f6f901877e7448cb..fbade451850c34be4d5c276b7416381e627ad950 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 ///