00001 #ifndef theplu_yat_omic_codon
00002 #define theplu_yat_omic_codon
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "DNA.h"
00026
00027 #include <functional>
00028 #include <map>
00029 #include <string>
00030 #include <vector>
00031
00032 namespace theplu {
00033 namespace yat {
00034 namespace omic {
00035
00066 class Codon
00067 {
00068 public:
00074 Codon(void);
00075
00082 Codon(const std::string& str);
00083
00087 Codon(const DNA& first, const DNA& second, const DNA& third);
00088
00093 char amino_acid(void) const;
00094
00098 const DNA& operator()(size_t i) const;
00099
00103 bool start(void) const;
00104
00108 bool stop(void) const;
00109 private:
00110 struct Compare_
00111 {
00112 bool operator()(const std::vector<DNA>& lhs,
00113 const std::vector<DNA>& rhs) const;
00114 };
00115 typedef std::map<std::vector<DNA>, char, Compare_> Map_;
00116 static Map_ map_;
00117
00118 Map_::const_iterator iter_;
00119
00120 void add_to_map(char aa, const std::string& codons);
00121
00122 void init(const std::vector<DNA>& vec);
00123 void create_map(void);
00124
00125
00126
00127
00128 };
00129
00137 struct AminoAcidEqual : public std::binary_function<Codon, Codon, bool>
00138 {
00140 bool operator()(const Codon& lhs, const Codon& rhs) const;
00141 };
00142
00143 }}}
00144 #endif