bpp-phyl3  3.0.0
YpR.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_NUCLEOTIDE_YPR_H
6 #define BPP_PHYL_MODEL_NUCLEOTIDE_YPR_H
7 
8 #include <Bpp/Seq/Alphabet/RNY.h>
9 
10 #include "../AbstractSubstitutionModel.h"
12 
13 // From Utils:
14 #include <Bpp/Exceptions.h>
15 
16 using namespace std;
17 
18 namespace bpp
19 {
86 class YpR :
88 {
89 protected:
90  std::unique_ptr<NucleotideSubstitutionModelInterface> pmodel_;
91 
92  // Prefix of the native pmodel_
93  std::string nestedPrefix_;
94 
95 protected:
100  YpR(
101  std::shared_ptr<const RNY>,
102  std::unique_ptr<NucleotideSubstitutionModelInterface> const,
103  const std::string& prefix);
104 
105  YpR(const YpR& ypr);
106 
107  YpR& operator=(const YpR& ypr)
108  {
109  AbstractParameterAliasable::operator=(ypr);
110  AbstractSubstitutionModel::operator=(ypr);
111  nestedPrefix_ = ypr.nestedPrefix_;
112  pmodel_.reset(ypr.pmodel_->clone());
113  return *this;
114  }
115 
116 public:
117  virtual ~YpR() {}
118 
119 protected:
120  void updateMatrices_(double, double, double, double,
121  double, double, double, double);
122 
123  virtual void updateMatrices_() override;
124 
125  string getNestedPrefix() const
126  {
127  return nestedPrefix_;
128  }
129 
130 public:
131  // virtual std::string getName() const;
132 
133  const NucleotideSubstitutionModelInterface& nestedModel() const { return *pmodel_; }
134 
135  size_t getNumberOfStates() const override { return 36; }
136 
137  virtual void setNamespace(const std::string&) override;
138 
139  void fireParameterChanged(const ParameterList& parameters) override
140  {
141  AbstractSubstitutionModel::fireParameterChanged(parameters);
142  pmodel_->matchParametersValues(parameters);
143  updateMatrices_();
144  }
145 
146  // Check that the model is good for YpR
147  void checkModel(const SubstitutionModelInterface& model) const;
148 };
149 }
150 
151 
152 // //////////////////////////////////////
153 // //////// YpR_symetrical
154 
155 namespace bpp
156 {
169 class YpR_Sym :
170  public YpR
171 {
172 public:
179  YpR_Sym(
180  std::shared_ptr<const RNY> alph,
181  std::unique_ptr<NucleotideSubstitutionModelInterface> pm,
182  double CgT = 0., double TgC = 0.,
183  double CaT = 0., double TaC = 0.);
184 
185  YpR_Sym(const YpR_Sym&);
186 
187  virtual ~YpR_Sym() {}
188 
189  YpR_Sym* clone() const override { return new YpR_Sym(*this); }
190 
191  std::string getName() const override;
192 
193 protected:
194  void updateMatrices_() override;
195 };
196 
197 // //////////////////////////////////////
198 // //////// YpR_general
199 
210 class YpR_Gen :
211  public YpR
212 {
213 public:
221  YpR_Gen(
222  std::shared_ptr<const RNY> alph,
223  std::unique_ptr<NucleotideSubstitutionModelInterface> pm,
224  double CgT = 0., double cGA = 0.,
225  double TgC = 0., double tGA = 0.,
226  double CaT = 0., double cAG = 0.,
227  double TaC = 0., double tAG = 0.);
228 
229  YpR_Gen(const YpR_Gen&);
230 
231  virtual ~YpR_Gen() {}
232 
233  YpR_Gen* clone() const override { return new YpR_Gen(*this); }
234 
235  std::string getName() const override;
236 
237 protected:
238  void updateMatrices_() override;
239 };
240 }
241 #endif // BPP_PHYL_MODEL_NUCLEOTIDE_YPR_H
Specialisation interface for nucleotide substitution model.
Interface for all substitution models.
General YpR model.
Definition: YpR.h:212
YpR_Gen * clone() const override
Definition: YpR.h:233
virtual ~YpR_Gen()
Definition: YpR.h:231
symmetrical YpR model.
Definition: YpR.h:171
YpR_Sym * clone() const override
Definition: YpR.h:189
virtual ~YpR_Sym()
Definition: YpR.h:187
YpR model.
Definition: YpR.h:88
std::string nestedPrefix_
Definition: YpR.h:93
size_t getNumberOfStates() const override
Get the number of states.
Definition: YpR.h:135
virtual ~YpR()
Definition: YpR.h:117
const NucleotideSubstitutionModelInterface & nestedModel() const
Definition: YpR.h:133
void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
Definition: YpR.h:139
std::unique_ptr< NucleotideSubstitutionModelInterface > pmodel_
Definition: YpR.h:90
string getNestedPrefix() const
Definition: YpR.h:125
YpR & operator=(const YpR &ypr)
Definition: YpR.h:107
Defines the basic types of data flow nodes.