bpp-phyl3  3.0.0
TS98.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_TS98_H
6 #define BPP_PHYL_MODEL_TS98_H
7 
8 
10 
11 // From NumCalc:
13 #include <Bpp/Numeric/Parameter.h>
14 
15 namespace bpp
16 {
42 class TS98 :
44 {
45 public:
55  std::unique_ptr<ReversibleSubstitutionModelInterface> model,
56  double s1 = 1.,
57  double s2 = 1.,
58  bool normalizeRateChanges = false) :
59  MarkovModulatedSubstitutionModel(std::move(model), 2, normalizeRateChanges, "TS98.")
60  {
61  addParameter_(new Parameter("TS98.s1", s1, Parameter::R_PLUS_STAR));
62  addParameter_(new Parameter("TS98.s2", s2, Parameter::R_PLUS_STAR));
65  }
66 
67  virtual ~TS98() {}
68 
69  TS98* clone() const override { return new TS98(*this); }
70 
71 public:
72  std::string getName() const override { return "TS98"; }
73 
74  double getRate() const override { return 1.; }
75 
76  void setRate(double rate) override {}
77 
78  void addRateParameter() override {}
79 
80 protected:
81  void updateRatesModel_() override
82  {
83  double s1 = getParameterValue("s1");
84  double s2 = getParameterValue("s2");
85  ratesFreq_[0] = s2 / (s1 + s2);
86  ratesFreq_[1] = s1 / (s1 + s2);
87  rates_(1, 1) = (s1 + s2) / s1;
88  ratesExchangeability_(0, 1) = ratesExchangeability_(1, 0) = s1 + s2;
89  ratesExchangeability_(0, 0) = -s1 * (s1 + s2) / s2;
90  ratesExchangeability_(1, 1) = -s2 * (s1 + s2) / s1;
91  }
92 };
93 } // end of namespace bpp.
94 #endif // BPP_PHYL_MODEL_TS98_H
void addParameter_(Parameter *parameter)
double getParameterValue(const std::string &name) const override
Partial implementation of the Markov-modulated class of substitution models.
static const std::shared_ptr< IntervalConstraint > R_PLUS_STAR
Tuffley and Steel's 1998 covarion model.
Definition: TS98.h:44
virtual ~TS98()
Definition: TS98.h:67
double getRate() const override
Get the rate.
Definition: TS98.h:74
std::string getName() const override
Get the name of the model.
Definition: TS98.h:72
TS98 * clone() const override
Definition: TS98.h:69
TS98(std::unique_ptr< ReversibleSubstitutionModelInterface > model, double s1=1., double s2=1., bool normalizeRateChanges=false)
Build a new TS98 substitution model.
Definition: TS98.h:54
void addRateParameter() override
Definition: TS98.h:78
void updateRatesModel_() override
Update the rates vector, generator and equilibrium frequencies.
Definition: TS98.h:81
void setRate(double rate) override
Set the rate of the model (must be positive).
Definition: TS98.h:76
Defines the basic types of data flow nodes.