bpp-phyl  2.2.0
RE08.h
Go to the documentation of this file.
1 //
2 // File: RE08.h
3 // Created by: Julien Dutheil
4 // Created on: Mon Dec 29 10:15 2008
5 //
6 
7 /*
8  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
9 
10  This software is a computer program whose purpose is to provide classes
11  for phylogenetic data analysis.
12 
13  This software is governed by the CeCILL license under French law and
14  abiding by the rules of distribution of free software. You can use,
15  modify and/ or redistribute the software under the terms of the CeCILL
16  license as circulated by CEA, CNRS and INRIA at the following URL
17  "http://www.cecill.info".
18 
19  As a counterpart to the access to the source code and rights to copy,
20  modify and redistribute granted by the license, users are provided only
21  with a limited warranty and the software's author, the holder of the
22  economic rights, and the successive licensors have only limited
23  liability.
24 
25  In this respect, the user's attention is drawn to the risks associated
26  with loading, using, modifying and/or developing or reproducing the
27  software by the user in light of its specific status of free software,
28  that may mean that it is complicated to manipulate, and that also
29  therefore means that it is reserved for developers and experienced
30  professionals having in-depth computer knowledge. Users are therefore
31  encouraged to load and test the software's suitability as regards their
32  requirements in conditions enabling the security of their systems and/or
33  data to be ensured and, more generally, to use and operate it in the
34  same conditions as regards security.
35 
36  The fact that you are presently reading this means that you have had
37  knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _RE08_H_
41 #define _RE08_H_
42 
43 #include "SubstitutionModel.h"
45 
46 namespace bpp
47 {
48 
96  class RE08:
98  {
99  private:
100  std::auto_ptr<ReversibleSubstitutionModel> simpleModel_;
101  RowMatrix<double> simpleGenerator_;
102  RowMatrix<double> simpleExchangeabilities_;
103  mutable double exp_;
104  mutable RowMatrix<double> p_;
105  double lambda_;
106  double mu_;
107  std::string nestedPrefix_;
108 
109  public:
121  RE08(ReversibleSubstitutionModel* simpleModel, double lambda = 0, double mu = 0);
122 
123  RE08(const RE08& model):
124  AbstractParameterAliasable(model),
125  //AbstractSubstitutionModel(model),
130  exp_(model.exp_),
131  p_(model.p_),
132  lambda_(model.lambda_),
133  mu_(model.mu_),
135  {}
136 
137  RE08& operator=(const RE08& model)
138  {
139  AbstractParameterAliasable::operator=(model);
142  simpleModel_.reset(dynamic_cast<ReversibleSubstitutionModel*>(model.simpleModel_->clone()));
145  exp_ = model.exp_;
146  p_ = model.p_;
147  lambda_ = model.lambda_;
148  mu_ = model.mu_;
150  return *this;
151  }
152 
153  virtual ~RE08() {}
154 
155  RE08* clone() const { return new RE08(*this); }
156 
157  public:
158 
159  double Pij_t (size_t i, size_t j, double d) const;
160  double dPij_dt (size_t i, size_t j, double d) const;
161  double d2Pij_dt2(size_t i, size_t j, double d) const;
162  const Matrix<double>& getPij_t (double d) const;
163  const Matrix<double>& getdPij_dt (double d) const;
164  const Matrix<double>& getd2Pij_dt2(double d) const;
165 
166  std::string getName() const { return "RE08"; }
167 
174  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0)
175  {
176  simpleModel_->setFreqFromData(data, pseudoCount);
177  }
178 
179  void fireParameterChanged(const ParameterList& parameters)
180  {
181  AbstractParameterAliasable::fireParameterChanged(parameters);
182  simpleModel_->matchParametersValues(parameters);
183  lambda_ = getParameter_(0).getValue();
184  mu_ = getParameter_(1).getValue();
185  updateMatrices();
186  }
187 
188  size_t getNumberOfStates() const { return size_; }
189 
190  double getInitValue(size_t i, int state) const throw (IndexOutOfBoundsException, BadIntException);
191 
192  void setNamespace(const std::string& prefix);
193 
194  const SubstitutionModel* getNestedModel() const { return simpleModel_.get(); }
195 
196  protected:
197 
198  void updateMatrices();
199  };
200 
201 } //end of namespace bpp.
202 
203 #endif //_RE08_H_
204 
const Matrix< double > & getd2Pij_dt2(double d) const
Definition: RE08.cpp:267
Interface for all substitution models.
RE08 & operator=(const RE08 &model)
Definition: RE08.h:137
void setNamespace(const std::string &prefix)
Definition: RE08.cpp:311
std::string getName() const
Get the name of the model.
Definition: RE08.h:166
const Matrix< double > & getPij_t(double d) const
Definition: RE08.cpp:213
RowMatrix< double > simpleGenerator_
Definition: RE08.h:101
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
This method is forwarded to the simple model.
Definition: RE08.h:174
size_t getNumberOfStates() const
Get the number of states.
Definition: RE08.h:188
RowMatrix< double > p_
Definition: RE08.h:104
void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
Definition: RE08.h:179
const Matrix< double > & getdPij_dt(double d) const
Definition: RE08.cpp:239
double mu_
Definition: RE08.h:106
void updateMatrices()
Compute and diagonalize the matrix, and fill the eigenValues_, leftEigenVectors_ and rightEigenVecto...
Definition: RE08.cpp:78
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
Partial implementation of the ReversibleSubstitutionModel interface.
const SubstitutionModel * getNestedModel() const
Definition: RE08.h:194
double d2Pij_dt2(size_t i, size_t j, double d) const
Definition: RE08.cpp:181
RE08 * clone() const
Definition: RE08.h:155
Interface for reversible substitution models.
double lambda_
Definition: RE08.h:105
double exp_
Definition: RE08.h:103
RE08(const RE08 &model)
Definition: RE08.h:123
RowMatrix< double > simpleExchangeabilities_
Definition: RE08.h:102
virtual ~RE08()
Definition: RE08.h:153
size_t size_
The size of the generator, i.e. the number of states.
double dPij_dt(size_t i, size_t j, double d) const
Definition: RE08.cpp:150
RE08(ReversibleSubstitutionModel *simpleModel, double lambda=0, double mu=0)
Build a new Rivas & Eddy model from a standard substitution model.
Definition: RE08.cpp:50
std::string nestedPrefix_
Definition: RE08.h:107
double getInitValue(size_t i, int state) const
Definition: RE08.cpp:297
The Rivas-Eddy substitution model with gap characters.
Definition: RE08.h:96
std::auto_ptr< ReversibleSubstitutionModel > simpleModel_
Definition: RE08.h:100
double Pij_t(size_t i, size_t j, double d) const
Definition: RE08.cpp:120