~ubuntu-branches/ubuntu/raring/libbpp-phyl/raring

« back to all changes in this revision

Viewing changes to src/Bpp/Phyl/Model/YNGKP_M8.h

  • Committer: Bazaar Package Importer
  • Author(s): Julien Dutheil
  • Date: 2011-06-09 11:00:00 UTC
  • Revision ID: james.westby@ubuntu.com-20110609110000-yvx78svv6w7xxgph
Tags: upstream-2.0.2
Import upstream version 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// File: YNGKP_M8.h
 
3
// Created by: Laurent Gueguen
 
4
// Created on: May 2010
 
5
//
 
6
 
 
7
/*
 
8
Copyright or © or Copr. CNRS, (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 _YNGKP_M8_H_
 
41
#define _YNGKP_M8_H_
 
42
 
 
43
#include "MixtureOfASubstitutionModel.h"
 
44
#include "FrequenciesSet.h"
 
45
 
 
46
#include <Bpp/Seq/GeneticCode/GeneticCode.h>
 
47
 
 
48
namespace bpp
 
49
{
 
50
 
 
51
/**
 
52
 * @brief The Yang et al (2000) M8 substitution model for codons.
 
53
 * @author Laurent Guéguen
 
54
 *
 
55
 * This model is a mixture of models as described in YN98 class, the
 
56
 * mixture being defined on the selection parameter oomega to allow it
 
57
 * to vary among sites, following a mixture of a Beta distribution and
 
58
 * of another value above 1.
 
59
 *
 
60
 * This model includes 5 parameters (@f$\kappa@f$, @f$ \alpha @f$ and
 
61
 * @f$\beta@f$) of the Beta distribution, @f$p0@f$ the weight of the
 
62
 * Beta distribution and @f$\omega @f$ the selection parameter above 1
 
63
 * (with weight @f$ 1-p0 @f$). The codon frequencies @f$ \pi_j @f$ are
 
64
 * either observed or infered.
 
65
 *
 
66
 * References:
 
67
 *
 
68
 * Yang, Z., R. Nielsen, N. Goldman, and A.-M. K. Pedersen (2000)
 
69
 * Genetics 155:431-449.
 
70
 * 
 
71
 */
 
72
class YNGKP_M8:
 
73
  public AbstractMixedSubstitutionModel
 
74
{
 
75
private:
 
76
  MixtureOfASubstitutionModel* pmixmodel_;
 
77
 
 
78
  /*
 
79
   *@brief indexes of 2 codons between which the substitution is
 
80
   * synonymous, to set a basis to the homogeneization of the rates.
 
81
   *
 
82
   */
 
83
 
 
84
  int synfrom_, synto_;
 
85
  
 
86
private:
 
87
  /**
 
88
   * @brief Tools to make the link between the Parameters of the
 
89
   * object and those of pmixmodel_.
 
90
   *
 
91
   */
 
92
 
 
93
  std::map<std::string,std::string> mapParNamesFromPmodel_;
 
94
  
 
95
  ParameterList lParPmodel_;
 
96
  
 
97
 
 
98
public:
 
99
  /*
 
100
   *@brief Constructor that requires the number of classes of the
 
101
   * BetaDiscreteDistribution.
 
102
   *
 
103
   */
 
104
  
 
105
  YNGKP_M8(const GeneticCode* gc, FrequenciesSet* codonFreqs, unsigned int nbclass);
 
106
 
 
107
  ~YNGKP_M8();
 
108
  
 
109
  YNGKP_M8* clone() const { return new YNGKP_M8(*this); }
 
110
 
 
111
  YNGKP_M8(const YNGKP_M8&);
 
112
 
 
113
  YNGKP_M8& operator=(const YNGKP_M8&);
 
114
 
 
115
  unsigned int getNumberOfStates() const  { return pmixmodel_->getNumberOfStates();  }
 
116
 
 
117
protected:
 
118
  void updateMatrices();
 
119
 
 
120
public:
 
121
  const SubstitutionModel* getNModel(unsigned int i) const {
 
122
    return pmixmodel_->getNModel(i);
 
123
  }
 
124
 
 
125
  SubstitutionModel* getNModel(unsigned int i) {
 
126
    return pmixmodel_->getNModel(i);
 
127
  }
 
128
 
 
129
  /**
 
130
   * @brief Returns the  probability of a specific model from the mixture
 
131
   */
 
132
  
 
133
  double getNProbability(unsigned int i) const {
 
134
    return pmixmodel_->getNProbability(i);
 
135
  }
 
136
 
 
137
  const std::vector<double>& getProbabilities() const {
 
138
    return pmixmodel_->getProbabilities();
 
139
  }
 
140
    
 
141
  unsigned int getNumberOfModels() const {
 
142
    return pmixmodel_->getNumberOfModels();
 
143
  }
 
144
 
 
145
  std::string getName() const { return "YNGKP_M8"; }
 
146
 
 
147
  /**
 
148
   * @brief inactivated method to prevent out of model manipulations
 
149
   *
 
150
   **/
 
151
  
 
152
  void setVRates(Vdouble & vd){};
 
153
 
 
154
  double Pij_t(unsigned int i, unsigned int j, double t) const {
 
155
    return pmixmodel_->Pij_t(i,j,t);
 
156
  }
 
157
  double dPij_dt(unsigned int i, unsigned int j, double t) const {
 
158
    return pmixmodel_->dPij_dt(i,j,t);
 
159
  };
 
160
  double d2Pij_dt2(unsigned int i, unsigned int j, double t) const {
 
161
    return pmixmodel_->dPij_dt(i,j,t);
 
162
  };
 
163
  const Matrix<double>& getPij_t(double t) const {
 
164
    return pmixmodel_->getPij_t(t);
 
165
  };
 
166
  const Matrix<double>& getdPij_dt(double t) const {
 
167
    return pmixmodel_->getdPij_dt(t);
 
168
  };
 
169
  const Matrix<double>& getd2Pij_dt2(double t) const {
 
170
    return pmixmodel_->getd2Pij_dt2(t);
 
171
  };
 
172
  
 
173
  const Vdouble& getFrequencies() const {
 
174
    return pmixmodel_->getFrequencies();
 
175
  };
 
176
  
 
177
  double freq(unsigned int i) const {
 
178
    return pmixmodel_->freq(i);
 
179
  };
 
180
 
 
181
  void setFreq(std::map<int,double>& m);
 
182
 
 
183
  double getRate() const { return pmixmodel_->getRate();}
 
184
  
 
185
  void setRate(double rate) { pmixmodel_->setRate(rate);}
 
186
};
 
187
 
 
188
} //end of namespace bpp.
 
189
 
 
190
#endif  //_YNGKP_M8_H_
 
191