Skip to content
Snippets Groups Projects
Commit d39bdc88 authored by Bienchen's avatar Bienchen
Browse files

Added translation from mmCIF chain name to traditional PDB chain name.

parent 6630bf40
Branches
Tags
No related merge requests found
......@@ -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
......@@ -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,
......
......@@ -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
......
......@@ -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_;
};
......
......@@ -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
......
......@@ -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.");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment