bpp-seq  2.2.0
CodonAlphabet.h
Go to the documentation of this file.
1 //
2 // File: CodonAlphabet.h
3 // Created by: Julien Dutheil
4 // Created on: Sun Oct 12 17:41:56 2003
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 17, 2004)
9 
10 This software is a computer program whose purpose is to provide classes
11 for sequences analysis.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided
21 only with a limited warranty and the software's author, the holder of
22 the economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards
32 their requirements in conditions enabling the security of their
33 systems and/or data to be ensured and, more generally, to use and
34 operate it in the same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _CODONALPHABET_H_
41 #define _CODONALPHABET_H_
42 
43 #include "WordAlphabet.h"
44 #include "NucleicAlphabet.h"
45 
46 // From the STL:
47 #include <string>
48 
49 
50 namespace bpp
51 {
52 
64  public WordAlphabet
65 {
66 public: // Constructor and destructor.
67 
74  WordAlphabet(alpha, 3) {}
75 
77 
79  {
81  return *this;
82  }
83 
85  {
86  return new CodonAlphabet(*this);
87  }
88 
89  virtual ~CodonAlphabet() {}
90 
91  std::string getAlphabetType() const
92  {
93  return "Codon alphabet("+ vAbsAlph_[0]->getAlphabetType() + ")";
94  }
95 
96 
97 public:
98 
114  virtual int getCodon(int pos1, int pos2, int pos3) const throw (BadIntException);
115 
126  virtual std::string getCodon(const std::string& pos1, const std::string& pos2, const std::string& pos3) const throw (BadCharException);
127 
134  virtual int getFirstPosition(int codon) const throw (BadIntException);
135 
142  virtual int getSecondPosition(int codon) const throw (BadIntException);
143 
150  virtual int getThirdPosition(int codon) const throw (BadIntException);
151 
158  virtual std::string getFirstPosition (const std::string& codon) const throw (BadCharException);
159 
166  virtual std::string getSecondPosition(const std::string& codon) const throw (BadCharException);
167 
174  virtual std::string getThirdPosition(const std::string& codon) const throw (BadCharException);
175 
179  virtual const NucleicAlphabet* const getNucleicAlphabet() const
180  {
181  return dynamic_cast<const NucleicAlphabet*>(vAbsAlph_[0]);
182  }
183 
185 };
186 
187 } //end of namespace bpp.
188 
189 #endif //_CODONALPHABET_H_
190 
An alphabet exception thrown when trying to specify a bad char to the alphabet.
This alphabet is used to deal NumericAlphabet.
std::string getAlphabetType() const
Identification method.
Definition: CodonAlphabet.h:91
virtual int getCodon(int pos1, int pos2, int pos3) const
Get the int code for a codon given the int code of the three underlying positions.
The base class for word alphabets.
Definition: WordAlphabet.h:66
virtual ~CodonAlphabet()
Definition: CodonAlphabet.h:89
WordAlphabet & operator=(const WordAlphabet &bia)
Definition: WordAlphabet.h:95
virtual int getFirstPosition(int codon) const
Get the int code of the first position of a codon given its int description.
Codon alphabet class.
Definition: CodonAlphabet.h:63
CodonAlphabet(const CodonAlphabet &bia)
Definition: CodonAlphabet.h:76
std::vector< const Alphabet *> vAbsAlph_
Definition: WordAlphabet.h:70
virtual int getSecondPosition(int codon) const
Get the int code of the second position of a codon given its int description.
virtual const NucleicAlphabet *const getNucleicAlphabet() const
CodonAlphabet & operator=(const CodonAlphabet &bia)
Definition: CodonAlphabet.h:78
An alphabet exception thrown when trying to specify a bad int to the alphabet.
The abstract base class for nucleic alphabets.
virtual int getThirdPosition(int codon) const
Get the int code of the third position of a codon given its int description.
CodonAlphabet(const NucleicAlphabet *alpha)
Builds a new codon alphabet from a nucleic alphabet.
Definition: CodonAlphabet.h:73
CodonAlphabet * clone() const
Definition: CodonAlphabet.h:84