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

« back to all changes in this revision

Viewing changes to src/Bpp/Phyl/Model/LLG08_EX3.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: LLG08_EX3.h
 
3
// Created by: Laurent Gueguen
 
4
// Created on: jeudi 21 octobre 2010, à 13h 50
 
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 _LLG08_EX3_H_
 
41
#define _LLG08_EX3_H_
 
42
 
 
43
#include "MixtureOfSubstitutionModels.h"
 
44
#include "ProteinSubstitutionModel.h"
 
45
#include "AbstractSubstitutionModel.h"
 
46
 
 
47
using namespace std;
 
48
 
 
49
namespace bpp
 
50
{
 
51
 
 
52
  /**
 
53
   * @brief The Le et al  (2008) EX3 substitution model for proteins.
 
54
   * @author Laurent Guéguen
 
55
   *
 
56
   * This model is a mixture of three models corresponding to
 
57
   * buried/intermediate/highly exposed sites in proteins. The models
 
58
   * are considered in this order.
 
59
   *
 
60
   *
 
61
   * This model includes 4 parameters :
 
62
   *
 
63
   * - relrate1 is the relative rate of model of buried sites;
 
64
   * - relrate2 is the relative rate of intermediate sites;
 
65
   * - relproba1 is the proportion  of buried sites;
 
66
   * - relproba2 is the ratio of the proportions of intermediate sites
 
67
   * over the sum of the proportion of intermediate sites plus the
 
68
   * proportion of highly exposed sites.
 
69
   *
 
70
   * Important: See the relation between these parameters and the
 
71
   * rates and probabilities of the models in the description of
 
72
   * MixtureOfSubstitutionModels class.
 
73
   *
 
74
   * Reference:
 
75
   *
 
76
   * Le S.Q., Lartillot N., Gascuel O. (2008) Phil. Trans. R. Soc. B 363:3965--3976.
 
77
   */
 
78
  
 
79
class LLG08_EX3:
 
80
  public AbstractMixedSubstitutionModel
 
81
{
 
82
public:
 
83
  class EmbeddedModel:
 
84
    public virtual ProteinSubstitutionModel,
 
85
    public AbstractReversibleSubstitutionModel
 
86
  {
 
87
  private:
 
88
    double proportion_;
 
89
    string name_;
 
90
  public:
 
91
    EmbeddedModel(const ProteicAlphabet* alpha, string name);
 
92
    ~EmbeddedModel(){};
 
93
    EmbeddedModel* clone() const { return new EmbeddedModel(*this); }
 
94
    string getName() const { return name_;}
 
95
    double getProportion() const { return proportion_;}
 
96
  };
 
97
  
 
98
private:
 
99
  MixtureOfSubstitutionModels* pmixmodel_;
 
100
 
 
101
private:
 
102
  /**
 
103
   * @brief Tools to make the link between the Parameters of the
 
104
   * object and those of pmixmodel_.
 
105
   *
 
106
   */
 
107
 
 
108
  std::map<std::string,std::string> mapParNamesFromPmodel_;
 
109
  
 
110
  ParameterList lParPmodel_;
 
111
  
 
112
 
 
113
public:
 
114
 
 
115
  /**
 
116
   * @brief Build a  EX3 model, with original equilibrium frequencies, probabilities and rates.
 
117
   *
 
118
   * @param alpha A proteic alphabet.
 
119
   *
 
120
   */
 
121
 
 
122
  LLG08_EX3(const ProteicAlphabet* alpha);
 
123
 
 
124
  ~LLG08_EX3();
 
125
  
 
126
  LLG08_EX3* clone() const { return new LLG08_EX3(*this); }
 
127
 
 
128
  LLG08_EX3(const LLG08_EX3&);
 
129
 
 
130
  LLG08_EX3& operator=(const LLG08_EX3&);
 
131
 
 
132
  unsigned int getNumberOfStates() const  { return pmixmodel_->getNumberOfStates();  }
 
133
 
 
134
protected:
 
135
  void updateMatrices();
 
136
 
 
137
public:
 
138
  const SubstitutionModel* getNModel(unsigned int i) const {
 
139
    return pmixmodel_->getNModel(i);
 
140
  }
 
141
 
 
142
  SubstitutionModel* getNModel(unsigned int i) {
 
143
    return pmixmodel_->getNModel(i);
 
144
  }
 
145
 
 
146
  /**
 
147
   * @brief Returns the  probability of a specific model from the mixture
 
148
   */
 
149
  
 
150
  double getNProbability(unsigned int i) const {
 
151
    return pmixmodel_->getNProbability(i);
 
152
  }
 
153
 
 
154
  const std::vector<double>& getProbabilities() const {
 
155
    return pmixmodel_->getProbabilities();
 
156
  }
 
157
    
 
158
  unsigned int getNumberOfModels() const {
 
159
    return pmixmodel_->getNumberOfModels();
 
160
  }
 
161
 
 
162
  std::string getName() const { return "LLG08_EX3"; }
 
163
 
 
164
  void setVRates(Vdouble & vd);
 
165
 
 
166
  double Pij_t(unsigned int i, unsigned int j, double t) const {
 
167
    return pmixmodel_->Pij_t(i,j,t);
 
168
  }
 
169
  double dPij_dt(unsigned int i, unsigned int j, double t) const {
 
170
    return pmixmodel_->dPij_dt(i,j,t);
 
171
  };
 
172
  double d2Pij_dt2(unsigned int i, unsigned int j, double t) const {
 
173
    return pmixmodel_->dPij_dt(i,j,t);
 
174
  };
 
175
  const Matrix<double>& getPij_t(double t) const {
 
176
    return pmixmodel_->getPij_t(t);
 
177
  };
 
178
  const Matrix<double>& getdPij_dt(double t) const {
 
179
    return pmixmodel_->getdPij_dt(t);
 
180
  };
 
181
  const Matrix<double>& getd2Pij_dt2(double t) const {
 
182
    return pmixmodel_->getd2Pij_dt2(t);
 
183
  };
 
184
  
 
185
  const Vdouble& getFrequencies() const {
 
186
    return pmixmodel_->getFrequencies();
 
187
  };
 
188
  
 
189
  double freq(unsigned int i) const {
 
190
    return pmixmodel_->freq(i);
 
191
  };
 
192
 
 
193
  void setFreq(std::map<int,double>& m);
 
194
 
 
195
};
 
196
 
 
197
} //end of namespace bpp.
 
198
 
 
199
#endif  //_LLG08_EX3_H_
 
200