diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst index 0572ce2b9f34d6dd332b131273cd7460cfb80cca..33aa310fee90640e8ee9f3fdcf560ca58c04223d 100644 --- a/modules/io/doc/mmcif.rst +++ b/modules/io/doc/mmcif.rst @@ -3,14 +3,14 @@ mmCIF File Format .. currentmodule:: ost.io -The mmCIF file format is an alternate container for structural entities, also -provided by the PDB. Here we describe how to load those files and how to deal -with information provided above the common PDB format (:class:`MMCifInfo`, +The mmCIF file format is a container for structural entities provided by the +PDB. Here we describe how to load those files and how to deal with information +provided above the legacy PDB format (:class:`MMCifInfo`, :class:`MMCifInfoCitation`, :class:`MMCifInfoTransOp`, :class:`MMCifInfoBioUnit`, :class:`MMCifInfoStructDetails`, :class:`MMCifInfoObsolete`, :class:`MMCifInfoStructRef`, :class:`MMCifInfoStructRefSeq`, :class:`MMCifInfoStructRefSeqDif`, -:class:`MMCifInfoRevisions`). +:class:`MMCifInfoRevisions`, :class:`MMCifInfoEntityBranchLink`). Loading mmCIF Files @@ -50,6 +50,9 @@ The following categories of a mmCIF file are considered by the reader: :class:`MMCifInfoRevisions` * ``pdbx_audit_revision_history`` and ``pdbx_audit_revision_details`` (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` Notes: @@ -303,6 +306,31 @@ of the annotation available. See :attr:`obsolete` + .. method:: GetEntityBranchLinks() + + Get bond information for branched entities. Returns all + :class:`MMCifInfoEntityBranchLink` objects in one list. Chain and residue + information is available by the stored + :class:`AtomHandles <ost.mol.AtomHandle>` of each entry. + + .. method:: AddEntityBranchLink(chain_name, atom1, atom2, bond_order) + + Add bond information for a branched entity. + + :param chain_name: Chain the bond belongs to + :type chain_name: :class:`str` + :param atom1: First atom of the bond + :type atom1: :class:`~ost.mol.AtomHandle` + :param atom2: Second atom of the bond + :type atom2: :class:`~ost.mol.AtomHandle` + :param bond_order: bond order (e.g. 1=single, 2=double, 3=triple) + :type bond_order: :class:`int` + :returns: Nothing + + .. method:: ConnectBranchLinks() + + Establish all bonds stored for branched entities. + .. class:: MMCifInfoCitation This stores citation information from an input file. diff --git a/modules/io/pymod/__init__.py b/modules/io/pymod/__init__.py index 8f5836c6edc63be2c592389e26d2526b4c993b6a..cf8063d011627d477fd7401d004d7b6664a621f7 100644 --- a/modules/io/pymod/__init__.py +++ b/modules/io/pymod/__init__.py @@ -277,9 +277,9 @@ def LoadCHARMMTraj(crd, dcd_file=None, profile='CHARMM', def LoadMMCIF(filename, fault_tolerant=None, calpha_only=None, profile='DEFAULT', remote=False, seqres=False, info=False): """ - Load MMCIF file from disk and return one or more entities. Several options - allow to customize the exact behaviour of the MMCIF import. For more - information on these options, see :doc:`profile`. + Load a mmCIF file and return one or more entities. Several options allow to + customize the exact behaviour of the mmCIF import. For more information on + these options, see :doc:`profile`. Residues are flagged as ligand if they are mentioned in a HET record. diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index aa7b290a563cefa37aa4fdea444203856293a94b..b8dae1b0509e0e13fc081f52d3456555bf350324 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -333,31 +333,33 @@ void export_mmcif_io() .add_property("first_release", &MMCifInfoRevisions::GetFirstRelease) ; - class_<MMCifInfoEntityBranch>("MMCifInfoEntityBranch", init<mol::AtomHandle, - mol::AtomHandle, unsigned char>()) - .def("GetAtom1", &MMCifInfoEntityBranch::GetAtom1) - .def("GetAtom2", &MMCifInfoEntityBranch::GetAtom2) - .def("GetBondOrder", &MMCifInfoEntityBranch::GetBondOrder) - .def("ConnectBranchLink", &MMCifInfoEntityBranch::ConnectBranchLink) - .def("SetAtom1", &MMCifInfoEntityBranch::SetAtom1) - .def("SetAtom2", &MMCifInfoEntityBranch::SetAtom2) - .def("SetBondOrder", &MMCifInfoEntityBranch::SetBondOrder) + class_<MMCifInfoEntityBranchLink>("MMCifInfoEntityBranchLink", + init<mol::AtomHandle, + mol::AtomHandle, unsigned char>()) + .def("GetAtom1", &MMCifInfoEntityBranchLink::GetAtom1) + .def("GetAtom2", &MMCifInfoEntityBranchLink::GetAtom2) + .def("GetBondOrder", &MMCifInfoEntityBranchLink::GetBondOrder) + .def("ConnectBranchLink", &MMCifInfoEntityBranchLink::ConnectBranchLink) + .def("SetAtom1", &MMCifInfoEntityBranchLink::SetAtom1) + .def("SetAtom2", &MMCifInfoEntityBranchLink::SetAtom2) + .def("SetBondOrder", &MMCifInfoEntityBranchLink::SetBondOrder) .def(self_ns::str(self)) - .add_property("atom1", &MMCifInfoEntityBranch::GetAtom1, - &MMCifInfoEntityBranch::SetAtom1) - .add_property("atom2", &MMCifInfoEntityBranch::GetAtom2, - &MMCifInfoEntityBranch::SetAtom2) - .add_property("bond_order", &MMCifInfoEntityBranch::GetBondOrder, - &MMCifInfoEntityBranch::SetBondOrder) + .add_property("atom1", &MMCifInfoEntityBranchLink::GetAtom1, + &MMCifInfoEntityBranchLink::SetAtom1) + .add_property("atom2", &MMCifInfoEntityBranchLink::GetAtom2, + &MMCifInfoEntityBranchLink::SetAtom2) + .add_property("bond_order", &MMCifInfoEntityBranchLink::GetBondOrder, + &MMCifInfoEntityBranchLink::SetBondOrder) ; - class_<MMCifInfoEntityBranchMap>("MMCifInfoEntityBranchMap", init<>()) - .def(map_indexing_suite<MMCifInfoEntityBranchMap>()) + class_<MMCifInfoEntityBranchLinkMap>("MMCifInfoEntityBranchLinkMap", init<>()) + .def(map_indexing_suite<MMCifInfoEntityBranchLinkMap>()) ; - class_<std::vector<MMCifInfoEntityBranch> >("MMCifInfoEntityBranchList", - init<>()) - .def(vector_indexing_suite<std::vector<MMCifInfoEntityBranch> >()) + class_<std::vector<MMCifInfoEntityBranchLink> >( + "MMCifInfoEntityBranchLinkList", + init<>()) + .def(vector_indexing_suite<std::vector<MMCifInfoEntityBranchLink> >()) .def(self_ns::str(self)) ; diff --git a/modules/io/src/mol/mmcif_info.cc b/modules/io/src/mol/mmcif_info.cc index 43dca70f8eab97b2954550883d56386f2191e382..5db86d1cc86144d3cdeadb221b62ed2b241bebe4 100644 --- a/modules/io/src/mol/mmcif_info.cc +++ b/modules/io/src/mol/mmcif_info.cc @@ -201,23 +201,24 @@ void MMCifInfo::AddEntityBranchLink(String chain_name, unsigned char bond_order) { // check if element already exists - MMCifInfoEntityBranchMap::iterator blm_it = entity_branches_.find(chain_name); + MMCifInfoEntityBranchLinkMap::iterator blm_it = + entity_branches_.find(chain_name); if (blm_it == entity_branches_.end()) { // `find` points to the end of the map so chain_name was not found - std::pair<MMCifInfoEntityBranchMap::iterator, bool> rit = - entity_branches_.insert(MMCifInfoEntityBranchMap::value_type(chain_name, - std::vector<MMCifInfoEntityBranch>())); + std::pair<MMCifInfoEntityBranchLinkMap::iterator, bool> rit = + entity_branches_.insert(MMCifInfoEntityBranchLinkMap::value_type(chain_name, + std::vector<MMCifInfoEntityBranchLink>())); // let blm_it point to the new element so we can add to the vector blm_it = rit.first; } // add new branch element - blm_it->second.push_back(MMCifInfoEntityBranch(atom1, atom2, bond_order)); + blm_it->second.push_back(MMCifInfoEntityBranchLink(atom1, atom2, bond_order)); } -const std::vector<MMCifInfoEntityBranch> MMCifInfo::GetEntityBranchLinks() const +const std::vector<MMCifInfoEntityBranchLink> MMCifInfo::GetEntityBranchLinks() const { - std::vector<MMCifInfoEntityBranch> all_links; - MMCifInfoEntityBranchMap::const_iterator blm_it; + std::vector<MMCifInfoEntityBranchLink> all_links; + MMCifInfoEntityBranchLinkMap::const_iterator blm_it; for (blm_it = entity_branches_.begin(); blm_it != entity_branches_.end(); ++blm_it) { std::copy(blm_it->second.begin(), blm_it->second.end(), @@ -228,12 +229,13 @@ const std::vector<MMCifInfoEntityBranch> MMCifInfo::GetEntityBranchLinks() const void MMCifInfo::ConnectBranchLinks() { - MMCifInfoEntityBranchMap::iterator blm_it; + MMCifInfoEntityBranchLinkMap::iterator blm_it; for (blm_it = entity_branches_.begin(); blm_it != entity_branches_.end(); ++blm_it) { // We assume that one chain only comes from one entity, so we go with one // editor per chain - std::vector<MMCifInfoEntityBranch>::iterator blv_it = blm_it->second.begin(); + std::vector<MMCifInfoEntityBranchLink>::iterator blv_it = + blm_it->second.begin(); if (blv_it != blm_it->second.end()) { mol::XCSEditor editor = blv_it->GetAtom1().GetEntity().EditXCS(); for (; blv_it != blm_it->second.end(); ++blv_it) { @@ -243,18 +245,18 @@ void MMCifInfo::ConnectBranchLinks() } } -std::ostream& operator<<(std::ostream& os, const MMCifInfoEntityBranch& eb) +std::ostream& operator<<(std::ostream& os, const MMCifInfoEntityBranchLink& eb) { - os << "<MMCifInfoEntityBranch atom1:" << eb.GetAtom1() << " atom2:" + os << "<MMCifInfoEntityBranchLink atom1:" << eb.GetAtom1() << " atom2:" << eb.GetAtom2() << ">"; return os; } std::ostream& operator<<(std::ostream& os, - const std::vector<MMCifInfoEntityBranch>& eb_list) + const std::vector<MMCifInfoEntityBranchLink>& eb_list) { - os << "<MMCifInfoEntityBranchList"; - std::vector<MMCifInfoEntityBranch>::const_iterator bl_it; + os << "<MMCifInfoEntityBranchLinkList"; + std::vector<MMCifInfoEntityBranchLink>::const_iterator bl_it; for (bl_it = eb_list.begin(); bl_it != eb_list.end(); ++bl_it) { os << " <atom1:" << bl_it->GetAtom1() << " atom2:" << bl_it->GetAtom2() << ">"; diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index db32cd504f87940951a490e1c3188486fb3f7c49..15237188546fe36add5a81a786d8ac72c96e9ed0 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -921,11 +921,11 @@ private: /// \brief Store information on brnached structures (oligosaccharides) /// -class DLLEXPORT_OST_IO MMCifInfoEntityBranch { +class DLLEXPORT_OST_IO MMCifInfoEntityBranchLink { public: - MMCifInfoEntityBranch(mol::AtomHandle atom1, - mol::AtomHandle atom2, - unsigned char bond_order): + MMCifInfoEntityBranchLink(mol::AtomHandle atom1, + mol::AtomHandle atom2, + unsigned char bond_order): atom1_(atom1), atom2_(atom2), bond_order_(bond_order) {} mol::AtomHandle GetAtom1() const { return atom1_;} mol::AtomHandle GetAtom2() const { return atom2_; } @@ -937,7 +937,7 @@ atom1_(atom1), atom2_(atom2), bond_order_(bond_order) {} editor.Connect(atom1_, atom2_, bond_order_); } - bool operator==(const MMCifInfoEntityBranch& eb) const { + bool operator==(const MMCifInfoEntityBranchLink& eb) const { if (this->atom1_ != eb.atom1_) { return false; } @@ -947,7 +947,7 @@ atom1_(atom1), atom2_(atom2), bond_order_(bond_order) {} return true; } - bool operator!=(const MMCifInfoEntityBranch& eb) const { + bool operator!=(const MMCifInfoEntityBranchLink& eb) const { return !this->operator == (eb); } @@ -956,7 +956,7 @@ private: mol::AtomHandle atom2_; unsigned char bond_order_; }; -typedef std::map<String, std::vector<MMCifInfoEntityBranch> > MMCifInfoEntityBranchMap; +typedef std::map<String, std::vector<MMCifInfoEntityBranchLink> > MMCifInfoEntityBranchLinkMap; /// \brief container class for additional information from MMCif files /// @@ -1179,7 +1179,7 @@ public: /// \brief Get all links for all branched entities /// - const std::vector<MMCifInfoEntityBranch> GetEntityBranchLinks() const; + const std::vector<MMCifInfoEntityBranchLink> GetEntityBranchLinks() const; //GetEntityBranchChains //GetEntityBranchByChain @@ -1205,14 +1205,14 @@ private: std::map<String, String> cif_2_pdb_chain_id_; std::map<String, String> pdb_2_cif_chain_id_; std::map<String, String> cif_2_entity_id_; - std::map<String, std::vector<MMCifInfoEntityBranch> > entity_branches_; + std::map<String, std::vector<MMCifInfoEntityBranchLink> > entity_branches_; }; DLLEXPORT_OST_IO std::ostream& operator<<(std::ostream& os, - const MMCifInfoEntityBranch& eb); + const MMCifInfoEntityBranchLink& eb); DLLEXPORT_OST_IO std::ostream& operator<<(std::ostream& os, - const std::vector<MMCifInfoEntityBranch>& eb_list); + const std::vector<MMCifInfoEntityBranchLink>& eb_list); }} // ns #endif diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py index 8e909c349449776b44018dff29bb43607909430c..d0f902ac48aa8b2ad744a8c189c8a96009703acd 100644 --- a/modules/io/tests/test_io_mmcif.py +++ b/modules/io/tests/test_io_mmcif.py @@ -264,7 +264,7 @@ class TestMMCifInfo(unittest.TestCase): self.assertEqual(len(crambin_pdb.atoms), 327) def test_mmcifinfo_entitybranch(self): - # test MMCifInfoEntityBranch + # test MMCifInfoEntityBranchLink eh = mol.CreateEntity() editor = eh.EditXCS(); ch = editor.InsertChain("A"); @@ -272,7 +272,7 @@ class TestMMCifInfo(unittest.TestCase): res2 = editor.AppendResidue(ch, "MAN"); atom1 = editor.InsertAtom(res2, "C1", geom.Vec3()); atom2 = editor.InsertAtom(res1, "O3", geom.Vec3()); - branch = io.MMCifInfoEntityBranch(atom1, atom2, 1) + branch = io.MMCifInfoEntityBranchLink(atom1, atom2, 1) self.assertEqual(branch.atom1.qualified_name, "A.MAN2.C1") self.assertEqual(branch.bond_order, 1) diff --git a/modules/io/tests/test_mmcif_info.cc b/modules/io/tests/test_mmcif_info.cc index 2c4a760e3e41df03a2ddd32ff8d90b88ddf8be4d..0ab74afb94bb1c3056bdf1042a9b2c1b36f5b67c 100644 --- a/modules/io/tests/test_mmcif_info.cc +++ b/modules/io/tests/test_mmcif_info.cc @@ -293,7 +293,7 @@ BOOST_AUTO_TEST_CASE(mmcif_info_branch) mol::AtomHandle atom1 = editor.InsertAtom(res2, "C1",geom::Vec3()); mol::AtomHandle atom2 = editor.InsertAtom(res1, "O4",geom::Vec3()); - MMCifInfoEntityBranch branch1(atom1, atom2, 1); + MMCifInfoEntityBranchLink branch1(atom1, atom2, 1); BOOST_CHECK(branch1.GetAtom1().GetQualifiedName() == "A.NAG2.C1"); BOOST_CHECK(branch1.GetAtom2().GetQualifiedName() == "A.NAG1.O4"); BOOST_CHECK(branch1.GetBondOrder() == 1); @@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(mmcif_info) mol::AtomHandle atom22 = editor.InsertAtom(res21, "O3",geom::Vec3()); info.AddEntityBranchLink(ch1.GetName(), atom11, atom12, 1); info.AddEntityBranchLink(ch2.GetName(), atom21, atom22, 1); - std::vector<MMCifInfoEntityBranch> blinks = info.GetEntityBranchLinks(); + std::vector<MMCifInfoEntityBranchLink> blinks = info.GetEntityBranchLinks(); BOOST_CHECK(blinks.size() == 2); BOOST_CHECK(blinks[0].GetAtom1().GetQualifiedName() == "A.NAG2.C1");