bpp-phyl3  3.0.0
EquiprobableSubstitutionModel.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_EQUIPROBABLESUBSTITUTIONMODEL_H
6 #define BPP_PHYL_MODEL_EQUIPROBABLESUBSTITUTIONMODEL_H
7 
9 
12 
13 namespace bpp
14 {
102 {
103 private:
104  mutable double exp_;
106  std::unique_ptr<FrequencySetInterface> freqSet_;
107 
108 public:
114  EquiprobableSubstitutionModel(std::shared_ptr<const Alphabet> alpha);
115 
125  std::shared_ptr<const Alphabet> alpha,
126  std::unique_ptr<FrequencySetInterface> freqSet,
127  bool initFreqs = false);
128 
132  exp_(model.exp_),
133  p_(model.p_),
134  freqSet_(model.freqSet_->clone())
135  {}
136 
138  {
141  exp_ = model.exp_;
142  p_ = model.p_;
143  freqSet_.reset(model.freqSet_->clone());
144  return *this;
145  }
146 
148 
149  EquiprobableSubstitutionModel* clone() const override { return new EquiprobableSubstitutionModel(*this); }
150 
151 public:
152  double Pij_t (size_t i, size_t j, double d) const override;
153  double dPij_dt (size_t i, size_t j, double d) const override;
154  double d2Pij_dt2(size_t i, size_t j, double d) const override;
155  const Matrix<double>& getPij_t (double d) const override;
156  const Matrix<double>& getdPij_dt (double d) const override;
157  const Matrix<double>& getd2Pij_dt2(double d) const override;
158 
159  std::string getName() const override
160  {
161  if (freqSet_->getNamespace().find("+F.") != std::string::npos)
162  return "Equi+F";
163  else
164  return "Equi";
165  }
166 
167  void fireParameterChanged(const ParameterList& parameters) override
168  {
169  freqSet_->matchParametersValues(parameters);
170  freq_ = freqSet_->getFrequencies();
172  }
173 
175  {
176  freqSet_.reset(freqSet.clone());
178  addParameters_(freqSet_->getParameters());
179  }
180 
181  const FrequencySetInterface& frequencySet() const override { return *freqSet_; }
182 
183  void setFreq(std::map<int, double>& freq) override;
184 
185 protected:
191  void updateMatrices_() override;
192 };
193 } // end of namespace bpp.
194 #endif // BPP_PHYL_MODEL_EQUIPROBABLESUBSTITUTIONMODEL_H
void addParameters_(const ParameterList &parameters)
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
Partial implementation of the ReversibleSubstitutionModel interface.
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
virtual void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
Vdouble freq_
The vector of equilibrium frequencies.
virtual double freq(size_t i) const override
The EquiprobableSubstitutionModel substitution model for any kind of alphabet. Jukes-Cantor models ar...
double Pij_t(size_t i, size_t j, double d) const override
std::unique_ptr< FrequencySetInterface > freqSet_
EquiprobableSubstitutionModel & operator=(const EquiprobableSubstitutionModel &model)
const Matrix< double > & getd2Pij_dt2(double d) const override
const FrequencySetInterface & frequencySet() const override
void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
void setFreq(std::map< int, double > &freq) override
Set equilibrium frequencies.
double d2Pij_dt2(size_t i, size_t j, double d) const override
EquiprobableSubstitutionModel(std::shared_ptr< const Alphabet > alpha)
Build a simple equiprobable model, with original equilibrium frequencies.
EquiprobableSubstitutionModel(const EquiprobableSubstitutionModel &model)
double dPij_dt(size_t i, size_t j, double d) const override
void setFrequencySet(const FrequencySetInterface &freqSet)
const Matrix< double > & getdPij_dt(double d) const override
EquiprobableSubstitutionModel * clone() const override
std::string getName() const override
Get the name of the model.
const Matrix< double > & getPij_t(double d) const override
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
FrequencySetInterface * clone() const =0
Defines the basic types of data flow nodes.