bpp-phyl3 3.0.0
RegisterRatesSubstitutionModel.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_REGISTERRATESSUBSTITUTIONMODEL_H
6#define BPP_PHYL_MODEL_REGISTERRATESSUBSTITUTIONMODEL_H
7
9
10#include "../Mapping/SubstitutionRegister.h"
14
15namespace bpp
16{
29{
30private:
34 std::unique_ptr<SubstitutionModelInterface> originalModel_;
35
39 std::string registerName_;
40
46 size_t nbTypes_;
47
52
53public:
63 std::unique_ptr<SubstitutionModelInterface> originalModel,
65 bool isNormalized = false);
66
67
77 nbTypes_(fmsm.nbTypes_),
78 vRates_(fmsm.vRates_)
79 {}
80
81
83 {
86
87 originalModel_.reset(fmsm.originalModel_->clone());
90 nbTypes_ = fmsm.nbTypes_;
91 vRates_ = fmsm.vRates_;
92
93 return *this;
94 }
95
97
99 {
100 return new RegisterRatesSubstitutionModel(*this);
101 }
102
103public:
108 {
109 return *originalModel_;
110 }
111
113 {
114 return *originalModel_;
115 }
116
117protected:
119 {
120 return *originalModel_;
121 }
122
123
125 {
126 return *originalModel_;
127 }
128
129public:
130 void fireParameterChanged(const ParameterList& parameters) override
131 {
135 }
136
137 size_t getNumberOfStates() const override
138 {
140 }
141
142public:
143 std::string getName() const override
144 {
145 return "FromRegister";
146 }
147
148 const std::string& getRegisterName() const
149 {
150 return registerName_;
151 }
152
153 void addRateParameter() override
154 {
155 throw Exception("RegisterRatesSubstitutionModel::addRateParameter method should not be called, because rates are defined through registers.");
156 }
157
164 const std::vector<int>& getAlphabetStates() const override
165 {
167 }
168
169 std::vector<size_t> getModelStates(int i) const override
170 {
172 }
173
174 std::vector<size_t> getModelStates(const std::string& s) const override
175 {
177 }
178
179 int getAlphabetStateAsInt(size_t i) const override
180 {
182 }
183
184 std::string getAlphabetStateAsChar(size_t s) const override
185 {
187 }
188
189 const Alphabet& alphabet() const override
190 {
192 }
193
194 std::shared_ptr<const Alphabet> getAlphabet() const override
195 {
197 }
198
199 const StateMapInterface& stateMap() const override
200 {
202 }
203
204 std::shared_ptr<const StateMapInterface> getStateMap() const override
205 {
207 }
208
209 const FrequencySetInterface& frequencySet() const override
210 {
212 }
213
216 void setRate(double rate) override { model_().setRate(rate); }
217
218 double getRate() const override { return model().getRate(); }
219
220private:
222
223protected:
224 void updateMatrices_() override;
225};
226} // end of namespace bpp.
227#endif // BPP_PHYL_MODEL_REGISTERRATESSUBSTITUTIONMODEL_H
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
virtual void fireParameterChanged(const ParameterList &parameters)
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
Abstract class of Wrapping model class, where all methods are redirected from model().
std::shared_ptr< const StateMapInterface > getStateMap() const override
const Alphabet & alphabet() const override
const std::vector< int > & getAlphabetStates() const override
std::shared_ptr< const Alphabet > getAlphabet() const override
std::string getAlphabetStateAsChar(size_t i) const override
std::vector< size_t > getModelStates(int code) const override
Get the state in the model corresponding to a particular state in the alphabet.
const StateMapInterface & stateMap() const override
int getAlphabetStateAsInt(size_t i) const override
const BranchModelInterface & model() const override
const FrequencySetInterface & frequencySet() const override
virtual void setRate(double rate)=0
Set the rate of the model (must be positive).
virtual double getRate() const =0
Get the rate.
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
virtual bool matchParametersValues(const ParameterList &parameters)=0
From a model, substitution rates are set into categories following a given register....
RegisterRatesSubstitutionModel * clone() const override
VVVuint vRegStates_
Vector of register state -> vector of from states -> vector of to states (for acceleration purpose)
std::vector< size_t > getModelStates(int i) const override
Get the state in the model corresponding to a particular state in the alphabet.
RegisterRatesSubstitutionModel(const RegisterRatesSubstitutionModel &fmsm)
const StateMapInterface & stateMap() const override
std::shared_ptr< const Alphabet > getAlphabet() const override
const TransitionModelInterface & transitionModel() const override
const Alphabet & alphabet() const override
const SubstitutionModelInterface & substitutionModel() const override
From AbstractWrappedSubstitutionModel.
TransitionModelInterface & transitionModel_() override
std::unique_ptr< SubstitutionModelInterface > originalModel_
The related model.
RegisterRatesSubstitutionModel & operator=(const RegisterRatesSubstitutionModel &fmsm)
std::string getAlphabetStateAsChar(size_t s) const override
void setRate(double rate) override
Set the rate of the model (must be positive).
const FrequencySetInterface & frequencySet() const override
double getRate() const override
The rate of the substitution process.
Vdouble vRates_
vector of the rates of the register types
const std::vector< int > & getAlphabetStates() const override
Overrides of AbstractSubstitutionModel and AbstractWrappedSubstitutionModel.
RegisterRatesSubstitutionModel(std::unique_ptr< SubstitutionModelInterface > originalModel, const SubstitutionRegisterInterface &reg, bool isNormalized=false)
Constructor.
void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
std::string getName() const override
Get the name of the model.
SubstitutionModelInterface & substitutionModel_() override
size_t getNumberOfStates() const override
Get the number of states.
void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
std::shared_ptr< const StateMapInterface > getStateMap() const override
void addRateParameter() override
add a "rate" parameter to the model, that handles the overall rate of the process.
std::vector< size_t > getModelStates(const std::string &s) const override
Get the state in the model corresponding to a particular state in the alphabet.
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:25
virtual size_t getNumberOfModelStates() const =0
Interface for all substitution models.
The SubstitutionRegister interface.
Interface for all transition models.
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
std::vector< VVuint > VVVuint