OpenStructure
amino_acids.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_QA_AMINO_ACIDS_HH
20 #define OST_QA_AMINO_ACIDS_HH
21 /*
22  Author: Marco Biasini
23  */
24 #include <set>
25 #include <ost/dllexport.hh>
28 
29 #include <ost/qa/module_config.hh>
30 namespace ost { namespace qa {
31 
32 // convenience enum for standard set of 20 amino acids
33 // Xxx signifies an unknown amino acid.
34 typedef enum {
35  Ala, Arg, Asn,
36  Asp, Gln, Glu,
37  Lys, Ser, Cys,
38  Met, Trp, Tyr,
39  Thr, Val, Ile,
40  Leu, Gly, Pro,
42 
43 } AminoAcid;
44 
49 
50 // \brief from amino acid to residue name
52 
54 
56 
58 
59 class AminoAcidSetIterator : public std::iterator<std::forward_iterator_tag,
60  AminoAcid> {
61 public:
62  AminoAcidSetIterator(unsigned int bits, int start):
63  bits_(bits), curr_(start)
64  {
65  }
67  {
68  this->Advance();
69  return *this;
70  }
71 
73  {
74  return AminoAcid(curr_);
75  }
76 
77  bool operator==(const AminoAcidSetIterator& rhs) const
78  {
79  return curr_==rhs.curr_;
80  }
81  bool operator!=(const AminoAcidSetIterator& rhs) const
82  {
83  return !this->operator==(rhs);
84  }
85 private:
86  void Advance()
87  {
88  ++curr_;
89  while (curr_<=Xxx && !(bits_ & (1 << curr_))) { ++curr_; }
90  }
91  unsigned int bits_;
92  int curr_;
93 };
94 
95 
96 
99 public:
101 
102  static AminoAcidSet CreatePolarSet();
103 
104  static AminoAcidSet CreateAromaticSet();
105 
106  static AminoAcidSet CreateApolarSet();
107 
108  static AminoAcidSet CreateSet(AminoAcid aa);
109 
110  static std::vector<AminoAcidSet> CreateCompleteSet();
111 
112  static std::vector<AminoAcidSet> CreateThreeStateSet();
113 
114  static std::vector<AminoAcidSet> CreatePseudoSet();
115 
116  AminoAcidSet();
117 
119  void Add(AminoAcid amino_acid);
120 
122  void Remove(AminoAcid amino_acid);
123 
125  bool Contains(AminoAcid amino_acid) const;
126 
128  bool Empty() const;
129 
137  Iterator Begin() const;
138 
140  Iterator End() const;
141 
142  bool operator==(const AminoAcidSet& rhs) const;
143 
144  bool operator!=(const AminoAcidSet& rhs) const;
145 
146  template <typename DS>
147  void Serialize(DS& ds)
148  {
149  ds & bits_;
150  }
151 private:
152  unsigned int bits_;
153 };
154 
155 DLLEXPORT_OST_QA std::ostream& operator<<(std::ostream& os,
156  const AminoAcidSet& aa_set);
157 
158 }}
159 
160 #endif