bpp-phyl3  3.0.0
POMO.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_POMO_H
6 #define BPP_PHYL_MODEL_POMO_H
7 
8 
11 
82 
83 namespace bpp
84 {
85 class POMO :
87 {
88 private:
89  uint nbAlleles_;
90 
91  std::unique_ptr<SubstitutionModelInterface> pmodel_;
92  std::unique_ptr<FrequencySetInterface> pfitness_;
93 
94 public:
98  POMO(std::shared_ptr<const AllelicAlphabet> allAlph,
99  std::unique_ptr<SubstitutionModelInterface> pmodel,
100  std::unique_ptr<FrequencySetInterface> pfitness);
101 
102  POMO(const POMO& model) :
105  nbAlleles_(model.nbAlleles_),
106  pmodel_(model.pmodel_->clone()),
107  pfitness_(model.pfitness_ ? model.pfitness_->clone() : nullptr)
108  {}
109 
110  POMO& operator=(const POMO& model)
111  {
113  nbAlleles_ = model.nbAlleles_;
114  pmodel_.reset(model.pmodel_->clone());
115  pfitness_.reset(model.pfitness_ ? model.pfitness_->clone() : nullptr);
116  return *this;
117  }
118 
119  POMO* clone() const override
120  {
121  return new POMO(*this);
122  }
123 
124  void fireParameterChanged(const ParameterList& parameters) override;
125 
126  void setFreq(std::map<int, double>& frequencies) override;
127 
128  void setNamespace(const std::string& prefix) override
129  {
131  pmodel_->setNamespace(prefix + pmodel_->getNamespace());
132  if (pfitness_)
133  pfitness_->setNamespace(prefix + pfitness_->getNamespace());
134  }
135 
136  std::shared_ptr<const AllelicAlphabet> getAllelicAlphabet() const
137  {
138  return std::dynamic_pointer_cast<const AllelicAlphabet>(alphabet_);
139  }
140 
142  {
143  return dynamic_cast<const AllelicAlphabet&>(*alphabet_);
144  }
145 
146  uint getNbAlleles() const
147  {
148  return nbAlleles_;
149  }
150 
151  bool hasFitness() const
152  {
153  return pfitness_ != nullptr;
154  }
155 
157  {
158  return *pfitness_;
159  }
160 
162  {
163  return *pmodel_;
164  }
165 
166  std::string getName() const override
167  {
168  return "POMO";
169  }
170 
171 protected:
172  void updateMatrices_() override;
173 };
174 } // end of namespace bpp.
175 #endif // BPP_PHYL_MODEL_POMO_H
AbstractParameterAliasable & operator=(const AbstractParameterAliasable &ap)
void setNamespace(const std::string &prefix)
std::shared_ptr< const Alphabet > alphabet_
The alphabet relevant to this model.
Parametrize a set of state frequencies.
Definition: FrequencySet.h:29
Definition: POMO.h:87
const AllelicAlphabet & allelicAlphabet() const
Definition: POMO.h:141
void fireParameterChanged(const ParameterList &parameters) override
Tells the model that a parameter value has changed.
Definition: POMO.cpp:158
POMO & operator=(const POMO &model)
Definition: POMO.h:110
const FrequencySetInterface & fitness() const
Definition: POMO.h:156
POMO * clone() const override
Definition: POMO.h:119
std::unique_ptr< FrequencySetInterface > pfitness_
Definition: POMO.h:92
std::unique_ptr< SubstitutionModelInterface > pmodel_
Definition: POMO.h:91
std::shared_ptr< const AllelicAlphabet > getAllelicAlphabet() const
Definition: POMO.h:136
const SubstitutionModelInterface & mutationModel() const
Definition: POMO.h:161
void setNamespace(const std::string &prefix) override
Definition: POMO.h:128
bool hasFitness() const
Definition: POMO.h:151
std::string getName() const override
Get the name of the model.
Definition: POMO.h:166
POMO(const POMO &model)
Definition: POMO.h:102
void updateMatrices_() override
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
Definition: POMO.cpp:43
uint getNbAlleles() const
Definition: POMO.h:146
uint nbAlleles_
Definition: POMO.h:89
void setFreq(std::map< int, double > &frequencies) override
Set equilibrium frequencies.
Definition: POMO.cpp:168
POMO(std::shared_ptr< const AllelicAlphabet > allAlph, std::unique_ptr< SubstitutionModelInterface > pmodel, std::unique_ptr< FrequencySetInterface > pfitness)
Build a POMO instance.
Definition: POMO.cpp:12
Interface for all substitution models.
Defines the basic types of data flow nodes.