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-2020 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 
62  using iterator_category = std::forward_iterator_tag;
63  using value_type = AminoAcid;
64  using difference_type = std::ptrdiff_t;
65  using pointer = AminoAcid*;
66  using reference = AminoAcid&;
67 
68 public:
69  AminoAcidSetIterator(unsigned int bits, int start):
70  bits_(bits), curr_(start)
71  {
72  }
74  {
75  this->Advance();
76  return *this;
77  }
78 
80  {
81  return AminoAcid(curr_);
82  }
83 
84  bool operator==(const AminoAcidSetIterator& rhs) const
85  {
86  return curr_==rhs.curr_;
87  }
88  bool operator!=(const AminoAcidSetIterator& rhs) const
89  {
90  return !this->operator==(rhs);
91  }
92 private:
93  void Advance()
94  {
95  ++curr_;
96  while (curr_<=XXX && !(bits_ & (1 << curr_))) { ++curr_; }
97  }
98  unsigned int bits_;
99  int curr_;
100 };
101 
104 public:
106 
107  static AminoAcidSet CreatePolarSet();
108 
109  static AminoAcidSet CreateAromaticSet();
110 
111  static AminoAcidSet CreateApolarSet();
112 
113  static AminoAcidSet CreateSet(AminoAcid aa);
114 
115  static std::vector<AminoAcidSet> CreateCompleteSet();
116 
117  static std::vector<AminoAcidSet> CreateThreeStateSet();
118 
119  static std::vector<AminoAcidSet> CreatePseudoSet();
120 
121  AminoAcidSet();
122 
124  void Add(AminoAcid amino_acid);
125 
127  void Remove(AminoAcid amino_acid);
128 
130  bool Contains(AminoAcid amino_acid) const;
131 
133  bool Empty() const;
134 
142  Iterator Begin() const;
143 
145  Iterator End() const;
146 
147  bool operator==(const AminoAcidSet& rhs) const;
148 
149  bool operator!=(const AminoAcidSet& rhs) const;
150 
151  template <typename DS>
152  void Serialize(DS& ds)
153  {
154  ds & bits_;
155  }
156 private:
157  unsigned int bits_;
158 };
159 
160 DLLEXPORT_OST_CONOP std::ostream& operator<<(std::ostream& os,
161  const AminoAcidSet& aa_set);
162 
163 typedef std::vector<AminoAcidSet> AminoAcidAlphabet;
164 
165 }}
166 
167 #endif
AminoAcidSetIterator & operator++()
Definition: amino_acids.hh:73
AminoAcidSetIterator Iterator
Definition: amino_acids.hh:105
char DLLEXPORT_OST_CONOP ResidueNameToOneLetterCode(String rn)
bool operator==(const AminoAcidSetIterator &rhs) const
Definition: amino_acids.hh:84
std::string String
Definition: base.hh:54
#define DLLEXPORT_OST_CONOP
Amino acid bit set.
Definition: amino_acids.hh:103
DLLEXPORT_OST_CONOP std::ostream & operator<<(std::ostream &os, const AminoAcidSet &aa_set)
bool DLLEXPORT_OST_GEOM operator==(const Line2 &l1, const Line2 &l2)
DLLEXPORT_OST_IMG_BASE bool operator!=(const ImageHandle &lhs, const ConstImageHandle &rhs)
AminoAcidSetIterator(unsigned int bits, int start)
Definition: amino_acids.hh:69
DLLEXPORT_OST_CONOP String AminoAcidToResidueName(AminoAcid aa)
DLLEXPORT_OST_CONOP AminoAcid ResidueToAminoAcid(const mol::ResidueHandle &r)
from residue name to amino acid.
std::vector< AminoAcidSet > AminoAcidAlphabet
Definition: amino_acids.hh:163
DLLEXPORT_OST_CONOP String OneLetterCodeToResidueName(char olc)
bool operator!=(const AminoAcidSetIterator &rhs) const
Definition: amino_acids.hh:88
AminoAcid operator*() const
Definition: amino_acids.hh:79
AminoAcid DLLEXPORT_OST_CONOP ResidueNameToAminoAcid(String rn)
DLLEXPORT_OST_CONOP AminoAcid OneLetterCodeToAminoAcid(char olc)