OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mmcif_info.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_MMCIF_INFO_HH
20 #define OST_MMCIF_INFO_HH
21 
22 #include <vector>
23 #include <map>
24 #include <boost/shared_ptr.hpp>
25 #include <ost/seq/sequence_list.hh>
26 #include <ost/geom/geom.hh>
27 #include <ost/string_ref.hh>
28 #include <ost/io/module_config.hh>
29 
30 namespace ost { namespace io {
31 
33 public:
35  MMCifInfoStructDetails(): entry_id_(""), title_(""), casp_flag_('\0'),
36  descriptor_(""), mass_(0.0), mass_method_(""), model_details_(""),
37  model_type_details_("") {};
38 
42  void SetEntryID(String id) { entry_id_ = id; }
46  String GetEntryID() const { return entry_id_; }
47 
51  void SetCASPFlag(char flag) { casp_flag_ = flag; }
55  char GetCASPFlag() const { return casp_flag_; }
56 
60  void SetDescriptor(String desc) { descriptor_ = desc; }
64  String GetDescriptor() const { return descriptor_; }
65 
69  void SetMass(Real mass) { mass_ = mass; }
73  Real GetMass() const { return mass_; }
74 
78  void SetMassMethod(String method) { mass_method_ = method; }
82  String GetMassMethod() const { return mass_method_; }
83 
87  void SetModelDetails(String desc) { model_details_ = desc; }
91  String GetModelDetails() const { return model_details_; }
92 
96  void SetModelTypeDetails(String desc) { model_type_details_ = desc; }
100  String GetModelTypeDetails() const { return model_type_details_; }
101 
105  void SetTitle(String title) { title_ = title; }
109  String GetTitle() const { return title_; }
110 
111  bool operator==(const MMCifInfoStructDetails& sd) const {
112  if (this->entry_id_ != sd.entry_id_) {
113  return false;
114  }
115  if (this->casp_flag_ != sd.casp_flag_) {
116  return false;
117  }
118  if (this->descriptor_ != sd.descriptor_) {
119  return false;
120  }
121  if (this->mass_ != sd.mass_) {
122  return false;
123  }
124  if (this->mass_method_ != sd.mass_method_) {
125  return false;
126  }
127  if (this->model_details_ != sd.model_details_) {
128  return false;
129  }
130  if (this->model_type_details_ != sd.model_type_details_) {
131  return false;
132  }
133  if (this->title_ != sd.title_) {
134  return false;
135  }
136 
137  return true;
138  }
139 
140  bool operator!=(const MMCifInfoStructDetails& sd) const {
141  return !this->operator == (sd);
142  }
143 
144 private:
145  String entry_id_;
146  String title_;
147  char casp_flag_;
148  String descriptor_;
149  Real mass_;
150  String mass_method_;
151  String model_details_;
152  String model_type_details_;
153 };
154 
156 public:
158  MMCifInfoTransOp(): id_(""), type_("")
159  {
160  translation_ = geom::Vec3();
161  };
162 
166  void SetID(String id) { id_ = id; }
170  String GetID() const { return id_; }
171 
175  void SetType(String type) { type_ = type; }
179  String GetType() const { return type_; }
180 
184  void SetVector(Real x, Real y, Real z)
185  {
186  translation_.SetX(x);
187  translation_.SetY(y);
188  translation_.SetZ(z);
189  }
193  geom::Vec3 GetVector() const { return translation_; }
194 
198  void SetMatrix(Real i00, Real i01, Real i02,
199  Real i10, Real i11, Real i12,
200  Real i20, Real i21, Real i22)
201  {
202  rotation_ = geom::Mat3(i00,i01,i02, i10,i11,i12, i20,i21,i22);
203  }
207  geom::Mat3 GetMatrix() const { return rotation_; }
208 
209  bool operator==(const MMCifInfoTransOp& op) const {
210  if (this->id_ != op.id_) {
211  return false;
212  }
213  if (this->type_ != op.type_) {
214  return false;
215  }
216  if (this->translation_ != op.translation_) {
217  return false;
218  }
219  if (this->rotation_ != op.rotation_) {
220  return false;
221  }
222 
223  return true;
224  }
225 
226  bool operator!=(const MMCifInfoTransOp& op) const {
227  return !this->operator==(op);
228  }
229 
230 private:
231  String id_;
232  String type_;
233  geom::Vec3 translation_;
234  geom::Mat3 rotation_;
235 };
236 typedef boost::shared_ptr<MMCifInfoTransOp> MMCifInfoTransOpPtr;
237 
238 
240 public:
242  MMCifInfoBioUnit(): id_(""), details_("") {};
243 
247  void SetID(String id) { id_ = id; }
251  String GetID() const { return id_; }
252 
256  void SetDetails(String details) { details_ = details; }
260  String GetDetails() const { return details_; }
261 
265  void AddChain(String chain) { chains_.push_back(chain); }
269  const std::vector<String>& GetChainList() const { return chains_; }
270 
274  void AddOperations(std::vector<MMCifInfoTransOpPtr> operations)
275  {
276  operations_.push_back(operations);
277  }
281  const std::vector<std::vector<MMCifInfoTransOpPtr> >& GetOperations()
282  {
283  return operations_;
284  }
285 
286  bool operator==(const MMCifInfoBioUnit& bu) const {
287  if (this->id_ != bu.id_) {
288  return false;
289  }
290  if (this->details_ != bu.details_) {
291  return false;
292  }
293  if (this->chains_ != bu.chains_) {
294  return false;
295  }
296  if (this->operations_.size() == bu.operations_.size()) {
297  std::vector<std::vector<MMCifInfoTransOpPtr> >::const_iterator th_ops_it;
298  std::vector<std::vector<MMCifInfoTransOpPtr> >::const_iterator bu_ops_it;
299  std::vector<MMCifInfoTransOpPtr>::const_iterator th_op_it;
300  std::vector<MMCifInfoTransOpPtr>::const_iterator bu_op_it;
301 
302  for (th_ops_it = this->operations_.begin(),
303  bu_ops_it = bu.operations_.begin();
304  th_ops_it != this->operations_.end();
305  ++th_ops_it, ++bu_ops_it) {
306  if (th_ops_it->size() == bu_ops_it->size()) {
307  for (th_op_it = th_ops_it->begin(), bu_op_it = bu_ops_it->begin();
308  th_op_it != th_ops_it->end();
309  ++th_op_it, ++bu_op_it) {
310  if (*th_op_it != *bu_op_it) {
311  return false;
312  }
313  }
314  } else {
315  return false;
316  }
317  }
318  } else {
319  return false;
320  }
321 
322  return true;
323  }
324 
325  bool operator!=(const MMCifInfoBioUnit& bu) const {
326  return !this->operator==(bu);
327  }
328 
329 private:
330  String id_;
331  String details_;
332  std::vector<String> chains_;
333  std::vector<std::vector<MMCifInfoTransOpPtr> > operations_;
334 };
335 
337 public:
339  MMCifInfoCitation(): id_(""), where_(UNKNOWN), cas_(""), published_in_(""),
340  volume_(""), page_first_(""), page_last_(""), doi_(""), pubmed_(0),
341  year_(0), title_("") {};
342 
346  void SetID(String id) { id_ = id; }
350  String GetID() const { return id_; }
351 
355  void SetCAS(String id) { cas_ = id; }
359  String GetCAS() const { return cas_; }
360 
364  void SetISBN(String code) { isbn_ = code; }
365 
369  String GetISBN() const { return isbn_; }
370 
374  void SetPublishedIn(String title) { published_in_ = title; }
375 
379  String GetPublishedIn() const { return published_in_; }
380 
384  void SetVolume(String volume) { volume_ = volume; }
385 
389  String GetVolume() const { return volume_; }
390 
394  void SetPageFirst(String first) { page_first_ = first; }
395 
399  String GetPageFirst() const { return page_first_; }
400 
404  void SetPageLast(String last) { page_last_ = last; }
405 
409  String GetPageLast() const { return page_last_; }
410 
414  void SetDOI(String doi) { doi_ = doi; }
415 
416 
420  String GetDOI() const { return doi_; }
421 
425  void SetPubMed(int no) { pubmed_ = no; }
426 
430  int GetPubMed() const { return pubmed_; }
431 
435  void SetYear(int year) { year_ = year; }
436 
437 
441  int GetYear() const { return year_; }
442 
443 
447  void SetTitle(String title) { title_ = title; }
448 
452  String GetTitle() const { return title_; }
453 
457  void SetAuthorList(std::vector<String> list) { authors_ = list; }
458 
462  const std::vector<String>& GetAuthorList() const { return authors_; }
463 
464  bool operator==(const MMCifInfoCitation& cit) const {
465  if (this->year_ != cit.year_) {
466  return false;
467  }
468  if (this->pubmed_ != cit.pubmed_) {
469  return false;
470  }
471  if (this->where_ != cit.where_) {
472  return false;
473  }
474  if (StringRef(this->id_.c_str(), this->id_.length()) !=
475  StringRef(cit.id_.c_str(), cit.id_.length())) {
476  return false;
477  }
478  if (StringRef(this->cas_.c_str(), this->cas_.length()) !=
479  StringRef(cit.cas_.c_str(), cit.cas_.length())) {
480  return false;
481  }
482  if (StringRef(this->isbn_.c_str(), this->isbn_.length()) !=
483  StringRef(cit.isbn_.c_str(), cit.isbn_.length())) {
484  return false;
485  }
486  if (StringRef(this->published_in_.c_str(), this->published_in_.length()) !=
487  StringRef(cit.published_in_.c_str(), cit.published_in_.length())) {
488  return false;
489  }
490  if (StringRef(this->volume_.c_str(), this->volume_.length()) !=
491  StringRef(cit.volume_.c_str(), cit.volume_.length())) {
492  return false;
493  }
494  if (StringRef(this->page_first_.c_str(), this->page_first_.length()) !=
495  StringRef(cit.page_first_.c_str(), cit.page_first_.length())) {
496  return false;
497  }
498  if (StringRef(this->page_last_.c_str(), this->page_last_.length()) !=
499  StringRef(cit.page_last_.c_str(), cit.page_last_.length())) {
500  return false;
501  }
502  if (StringRef(this->doi_.c_str(), this->doi_.length()) !=
503  StringRef(cit.doi_.c_str(), cit.doi_.length())) {
504  return false;
505  }
506  if (StringRef(this->title_.c_str(), this->title_.length()) !=
507  StringRef(cit.title_.c_str(), cit.title_.length())) {
508  return false;
509  }
510  if (this->authors_ != cit.authors_) {
511  return false;
512  }
513 
514  return true;
515  }
516 
517  bool operator!=(const MMCifInfoCitation& cit) const {
518  return !this->operator==(cit);
519  }
520 
521 private:
523  typedef enum {
524  JOURNAL,
525  BOOK,
526  UNKNOWN
527  } MMCifInfoCType;
528 
529  String id_;
530  MMCifInfoCType where_;
531  String cas_;
532  String isbn_;
533  String published_in_;
534  String volume_;
535  String page_first_;
536  String page_last_;
537  String doi_;
538  int pubmed_;
539  int year_;
540  String title_;
541  std::vector<String> authors_;
542 };
543 
547 public:
549  MMCifInfoObsolete(): date_(""), id_(UNKNOWN), pdb_id_(""),
550  replaced_pdb_id_("") {};
551 
555  void SetDate(String date) { date_ = date; }
556 
560  String GetDate() { return date_; }
561 
565  void SetID(StringRef type)
566  {
567  if (type == StringRef("OBSLTE", 6)) {
568  id_ = OBSLTE;
569  }
570  else if (type == StringRef("SPRSDE", 6)) {
571  id_ = SPRSDE;
572  }
573  }
574 
578  String GetID()
579  {
580  if (id_ == OBSLTE) {
581  return "Obsolete";
582  }
583  if (id_ == SPRSDE) {
584  return "Supersede";
585  }
586  return "Unknown";
587  }
588 
592  void SetPDBID(String id) { pdb_id_ = id; }
593 
597  String GetPDBID() { return pdb_id_; }
598 
602  void SetReplacedPDBID(String id) { replaced_pdb_id_ = id; }
603 
607  String GetReplacedPDBID() { return replaced_pdb_id_; }
608 
609 private:
611  typedef enum {
612  OBSLTE,
613  SPRSDE,
614  UNKNOWN
615  } MMCifObsoleteType;
616 
617  String date_;
618  MMCifObsoleteType id_;
619  String pdb_id_;
620  String replaced_pdb_id_;
621 };
622 
623 class MMCifInfoStructRef;
624 class MMCifInfoStructRefSeq;
626 
627 
628 typedef boost::shared_ptr<MMCifInfoStructRef> MMCifInfoStructRefPtr;
629 typedef boost::shared_ptr<MMCifInfoStructRefSeq> MMCifInfoStructRefSeqPtr;
630 typedef boost::shared_ptr<MMCifInfoStructRefSeqDif> MMCifInfoStructRefSeqDifPtr;
631 
632 typedef std::vector<MMCifInfoStructRefPtr> MMCifInfoStructRefs;
633 typedef std::vector<MMCifInfoStructRefSeqPtr> MMCifInfoStructRefSeqs;
634 typedef std::vector<MMCifInfoStructRefSeqDifPtr> MMCifInfoStructRefSeqDifs;
636 public:
637  MMCifInfoStructRef(const String& id, const String& ent_id,
638  const String& db_name,
639  const String& db_ident, const String& db_access):
640  id_(id), ent_id_(ent_id), db_name_(db_name), db_ident_(db_ident),
641  db_access_(db_access)
642  { }
643  const String& GetID() const { return id_; }
644  const String& GetDBName() const { return db_name_; }
645  const String& GetDBID() const { return db_ident_; }
646  const String& GetEntityID() const { return ent_id_; }
647  const String& GetDBAccess() const { return db_access_; }
648  MMCifInfoStructRefSeqPtr AddAlignedSeq(const String& align_id,
649  const String& chain_name, int seq_begin,
650  int seq_end, int db_begin, int db_end);
651  MMCifInfoStructRefSeqPtr GetAlignedSeq(const String& align_id) const;
652  MMCifInfoStructRefSeqs GetAlignedSeqs() const
653  {
655  seqs.reserve(seqs_.size());
656  for (std::map<String, MMCifInfoStructRefSeqPtr>::const_iterator
657  i=seqs_.begin(), e=seqs_.end(); i!=e; ++i) {
658  seqs.push_back(i->second);
659  }
660  return seqs;
661  }
662 private:
663  String id_;
664  String ent_id_;
665  String db_name_;
666  String db_ident_;
667  String db_access_;
668  std::map<String, MMCifInfoStructRefSeqPtr> seqs_;
669 };
670 
672 public:
673  MMCifInfoStructRefSeq(const String& align_id, const String& chain_name,
674  int seq_begin, int seq_end,
675  int db_begin, int db_end):
676  id_(align_id), chain_name_(chain_name),
677  seq_begin_(seq_begin), seq_end_(seq_end), db_begin_(db_begin), db_end_(db_end)
678  { }
679 
680  const String& GetID() const { return id_; }
681  const String& GetChainName() const { return chain_name_; }
682  int GetSeqBegin() const { return seq_begin_; }
683  int GetSeqEnd() const { return seq_end_; }
684  int GetDBBegin() const { return db_begin_; }
685  int GetDBEnd() const { return db_end_; }
686  MMCifInfoStructRefSeqDifPtr AddDif(int seq_num, int db_num,
687  const String& details);
688  const std::vector<MMCifInfoStructRefSeqDifPtr>& GetDifs() const { return difs_; }
689 private:
690  String id_;
691  String chain_name_;
692  int seq_begin_;
693  int seq_end_;
694  int db_begin_;
695  int db_end_;
696  std::vector<MMCifInfoStructRefSeqDifPtr> difs_;
697 };
698 
700 public:
701  MMCifInfoStructRefSeqDif(int seq_rnum, int db_rnum, const String& details):
702  seq_rnum_(seq_rnum), db_rnum_(db_rnum), details_(details) {}
703  int GetSeqRNum() const { return seq_rnum_;}
704  int GetDBRNum() const { return db_rnum_; }
705  const String& GetDetails() const { return details_; }
706 private:
707  int seq_rnum_;
708  int db_rnum_;
709  String details_;
710 };
711 
726 public:
728  MMCifInfo(): exptl_method_(""), resolution_(0.0f) {};
729 
733  void AddCitation(MMCifInfoCitation citation) // unit test
734  {
735  citations_.push_back(citation);
736  }
737 
742  void AddAuthorsToCitation(StringRef id, std::vector<String> list); //unit test
743 
747  const std::vector<MMCifInfoCitation>& GetCitations() const
748  {
749  return citations_;
750  }
751 
755  void SetMethod(String method) { exptl_method_ = method; }
756 
760  const StringRef GetMethod() const
761  {
762  return StringRef(exptl_method_.c_str(), exptl_method_.length());
763  }
764 
768  void SetResolution(Real res) { resolution_ = res; }
769 
773  Real GetResolution() const { return resolution_; }
774 
779  void AddMMCifPDBChainTr(String cif, String pdb);
780 
785  String GetMMCifPDBChainTr(String cif) const;
786 
791  void AddPDBMMCifChainTr(String pdb, String cif);
792 
797  String GetPDBMMCifChainTr(String pdb) const;
798 
802  void AddBioUnit(MMCifInfoBioUnit bu) // unit test
803  {
804  biounits_.push_back(bu);
805  }
806 
810  const std::vector<MMCifInfoBioUnit>& GetBioUnits() const
811  {
812  return biounits_;
813  }
814 
818  void AddOperation(MMCifInfoTransOpPtr op) // unit test
819  {
820  transops_.push_back(op);
821  }
822 
826  const std::vector<MMCifInfoTransOpPtr>& GetOperations() const
827  {
828  return transops_;
829  }
830 
834  void SetStructDetails(MMCifInfoStructDetails details)
835  {
836  struct_details_ = details;
837  }
838 
842  const MMCifInfoStructDetails GetStructDetails() const
843  {
844  return struct_details_;
845  }
846 
850  void SetObsoleteInfo(MMCifInfoObsolete obsolete)
851  {
852  obsolete_ = obsolete;
853  }
854 
858  MMCifInfoObsolete GetObsoleteInfo() const
859  {
860  return obsolete_;
861  }
862  const MMCifInfoStructRefs& GetStructRefs() const { return struct_refs_; }
863  void SetStructRefs(const MMCifInfoStructRefs& sr) { struct_refs_=sr; }
864 //protected:
865 
866 private:
867  // members
868  String exptl_method_;
869  Real resolution_;
870  MMCifInfoStructDetails struct_details_;
871  MMCifInfoObsolete obsolete_;
872  std::vector<MMCifInfoCitation> citations_;
873  std::vector<MMCifInfoBioUnit> biounits_;
874  std::vector<MMCifInfoTransOpPtr> transops_;
875  MMCifInfoStructRefs struct_refs_;
876  std::map<String, String> cif_2_pdb_chain_id_;
877  std::map<String, String> pdb_2_cif_chain_id_;
878 };
879 
880 
881 }} // ns
882 
883 #endif