yat  0.8.3pre
Codon.h
00001 #ifndef theplu_yat_omic_codon
00002 #define theplu_yat_omic_codon
00003 
00004 /*
00005   $Id: Codon.h 2441 2011-03-15 19:17:52Z peter $
00006 
00007   Copyright (C) 2010, 2011 Peter Johansson
00008 
00009   This file is part of the yat library, http://dev.thep.lu.se/yat
00010 
00011   The yat library is free software; you can redistribute it and/or
00012   modify it under the terms of the GNU General Public License as
00013   published by the Free Software Foundation; either version 3 of the
00014   License, or (at your option) any later version.
00015 
00016   The yat library is distributed in the hope that it will be useful,
00017   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00019   General Public License for more details.
00020 
00021   You should have received a copy of the GNU General Public License
00022   along with yat. If not, see <http://www.gnu.org/licenses/>.
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     // using compiler generated copy
00126     // Codon(const Codon&)
00127     // Codon& operator=(const Codon&)
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

Generated on Thu Dec 20 2012 03:12:57 for yat by  doxygen 1.8.0-20120409