yat  0.21pre
Codon.h
1 #ifndef theplu_yat_omic_codon
2 #define theplu_yat_omic_codon
3 
4 // $Id: Codon.h 3487 2016-03-24 04:24:05Z peter $
5 
6 /*
7  Copyright (C) 2010, 2011, 2012, 2013, 2016 Peter Johansson
8 
9  This file is part of the yat library, http://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <http://www.gnu.org/licenses/>.
23 */
24 
25 #include "DNA.h"
26 
27 #include <functional>
28 #include <map>
29 #include <string>
30 #include <vector>
31 
32 namespace theplu {
33 namespace yat {
34 namespace omic {
35 
66  class Codon
67  {
68  public:
74  Codon(void);
75 
82  Codon(const std::string& str);
83 
87  Codon(const DNA& first, const DNA& second, const DNA& third);
88 
93  char amino_acid(void) const;
94 
101  std::string amino_acid_long(void) const;
102 
106  const DNA& operator()(size_t i) const;
107 
111  bool start(void) const;
112 
116  bool stop(void) const;
117  private:
118  struct Compare_
119  {
120  bool operator()(const std::vector<DNA>& lhs,
121  const std::vector<DNA>& rhs) const;
122  };
123  typedef std::map<std::vector<DNA>, char, Compare_> Map_;
124  static Map_ map_;
125 
126  Map_::const_iterator iter_;
127 
128  void add_to_map(char aa, const std::string& codons);
129 
130  void init(const std::vector<DNA>& vec);
131  void create_map(void);
132 
133  // using compiler generated copy
134  // Codon(const Codon&)
135  // Codon& operator=(const Codon&)
136  };
137 
145  struct AminoAcidEqual : public std::binary_function<Codon, Codon, bool>
146  {
148  bool operator()(const Codon& lhs, const Codon& rhs) const;
149  };
150 
151 }}}
152 #endif
bool operator()(const Codon &lhs, const Codon &rhs) const
Functor comparing if two Codons translate to the same amino acid.
Definition: Codon.h:145
bool start(void) const
Codon(void)
Defaulf constructor.
The Department of Theoretical Physics namespace as we define it.
const DNA & operator()(size_t i) const
std::string amino_acid_long(void) const
char amino_acid(void) const
bool stop(void) const
Definition: Codon.h:66
Definition: DNA.h:61

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14