bpp-phyl3  3.0.0
KCM.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_PHYL_MODEL_CODON_KCM_H
6 #define BPP_PHYL_MODEL_CODON_KCM_H
7 
8 
9 #include "../AbstractBiblioSubstitutionModel.h"
11 
12 namespace bpp
13 {
41 class KCM :
44 {
45 private:
46  std::unique_ptr<KroneckerCodonDistanceSubstitutionModel> pmodel_;
47  bool oneModel_;
48 
49 public:
56  KCM(std::shared_ptr<const GeneticCode> gc, bool oneModel);
57 
58  KCM(const KCM& kcm);
59 
60  KCM& operator=(const KCM&);
61 
62  virtual ~KCM() {}
63 
64  KCM* clone() const override { return new KCM(*this); }
65 
66 public:
67  std::string getName() const override { return "KCM" + std::string(oneModel_ ? "7" : "19") + ".";}
68 
69  const SubstitutionModelInterface& substitutionModel() const override { return *pmodel_; }
70 
71  std::shared_ptr<const GeneticCode> getGeneticCode() const override { return pmodel_->getGeneticCode(); }
72 
73  double getCodonsMulRate(size_t i, size_t j) const override { return pmodel_->getCodonsMulRate(i, j); }
74 
75 protected:
77 
79  {
80  throw NullPointerException("KCM::codonFrequencySet. No FrequencySet available for this model.");
81  }
82 
83  bool hasCodonFrequencySet() const override
84  {
85  return false;
86  }
87 
88  void setFreq(std::map<int, double>& frequencies) override
89  {
91  }
92 };
93 } // end of namespace bpp.
94 #endif // BPP_PHYL_MODEL_CODON_KCM_H
void setFreq(std::map< int, double > &frequ) override
Set equilibrium frequencies.
Parametrize a set of state frequencies for codons.
Interface for reversible codon models.
The general multiple substitution model for codons, from Zaheri & al, 2014.
Definition: KCM.h:44
const CodonFrequencySetInterface & codonFrequencySet() const override
Definition: KCM.h:78
std::unique_ptr< KroneckerCodonDistanceSubstitutionModel > pmodel_
Definition: KCM.h:46
double getCodonsMulRate(size_t i, size_t j) const override
Returns the multiplicative rate specific to two codons specified by their number. The respective gene...
Definition: KCM.h:73
SubstitutionModelInterface & substitutionModel_() override
Definition: KCM.h:76
KCM * clone() const override
Definition: KCM.h:64
void setFreq(std::map< int, double > &frequencies) override
Set equilibrium frequencies.
Definition: KCM.h:88
const SubstitutionModelInterface & substitutionModel() const override
Definition: KCM.h:69
KCM & operator=(const KCM &)
Definition: KCM.cpp:80
std::string getName() const override
Get the name of the model.
Definition: KCM.h:67
KCM(std::shared_ptr< const GeneticCode > gc, bool oneModel)
constructor.
Definition: KCM.cpp:17
std::shared_ptr< const GeneticCode > getGeneticCode() const override
Definition: KCM.h:71
virtual ~KCM()
Definition: KCM.h:62
bool oneModel_
Definition: KCM.h:47
bool hasCodonFrequencySet() const override
Definition: KCM.h:83
Interface for all substitution models.
Defines the basic types of data flow nodes.