bpp-phyl3  3.0.0
AbstractBiblioMixedTransitionModel.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_ABSTRACTBIBLIOMIXEDTRANSITIONMODEL_H
6 #define BPP_PHYL_MODEL_ABSTRACTBIBLIOMIXEDTRANSITIONMODEL_H
7 
8 
10 #include "MixedTransitionModel.h"
11 
12 namespace bpp
13 {
19  public virtual MixedTransitionModelInterface,
20  public virtual AbstractBiblioTransitionModel
21 {
22 protected:
23  std::unique_ptr<MixedTransitionModelInterface> mixedModelPtr_;
24 
25 public:
26  AbstractBiblioMixedTransitionModel(const std::string& prefix);
27 
29 
31 
33 
34 public:
38  const TransitionModelInterface& nModel(size_t i) const override
39  {
40  return mixedModel().nModel(i);
41  }
42 
43  std::shared_ptr<const TransitionModelInterface> getNModel(size_t i) const override
44  {
45  return mixedModel().getNModel(i);
46  }
47 
51  double getNProbability(size_t i) const override
52  {
53  return mixedModel().getNProbability(i);
54  }
55 
61  const std::vector<double>& getProbabilities() const override
62  {
63  return mixedModel().getProbabilities();
64  }
65 
70  void setNProbability(size_t i, double prob) override
71  {
72  mixedModel_().setNProbability(i, prob);
73  }
74 
78  size_t getNumberOfModels() const override
79  {
80  return mixedModel().getNumberOfModels();
81  }
82 
87  void setVRates(const Vdouble& vd) override
88  {
89  mixedModel_().setVRates(vd);
90  }
91 
96  void normalizeVRates() override
97  {
99  }
100 
104  const std::vector<double>& getVRates() const override
105  {
106  return mixedModel().getVRates();
107  }
108 
112  double getNRate(size_t i) const override
113  {
114  return mixedModel().getNRate(i);
115  }
116 
123  const TransitionModelInterface& model(const std::string& name) const override
124  {
125  return mixedModel().model(name);
126  }
127 
132  Vuint getSubmodelNumbers(const std::string& desc) const override;
133 
134  const TransitionModelInterface& transitionModel() const override { return *mixedModelPtr_; }
135 
137 
138  const FrequencySetInterface& frequencySet() const override
139  {
140  return mixedModelPtr_->nModel(0).frequencySet();
141  }
142 
143 protected:
145  {
146  return *mixedModelPtr_;
147  }
148 
150 
151  TransitionModelInterface& nModel_(size_t i) override
152  {
153  return mixedModel_().nModel_(i);
154  }
155 };
156 } // end of namespace bpp.
157 #endif // BPP_PHYL_MODEL_ABSTRACTBIBLIOMIXEDTRANSITIONMODEL_H
Abstract class for mixture models based on the bibliography.
double getNRate(size_t i) const override
Returns the rate of a specific model from the mixture.
void setNProbability(size_t i, double prob) override
Sets the probabilities of the submodels of the mixture.
void normalizeVRates() override
normalizes the rates of the submodels.
AbstractBiblioMixedTransitionModel & operator=(const AbstractBiblioMixedTransitionModel &model)
void setVRates(const Vdouble &vd) override
sets the rates of the submodels.
Vuint getSubmodelNumbers(const std::string &desc) const override
Returns the vector of numbers of the submodels in the mixture that match a description.
const std::vector< double > & getProbabilities() const override
Returns the vector of the probabilities of the submodels of the mixture.
TransitionModelInterface & nModel_(size_t i) override
const TransitionModelInterface & transitionModel() const override
const std::vector< double > & getVRates() const override
Returns the vector of all the rates of the mixture.
const MixedTransitionModelInterface & mixedModel() const
const TransitionModelInterface & model(const std::string &name) const override
Access the submodel with the given name.
const TransitionModelInterface & nModel(size_t i) const override
Returns the submodel from the mixture.
size_t getNumberOfModels() const override
Returns the number of submodels.
std::unique_ptr< MixedTransitionModelInterface > mixedModelPtr_
TransitionModelInterface & transitionModel_() override
const FrequencySetInterface & frequencySet() const override
double getNProbability(size_t i) const override
Returns the probability of a specific model from the mixture.
std::shared_ptr< const TransitionModelInterface > getNModel(size_t i) const override
Partial implementation of the SubstitutionModel interface for models that are set for matching the bi...
const BranchModelInterface & model() const override
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
Interface for Transition models, defined as a mixture of "simple" transition models.
virtual double getNProbability(size_t i) const =0
Returns the probability of a specific model from the mixture.
virtual const std::vector< double > & getProbabilities() const =0
virtual double getNRate(size_t i) const =0
Returns the rate of a specific submodel.
virtual void setVRates(const Vdouble &vd)=0
Sets the rates of the submodels to be proportional to a given vector, and normalizes them so that the...
virtual const std::vector< double > & getVRates() const =0
Returns the rates of the submodels.
virtual const TransitionModelInterface & nModel(size_t i) const =0
Returns a specific model from the mixture.
virtual void setNProbability(size_t i, double prob)=0
Sets the probability of a specific model from the mixture.
virtual void normalizeVRates()=0
Normalizes the rates of the submodels so that the mean rate of the mixture equals rate_.
virtual TransitionModelInterface & nModel_(size_t i)=0
virtual std::shared_ptr< const TransitionModelInterface > getNModel(size_t i) const =0
virtual size_t getNumberOfModels() const =0
virtual const TransitionModelInterface & model(const std::string &name) const =0
Access the submodel with the given name.
Interface for all transition models.
virtual const BranchModelInterface & model() const =0
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
std::vector< unsigned int > Vuint