bpp-phyl3  3.0.0
OneChangeTransitionModel.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_ONECHANGETRANSITIONMODEL_H
6 #define BPP_PHYL_MODEL_ONECHANGETRANSITIONMODEL_H
7 
8 
10 
11 namespace bpp
12 {
22 {
23 public:
24  OneChangeTransitionModel(std::unique_ptr<SubstitutionModelInterface> originalModel) :
25  AbstractParameterAliasable("Onechange."),
26  AbstractWrappedModel("Onechange."),
27  AbstractWrappedTransitionModel("Onechange."),
28  AbstractFromSubstitutionModelTransitionModel(std::move(originalModel), "OneChange.")
29  {}
30 
36  {}
37 
39  {
43  return *this;
44  }
45 
47 
48  OneChangeTransitionModel* clone() const override { return new OneChangeTransitionModel(*this); }
49 
50 public:
51  double Pij_t (size_t i, size_t j, double t) const override;
52  double dPij_dt (size_t i, size_t j, double t) const override;
53  double d2Pij_dt2(size_t i, size_t j, double t) const override;
54 
55  const Matrix<double>& getPij_t(double t) const override;
56 
57  const Matrix<double>& getdPij_dt(double t) const override;
58 
59  const Matrix<double>& getd2Pij_dt2(double t) const override;
60 
61  double freq(size_t i) const override { return transitionModel().freq(i); }
62 
63  const Vdouble& getFrequencies() const override { return transitionModel().getFrequencies(); }
64 
65  const FrequencySetInterface& frequencySet() const override
66  {
67  return transitionModel().frequencySet();
68  }
69 
70  void setFreqFromData(const SequenceDataInterface& data, double pseudoCount) override
71  {
72  transitionModel_().setFreqFromData(data, pseudoCount);
73  }
74 
75  virtual void setFreq(std::map<int, double>& m) override
76  {
78  }
79 
80  double getRate() const override { return transitionModel().getRate(); }
81 
82  void setRate(double rate) override { return transitionModel_().setRate(rate); }
83 
84  double getInitValue(size_t i, int state) const override
85  {
86  return model().getInitValue(i, state);
87  }
88 
89  std::string getName() const override
90  {
91  return "OneChange";
92  }
93 
94 };
95 } // end of namespace bpp.
96 #endif // BPP_PHYL_MODEL_ONECHANGETRANSITIONMODEL_H
Virtual class of a Transition Model related to a given SubstitutionModel.
const TransitionModelInterface & transitionModel() const override
AbstractFromSubstitutionModelTransitionModel & operator=(const AbstractFromSubstitutionModelTransitionModel &fmsm)
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
Abstract class of Wrapping model class, where all methods are redirected from model().
virtual const FrequencySetInterface & frequencySet() const =0
virtual void setRate(double rate)=0
Set the rate of the model (must be positive).
virtual double getRate() const =0
Get the rate.
virtual double getInitValue(size_t i, int state) const =0
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
From a model, compute transition probabilities given there is at least a change in the branch.
const Matrix< double > & getPij_t(double t) const override
void setRate(double rate) override
Set the rate of the model (must be positive).
const Matrix< double > & getd2Pij_dt2(double t) const override
const FrequencySetInterface & frequencySet() const override
double Pij_t(size_t i, size_t j, double t) const override
virtual void setFreq(std::map< int, double > &m) override
Set equilibrium frequencies.
OneChangeTransitionModel(std::unique_ptr< SubstitutionModelInterface > originalModel)
double dPij_dt(size_t i, size_t j, double t) const override
const Matrix< double > & getdPij_dt(double t) const override
double d2Pij_dt2(size_t i, size_t j, double t) const override
const Vdouble & getFrequencies() const override
double getRate() const override
Get the rate.
double freq(size_t i) const override
double getInitValue(size_t i, int state) const override
OneChangeTransitionModel * clone() const override
OneChangeTransitionModel & operator=(const OneChangeTransitionModel &fmsm)
std::string getName() const override
Get the name of the model.
OneChangeTransitionModel(const OneChangeTransitionModel &fmsm)
void setFreqFromData(const SequenceDataInterface &data, double pseudoCount) override
Set equilibrium frequencies equal to the frequencies estimated from the data.
virtual double freq(size_t i) const =0
virtual const Vdouble & getFrequencies() const =0
virtual void setFreq(std::map< int, double > &frequencies)=0
Set equilibrium frequencies.
virtual void setFreqFromData(const SequenceDataInterface &data, double pseudoCount=0)=0
Set equilibrium frequencies equal to the frequencies estimated from the data.
Defines the basic types of data flow nodes.
std::vector< double > Vdouble