yat  0.12.3pre
Codon.h
1 #ifndef theplu_yat_omic_codon
2 #define theplu_yat_omic_codon
3 
4 // $Id: Codon.h 3114 2013-11-10 23:51:47Z peter $
5 
6 /*
7  Copyright (C) 2010, 2011, 2012, 2013 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 
98  const DNA& operator()(size_t i) const;
99 
103  bool start(void) const;
104 
108  bool stop(void) const;
109  private:
110  struct Compare_
111  {
112  bool operator()(const std::vector<DNA>& lhs,
113  const std::vector<DNA>& rhs) const;
114  };
115  typedef std::map<std::vector<DNA>, char, Compare_> Map_;
116  static Map_ map_;
117 
118  Map_::const_iterator iter_;
119 
120  void add_to_map(char aa, const std::string& codons);
121 
122  void init(const std::vector<DNA>& vec);
123  void create_map(void);
124 
125  // using compiler generated copy
126  // Codon(const Codon&)
127  // Codon& operator=(const Codon&)
128  };
129 
137  struct AminoAcidEqual : public std::binary_function<Codon, Codon, bool>
138  {
140  bool operator()(const Codon& lhs, const Codon& rhs) const;
141  };
142 
143 }}}
144 #endif
bool stop(void) const
Functor comparing if two Codons translate to the same amino acid.
Definition: Codon.h:137
Codon(void)
Defaulf constructor.
bool operator()(const Codon &lhs, const Codon &rhs) const
char amino_acid(void) const
const DNA & operator()(size_t i) const
bool start(void) const
Definition: Codon.h:66
Definition: DNA.h:61

Generated on Mon Jun 1 2015 12:29:51 for yat by  doxygen 1.8.5