diff --git a/modules/io/pymod/export_mmcif_io.cc b/modules/io/pymod/export_mmcif_io.cc index bddfecc1b72ac81cf466cd0cad885b2125899710..ca7b1410ae584a142231d31e406690e0a72a5f00 100644 --- a/modules/io/pymod/export_mmcif_io.cc +++ b/modules/io/pymod/export_mmcif_io.cc @@ -299,37 +299,37 @@ void export_mmcif_io() .def(vector_indexing_suite<std::vector<MMCifInfoTransOpPtrList >, true >()) ; class_<MMCifInfoStructRef, MMCifInfoStructRefPtr>("MMCifInfoStructRef", no_init) - .add_property("id", make_function(&MMCifInfoStructRef::GetID, - return_value_policy<copy_const_reference>())) - .add_property("db_name", make_function(&MMCifInfoStructRef::GetDBName, - return_value_policy<copy_const_reference>())) - .add_property("db_id", make_function(&MMCifInfoStructRef::GetDBID, - return_value_policy<copy_const_reference>())) - .add_property("entity_id", make_function(&MMCifInfoStructRef::GetEntityID, - return_value_policy<copy_const_reference>())) - .add_property("db_access", make_function(&MMCifInfoStructRef::GetDBAccess, - return_value_policy<copy_const_reference>())) - .def("GetAlignedSeq", &MMCifInfoStructRef::GetAlignedSeq, arg("align_id")) - .def("GetAlignedSeqs", &MMCifInfoStructRef::GetAlignedSeqs) - .add_property("aligned_seqs", &MMCifInfoStructRef::GetAlignedSeqs) + .add_property("id", make_function(&MMCifInfoStructRef::GetID, + return_value_policy<copy_const_reference>())) + .add_property("db_name", make_function(&MMCifInfoStructRef::GetDBName, + return_value_policy<copy_const_reference>())) + .add_property("db_id", make_function(&MMCifInfoStructRef::GetDBID, + return_value_policy<copy_const_reference>())) + .add_property("entity_id", make_function(&MMCifInfoStructRef::GetEntityID, + return_value_policy<copy_const_reference>())) + .add_property("db_access", make_function(&MMCifInfoStructRef::GetDBAccess, + return_value_policy<copy_const_reference>())) + .def("GetAlignedSeq", &MMCifInfoStructRef::GetAlignedSeq, arg("align_id")) + .def("GetAlignedSeqs", &MMCifInfoStructRef::GetAlignedSeqs) + .add_property("aligned_seqs", &MMCifInfoStructRef::GetAlignedSeqs) ; class_<MMCifInfoStructRefSeq, MMCifInfoStructRefSeqPtr>("MMCifInfoStructRefSeq", no_init) - .add_property("align_id", make_function(&MMCifInfoStructRefSeq::GetID, - return_value_policy<copy_const_reference>())) - .add_property("chain_name", make_function(&MMCifInfoStructRefSeq::GetChainName, - return_value_policy<copy_const_reference>())) - .add_property("seq_begin", &MMCifInfoStructRefSeq::GetSeqBegin) - .add_property("seq_end", &MMCifInfoStructRefSeq::GetSeqEnd) - .add_property("db_begin", &MMCifInfoStructRefSeq::GetDBBegin) - .add_property("db_end", &MMCifInfoStructRefSeq::GetDBEnd) - .add_property("difs", make_function(&MMCifInfoStructRefSeq::GetDifs, - return_value_policy<copy_const_reference>())) + .add_property("align_id", make_function(&MMCifInfoStructRefSeq::GetID, + return_value_policy<copy_const_reference>())) + .add_property("chain_name", make_function(&MMCifInfoStructRefSeq::GetChainName, + return_value_policy<copy_const_reference>())) + .add_property("seq_begin", &MMCifInfoStructRefSeq::GetSeqBegin) + .add_property("seq_end", &MMCifInfoStructRefSeq::GetSeqEnd) + .add_property("db_begin", &MMCifInfoStructRefSeq::GetDBBegin) + .add_property("db_end", &MMCifInfoStructRefSeq::GetDBEnd) + .add_property("difs", make_function(&MMCifInfoStructRefSeq::GetDifs, + return_value_policy<copy_const_reference>())) ; class_<MMCifInfoStructRefSeqDif, - MMCifInfoStructRefSeqDifPtr>("MMCifInfoStructRefSeqDif", no_init) - .add_property("details", make_function(&MMCifInfoStructRefSeqDif::GetDetails, - return_value_policy<copy_const_reference>())) - .add_property("seq_rnum", &MMCifInfoStructRefSeqDif::GetSeqRNum) + MMCifInfoStructRefSeqDifPtr>("MMCifInfoStructRefSeqDif", no_init) + .add_property("details", make_function(&MMCifInfoStructRefSeqDif::GetDetails, + return_value_policy<copy_const_reference>())) + .add_property("seq_rnum", &MMCifInfoStructRefSeqDif::GetSeqRNum) .add_property("db_rnum", make_function(&MMCifInfoStructRefSeqDif::GetDBRNum, return_value_policy<copy_const_reference>())) ; @@ -379,13 +379,13 @@ void export_mmcif_io() ; class_<MMCifInfoStructRefs>("MMCifInfoStructRefs", init<>()) - .def(vector_indexing_suite<MMCifInfoStructRefs, true>()) + .def(vector_indexing_suite<MMCifInfoStructRefs, true>()) ; class_<MMCifInfoStructRefSeqs>("MMCifInfoStructRefSeqs", init<>()) - .def(vector_indexing_suite<MMCifInfoStructRefSeqs, true>()) + .def(vector_indexing_suite<MMCifInfoStructRefSeqs, true>()) ; class_<MMCifInfoStructRefSeqDifs>("MMCifInfoStructRefSeqDifs", init<>()) - .def(vector_indexing_suite<MMCifInfoStructRefSeqDifs, true>()) + .def(vector_indexing_suite<MMCifInfoStructRefSeqDifs, true>()) ; class_<std::vector<MMCifInfoBioUnit> >("MMCifInfoBioUnitList", init<>()) .def(vector_indexing_suite<std::vector<MMCifInfoBioUnit> >()) @@ -561,7 +561,7 @@ void export_mmcif_io() .add_property("struct_details", &MMCifInfo::GetStructDetails, &MMCifInfo::SetStructDetails) .add_property("struct_refs", make_function(&MMCifInfo::GetStructRefs, - return_value_policy<copy_const_reference>())) + return_value_policy<copy_const_reference>())) .add_property("obsolete", &MMCifInfo::GetObsoleteInfo, &MMCifInfo::SetObsoleteInfo) .add_property("revisions", &MMCifInfo::GetRevisions) diff --git a/modules/io/src/mol/mmcif_info.cc b/modules/io/src/mol/mmcif_info.cc index f2c0bf7545634744acde58f727d06b350e885335..77ae604029e8a0b71a00a3c0b48fec6972c5bf61 100644 --- a/modules/io/src/mol/mmcif_info.cc +++ b/modules/io/src/mol/mmcif_info.cc @@ -195,18 +195,18 @@ void MMCifInfoBioUnit::Merge(MMCifInfoBioUnit& from) MMCifInfoStructRefSeqPtr MMCifInfoStructRef::AddAlignedSeq(const String& aid, const String& chain_name, - int seq_begin, int seq_end, int db_begin, - int db_end) + int seq_begin, int seq_end, int db_begin, + int db_end) { - std::map<String, MMCifInfoStructRefSeqPtr>::const_iterator i=seqs_.find(aid); - if (i!=seqs_.end()) { - throw IOException("duplicate align_id for struct_ref '"+id_+"'"); - } - MMCifInfoStructRefSeqPtr p(new MMCifInfoStructRefSeq(aid, chain_name, - seq_begin, seq_end, - db_begin, db_end)); - seqs_[aid]=p; - return p; + std::map<String, MMCifInfoStructRefSeqPtr>::const_iterator i=seqs_.find(aid); + if (i!=seqs_.end()) { + throw IOException("duplicate align_id for struct_ref '"+id_+"'"); + } + MMCifInfoStructRefSeqPtr p(new MMCifInfoStructRefSeq(aid, chain_name, + seq_begin, seq_end, + db_begin, db_end)); + seqs_[aid]=p; + return p; } @@ -221,10 +221,10 @@ MMCifInfoStructRef::GetAlignedSeq(const String& aid) const MMCifInfoStructRefSeqDifPtr MMCifInfoStructRefSeq::AddDif(int seq_rnum, const String& db_rnum, const String& details) { - MMCifInfoStructRefSeqDifPtr d(new MMCifInfoStructRefSeqDif(seq_rnum, db_rnum, - details)); - difs_.push_back(d); - return d; + MMCifInfoStructRefSeqDifPtr d(new MMCifInfoStructRefSeqDif(seq_rnum, db_rnum, + details)); + difs_.push_back(d); + return d; } void MMCifInfo::AddEntityBranchLink(String chain_name, diff --git a/modules/io/src/mol/mmcif_info.hh b/modules/io/src/mol/mmcif_info.hh index 8cfb031cb9a7d3466cfd176ec66f576ad8c91b3f..73d3c25d2b69feafb098ed4f0d1dbd00add0657a 100644 --- a/modules/io/src/mol/mmcif_info.hh +++ b/modules/io/src/mol/mmcif_info.hh @@ -846,47 +846,47 @@ typedef std::vector<MMCifInfoStructRefSeqDifPtr> MMCifInfoStructRefSeqDifs; class DLLEXPORT_OST_IO MMCifInfoStructRef { public: MMCifInfoStructRef(const String& id, const String& ent_id, - const String& db_name, - const String& db_ident, const String& db_access): - id_(id), ent_id_(ent_id), db_name_(db_name), db_ident_(db_ident), - db_access_(db_access) - { } + const String& db_name, + const String& db_ident, const String& db_access): + id_(id), ent_id_(ent_id), db_name_(db_name), db_ident_(db_ident), + db_access_(db_access) + { } const String& GetID() const { return id_; } const String& GetDBName() const { return db_name_; } const String& GetDBID() const { return db_ident_; } const String& GetEntityID() const { return ent_id_; } const String& GetDBAccess() const { return db_access_; } - MMCifInfoStructRefSeqPtr AddAlignedSeq(const String& align_id, - const String& chain_name, int seq_begin, - int seq_end, int db_begin, int db_end); + MMCifInfoStructRefSeqPtr AddAlignedSeq(const String& align_id, + const String& chain_name, int seq_begin, + int seq_end, int db_begin, int db_end); MMCifInfoStructRefSeqPtr GetAlignedSeq(const String& align_id) const; MMCifInfoStructRefSeqs GetAlignedSeqs() const - { - MMCifInfoStructRefSeqs seqs; - seqs.reserve(seqs_.size()); - for (std::map<String, MMCifInfoStructRefSeqPtr>::const_iterator - i=seqs_.begin(), e=seqs_.end(); i!=e; ++i) { - seqs.push_back(i->second); - } - return seqs; - } + { + MMCifInfoStructRefSeqs seqs; + seqs.reserve(seqs_.size()); + for (std::map<String, MMCifInfoStructRefSeqPtr>::const_iterator + i=seqs_.begin(), e=seqs_.end(); i!=e; ++i) { + seqs.push_back(i->second); + } + return seqs; + } private: - String id_; - String ent_id_; - String db_name_; - String db_ident_; - String db_access_; - std::map<String, MMCifInfoStructRefSeqPtr> seqs_; + String id_; + String ent_id_; + String db_name_; + String db_ident_; + String db_access_; + std::map<String, MMCifInfoStructRefSeqPtr> seqs_; }; class DLLEXPORT_OST_IO MMCifInfoStructRefSeq { public: - MMCifInfoStructRefSeq(const String& align_id, const String& chain_name, - int seq_begin, int seq_end, - int db_begin, int db_end): - id_(align_id), chain_name_(chain_name), - seq_begin_(seq_begin), seq_end_(seq_end), db_begin_(db_begin), db_end_(db_end) - { } + MMCifInfoStructRefSeq(const String& align_id, const String& chain_name, + int seq_begin, int seq_end, + int db_begin, int db_end): + id_(align_id), chain_name_(chain_name), + seq_begin_(seq_begin), seq_end_(seq_end), db_begin_(db_begin), db_end_(db_end) + { } const String& GetID() const { return id_; } const String& GetChainName() const { return chain_name_; } @@ -894,30 +894,30 @@ public: int GetSeqEnd() const { return seq_end_; } int GetDBBegin() const { return db_begin_; } int GetDBEnd() const { return db_end_; } - MMCifInfoStructRefSeqDifPtr AddDif(int seq_num, const String& db_rnum, + MMCifInfoStructRefSeqDifPtr AddDif(int seq_num, const String& db_rnum, const String& details); const std::vector<MMCifInfoStructRefSeqDifPtr>& GetDifs() const { return difs_; } private: - String id_; - String chain_name_; - int seq_begin_; - int seq_end_; - int db_begin_; - int db_end_; - std::vector<MMCifInfoStructRefSeqDifPtr> difs_; + String id_; + String chain_name_; + int seq_begin_; + int seq_end_; + int db_begin_; + int db_end_; + std::vector<MMCifInfoStructRefSeqDifPtr> difs_; }; class DLLEXPORT_OST_IO MMCifInfoStructRefSeqDif { public: - MMCifInfoStructRefSeqDif(int seq_rnum, const String& db_rnum, const String& details): - seq_rnum_(seq_rnum), db_rnum_(db_rnum), details_(details) {} - int GetSeqRNum() const { return seq_rnum_;} - const String& GetDBRNum() const { return db_rnum_; } - const String& GetDetails() const { return details_; } + MMCifInfoStructRefSeqDif(int seq_rnum, const String& db_rnum, const String& details): + seq_rnum_(seq_rnum), db_rnum_(db_rnum), details_(details) {} + int GetSeqRNum() const { return seq_rnum_;} + const String& GetDBRNum() const { return db_rnum_; } + const String& GetDetails() const { return details_; } private: - int seq_rnum_; - String db_rnum_; - String details_; + int seq_rnum_; + String db_rnum_; + String details_; }; /// \brief Store information on branched structures (oligosaccharides) diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc index 6f0293a2f0aa46e0e2a08380551012b770de9cd6..f4e2057b0b184fde25476d4ea0c840312fad7d09 100644 --- a/modules/io/src/mol/mmcif_reader.cc +++ b/modules/io/src/mol/mmcif_reader.cc @@ -33,7 +33,7 @@ namespace ost { namespace io { bool is_undef(StringRef value) { - return value.size()==1 && (value[0]=='?' || value[0]=='.'); + return value.size()==1 && (value[0]=='?' || value[0]=='.'); } MMCifReader::MMCifReader(std::istream& stream, mol::EntityHandle& ent_handle, @@ -308,7 +308,7 @@ bool MMCifReader::OnBeginLoop(const StarLoopDesc& header) indices_[SR_DB_ACCESS]=header.GetIndex("pdbx_db_accession"); cat_available = true; } else if (header.GetCategory() == "struct_ref_seq") { - category_ = STRUCT_REF_SEQ; + category_ = STRUCT_REF_SEQ; this->TryStoreIdx(SRS_ALIGN_ID, "align_id", header); this->TryStoreIdx(SRS_STRUCT_REF_ID, "ref_id", header); this->TryStoreIdx(SRS_ENT_ALIGN_BEG, "seq_align_beg", header); @@ -1632,17 +1632,17 @@ void MMCifReader::AssignSecStructure(mol::EntityHandle ent) void MMCifReader::ParseStructRef(const std::vector<StringRef>& columns) { - String ent_id=columns[indices_[SR_ENTITY_ID]].str(); - String db_name=columns[indices_[SR_DB_NAME]].str(); - String db_code=columns[indices_[SR_DB_CODE]].str(); - String id=columns[indices_[SR_ID]].str(); - String db_access; - if (indices_[SR_DB_ACCESS]!=-1) { - db_access=columns[indices_[SR_DB_ACCESS]].str(); - } - MMCifInfoStructRefPtr sr(new MMCifInfoStructRef(id, ent_id, db_name, - db_code, db_access)); - struct_refs_.push_back(sr); + String ent_id=columns[indices_[SR_ENTITY_ID]].str(); + String db_name=columns[indices_[SR_DB_NAME]].str(); + String db_code=columns[indices_[SR_DB_CODE]].str(); + String id=columns[indices_[SR_ID]].str(); + String db_access; + if (indices_[SR_DB_ACCESS]!=-1) { + db_access=columns[indices_[SR_DB_ACCESS]].str(); + } + MMCifInfoStructRefPtr sr(new MMCifInfoStructRef(id, ent_id, db_name, + db_code, db_access)); + struct_refs_.push_back(sr); } void MMCifReader::ParseStructRefSeq(const std::vector<StringRef>& columns) @@ -1651,43 +1651,43 @@ void MMCifReader::ParseStructRefSeq(const std::vector<StringRef>& columns) String sr_id=columns[indices_[SRS_STRUCT_REF_ID]].str(); String chain_name; if (indices_[SRS_PDBX_STRAND_ID]!=-1) { - chain_name=columns[indices_[SRS_PDBX_STRAND_ID]].str(); + chain_name=columns[indices_[SRS_PDBX_STRAND_ID]].str(); } std::pair<bool,int> dbbeg=this->TryGetInt(columns[indices_[SRS_DB_ALIGN_BEG]], - "_struct_ref_seq.db_align_beg", - profile_.fault_tolerant); + "_struct_ref_seq.db_align_beg", + profile_.fault_tolerant); std::pair<bool,int> dbend=this->TryGetInt(columns[indices_[SRS_DB_ALIGN_END]], - "_struct_ref_seq.db_align_end", - profile_.fault_tolerant); + "_struct_ref_seq.db_align_end", + profile_.fault_tolerant); std::pair<bool,int> entbeg=this->TryGetInt(columns[indices_[SRS_ENT_ALIGN_BEG]], - "_struct_ref_seq.seq_align_beg", - profile_.fault_tolerant); + "_struct_ref_seq.seq_align_beg", + profile_.fault_tolerant); std::pair<bool,int> entend=this->TryGetInt(columns[indices_[SRS_ENT_ALIGN_END]], - "_struct_ref_seq.seq_align_END", - profile_.fault_tolerant); + "_struct_ref_seq.seq_align_END", + profile_.fault_tolerant); if (!(dbbeg.first && dbend.first && entbeg.first && entend.first)) { - return; + return; } bool found=false; for (MMCifInfoStructRefs::iterator i=struct_refs_.begin(), - e=struct_refs_.end(); i!=e; ++i) { - if ((*i)->GetID()==sr_id) { - (*i)->AddAlignedSeq(aln_id, chain_name, entbeg.second, entend.second, - dbbeg.second, dbend.second); - found=true; - break; - } + e=struct_refs_.end(); i!=e; ++i) { + if ((*i)->GetID()==sr_id) { + (*i)->AddAlignedSeq(aln_id, chain_name, entbeg.second, entend.second, + dbbeg.second, dbend.second); + found=true; + break; + } } if (!found) { - if (profile_.fault_tolerant) { - LOG_ERROR("struct_ref_seq.ref_id points to inexistent struct_ref '" - << sr_id << "'"); - return; - } - std::stringstream ss; - ss << "struct_ref_seq.ref_id points to inexistent struct_ref '"; - ss << sr_id << "'"; - throw IOException(ss.str()); + if (profile_.fault_tolerant) { + LOG_ERROR("struct_ref_seq.ref_id points to inexistent struct_ref '" + << sr_id << "'"); + return; + } + std::stringstream ss; + ss << "struct_ref_seq.ref_id points to inexistent struct_ref '"; + ss << sr_id << "'"; + throw IOException(ss.str()); } } @@ -1716,27 +1716,27 @@ void MMCifReader::ParseStructRefSeqDif(const std::vector<StringRef>& columns) } String details; if (indices_[SRSD_DETAILS]!=-1) { - details=columns[indices_[SRSD_DETAILS]].str(); + details=columns[indices_[SRSD_DETAILS]].str(); } bool found=false; for (MMCifInfoStructRefs::iterator i=struct_refs_.begin(), - e=struct_refs_.end(); i!=e; ++i) { - if (MMCifInfoStructRefSeqPtr s=(*i)->GetAlignedSeq(aln_id)) { - s->AddDif(seq_rnum.second, db_rnum, details); - found=true; - break; - } + e=struct_refs_.end(); i!=e; ++i) { + if (MMCifInfoStructRefSeqPtr s=(*i)->GetAlignedSeq(aln_id)) { + s->AddDif(seq_rnum.second, db_rnum, details); + found=true; + break; + } } if (!found) { - if (profile_.fault_tolerant) { - LOG_ERROR("struct_ref_seq_dif.align_id points to inexistent " - "struct_ref_seq '" << aln_id << "'"); - return; - } - std::stringstream ss; - ss << "struct_ref_seq.ref_id points to inexistent struct_ref '"; - ss << aln_id << "'"; - throw IOException(ss.str()); + if (profile_.fault_tolerant) { + LOG_ERROR("struct_ref_seq_dif.align_id points to inexistent " + "struct_ref_seq '" << aln_id << "'"); + return; + } + std::stringstream ss; + ss << "struct_ref_seq.ref_id points to inexistent struct_ref '"; + ss << aln_id << "'"; + throw IOException(ss.str()); } } diff --git a/modules/io/src/mol/mmcif_reader.hh b/modules/io/src/mol/mmcif_reader.hh index cc61e9ca3eac72cf3c30d984d13d697524568611..23cfc2f4bc50c66bc4312680e1fbddeb6d77e879 100644 --- a/modules/io/src/mol/mmcif_reader.hh +++ b/modules/io/src/mol/mmcif_reader.hh @@ -203,7 +203,7 @@ protected: /// \param columns data row void ParseCitation(const std::vector<StringRef>& columns); - const MMCifInfoStructRefs& GetStructRefs() const { return struct_refs_; } + const MMCifInfoStructRefs& GetStructRefs() const { return struct_refs_; } /// \brief Fetch mmCIF citation_author information /// @@ -423,13 +423,13 @@ private: // \enum items of the struct_ref category typedef enum { - SR_ENTITY_ID, - SR_ID, - SR_DB_CODE, - SR_DB_NAME, - SR_DB_ACCESS - } StructRefItems; - + SR_ENTITY_ID, + SR_ID, + SR_DB_CODE, + SR_DB_NAME, + SR_DB_ACCESS + } StructRefItems; + /// \enum items of the struct_ref_seq category typedef enum { SRS_ALIGN_ID, diff --git a/modules/io/tests/test_mmcif_reader.cc b/modules/io/tests/test_mmcif_reader.cc index 4670b815a720cffb4bd61a0c38dd9313e5acc130..52d3a2c002fe7ba4dbcd3fda1b2dba9bbdf9a173 100644 --- a/modules/io/tests/test_mmcif_reader.cc +++ b/modules/io/tests/test_mmcif_reader.cc @@ -1098,7 +1098,7 @@ BOOST_AUTO_TEST_CASE(mmcif_parseatomident) columns.push_back(StringRef("30.691", 6)); // Cartn_y columns.push_back(StringRef("11.795", 6)); // Cartn_z BOOST_CHECK_EQUAL(tmmcif_p.ParseAtomIdent(columns, auth_chain_name, - cif_chain_name, res_name, + cif_chain_name, res_name, resnum, valid_res_num, atom_name, alt_loc), true); columns.pop_back(); @@ -1118,7 +1118,7 @@ BOOST_AUTO_TEST_CASE(mmcif_parseatomident) columns.push_back(StringRef("30.691", 6)); // Cartn_y columns.push_back(StringRef("11.795", 6)); // Cartn_z BOOST_CHECK_EQUAL(tmmcif_p.ParseAtomIdent(columns, auth_chain_name, - cif_chain_name, res_name, + cif_chain_name, res_name, resnum, valid_res_num, atom_name, alt_loc), false); }