diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst index a887323546f8b9687ec9c6e0bde909903261d2d7..837614d183facfc65111efacf1874d77ef788b00 100644 --- a/modules/io/doc/mmcif.rst +++ b/modules/io/doc/mmcif.rst @@ -499,7 +499,7 @@ of the annotation available. Chains involved in this bio unit. If not provided, resembles an empty list. Also available as :meth:`GetChainList`. May also be modified by - :meth:`AddChain`. + :meth:`AddChain` or :meth:`SetChainList`. .. attribute:: operations @@ -529,6 +529,13 @@ of the annotation available. See :attr:`chains` + .. method:: SetChainList(chains) + + :param chains: List of chain names. + :type chains: :class:`~ost.StringList` + + See :attr:`chains` + .. method:: AddChain(chain name) See :attr:`chains` @@ -567,7 +574,7 @@ of the annotation available. :param asu: Asymmetric unit to work on. Should be created from a mmCIF file. - :type asu: :class:`~ost.mol.EntityHandle>` + :type asu: :class:`~ost.mol.EntityHandle` :param seqres: If set to a valid sequence list, the length of the seqres records will be used to determine if a certain chain has the minimally required length. @@ -948,3 +955,6 @@ of the annotation available. .. LocalWords: auth GetMMCifPDBChainTr AddPDBCMMCifhainTr GetPDBMMCifChainTr .. LocalWords: GetRevisions AddRevision SetRevisionsDateOriginal GetSize .. LocalWords: GetNum num GetStatus GetLastDate GetFirstRelease storable +.. LocalWords: SetChainList MMCifInfoTransOp ChainTypes MMCifInfoStructRef +.. LocalWords: MMCifInfoRevisions bool difs MMCifInfoStructRefSeqDif rnum +.. LocalWords: SetDateOriginal GetDateOriginal yyyy diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index 78cd7e124f08460009e4f5b98432080e8422ae95..5f226e9fef82c3409d94e31ced923b4456dc4393 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -176,6 +176,7 @@ void export_mmcif_io() .def("SetDetails", &MMCifInfoBioUnit::SetDetails) .def("GetDetails", &MMCifInfoBioUnit::GetDetails) .def("AddChain", &MMCifInfoBioUnit::AddChain) + .def("SetChainList", &MMCifInfoBioUnit::SetChainList) .def("GetChainList", make_function(&MMCifInfoBioUnit::GetChainList, return_value_policy<copy_const_reference>())) .def("AddOperations", &MMCifInfoBioUnit::AddOperations) diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index f567af0520381f6b726be63046235e2dd0b9a87a..8eef288ef571a1ae71297214d958722a84110a1b 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -263,6 +263,12 @@ public: /// /// \param chain chain name void AddChain(String chain) { chains_.push_back(chain); } + + /// \brief Set a vector of chain names + /// + /// \param chain chain name + void SetChainList(std::vector<String> chains) { chains_ = chains; } + /// \brief Get vector of chain names /// /// \return chains diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc index 33e71d4e3daeced0ddf26484cdfb4c0dfe9bbccf..91d46cb9b86646add1832a8ea972b6c316a3cba7 100644 --- a/modules/io/src/mol/mmcif_reader.cc +++ b/modules/io/src/mol/mmcif_reader.cc @@ -981,14 +981,13 @@ std::vector<std::vector<String> > MMCifReader::UnPackOperExperession(StringRef e void MMCifReader::ParsePdbxStructAssemblyGen(const std::vector<StringRef>& columns) { MMCifBioUAssembly assembly; - assembly.biounit = MMCifInfoBioUnit(); - assembly.biounit.SetID(columns[indices_[ASSEMBLY_ID]].str()); + assembly.biounit_id = columns[indices_[ASSEMBLY_ID]].str(); std::vector<StringRef> tmp_chains=columns[indices_[ASYM_ID_LIST]].split(','); std::vector<StringRef>::const_iterator tc_it; for (tc_it = tmp_chains.begin(); tc_it != tmp_chains.end(); ++tc_it) { - assembly.biounit.AddChain(tc_it->str()); + assembly.chains.push_back(tc_it->str()); } assembly.operations = @@ -1620,19 +1619,22 @@ void MMCifReader::OnEndData() std::vector<MMCifInfoTransOpPtr> operations = info_.GetOperations(); info_.SetStructRefs(struct_refs_); std::vector<MMCifInfoTransOpPtr>::const_iterator buop_it; + MMCifInfoBioUnit biounit; for (bua_it = bu_assemblies_.begin(); bua_it != bu_assemblies_.end(); ++bua_it) { + biounit = MMCifInfoBioUnit(); // pair with pdbx_struct_assembly entry - buom_it = bu_origin_map_.find(bua_it->biounit.GetID()); + buom_it = bu_origin_map_.find(bua_it->biounit_id); if (buom_it == bu_origin_map_.end()) { throw IOException(this->FormatDiagnostic(STAR_DIAG_ERROR, "No pdbx_struct_assembly.id '"+ - bua_it->biounit.GetID() + + bua_it->biounit_id + "' found as requested by pdbx_struct_assembly_gen.")); } - bua_it->biounit.SetDetails(buom_it->second); - bua_it->biounit.SetID(buom_it->first); + biounit.SetDetails(buom_it->second); + biounit.SetID(buom_it->first); + biounit.SetChainList(bua_it->chains); // pair with pdbx_struct_oper_list for (aol_it = bua_it->operations.begin(); @@ -1657,9 +1659,9 @@ void MMCifReader::OnEndData() "' found as requested by pdbx_struct_assembly_gen.")); } } - bua_it->biounit.AddOperations(operation_list); + biounit.AddOperations(operation_list); } - info_.AddBioUnit(bua_it->biounit); + info_.AddBioUnit(biounit); } bu_assemblies_.clear(); diff --git a/modules/io/src/mol/mmcif_reader.hh b/modules/io/src/mol/mmcif_reader.hh index b8f6daed068fd5c96293d4d8e6442d24a74b3e0b..d91cf340355be48f58664a4ada5e02966365e931 100644 --- a/modules/io/src/mol/mmcif_reader.hh +++ b/modules/io/src/mol/mmcif_reader.hh @@ -559,9 +559,11 @@ private: /// \struct assembly information typedef struct { - MMCifInfoBioUnit biounit; + String biounit_id; ///< identifier for the bu + std::vector<String> chains; ///< chains affected by + /// this operations std::vector<std::vector<String> > operations; ///< list of links to - /// MMCifBioUOperation + /// MMCifBioUOperation } MMCifBioUAssembly; typedef std::vector<MMCifBioUAssembly> MMCifBioUAssemblyVector; diff --git a/modules/io/tests/test_io_mmcif.py b/modules/io/tests/test_io_mmcif.py index 9b5481d6d821ccc54c133961d4128fa2654ed915..f32150f69193ebf3301e06d94d990175b51e2841 100644 --- a/modules/io/tests/test_io_mmcif.py +++ b/modules/io/tests/test_io_mmcif.py @@ -71,6 +71,13 @@ class TestMMCifInfo(unittest.TestCase): b.AddChain('A') cl = b.GetChainList() self.assertEquals(cl[0], 'A') + s = ost.StringList() + s.append('B') + s.append('C') + b.SetChainList(s) + cl = b.GetChainList() + self.assertEquals(cl[0], 'B') + self.assertEquals(cl[1], 'C') i = io.MMCifInfo() i.AddBioUnit(b) diff --git a/modules/io/tests/test_mmcif_info.cc b/modules/io/tests/test_mmcif_info.cc index 3f3e21baf4b8a9e3f10b8f65380338668015bfd3..1719e914075554b3c6b42d7893704236516aca9d 100644 --- a/modules/io/tests/test_mmcif_info.cc +++ b/modules/io/tests/test_mmcif_info.cc @@ -114,6 +114,11 @@ BOOST_AUTO_TEST_CASE(mmcif_info_biounit) BOOST_CHECK(bu.GetDetails() == "author_defined_assembly"); BOOST_CHECK(bu.GetChainList().back() == "A"); + std::vector<String> chains; + chains.push_back("B"); + bu.SetChainList(chains); + BOOST_CHECK(bu.GetChainList().back() == "B"); + MMCifInfo info = MMCifInfo(); info.AddBioUnit(bu); std::vector<MMCifInfoBioUnit> biounits = info.GetBioUnits();