bpp-phyl3  3.0.0
CodonAdHocSubstitutionModel.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_CODONADHOCSUBSTITUTIONMODEL_H
6 #define BPP_PHYL_MODEL_CODON_CODONADHOCSUBSTITUTIONMODEL_H
7 
8 
10 
11 namespace bpp
12 {
26 {
27 private:
28  std::vector< std::unique_ptr<CoreCodonSubstitutionModelInterface>> vModel_;
29 
30  std::string name_;
31 
36  std::unique_ptr<CodonFrequencySetInterface> freqSet_;
37 
38 public:
51  std::shared_ptr<const GeneticCode> gCode,
52  std::unique_ptr<NucleotideSubstitutionModelInterface> pmod,
53  std::vector<std::unique_ptr<CoreCodonSubstitutionModelInterface>>& vpmodel,
54  const std::string& name);
55 
68  std::shared_ptr<const GeneticCode> gCode,
69  std::unique_ptr<NucleotideSubstitutionModelInterface> pmod1,
70  std::unique_ptr<NucleotideSubstitutionModelInterface> pmod2,
71  std::unique_ptr<NucleotideSubstitutionModelInterface> pmod3,
72  std::vector<std::unique_ptr<CoreCodonSubstitutionModelInterface>>& vpmodel,
73  const std::string& name);
74 
76 
78 
80 
82  {
83  return new CodonAdHocSubstitutionModel(*this);
84  }
85 
86 public:
87  void fireParameterChanged(const ParameterList& parameterlist) override;
88 
89  std::string getName() const override
90  {
91  return name_;
92  }
93 
94  void setNamespace(const std::string& prefix) override
95  {
97  for (auto& model : vModel_)
98  {
99  model->setNamespace(prefix);
100  }
101  }
102 
103  size_t getNumberOfModels() const
104  {
105  return vModel_.size();
106  }
107 
109  {
110  return *vModel_[i];
111  }
112 
113  double getCodonsMulRate(size_t i, size_t j) const override;
114 
115  void setFreq(std::map<int, double>& frequencies) override;
116 
118  {
119  return *freqSet_;
120  }
121 
122  bool hasCodonFrequencySet() const override
123  {
124  return freqSet_ != nullptr;
125  }
126 };
127 } // end of namespace bpp.
128 #endif // BPP_PHYL_MODEL_CODON_CODONADHOCSUBSTITUTIONMODEL_H
Abstract class for substitution models on codons.
void setNamespace(const std::string &prefix) override
Class for substitution models of codons with several layers of codon models.
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...
void fireParameterChanged(const ParameterList &parameterlist) override
Tells the model that a parameter value has changed.
CodonAdHocSubstitutionModel * clone() const override
const CodonFrequencySetInterface & codonFrequencySet() const override
CodonAdHocSubstitutionModel(std::shared_ptr< const GeneticCode > gCode, std::unique_ptr< NucleotideSubstitutionModelInterface > pmod, std::vector< std::unique_ptr< CoreCodonSubstitutionModelInterface >> &vpmodel, const std::string &name)
Build a new CodonAdHocSubstitutionModel object from a pointer to NucleotideSubstitutionModel.
std::vector< std::unique_ptr< CoreCodonSubstitutionModelInterface > > vModel_
void setNamespace(const std::string &prefix) override
void setFreq(std::map< int, double > &frequencies) override
Estimation of the parameters of the models so that the equilibrium frequencies match the given ones.
std::unique_ptr< CodonFrequencySetInterface > freqSet_
optional FrequencySet if model is defined through a FrequencySet.
std::string getName() const override
Get the name of the model.
const CoreCodonSubstitutionModelInterface & layerModel(size_t i) const
CodonAdHocSubstitutionModel & operator=(const CodonAdHocSubstitutionModel &model)
Parametrize a set of state frequencies for codons.
Defines the basic types of data flow nodes.