OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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_CONOP_AMINO_ACIDS_HH
20 #define OST_CONOP_AMINO_ACIDS_HH
21 /*
22  Author: Marco Biasini
23  */
24 #include <set>
25 #include <ost/dllexport.hh>
28 
30 
31 namespace ost { namespace conop {
32 
33 // convenience enum for standard set of 20 amino acids
34 // Xxx signifies an unknown amino acid.
35 typedef enum {
36  ALA, ARG, ASN,
37  ASP, GLN, GLU,
38  LYS, SER, CYS,
39  MET, TRP, TYR,
40  THR, VAL, ILE,
41  LEU, GLY, PRO,
43 } AminoAcid;
44 
49 
50 // \brief from amino acid to residue name
52 
54 
56 
58 
60 
61 class AminoAcidSetIterator : public std::iterator<std::forward_iterator_tag,
62  AminoAcid> {
63 public:
64  AminoAcidSetIterator(unsigned int bits, int start):
65  bits_(bits), curr_(start)
66  {
67  }
69  {
70  this->Advance();
71  return *this;
72  }
73 
75  {
76  return AminoAcid(curr_);
77  }
78 
79  bool operator==(const AminoAcidSetIterator& rhs) const
80  {
81  return curr_==rhs.curr_;
82  }
83  bool operator!=(const AminoAcidSetIterator& rhs) const
84  {
85  return !this->operator==(rhs);
86  }
87 private:
88  void Advance()
89  {
90  ++curr_;
91  while (curr_<=XXX && !(bits_ & (1 << curr_))) { ++curr_; }
92  }
93  unsigned int bits_;
94  int curr_;
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_CONOP std::ostream& operator<<(std::ostream& os,
156  const AminoAcidSet& aa_set);
157 
158 typedef std::vector<AminoAcidSet> AminoAcidAlphabet;
159 
160 }}
161 
162 #endif