From ca5d8dd46e0f53dad344e45b3b6240a21f63b47b Mon Sep 17 00:00:00 2001 From: Stefan Bienert <stefan.bienert@unibas.ch> Date: Mon, 3 Jun 2013 11:06:54 +0200 Subject: [PATCH] Added pdbx_struct_assembly.method_details to mmCIF parser --- modules/io/doc/mmcif.rst | 19 +++++++++++++++++-- modules/io/pymod/export_mmcif_io.cc | 4 ++++ modules/io/src/mol/mmcif_info.hh | 12 ++++++++++++ modules/io/src/mol/mmcif_reader.cc | 26 +++++++++++++++++--------- modules/io/src/mol/mmcif_reader.hh | 11 +++++++++-- modules/io/tests/test_io_mmcif.py | 4 ++++ modules/io/tests/test_mmcif_info.cc | 2 ++ modules/io/tests/test_mmcif_reader.cc | 1 + 8 files changed, 66 insertions(+), 13 deletions(-) diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst index b8c63d9de..0a6520a47 100644 --- a/modules/io/doc/mmcif.rst +++ b/modules/io/doc/mmcif.rst @@ -501,6 +501,13 @@ of the annotation available. Also available as :meth:`GetDetails`. May also be modified by :meth:`SetDetails`. + .. attribute:: method_details + + Details about the method used to determine this biological assembly. + + Also available as :meth:`GetMethodDetails`. May also be modified by + :meth:`SetMethodDetails`. + .. attribute:: chains Chains involved in this bio unit. If not provided, resembles an empty list. @@ -552,6 +559,14 @@ of the annotation available. See :attr:`details` + .. method:: GetMethodDetails() + + See :attr:`method_details` + + .. method:: SetMethodDetails(details) + + See :attr:`method_details` + .. method:: GetChainList() See :attr:`chains` @@ -997,5 +1012,5 @@ of the annotation available. .. LocalWords: SetChainList MMCifInfoTransOp ChainTypes MMCifInfoStructRef .. LocalWords: MMCifInfoRevisions bool difs MMCifInfoStructRefSeqDif rnum .. LocalWords: SetDateOriginal GetDateOriginal yyyy operationsintervalls -.. LocalWords: chainintervalls GetChainIntervalList -.. LocalWords: GetOperationsIntervalList +.. LocalWords: chainintervalls GetChainIntervalList GetMethodDetails +.. LocalWords: GetOperationsIntervalList SetMethodDetails diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index 9a21bdb1a..d32133571 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -184,6 +184,8 @@ void export_mmcif_io() class_<MMCifInfoBioUnit>("MMCifInfoBioUnit", init<>()) .def("SetDetails", &MMCifInfoBioUnit::SetDetails) .def("GetDetails", &MMCifInfoBioUnit::GetDetails) + .def("SetMethodDetails", &MMCifInfoBioUnit::SetMethodDetails) + .def("GetMethodDetails", &MMCifInfoBioUnit::GetMethodDetails) .def("AddChain", &MMCifInfoBioUnit::AddChain) .def("SetChainList", &MMCifInfoBioUnit::SetChainList) .def("GetChainList", make_function(&MMCifInfoBioUnit::GetChainList, @@ -201,6 +203,8 @@ void export_mmcif_io() .def("GetID", &MMCifInfoBioUnit::GetID) .add_property("details", &MMCifInfoBioUnit::GetDetails, &MMCifInfoBioUnit::SetDetails) + .add_property("method_details", &MMCifInfoBioUnit::GetMethodDetails, + &MMCifInfoBioUnit::SetMethodDetails) .add_property("chains", make_function(&MMCifInfoBioUnit::GetChainList, return_value_policy<copy_const_reference>())) .add_property("chainintervalls", make_function( diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index 52a44aedc..593fed6f2 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -264,6 +264,17 @@ public: /// \return details String GetDetails() const { return details_; } + /// \brief Set method details + /// + /// \param method details + void SetMethodDetails(String method_details) { + method_details_ = method_details; + } + /// \brief Get method details + /// + /// \return method details + String GetMethodDetails() const { return method_details_; } + /// \brief Add a chain name /// /// \param chain chain name @@ -360,6 +371,7 @@ public: private: String id_; ///< pdbx_struct_assembly.id String details_; ///< pdbx_struct_assembly.details + String method_details_; ///< pdbx_struct_assembly.method_details std::vector<String> chains_; ///< all chains of this this assembly std::vector<std::pair<int, int> > tr_chains_; //< chains of a transformation std::vector<std::vector<MMCifInfoTransOpPtr> > operations_; diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc index cd21e62a1..52cd7e1ae 100644 --- a/modules/io/src/mol/mmcif_reader.cc +++ b/modules/io/src/mol/mmcif_reader.cc @@ -224,7 +224,7 @@ bool MMCifReader::OnBeginLoop(const StarLoopDesc& header) this->TryStoreIdx(PSA_ID, "id", header); // optional indices_[PSA_DETAILS] = header.GetIndex("details"); - //indices_[METHOD_DETAILS] = header.GetIndex("method_details"); + indices_[METHOD_DETAILS] = header.GetIndex("method_details"); cat_available = true; } else if (header.GetCategory() == "pdbx_struct_assembly_gen") { category_ = PDBX_STRUCT_ASSEMBLY_GEN; @@ -870,15 +870,22 @@ void MMCifReader::ParseRefine(const std::vector<StringRef>& columns) void MMCifReader::ParsePdbxStructAssembly(const std::vector<StringRef>& columns) { + MMCifPSAEntry psa; + if (indices_[PSA_DETAILS] != -1) { - bu_origin_map_.insert(std::pair<String, - String>(columns[indices_[PSA_ID]].str(), - columns[indices_[PSA_DETAILS]].str())); + psa.details = columns[indices_[PSA_DETAILS]].str(); } else { - bu_origin_map_.insert(std::pair<String, - String>(columns[indices_[PSA_ID]].str(), - "?")); + psa.details = "?"; } + + if (indices_[METHOD_DETAILS] != -1) { + psa.method_details = columns[indices_[METHOD_DETAILS]].str(); + } else { + psa.method_details = "?"; + } + + bu_origin_map_.insert(std::pair<String, + MMCifPSAEntry>(columns[indices_[PSA_ID]].str(), psa)); } void MMCifReader::StoreExpression(const char* l, const char* s, @@ -1614,7 +1621,7 @@ void MMCifReader::OnEndData() std::vector<std::vector<String> >::const_iterator aol_it; std::vector<String>::const_iterator aob_it; std::vector<MMCifInfoTransOpPtr> operation_list; - std::map<String, String>::const_iterator buom_it; + std::map<String, MMCifPSAEntry>::const_iterator buom_it; std::vector<MMCifInfoTransOpPtr> operations = info_.GetOperations(); info_.SetStructRefs(struct_refs_); std::vector<MMCifInfoTransOpPtr>::const_iterator buop_it; @@ -1631,7 +1638,8 @@ void MMCifReader::OnEndData() bua_it->biounit_id + "' found as requested by pdbx_struct_assembly_gen.")); } - biounit.SetDetails(buom_it->second); + biounit.SetDetails(buom_it->second.details); + biounit.SetMethodDetails(buom_it->second.method_details); biounit.SetID(buom_it->first); biounit.SetChainList(bua_it->chains); diff --git a/modules/io/src/mol/mmcif_reader.hh b/modules/io/src/mol/mmcif_reader.hh index d91cf3403..15cc727ad 100644 --- a/modules/io/src/mol/mmcif_reader.hh +++ b/modules/io/src/mol/mmcif_reader.hh @@ -578,6 +578,13 @@ private: } MMCifHSEntry; typedef std::vector<MMCifHSEntry> MMCifHSVector; + /// \struct store pdbx_struct_assembly info + typedef struct { + String details; + String method_details; + } MMCifPSAEntry; + typedef std::map<String, MMCifPSAEntry> MMCifPSAMap; + // members MMCifCategory category_; int category_counts_[DONT_KNOW+1]; ///< overall no. of atom_site loops @@ -605,10 +612,10 @@ private: MMCifInfo info_; ///< info container MMCifCitationAuthorMap authors_map_; MMCifBioUAssemblyVector bu_assemblies_; - std::map<String, String> bu_origin_map_; ///< pdbx_struct_assembly.details + MMCifPSAMap bu_origin_map_; ///< pdbx_struct_assembly MMCifHSVector helix_list_; ///< for storing struct_conf sec.struct. data MMCifHSVector strand_list_; ///< for storing struct_conf sec.struct. data - MMCifInfoStructRefs struct_refs_; + MMCifInfoStructRefs struct_refs_; }; }} diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py index 4b64aa554..3c1a0ec23 100644 --- a/modules/io/tests/test_io_mmcif.py +++ b/modules/io/tests/test_io_mmcif.py @@ -68,7 +68,11 @@ class TestMMCifInfo(unittest.TestCase): def test_mmcifinfo_biounit(self): b = io.MMCifInfoBioUnit() b.SetDetails('Details') + b.SetMethodDetails('MethodDetails') self.assertEquals(b.GetDetails(), 'Details') + self.assertEquals(b.GetMethodDetails(), 'MethodDetails') + b.method_details = 'AttrMethodDetails' + self.assertEquals(b.method_details, 'AttrMethodDetails') b.AddChain('A') b.AddChain('B') cl = b.GetChainList() diff --git a/modules/io/tests/test_mmcif_info.cc b/modules/io/tests/test_mmcif_info.cc index 4b204a2a5..69f369a4d 100644 --- a/modules/io/tests/test_mmcif_info.cc +++ b/modules/io/tests/test_mmcif_info.cc @@ -109,11 +109,13 @@ BOOST_AUTO_TEST_CASE(mmcif_info_biounit) MMCifInfoBioUnit bu = MMCifInfoBioUnit(); bu.SetDetails("author_defined_assembly"); + bu.SetMethodDetails("PISA"); bu.SetID("1"); bu.AddChain("B"); bu.AddChain("A"); BOOST_CHECK(bu.GetDetails() == "author_defined_assembly"); + BOOST_CHECK(bu.GetMethodDetails() == "PISA"); BOOST_CHECK(bu.GetChainList().back() == "A"); std::vector<std::pair<int, int> > tr = bu.GetChainIntervalList(); BOOST_CHECK(tr[0].first == 0); diff --git a/modules/io/tests/test_mmcif_reader.cc b/modules/io/tests/test_mmcif_reader.cc index 0b9e94b58..6f6866622 100644 --- a/modules/io/tests/test_mmcif_reader.cc +++ b/modules/io/tests/test_mmcif_reader.cc @@ -1266,6 +1266,7 @@ BOOST_AUTO_TEST_CASE(mmcif_testreader) BOOST_CHECK(mmcif_p.GetInfo().GetMethod().str() == "Deep-fry"); BOOST_CHECK(mmcif_p.GetInfo().GetBioUnits().back().GetDetails() == "author_defined_assembly"); + BOOST_CHECK(mmcif_p.GetInfo().GetBioUnits().back().GetMethodDetails() == "?"); BOOST_CHECK(mmcif_p.GetInfo().GetBioUnits().back().GetID() == "2"); BOOST_CHECK(mmcif_p.GetInfo().GetBioUnits().back().GetChainList().back() == "F"); -- GitLab