diff --git a/modules/io/doc/mmcif.rst b/modules/io/doc/mmcif.rst index 855ed0ea208cfd8cd77ef537edd736144f6260ff..758862eeb797c966b2336edd499ba00a930b065a 100644 --- a/modules/io/doc/mmcif.rst +++ b/modules/io/doc/mmcif.rst @@ -160,6 +160,25 @@ of the annotation available. .. method:: GetStructDetails() + .. method:: AddMMCifPDBChainTr(cif_chain_id, pdb_chain_id) + + Set up a translation for a certain mmCIF chain name to the traditional PDB + chain name. + + :param cif_chain_id: atom_site.label_asym_id + :type cif_chain_id: :class:`str` + :param pdb_chain_id: atom_site.auth_asym_id + :type pdb_chain_id: :class:`str` + + .. method:: GetMMCifPDBChainTr(cif_chain_id) + + Get the translation of a certain mmCIF chain name to the traditional PDB + chain name. + + :param cif_chain_id: atom_site.label_asym_id + :type cif_chain_id: :class:`str` + :returns: atom_site.auth_asym_id as :class:`str` + .. class:: MMCifInfoCitation This stores citation information from an input file. @@ -793,4 +812,5 @@ of the annotation available. .. LocalWords: cas isbn pubmed asu seqres conop ConnectAll casp COMPND OBSLTE .. LocalWords: SPRSDE pdb func autofunction exptl attr pdbx oper conf spr dif -.. LocalWords: biounits biounit uniprot UNP seqs +.. LocalWords: biounits biounit uniprot UNP seqs AddMMCifPDBChainTr cif asym +.. LocalWords: auth GetMMCifPDBChainTr diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index 6654393be01fefaefa346b9f86bcdef5f63e9c7e..f94c257e647a6499992dea5172169a029ddd8d85 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -280,6 +280,8 @@ void export_mmcif_io() .def("GetStructDetails", &MMCifInfo::GetStructDetails) .def("SetObsoleteInfo", &MMCifInfo::SetObsoleteInfo) .def("GetObsoleteInfo", &MMCifInfo::GetObsoleteInfo) + .def("AddMMCifPDBChainTr", &MMCifInfo::AddMMCifPDBChainTr) + .def("GetMMCifPDBChainTr", &MMCifInfo::GetMMCifPDBChainTr) .add_property("citations", make_function(&MMCifInfo::GetCitations, return_value_policy<copy_const_reference>())) .add_property("biounits", make_function(&MMCifInfo::GetBioUnits, diff --git a/modules/io/src/mol/mmcif_info.cc b/modules/io/src/mol/mmcif_info.cc index c8565a2e809ff1f84b182b9f73e4cacd1866c509..140676fe6c409c03e2da8a427c2a502da2a936c3 100644 --- a/modules/io/src/mol/mmcif_info.cc +++ b/modules/io/src/mol/mmcif_info.cc @@ -22,6 +22,24 @@ namespace ost { namespace io { +void MMCifInfo::AddMMCifPDBChainTr(String cif, String pdb) +{ + std::map<String, String>::iterator tr_it = cif_2_pdb_chain_id_.find(cif); + if (tr_it != cif_2_pdb_chain_id_.end()) { + throw IOException("mmCIF chain id '"+ cif +"' is already mapped to '"+ + tr_it->second+"'."); + } + cif_2_pdb_chain_id_.insert(std::pair<String, String>(cif, pdb)); +} + +String MMCifInfo::GetMMCifPDBChainTr(String cif) const +{ + std::map<String, String>::const_iterator tr_it = + cif_2_pdb_chain_id_.find(cif); + if (tr_it == cif_2_pdb_chain_id_.end()) { return ""; } + return tr_it->second; +} + void MMCifInfo::AddAuthorsToCitation(StringRef id, std::vector<String> list) { // find citation diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index b240e5a1c86eedaddd76de2ba71bbe009b590f3d..68aa79befa08c11015178075d7daceea3d86c051 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -771,6 +771,18 @@ public: /// \return experiment resolution Real GetResolution() const { return resolution_; } + /// \brief Add a new mmCIF/ PDB chain name tuple. + /// + /// \param cif chain name as used by the mmCIF file (label_asym_id) + /// \param pdb chain name as used in the PDB file (auth_asym_id) + void AddMMCifPDBChainTr(String cif, String pdb); + + /// \brief Get a PDB chain name for a CIF chain name + /// + /// \param cif chain name as used by the mmCIF file (label_asym_id) + /// \return chain name as used in the PDB file (auth_asym_id) + String GetMMCifPDBChainTr(String cif) const; + /// \brief Add a biounit /// /// \param bu biounit to be added @@ -848,6 +860,7 @@ private: std::vector<MMCifInfoBioUnit> biounits_; ///< list of biounits std::vector<MMCifInfoTransOpPtr> transops_; MMCifInfoStructRefs struct_refs_; + std::map<String, String> cif_2_pdb_chain_id_; }; diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc index 2bcdee810c013971aec9f1c9f631320bbfe719b6..6f35d4a2f206286578d20339fff710a1d0d1a2eb 100644 --- a/modules/io/src/mol/mmcif_reader.cc +++ b/modules/io/src/mol/mmcif_reader.cc @@ -500,6 +500,8 @@ void MMCifReader::ParseAndAddAtom(const std::vector<StringRef>& columns) // store entity id chain_id_pairs_.push_back(std::pair<mol::ChainHandle,String>(curr_chain_, columns[indices_[LABEL_ENTITY_ID]].str())); + // store mmCIF - PDB chain name mapping + info_.AddMMCifPDBChainTr(cif_chain_name, auth_chain_name); } assert(curr_chain_.IsValid()); } else if (chain_id_pairs_.back().second != // unit test diff --git a/modules/io/tests/test_mmcif_info.cc b/modules/io/tests/test_mmcif_info.cc index 3d26747976b618212b05d0416012ecc2b78f5fc5..d5a1ac1a465edbbe121d173b4167244adf804b27 100644 --- a/modules/io/tests/test_mmcif_info.cc +++ b/modules/io/tests/test_mmcif_info.cc @@ -202,7 +202,12 @@ BOOST_AUTO_TEST_CASE(mmcif_info) #else BOOST_CHECK_CLOSE(info.GetResolution(), 1.9f, 0.001f); #endif - + + info.AddMMCifPDBChainTr("A", "B"); + BOOST_CHECK_THROW(info.AddMMCifPDBChainTr("A", "B"), IOException); + BOOST_CHECK("B" == info.GetMMCifPDBChainTr("A")); + BOOST_CHECK("" == info.GetMMCifPDBChainTr("C")); + BOOST_MESSAGE(" done."); }