diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc index 3bac82e55f395b2a2ea19b7477273eb52ba10312..7fba2529318638dbd62ec989d89905dcec4efe03 100644 --- a/modules/io/src/mol/mmcif_reader.cc +++ b/modules/io/src/mol/mmcif_reader.cc @@ -154,7 +154,8 @@ bool MMCifParser::OnBeginLoop(const StarLoopDesc& header) // mandatory items this->TryStoreIdx(E_ID, "id", header); // optional - indices_[E_TYPE] = header.GetIndex("type"); + indices_[E_TYPE] = header.GetIndex("type"); + indices_[DETAILS] = header.GetIndex("details"); return true; } /*else if (header.GetCategory()=="entity_poly") { @@ -451,6 +452,11 @@ void MMCifParser::ParseEntity(const std::vector<StringRef>& columns) store = true; } + // description + if (indices_[DETAILS] != -1) { + desc.details = columns[indices_[E_TYPE]].str(); + } + if (store) { entity_desc_map_.insert( MMCifEntityDescMap::value_type(columns[indices_[E_ID]].str(), diff --git a/modules/io/src/mol/mmcif_reader.hh b/modules/io/src/mol/mmcif_reader.hh index 529702a7466fcfc4e6aa698c1273e6687687d3b9..73e378aebf5324deb8a7d6cfd12a916481099087 100644 --- a/modules/io/src/mol/mmcif_reader.hh +++ b/modules/io/src/mol/mmcif_reader.hh @@ -186,7 +186,8 @@ private: /// \enum items of the entity category typedef enum { E_ID, ///< unique identifier - E_TYPE ///< polymer, non-polymer or water + E_TYPE, ///< polymer, non-polymer or water + DETAILS ///< special aspects of the entity } EntityItems; /// \enum categories of the mmcif format @@ -199,6 +200,7 @@ private: /// \struct keeping track of entity information typedef struct { ChainType type; ///< characterise entity + String details; ///< description of this entity } MMCifEntityDesc; typedef std::map<String, MMCifEntityDesc> MMCifEntityDescMap; diff --git a/modules/mol/base/src/chain_base.cc b/modules/mol/base/src/chain_base.cc index 4147ed5322abccca4cc904563c34786e3c67ff01..1f5b04cd0d573f45a0bf5fcb1928198648e77824 100644 --- a/modules/mol/base/src/chain_base.cc +++ b/modules/mol/base/src/chain_base.cc @@ -48,6 +48,10 @@ ChainType ChainBase::GetChainType() const { return impl_->GetChainType(); } +String ChainBase::GetChainDescription() const { + return impl_->GetChainDescription(); +} + void ChainBase::CheckValidity() const { if (!impl_) throw InvalidHandle(); diff --git a/modules/mol/base/src/chain_base.hh b/modules/mol/base/src/chain_base.hh index ca9e45724ac13f929a166d2f461913e846dbb63f..5410ada9f457617f1ae9448e0599c57a8e188414 100644 --- a/modules/mol/base/src/chain_base.hh +++ b/modules/mol/base/src/chain_base.hh @@ -65,6 +65,11 @@ public: /// \return chain type of ChainType ChainType GetChainType() const; + /// \brief Get information about a chain. + /// + /// \return description + String GetChainDescription() const; + const impl::ChainImplPtr& Impl() const { return impl_; } diff --git a/modules/mol/base/src/editor_base.cc b/modules/mol/base/src/editor_base.cc index b959d23ea693bec300aa31c9e40b537fc8aa66b7..c9fa92bd40ffbbdf6792cfc79df08f1050b65bee 100644 --- a/modules/mol/base/src/editor_base.cc +++ b/modules/mol/base/src/editor_base.cc @@ -88,6 +88,12 @@ void EditorBase::SetChainType(ChainHandle chain, const ChainType type) chain.Impl()->SetChainType(type); } +void EditorBase::SetChainDescription(ChainHandle chain, const String desc) +{ + CheckHandleValidity(chain); + chain.Impl()->SetChainDescription(desc); +} + AtomHandle EditorBase::InsertAtom(ResidueHandle res, const String& name, const geom::Vec3& pos, const String& ele, Real occupancy, Real b_factor, diff --git a/modules/mol/base/src/editor_base.hh b/modules/mol/base/src/editor_base.hh index cb009474c698fe73fa488a24e8415c8b88ea744b..cd8c811cadb681c8f6828840b13893823a57420e 100644 --- a/modules/mol/base/src/editor_base.hh +++ b/modules/mol/base/src/editor_base.hh @@ -162,6 +162,12 @@ public: /// \param type type of the chain void SetChainType(ChainHandle chain, const ChainType type); + /// \brief Assign a description to a chain. + /// + /// \param chain chain to assign to + /// \param desc description + void SetChainDescription(ChainHandle chain, const String desc); + /// \brief Delete all atoms of residue /// /// All associated torsions and bonds will also be removed diff --git a/modules/mol/base/src/impl/chain_impl.cc b/modules/mol/base/src/impl/chain_impl.cc index 558eb2c526df71e9e076a98d709ecc6e5987a728..a96ce571cc4477f36589f98f2c310ec48ff05014 100644 --- a/modules/mol/base/src/impl/chain_impl.cc +++ b/modules/mol/base/src/impl/chain_impl.cc @@ -37,7 +37,8 @@ ChainImpl::ChainImpl(const EntityImplPtr& e, const String& name): name_(name), residue_list_(), in_sequence_(true), - chain_type_(CHAINTYPE_UNKNOWN) + chain_type_(CHAINTYPE_UNKNOWN), + description_() {} String ChainImpl::GetName() const diff --git a/modules/mol/base/src/impl/chain_impl.hh b/modules/mol/base/src/impl/chain_impl.hh index 4758297b06dc4bab7efaab60af17047468129d2e..31bd368796ac86a2be1a748501e3475f293a168d 100644 --- a/modules/mol/base/src/impl/chain_impl.hh +++ b/modules/mol/base/src/impl/chain_impl.hh @@ -64,6 +64,22 @@ public: return chain_type_; } + /// \brief Assign a description to a chain. + /// + /// \param desc description + void SetChainDescription(const String desc) + { + description_ = desc; + } + + /// \brief Get information about a chain + /// + /// \return description + String GetChainDescription() const + { + return description_; + } + /// \brief append new residue with exactly the same parameters as res, but /// no atoms and bonds ResidueImplPtr AppendResidue(const ResidueImplPtr& res); @@ -152,6 +168,7 @@ private: /// to optimize residue by number lookup. bool in_sequence_; ChainType chain_type_; + String description_; ///< special aspects of the chain }; }}} // ns diff --git a/modules/mol/base/tests/test_chain.cc b/modules/mol/base/tests/test_chain.cc index 80b729d75ce65817faa94f776dddf44b55e59d0e..b866ecd00df2ee57b6f53fc9ecded48e7861f5ee 100644 --- a/modules/mol/base/tests/test_chain.cc +++ b/modules/mol/base/tests/test_chain.cc @@ -204,9 +204,9 @@ BOOST_AUTO_TEST_CASE(rename_chain) BOOST_AUTO_TEST_CASE(chain_type) { - EntityHandle eh=CreateEntity(); - XCSEditor e=eh.EditXCS(); - ChainHandle ch1=e.InsertChain("A"); + EntityHandle eh = CreateEntity(); + XCSEditor e = eh.EditXCS(); + ChainHandle ch1 = e.InsertChain("A"); BOOST_CHECK(ch1.GetChainType() == CHAINTYPE_UNKNOWN); e.SetChainType(ch1, CHAINTYPE_POLY); @@ -235,4 +235,14 @@ BOOST_AUTO_TEST_CASE(chain_type) BOOST_CHECK(ch1.GetChainType() == CHAINTYPE_UNKNOWN); } +BOOST_AUTO_TEST_CASE(chain_description) +{ + EntityHandle eh=CreateEntity(); + XCSEditor e = eh.EditXCS(); + ChainHandle ch1 = e.InsertChain("A"); + String description = "Very important information"; + e.SetChainDescription(ch1, description); + BOOST_CHECK(ch1.GetChainDescription() == description); +} + BOOST_AUTO_TEST_SUITE_END()