bpp-seq3  3.0.0
MoldMitochondrialGeneticCode.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_MOLDMITOCHONDRIALGENETICCODE_H
6 #define BPP_SEQ_GENETICCODE_MOLDMITOCHONDRIALGENETICCODE_H
7 
8 
9 #include "../Alphabet/NucleicAlphabet.h"
10 #include "GeneticCode.h"
11 
12 namespace bpp
13 {
20  public virtual GeneticCode
21 {
22 public:
23  MoldMitochondrialGeneticCode(std::shared_ptr<const NucleicAlphabet> alphabet) :
24  GeneticCode(alphabet)
25  {
26  init_();
27  }
28 
30 
32  {
33  return new MoldMitochondrialGeneticCode(*this);
34  }
35 
36 public:
37  size_t getNumberOfStopCodons() const { return 2; }
38 
39  std::vector<int> getStopCodonsAsInt() const
40  {
41  return std::vector<int>({48, 50});
42  }
43 
44  std::vector<std::string> getStopCodonsAsChar() const
45  {
46  return std::vector<std::string>({"TAA", "TAG"});
47  }
48 
49  bool isStop(int state) const
50  {
51  // Test:
52  codonAlphabet_->intToChar(state); // throw exception if invalid state!
53  return state == 48 || state == 50;
54  }
55 
56  bool isStop(const std::string& state) const
57  {
58  int i = codonAlphabet_->charToInt(state);
59  return i == 48 || i == 50;
60  }
61 
62  bool isAltStart(int state) const
63  {
64  // Test:
65  codonAlphabet_->intToChar(state); // throw exception if invalid state!
66  return state == 12 || state == 13 || state == 15 || state == 30 || state == 46 || state == 60 || state == 62;
67  }
68 
69  bool isAltStart(const std::string& state) const
70  {
71  int i = codonAlphabet_->charToInt(state);
72  return i == 12 || i == 13 || i == 15 || i == 30 || i == 46 || i == 60 || i == 62;
73  }
74 
75 private:
76  void init_();
77 };
78 } // end of namespace bpp.
79 #endif // BPP_SEQ_GENETICCODE_MOLDMITOCHONDRIALGENETICCODE_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 mold, protozoan, and coelenterate mitochondrial code and the Mycoplasma/Spi...
bool isStop(int state) const
Tells is a particular codon is a stop codon.
virtual MoldMitochondrialGeneticCode * clone() const
bool isAltStart(const std::string &state) const
Tells is a particular codon is an alternative start codon.
bool isAltStart(int state) const
Tells is a particular codon is an alternative start codon.
bool isStop(const std::string &state) const
Tells is a particular codon is a stop codon.
std::vector< std::string > getStopCodonsAsChar() const
MoldMitochondrialGeneticCode(std::shared_ptr< const NucleicAlphabet > alphabet)
This alphabet is used to deal NumericAlphabet.