bpp-phyl  2.2.0
TS98.h
Go to the documentation of this file.
1 //
2 // File: TS98.h
3 // Created by: Julien Dutheil
4 // Created on: Sat Aug 19 11:37 2006
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 _TS98_H_
41 #define _TS98_H_
42 
44 
45 //From NumCalc:
46 #include <Bpp/Numeric/Prob/DiscreteDistribution.h>
47 #include <Bpp/Numeric/Parameter.h>
48 
49 namespace bpp
50 {
51 
77  class TS98:
79  {
80  public:
89  TS98(ReversibleSubstitutionModel* model, double s1 = 1., double s2 = 1., bool normalizeRateChanges = false):
90  MarkovModulatedSubstitutionModel(model, 2, normalizeRateChanges, "TS98.")
91  {
92  addParameter_(new Parameter("TS98.s1", s1, &Parameter::R_PLUS_STAR));
93  addParameter_(new Parameter("TS98.s2", s2, &Parameter::R_PLUS_STAR));
96  }
97 
98  virtual ~TS98() {}
99 
100 #ifndef NO_VIRTUAL_COV
101  TS98*
102 #else
103  Clonable*
104 #endif
105  clone() const { return new TS98(*this); }
106 
107  public:
108  std::string getName() const { return "TS98"; }
109 
110  double getRate() const { return 1.;}
111 
112  void setRate(double rate) {};
113 
114  void addRateParameter() {};
115 
116  protected:
118  {
119  double s1 = getParameterValue("s1");
120  double s2 = getParameterValue("s2");
121  ratesFreq_[0] = s2/(s1+s2);
122  ratesFreq_[1] = s1/(s1+s2);
123  rates_(1,1) = (s1+s2)/s1;
124  ratesExchangeability_(0,1) = ratesExchangeability_(1,0) = s1+s2;
125  ratesExchangeability_(0,0) = -s1*(s1+s2)/s2;
126  ratesExchangeability_(1,1) = -s2*(s1+s2)/s1;
127  }
128 
129  };
130 
131 } //end of namespace bpp.
132 
133 #endif // _TS98_H_
134 
void updateRatesModel()
Update the rates vector, generator and equilibrium frequencies.
Definition: TS98.h:117
Interface for reversible substitution models.
void addRateParameter()
Definition: TS98.h:114
Tuffley and Steel&#39;s 1998 covarion model.
Definition: TS98.h:77
virtual ~TS98()
Definition: TS98.h:98
double getRate() const
Get the rate.
Definition: TS98.h:110
Partial implementation of the Markov-modulated class of substitution models.
std::string getName() const
Get the name of the model.
Definition: TS98.h:108
TS98(ReversibleSubstitutionModel *model, double s1=1., double s2=1., bool normalizeRateChanges=false)
Build a new TS98 substitution model.
Definition: TS98.h:89
void setRate(double rate)
Set the rate of the model (must be positive).
Definition: TS98.h:112
TS98 * clone() const
Definition: TS98.h:105