00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_MMCIF_INFO_HH
00020 #define OST_MMCIF_INFO_HH
00021
00022 #include <vector>
00023 #include <map>
00024 #include <boost/shared_ptr.hpp>
00025 #include <ost/seq/sequence_list.hh>
00026 #include <ost/geom/geom.hh>
00027 #include <ost/string_ref.hh>
00028 #include <ost/io/module_config.hh>
00029
00030 namespace ost { namespace io {
00031
00032 class DLLEXPORT_OST_IO MMCifInfoStructDetails {
00033 public:
00035 MMCifInfoStructDetails(): entry_id_(""), title_(""), casp_flag_('\0'),
00036 descriptor_(""), mass_(0.0), mass_method_(""), model_details_(""),
00037 model_type_details_("") {};
00038
00042 void SetEntryID(String id) { entry_id_ = id; }
00046 String GetEntryID() const { return entry_id_; }
00047
00051 void SetCASPFlag(char flag) { casp_flag_ = flag; }
00055 char GetCASPFlag() const { return casp_flag_; }
00056
00060 void SetDescriptor(String desc) { descriptor_ = desc; }
00064 String GetDescriptor() const { return descriptor_; }
00065
00069 void SetMass(Real mass) { mass_ = mass; }
00073 Real GetMass() const { return mass_; }
00074
00078 void SetMassMethod(String method) { mass_method_ = method; }
00082 String GetMassMethod() const { return mass_method_; }
00083
00087 void SetModelDetails(String desc) { model_details_ = desc; }
00091 String GetModelDetails() const { return model_details_; }
00092
00096 void SetModelTypeDetails(String desc) { model_type_details_ = desc; }
00100 String GetModelTypeDetails() const { return model_type_details_; }
00101
00105 void SetTitle(String title) { title_ = title; }
00109 String GetTitle() const { return title_; }
00110
00111 bool operator==(const MMCifInfoStructDetails& sd) const {
00112 if (this->entry_id_ != sd.entry_id_) {
00113 return false;
00114 }
00115 if (this->casp_flag_ != sd.casp_flag_) {
00116 return false;
00117 }
00118 if (this->descriptor_ != sd.descriptor_) {
00119 return false;
00120 }
00121 if (this->mass_ != sd.mass_) {
00122 return false;
00123 }
00124 if (this->mass_method_ != sd.mass_method_) {
00125 return false;
00126 }
00127 if (this->model_details_ != sd.model_details_) {
00128 return false;
00129 }
00130 if (this->model_type_details_ != sd.model_type_details_) {
00131 return false;
00132 }
00133 if (this->title_ != sd.title_) {
00134 return false;
00135 }
00136
00137 return true;
00138 }
00139
00140 bool operator!=(const MMCifInfoStructDetails& sd) const {
00141 return !this->operator == (sd);
00142 }
00143
00144 private:
00145 String entry_id_;
00146 String title_;
00147 char casp_flag_;
00148 String descriptor_;
00149 Real mass_;
00150 String mass_method_;
00151 String model_details_;
00152 String model_type_details_;
00153 };
00154
00155 class DLLEXPORT_OST_IO MMCifInfoTransOp {
00156 public:
00158 MMCifInfoTransOp(): id_(""), type_("")
00159 {
00160 translation_ = geom::Vec3();
00161 };
00162
00166 void SetID(String id) { id_ = id; }
00170 String GetID() const { return id_; }
00171
00175 void SetType(String type) { type_ = type; }
00179 String GetType() const { return type_; }
00180
00186 void SetVector(Real x, Real y, Real z)
00187 {
00188 translation_.SetX(x);
00189 translation_.SetY(y);
00190 translation_.SetZ(z);
00191 }
00195 geom::Vec3 GetVector() const { return translation_; }
00196
00208 void SetMatrix(Real i00, Real i01, Real i02,
00209 Real i10, Real i11, Real i12,
00210 Real i20, Real i21, Real i22)
00211 {
00212 rotation_ = geom::Mat3(i00,i01,i02, i10,i11,i12, i20,i21,i22);
00213 }
00217 geom::Mat3 GetMatrix() const { return rotation_; }
00218
00219 bool operator==(const MMCifInfoTransOp& op) const {
00220 if (this->id_ != op.id_) {
00221 return false;
00222 }
00223 if (this->type_ != op.type_) {
00224 return false;
00225 }
00226 if (this->translation_ != op.translation_) {
00227 return false;
00228 }
00229 if (this->rotation_ != op.rotation_) {
00230 return false;
00231 }
00232
00233 return true;
00234 }
00235
00236 bool operator!=(const MMCifInfoTransOp& op) const {
00237 return !this->operator==(op);
00238 }
00239
00240 private:
00241 String id_;
00242 String type_;
00243 geom::Vec3 translation_;
00244 geom::Mat3 rotation_;
00245 };
00246 typedef boost::shared_ptr<MMCifInfoTransOp> MMCifInfoTransOpPtr;
00247
00248
00249 class DLLEXPORT_OST_IO MMCifInfoBioUnit {
00250 public:
00252 MMCifInfoBioUnit(): id_(""), details_("") {};
00253
00257 void Merge(MMCifInfoBioUnit& from);
00258
00262 void SetID(String id) { id_ = id; }
00266 String GetID() const { return id_; }
00267
00271 void SetDetails(String details) { details_ = details; }
00275 String GetDetails() const { return details_; }
00276
00280 void SetMethodDetails(String method_details) {
00281 method_details_ = method_details;
00282 }
00286 String GetMethodDetails() const { return method_details_; }
00287
00291 void AddChain(String chain);
00292
00296 void SetChainList(std::vector<String> chains);
00297
00301 const std::vector<String>& GetChainList() const { return chains_; }
00302
00306 const std::vector<std::pair<int, int> >& GetChainIntervalList()
00307 {
00308 return tr_chains_;
00309 }
00310
00314 void AddOperations(std::vector<MMCifInfoTransOpPtr> operations);
00315
00319 const std::vector<std::pair<int, int> >& GetOperationsIntervalList()
00320 {
00321 return tr_operations_;
00322 }
00323
00327 const std::vector<std::vector<MMCifInfoTransOpPtr> >& GetOperations()
00328 {
00329 return operations_;
00330 }
00331
00332 bool operator==(const MMCifInfoBioUnit& bu) const {
00333 if (this->id_ != bu.id_) {
00334 return false;
00335 }
00336 if (this->details_ != bu.details_) {
00337 return false;
00338 }
00339 if (this->chains_ != bu.chains_) {
00340 return false;
00341 }
00342 if (this->tr_chains_ != bu.tr_chains_) {
00343 return false;
00344 }
00345 if (this->tr_operations_ != bu.tr_operations_) {
00346 return false;
00347 }
00348 if (this->operations_.size() == bu.operations_.size()) {
00349 std::vector<std::vector<MMCifInfoTransOpPtr> >::const_iterator th_ops_it;
00350 std::vector<std::vector<MMCifInfoTransOpPtr> >::const_iterator bu_ops_it;
00351 std::vector<MMCifInfoTransOpPtr>::const_iterator th_op_it;
00352 std::vector<MMCifInfoTransOpPtr>::const_iterator bu_op_it;
00353
00354 for (th_ops_it = this->operations_.begin(),
00355 bu_ops_it = bu.operations_.begin();
00356 th_ops_it != this->operations_.end();
00357 ++th_ops_it, ++bu_ops_it) {
00358 if (th_ops_it->size() == bu_ops_it->size()) {
00359 for (th_op_it = th_ops_it->begin(), bu_op_it = bu_ops_it->begin();
00360 th_op_it != th_ops_it->end();
00361 ++th_op_it, ++bu_op_it) {
00362 if (*th_op_it != *bu_op_it) {
00363 return false;
00364 }
00365 }
00366 } else {
00367 return false;
00368 }
00369 }
00370 } else {
00371 return false;
00372 }
00373
00374 return true;
00375 }
00376
00377 bool operator!=(const MMCifInfoBioUnit& bu) const {
00378 return !this->operator==(bu);
00379 }
00380
00381 private:
00382 String id_;
00383 String details_;
00384 String method_details_;
00385 std::vector<String> chains_;
00386 std::vector<std::pair<int, int> > tr_chains_;
00387 std::vector<std::vector<MMCifInfoTransOpPtr> > operations_;
00388 std::vector<std::pair<int, int> > tr_operations_;
00389 };
00390
00391 class DLLEXPORT_OST_IO MMCifInfoCitation {
00392 public:
00394 MMCifInfoCitation(): id_(""), where_(UNKNOWN), cas_(""), published_in_(""),
00395 volume_(""), page_first_(""), page_last_(""), doi_(""), pubmed_(0),
00396 year_(0), title_("") {};
00397
00401 void SetID(String id) { id_ = id; }
00405 String GetID() const { return id_; }
00406
00410 void SetCAS(String id) { cas_ = id; }
00414 String GetCAS() const { return cas_; }
00415
00419 void SetISBN(String code) { isbn_ = code; }
00420
00424 String GetISBN() const { return isbn_; }
00425
00429 void SetPublishedIn(String title) { published_in_ = title; }
00430
00434 String GetPublishedIn() const { return published_in_; }
00435
00439 void SetVolume(String volume) { volume_ = volume; }
00440
00444 String GetVolume() const { return volume_; }
00445
00449 void SetPageFirst(String first) { page_first_ = first; }
00450
00454 String GetPageFirst() const { return page_first_; }
00455
00459 void SetPageLast(String last) { page_last_ = last; }
00460
00464 String GetPageLast() const { return page_last_; }
00465
00469 void SetDOI(String doi) { doi_ = doi; }
00470
00471
00475 String GetDOI() const { return doi_; }
00476
00480 void SetPubMed(int no) { pubmed_ = no; }
00481
00485 int GetPubMed() const { return pubmed_; }
00486
00490 void SetYear(int year) { year_ = year; }
00491
00492
00496 int GetYear() const { return year_; }
00497
00498
00502 void SetTitle(String title) { title_ = title; }
00503
00507 String GetTitle() const { return title_; }
00508
00512 void SetAuthorList(std::vector<String> list) { authors_ = list; }
00513
00517 const std::vector<String>& GetAuthorList() const { return authors_; }
00518
00519 bool operator==(const MMCifInfoCitation& cit) const {
00520 if (this->year_ != cit.year_) {
00521 return false;
00522 }
00523 if (this->pubmed_ != cit.pubmed_) {
00524 return false;
00525 }
00526 if (this->where_ != cit.where_) {
00527 return false;
00528 }
00529 if (StringRef(this->id_.c_str(), this->id_.length()) !=
00530 StringRef(cit.id_.c_str(), cit.id_.length())) {
00531 return false;
00532 }
00533 if (StringRef(this->cas_.c_str(), this->cas_.length()) !=
00534 StringRef(cit.cas_.c_str(), cit.cas_.length())) {
00535 return false;
00536 }
00537 if (StringRef(this->isbn_.c_str(), this->isbn_.length()) !=
00538 StringRef(cit.isbn_.c_str(), cit.isbn_.length())) {
00539 return false;
00540 }
00541 if (StringRef(this->published_in_.c_str(), this->published_in_.length()) !=
00542 StringRef(cit.published_in_.c_str(), cit.published_in_.length())) {
00543 return false;
00544 }
00545 if (StringRef(this->volume_.c_str(), this->volume_.length()) !=
00546 StringRef(cit.volume_.c_str(), cit.volume_.length())) {
00547 return false;
00548 }
00549 if (StringRef(this->page_first_.c_str(), this->page_first_.length()) !=
00550 StringRef(cit.page_first_.c_str(), cit.page_first_.length())) {
00551 return false;
00552 }
00553 if (StringRef(this->page_last_.c_str(), this->page_last_.length()) !=
00554 StringRef(cit.page_last_.c_str(), cit.page_last_.length())) {
00555 return false;
00556 }
00557 if (StringRef(this->doi_.c_str(), this->doi_.length()) !=
00558 StringRef(cit.doi_.c_str(), cit.doi_.length())) {
00559 return false;
00560 }
00561 if (StringRef(this->title_.c_str(), this->title_.length()) !=
00562 StringRef(cit.title_.c_str(), cit.title_.length())) {
00563 return false;
00564 }
00565 if (this->authors_ != cit.authors_) {
00566 return false;
00567 }
00568
00569 return true;
00570 }
00571
00572 bool operator!=(const MMCifInfoCitation& cit) const {
00573 return !this->operator==(cit);
00574 }
00575
00576 private:
00578 typedef enum {
00579 JOURNAL,
00580 BOOK,
00581 UNKNOWN
00582 } MMCifInfoCType;
00583
00584 String id_;
00585 MMCifInfoCType where_;
00586 String cas_;
00587 String isbn_;
00588 String published_in_;
00589 String volume_;
00590 String page_first_;
00591 String page_last_;
00592 String doi_;
00593 int pubmed_;
00594 int year_;
00595 String title_;
00596 std::vector<String> authors_;
00597 };
00598
00601 class DLLEXPORT_OST_IO MMCifInfoObsolete {
00602 public:
00604 MMCifInfoObsolete(): date_(""), id_(UNKNOWN), pdb_id_(""),
00605 replaced_pdb_id_("") {};
00606
00610 void SetDate(String date) { date_ = date; }
00611
00615 String GetDate() { return date_; }
00616
00620 void SetID(StringRef type)
00621 {
00622 if (type == StringRef("OBSLTE", 6)) {
00623 id_ = OBSLTE;
00624 }
00625 else if (type == StringRef("SPRSDE", 6)) {
00626 id_ = SPRSDE;
00627 }
00628 }
00629
00633 String GetID()
00634 {
00635 if (id_ == OBSLTE) {
00636 return "Obsolete";
00637 }
00638 if (id_ == SPRSDE) {
00639 return "Supersede";
00640 }
00641 return "Unknown";
00642 }
00643
00647 void SetPDBID(String id) { pdb_id_ = id; }
00648
00652 String GetPDBID() { return pdb_id_; }
00653
00657 void SetReplacedPDBID(String id) { replaced_pdb_id_ = id; }
00658
00662 String GetReplacedPDBID() { return replaced_pdb_id_; }
00663
00664 private:
00666 typedef enum {
00667 OBSLTE,
00668 SPRSDE,
00669 UNKNOWN
00670 } MMCifObsoleteType;
00671
00672 String date_;
00673 MMCifObsoleteType id_;
00674 String pdb_id_;
00675 String replaced_pdb_id_;
00676 };
00677
00680 class DLLEXPORT_OST_IO MMCifInfoRevisions {
00681 public:
00683 MMCifInfoRevisions(): date_original_("?"), first_release_(0) {};
00684
00688 void SetDateOriginal(String date) { date_original_ = date; }
00689
00693 String GetDateOriginal() const { return date_original_; }
00694
00700 void AddRevision(int num, String date, String status)
00701 {
00702 if (num_.size() && (num_.back() > num)) {
00703 std::stringstream ss;
00704 ss << "'num' component of 'database_pdb_rev' category has to increase ";
00705 ss << "with every revision, last was ";
00706 ss << num_.back();
00707 ss << ", trying to add ";
00708 ss << num;
00709 throw IOException(ss.str());
00710 }
00711 num_.push_back(num);
00712 date_.push_back(date);
00713 status_.push_back(status);
00714
00715 if (first_release_ == 0) {
00716 if (status == "full release") {
00717 first_release_ = status_.size();
00718 }
00719 }
00720 }
00721
00725 size_t GetSize() const { return num_.size(); }
00726
00731 String GetDate(size_t i) const { return date_[i]; }
00732
00737 int GetNum(size_t i) const { return num_[i]; }
00738
00743 String GetStatus(size_t i) const { return status_[i]; }
00744
00748 String GetLastDate() const { return date_.back(); }
00749
00753 size_t GetFirstRelease() const
00754 {
00755 return first_release_;
00756 }
00757
00758 private:
00759 String date_original_;
00760 size_t first_release_;
00761 std::vector<int> num_;
00762 std::vector<String> date_;
00763 std::vector<String> status_;
00764 };
00765
00766
00767 class MMCifInfoStructRef;
00768 class MMCifInfoStructRefSeq;
00769 class MMCifInfoStructRefSeqDif;
00770
00771
00772 typedef boost::shared_ptr<MMCifInfoStructRef> MMCifInfoStructRefPtr;
00773 typedef boost::shared_ptr<MMCifInfoStructRefSeq> MMCifInfoStructRefSeqPtr;
00774 typedef boost::shared_ptr<MMCifInfoStructRefSeqDif> MMCifInfoStructRefSeqDifPtr;
00775
00776 typedef std::vector<MMCifInfoStructRefPtr> MMCifInfoStructRefs;
00777 typedef std::vector<MMCifInfoStructRefSeqPtr> MMCifInfoStructRefSeqs;
00778 typedef std::vector<MMCifInfoStructRefSeqDifPtr> MMCifInfoStructRefSeqDifs;
00779 class DLLEXPORT_OST_IO MMCifInfoStructRef {
00780 public:
00781 MMCifInfoStructRef(const String& id, const String& ent_id,
00782 const String& db_name,
00783 const String& db_ident, const String& db_access):
00784 id_(id), ent_id_(ent_id), db_name_(db_name), db_ident_(db_ident),
00785 db_access_(db_access)
00786 { }
00787 const String& GetID() const { return id_; }
00788 const String& GetDBName() const { return db_name_; }
00789 const String& GetDBID() const { return db_ident_; }
00790 const String& GetEntityID() const { return ent_id_; }
00791 const String& GetDBAccess() const { return db_access_; }
00792 MMCifInfoStructRefSeqPtr AddAlignedSeq(const String& align_id,
00793 const String& chain_name, int seq_begin,
00794 int seq_end, int db_begin, int db_end);
00795 MMCifInfoStructRefSeqPtr GetAlignedSeq(const String& align_id) const;
00796 MMCifInfoStructRefSeqs GetAlignedSeqs() const
00797 {
00798 MMCifInfoStructRefSeqs seqs;
00799 seqs.reserve(seqs_.size());
00800 for (std::map<String, MMCifInfoStructRefSeqPtr>::const_iterator
00801 i=seqs_.begin(), e=seqs_.end(); i!=e; ++i) {
00802 seqs.push_back(i->second);
00803 }
00804 return seqs;
00805 }
00806 private:
00807 String id_;
00808 String ent_id_;
00809 String db_name_;
00810 String db_ident_;
00811 String db_access_;
00812 std::map<String, MMCifInfoStructRefSeqPtr> seqs_;
00813 };
00814
00815 class DLLEXPORT_OST_IO MMCifInfoStructRefSeq {
00816 public:
00817 MMCifInfoStructRefSeq(const String& align_id, const String& chain_name,
00818 int seq_begin, int seq_end,
00819 int db_begin, int db_end):
00820 id_(align_id), chain_name_(chain_name),
00821 seq_begin_(seq_begin), seq_end_(seq_end), db_begin_(db_begin), db_end_(db_end)
00822 { }
00823
00824 const String& GetID() const { return id_; }
00825 const String& GetChainName() const { return chain_name_; }
00826 int GetSeqBegin() const { return seq_begin_; }
00827 int GetSeqEnd() const { return seq_end_; }
00828 int GetDBBegin() const { return db_begin_; }
00829 int GetDBEnd() const { return db_end_; }
00830 MMCifInfoStructRefSeqDifPtr AddDif(int seq_num, const String& db_rnum,
00831 const String& details);
00832 const std::vector<MMCifInfoStructRefSeqDifPtr>& GetDifs() const { return difs_; }
00833 private:
00834 String id_;
00835 String chain_name_;
00836 int seq_begin_;
00837 int seq_end_;
00838 int db_begin_;
00839 int db_end_;
00840 std::vector<MMCifInfoStructRefSeqDifPtr> difs_;
00841 };
00842
00843 class DLLEXPORT_OST_IO MMCifInfoStructRefSeqDif {
00844 public:
00845 MMCifInfoStructRefSeqDif(int seq_rnum, const String& db_rnum, const String& details):
00846 seq_rnum_(seq_rnum), db_rnum_(db_rnum), details_(details) {}
00847 int GetSeqRNum() const { return seq_rnum_;}
00848 const String& GetDBRNum() const { return db_rnum_; }
00849 const String& GetDetails() const { return details_; }
00850 private:
00851 int seq_rnum_;
00852 String db_rnum_;
00853 String details_;
00854 };
00855
00869 class DLLEXPORT_OST_IO MMCifInfo {
00870 public:
00872 MMCifInfo(): exptl_method_(""), resolution_(0.0f) {};
00873
00877 void AddCitation(MMCifInfoCitation citation)
00878 {
00879 citations_.push_back(citation);
00880 }
00881
00886 void AddAuthorsToCitation(StringRef id, std::vector<String> list);
00887
00891 const std::vector<MMCifInfoCitation>& GetCitations() const
00892 {
00893 return citations_;
00894 }
00895
00899 void SetMethod(String method) { exptl_method_ = method; }
00900
00904 const StringRef GetMethod() const
00905 {
00906 return StringRef(exptl_method_.c_str(), exptl_method_.length());
00907 }
00908
00912 void SetResolution(Real res) { resolution_ = res; }
00913
00917 Real GetResolution() const { return resolution_; }
00918
00923 void AddMMCifPDBChainTr(String cif, String pdb);
00924
00929 String GetMMCifPDBChainTr(String cif) const;
00930
00935 void AddPDBMMCifChainTr(String pdb, String cif);
00936
00941 String GetPDBMMCifChainTr(String pdb) const;
00942
00946 void AddBioUnit(MMCifInfoBioUnit bu);
00947
00951 const std::vector<MMCifInfoBioUnit>& GetBioUnits() const
00952 {
00953 return biounits_;
00954 }
00955
00959 void AddOperation(MMCifInfoTransOpPtr op)
00960 {
00961 transops_.push_back(op);
00962 }
00963
00967 const std::vector<MMCifInfoTransOpPtr>& GetOperations() const
00968 {
00969 return transops_;
00970 }
00971
00975 void SetStructDetails(MMCifInfoStructDetails details)
00976 {
00977 struct_details_ = details;
00978 }
00979
00983 const MMCifInfoStructDetails GetStructDetails() const
00984 {
00985 return struct_details_;
00986 }
00987
00991 void SetObsoleteInfo(MMCifInfoObsolete obsolete)
00992 {
00993 obsolete_ = obsolete;
00994 }
00995
00999 MMCifInfoObsolete GetObsoleteInfo() const
01000 {
01001 return obsolete_;
01002 }
01003 const MMCifInfoStructRefs& GetStructRefs() const { return struct_refs_; }
01004 void SetStructRefs(const MMCifInfoStructRefs& sr) { struct_refs_=sr; }
01005
01009 void SetRevisionsDateOriginal(String date)
01010 {
01011 revisions_.SetDateOriginal(date);
01012 }
01013
01019 void AddRevision(int num, String date, String status)
01020 {
01021 revisions_.AddRevision(num, date, status);
01022 }
01023
01027 MMCifInfoRevisions GetRevisions() const
01028 {
01029 return revisions_;
01030 }
01031
01032
01033 private:
01034
01035 String exptl_method_;
01036 Real resolution_;
01037 MMCifInfoStructDetails struct_details_;
01038 MMCifInfoObsolete obsolete_;
01039 MMCifInfoRevisions revisions_;
01040 std::vector<MMCifInfoCitation> citations_;
01041 std::vector<MMCifInfoBioUnit> biounits_;
01042 std::vector<MMCifInfoTransOpPtr> transops_;
01043 MMCifInfoStructRefs struct_refs_;
01044 std::map<String, String> cif_2_pdb_chain_id_;
01045 std::map<String, String> pdb_2_cif_chain_id_;
01046 };
01047
01048
01049 }}
01050
01051 #endif