bpp-phyl  2.2.0
JCprot.h
Go to the documentation of this file.
1 //
2 // File: JCprot.h
3 // Created by: Julien Dutheil
4 // Created on: Tue May 25 16:04:36 2003
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 _JCPROT_H_
41 #define _JCPROT_H_
42 
43 #include <Bpp/Seq/Alphabet/ProteicAlphabet.h>
45 #include "../AbstractSubstitutionModel.h"
46 #include "../FrequenciesSet/ProteinFrequenciesSet.h"
47 
48 namespace bpp
49 {
50 
134  class JCprot:
135  public virtual ProteinSubstitutionModel,
137  {
138  private:
139  mutable double exp_;
140  mutable RowMatrix<double> p_;
142 
143  public:
149  JCprot(const ProteicAlphabet* alpha);
150 
159  JCprot(const ProteicAlphabet* alpha, ProteinFrequenciesSet* freqSet, bool initFreqs = false);
160 
161  JCprot(const JCprot& model) :
162  AbstractParameterAliasable(model),
163  //AbstractSubstitutionModel(model),
165  exp_(model.exp_),
166  p_(model.p_),
167  freqSet_(dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone()))
168  {}
169 
170  JCprot& operator=(const JCprot& model)
171  {
172  AbstractParameterAliasable::operator=(model);
175  exp_ = model.exp_;
176  p_ = model.p_;
177  if (freqSet_) delete freqSet_;
178  freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(model.freqSet_->clone());
179  return *this;
180  }
181 
182  virtual ~JCprot() { delete freqSet_; }
183 
184 #ifndef NO_VIRTUAL_COV
185  JCprot*
186 #else
187  Clonable*
188 #endif
189  clone() const { return new JCprot(*this); }
190 
191  public:
192  double Pij_t (size_t i, size_t j, double d) const;
193  double dPij_dt (size_t i, size_t j, double d) const;
194  double d2Pij_dt2(size_t i, size_t j, double d) const;
195  const Matrix<double>& getPij_t (double d) const;
196  const Matrix<double>& getdPij_dt (double d) const;
197  const Matrix<double>& getd2Pij_dt2(double d) const;
198 
199  std::string getName() const
200  {
201  if (freqSet_->getNamespace().find("+F.")!=std::string::npos)
202  return "JC69+F";
203  else
204  return "JC69";
205  }
206 
207  void fireParameterChanged(const ParameterList& parameters)
208  {
209  freqSet_->matchParametersValues(parameters);
212  }
213 
215  {
216  delete freqSet_;
217  freqSet_ = dynamic_cast<ProteinFrequenciesSet*>(freqSet.clone());
218  resetParameters_();
219  addParameters_(freqSet_->getParameters());
220  }
221 
222  const FrequenciesSet* getFrequenciesSet() const { return freqSet_; }
223 
224  void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0);
225 
226  protected:
232  void updateMatrices();
233 
234 
235  };
236 
237 } //end of namespace bpp.
238 
239 #endif //_JCPROT_H_
240 
The Jukes-Cantor substitution model for proteins.
Definition: JCprot.h:134
virtual void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
const Matrix< double > & getPij_t(double d) const
Definition: JCprot.cpp:139
const Matrix< double > & getdPij_dt(double d) const
Definition: JCprot.cpp:152
const FrequenciesSet * getFrequenciesSet() const
If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0.
Definition: JCprot.h:222
double d2Pij_dt2(size_t i, size_t j, double d) const
Definition: JCprot.cpp:131
Specialized interface for protein substitution model.
void setFrequenciesSet(const ProteinFrequenciesSet &freqSet)
Definition: JCprot.h:214
virtual const std::vector< double > getFrequencies() const =0
Vdouble freq_
The vector of equilibrium frequencies.
JCprot * clone() const
Definition: JCprot.h:189
virtual ~JCprot()
Definition: JCprot.h:182
Parametrize a set of state frequencies.
double exp_
Definition: JCprot.h:139
ProteinFrequenciesSet * clone() const =0
AbstractSubstitutionModel & operator=(const AbstractSubstitutionModel &model)
Partial implementation of the ReversibleSubstitutionModel interface.
JCprot(const ProteicAlphabet *alpha)
Build a simple JC69 model, with original equilibrium frequencies.
Definition: JCprot.cpp:54
const Matrix< double > & getd2Pij_dt2(double d) const
Definition: JCprot.cpp:165
JCprot & operator=(const JCprot &model)
Definition: JCprot.h:170
Parametrize a set of state frequencies for proteins.
RowMatrix< double > p_
Definition: JCprot.h:140
void setFreqFromData(const SequenceContainer &data, double pseudoCount=0)
Set equilibrium frequencies equal to the frequencies estimated from the data.
Definition: JCprot.cpp:180
void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
Definition: JCprot.h:207
double dPij_dt(size_t i, size_t j, double d) const
Definition: JCprot.cpp:123
void updateMatrices()
Definition: JCprot.cpp:78
double Pij_t(size_t i, size_t j, double d) const
Definition: JCprot.cpp:115
ProteinFrequenciesSet * freqSet_
Definition: JCprot.h:141
JCprot(const JCprot &model)
Definition: JCprot.h:161
std::string getName() const
Get the name of the model.
Definition: JCprot.h:199