bpp-seq3  3.0.0
StandardGeneticCode.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_GENETICCODE_STANDARDGENETICCODE_H
6 #define BPP_SEQ_GENETICCODE_STANDARDGENETICCODE_H
7 
8 
9 #include "../Alphabet/NucleicAlphabet.h"
10 #include "GeneticCode.h"
11 
12 namespace bpp
13 {
19  public virtual GeneticCode
20 {
21 public:
22  StandardGeneticCode(std::shared_ptr<const NucleicAlphabet> alphabet) :
23  GeneticCode(alphabet)
24  {
25  init_();
26  }
27 
28  virtual ~StandardGeneticCode() {}
29 
30  virtual StandardGeneticCode* clone() const
31  {
32  return new StandardGeneticCode(*this);
33  }
34 
35 public:
36  size_t getNumberOfStopCodons() const { return 3; }
37 
38  std::vector<int> getStopCodonsAsInt() const
39  {
40  return std::vector<int>({48, 50, 56});
41  }
42 
43  std::vector<std::string> getStopCodonsAsChar() const
44  {
45  return std::vector<std::string>({"TAA", "TAG", "TGA"});
46  }
47 
48  bool isStop(int state) const
49  {
50  // Test:
51  codonAlphabet_->intToChar(state); // throw exception if invalid state!
52  return state == 48 || state == 50 || state == 56;
53  }
54 
55  bool isStop(const std::string& state) const
56  {
57  int i = codonAlphabet_->charToInt(state);
58  return i == 48 || i == 50 || i == 56;
59  }
60 
61  bool isAltStart(int state) const
62  {
63  // Test:
64  codonAlphabet_->intToChar(state); // throw exception if invalid state!
65  return state == 62 || state == 30;
66  }
67 
68  bool isAltStart(const std::string& state) const
69  {
70  int i = codonAlphabet_->charToInt(state);
71  return i == 62 || i == 30;
72  }
73 
74 private:
75  void init_();
76 };
77 } // end of namespace bpp.
78 #endif // BPP_SEQ_GENETICCODE_STANDARDGENETICCODE_H
Partial implementation of the Transliterator interface for genetic code object.
Definition: GeneticCode.h:50
std::shared_ptr< const CodonAlphabet > codonAlphabet_
Definition: GeneticCode.h:52
This class implements the standard genetic code as describe on the NCBI web site: http://www....
std::vector< int > getStopCodonsAsInt() const
bool isStop(int state) const
Tells is a particular codon is a stop codon.
StandardGeneticCode(std::shared_ptr< const NucleicAlphabet > alphabet)
bool isStop(const std::string &state) const
Tells is a particular codon is a stop codon.
std::vector< std::string > getStopCodonsAsChar() const
virtual StandardGeneticCode * clone() const
bool isAltStart(int state) const
Tells is a particular codon is an alternative start codon.
size_t getNumberOfStopCodons() const
bool isAltStart(const std::string &state) const
Tells is a particular codon is an alternative start codon.
This alphabet is used to deal NumericAlphabet.