diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst index 2a9bccd2e94a42db035ecd7011473281ca0771da..510cd7d454fe410157cc72d4bfe040ecc0504ad2 100644 --- a/modules/io/doc/mmcif.rst +++ b/modules/io/doc/mmcif.rst @@ -52,7 +52,8 @@ The following categories of a mmCIF file are considered by the reader: (mmCIF dictionary version >= 5) used to fill :class:`MMCifInfoRevisions` * ``pdbx_entity_branch`` and ``pdbx_entity_branch_link`` used for :class:`MMCifInfoEntityBranchLink`, a list of links is available by - :meth:`~MMCifInfo.GetEntityBranchLinks` + :meth:`~MMCifInfo.GetEntityBranchLinks` and + :meth:`~MMCifInfo.GetEntityBranchByChain` Notes: @@ -313,6 +314,18 @@ of the annotation available. information is available by the stored :class:`AtomHandles <ost.mol.AtomHandle>` of each entry. + :returns: :class:`list` of :class:`MMCifInfoEntityBranchLink` + + .. method:: GetEntityBranchByChain(chain_name) + + Get bond information for chains with branched entities. Returns all + :class:`MMCifInfoEntityBranchLink` objects in one list if chain is a + branched entity, an empty list otherwise. + + :param chain_name: Chain name to check for branch links + :type chain_name: :class:`str` + :returns: :class:`list` of :class:`MMCifInfoEntityBranchLink` + .. method:: AddEntityBranchLink(chain_name, atom1, atom2, bond_order) Add bond information for a branched entity. @@ -327,7 +340,19 @@ of the annotation available. :type bond_order: :class:`int` :returns: Nothing - .. method:: ConnectBranchLinks() + .. method:: GetEntityBranchChainNames + + Get a list of chain names which contain branched entities. + + :returns: :class:`list` of :class:`str` + + .. method:: GetEntityBranchChains + + Get a list of chains which contain branched entities. + + :returns: :class:`list` of :class:`~ost.mol.ChainHandle` + + .. method:: ConnectBranchLinks Establish all bonds stored for branched entities. @@ -1246,18 +1271,6 @@ of the annotation available. :type editor: :class:`~ost.mol.XCSEditor` :returns: Nothing - .. method:: GetEntityBranchChainNames - - Get a list of chain names which contain branched entities. - - :returns: :class:`list` of :class:`str` - - .. method:: GetEntityBranchChains - - Get a list of chains which contain branched entities. - - :returns: :class:`list` of :class:`~ost.mol.ChainHandle` - .. method:: GetAtom1 See :attr:`atom1` @@ -1286,7 +1299,7 @@ of the annotation available. .. LocalWords: SPRSDE pdb func autofunction exptl attr pdbx oper conf spr dif .. LocalWords: biounits biounit uniprot UNP seqs AddMMCifPDBChainTr cif asym .. LocalWords: auth GetMMCifPDBChainTr AddPDBCMMCifhainTr GetPDBMMCifChainTr -.. LocalWords: GetRevisions AddRevision SetRevisionsDateOriginal GetSize +.. LocalWords: GetRevisions AddRevision SetRevisionsDateOriginal GetSize str .. LocalWords: GetNum num GetStatus GetLastDate GetFirstRelease storable .. LocalWords: cas isbn pubmed asu seqres conop casp COMPND OBSLTE LoadMMCIF .. LocalWords: SetChainList MMCifInfoTransOp ChainTypes MMCifInfoStructRef @@ -1295,3 +1308,4 @@ of the annotation available. .. LocalWords: chainintervalls GetChainIntervalList GetMethodDetails GetAtom .. LocalWords: GetOperationsIntervalList SetMethodDetails oligosaccharides .. LocalWords: SetAtom GetBondOrder SetBondOrder MMCifInfoEntityBranchLink +.. LocalWords: GetEntityBranchByChain param diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index ea953160fecc97618df6d142976f6293cc4e75e5..11223672cc0e6fb8121cdc44a2ad58ede5c0211c 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -413,6 +413,7 @@ void export_mmcif_io() .def("GetRevisions", &MMCifInfo::GetRevisions) .def("AddEntityBranchLink", &MMCifInfo::AddEntityBranchLink) .def("GetEntityBranchLinks", &MMCifInfo::GetEntityBranchLinks) + .def("GetEntityBranchByChain", &MMCifInfo::GetEntityBranchByChain) .def("ConnectBranchLinks", &MMCifInfo::ConnectBranchLinks) .def("GetEntityBranchChainNames", &WrapGetNames) .def("GetEntityBranchChains", &MMCifInfo::GetEntityBranchChains) diff --git a/modules/io/src/mol/mmcif_info.cc b/modules/io/src/mol/mmcif_info.cc index 62ea686e6f01b1f6c34af84e1226848d98448fcc..ce93b67789ce168b1c77eaf04105da03967c1f63 100644 --- a/modules/io/src/mol/mmcif_info.cc +++ b/modules/io/src/mol/mmcif_info.cc @@ -227,6 +227,18 @@ const std::vector<MMCifInfoEntityBranchLink> MMCifInfo::GetEntityBranchLinks() c return all_links; } +const std::vector<MMCifInfoEntityBranchLink> MMCifInfo::GetEntityBranchByChain( + const String& chain_name) const +{ + // search the requested chain + MMCifInfoEntityBranchLinkMap::const_iterator blm_it = + entity_branches_.find(chain_name); + if (blm_it != entity_branches_.end()) { + return blm_it->second; + } + return std::vector<MMCifInfoEntityBranchLink>(); +} + const std::vector<String> MMCifInfo::GetEntityBranchChainNames() const { std::vector<String> chain_names; diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index bebccefa06b7be287af43198c297095bd2814287..b97949105b4818777d0650d8ba59f45e8f05e8ab 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -1181,15 +1181,19 @@ public: /// const std::vector<MMCifInfoEntityBranchLink> GetEntityBranchLinks() const; + /// \brief Check if a chain is a branched entity and return it + /// + /// \param chain_name Name of the chain to check + const std::vector<MMCifInfoEntityBranchLink> GetEntityBranchByChain( + const String& chain_name) const; + /// \brief Get the names of all chains of branched entities. /// const std::vector<String> GetEntityBranchChainNames() const; /// \brief Get the all chains of branched entities. /// -const mol::ChainHandleList GetEntityBranchChains() const; - - //GetEntityBranchByChain + const mol::ChainHandleList GetEntityBranchChains() const; /// \brief Connect all atoms listed as links for branched entities. /// diff --git a/modules/io/src/mol/mmcif_reader.hh b/modules/io/src/mol/mmcif_reader.hh index 03ceb32c9b1da31df563a81949065647779b9a6d..c6e2e32fdbfef23eba378f9e6efbffb7ac3a79df 100644 --- a/modules/io/src/mol/mmcif_reader.hh +++ b/modules/io/src/mol/mmcif_reader.hh @@ -631,7 +631,8 @@ private: /// \brief Get an iterator for MMCifEntityDescMap by finding an element or /// inserting a new one into the map. - MMCifEntityDescMap::iterator GetEntityDescMapIterator(const String&); + /// \param entity_id ID of the entity to talk to + MMCifEntityDescMap::iterator GetEntityDescMapIterator(const String& entity_id); /// \struct assembly information typedef struct { diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py index 0da0a4c2e4ba5751755952dba846f29b6eba558e..20162281d3584abb31dfb024edb01c50baebe068 100644 --- a/modules/io/tests/test_io_mmcif.py +++ b/modules/io/tests/test_io_mmcif.py @@ -306,6 +306,12 @@ class TestMMCifInfo(unittest.TestCase): self.assertEqual(chains[0].name, 'A') self.assertEqual(chains[1].name, 'B') + blinks = info.GetEntityBranchByChain('B') + self.assertEqual(len(blinks), 1) + self.assertEqual(blinks[0].atom1.qualified_name, "B.NAG2.C1") + blinks = info.GetEntityBranchByChain('C') + self.assertEqual(len(blinks), 0) + if __name__== '__main__': from ost import testutils testutils.RunTests() diff --git a/modules/io/tests/test_mmcif_info.cc b/modules/io/tests/test_mmcif_info.cc index a2b78b0544c0f2c9676c4f8065e0eba035a9953d..5370d2ce1eeb733bbba23b2ff52fadaf2cd22274 100644 --- a/modules/io/tests/test_mmcif_info.cc +++ b/modules/io/tests/test_mmcif_info.cc @@ -377,6 +377,13 @@ BOOST_AUTO_TEST_CASE(mmcif_info) BOOST_CHECK(chains[0].GetName() == "A"); BOOST_CHECK(chains[1].GetName() == "B"); + // check retrieval of links by chain name + std::vector<MMCifInfoEntityBranchLink> cblinks = + info.GetEntityBranchByChain("A"); + BOOST_CHECK(cblinks.size() == 1); + cblinks = info.GetEntityBranchByChain("C"); + BOOST_CHECK(cblinks.size() == 0); + BOOST_TEST_MESSAGE(" done."); }