~ubuntu-branches/ubuntu/saucy/libbpp-phyl/saucy

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Julien Dutheil
  • Date: 2013-02-09 16:00:00 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20130209160000-5v65ba68z8032nzj
Tags: 2.0.3-1
* Reorganized model hierarchy
* New pairwise models
* Several bugs fixed

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
//
6
6
 
7
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
 
*/
 
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
39
 
40
40
#ifndef _YN98_H_
41
41
#define _YN98_H_
42
42
 
43
 
#include "CodonAsynonymousFrequenciesReversibleSubstitutionModel.h"
 
43
#include "AbstractBiblioSubstitutionModel.h"
 
44
#include "CodonDistanceFrequenciesSubstitutionModel.h"
44
45
 
45
46
namespace bpp
46
47
{
47
 
 
48
48
/**
49
49
 * @brief The Yang and Nielsen (1998) substitution model for codons.
50
50
 * @author Laurent Guéguen
54
54
 * between codons. A multiplicative factor accounts for the selective
55
55
 * restraints at the amino acid level, depending on the synonymy of
56
56
 * the amino acids.
57
 
 * 
 
57
 *
58
58
 * For codons @f$i=i_1i_2i_3@f$ and @f$j=j_1j_2j_3@f$, the generator
59
59
 * term @f$Q_{ij} (i \neq j)@f$ is:
60
60
 *
85
85
 * Reference:
86
86
 * -  Yang Z. and Nielsen R. (1998), _Journal of Molecular Evolution_ 46:409--418.
87
87
 */
88
 
class YN98:
89
 
  public AbstractReversibleSubstitutionModel
 
88
class YN98 : public AbstractBiblioSubstitutionModel
90
89
{
91
90
private:
92
 
 
93
 
  CodonAsynonymousFrequenciesReversibleSubstitutionModel pmodel_;
94
 
 
95
 
private:
96
 
  /**
97
 
   * @brief Tools to make the link between the Parameters of the
98
 
   * object and those of pmodel_.
99
 
   *
100
 
   */
101
 
 
102
 
  std::map<std::string,std::string> mapParNamesFromPmodel_;
103
 
  
104
 
  ParameterList lParPmodel_;
105
 
  
 
91
  CodonDistanceFrequenciesSubstitutionModel* pmodel_;
 
92
 
106
93
public:
107
94
  YN98(const GeneticCode* gc, FrequenciesSet* codonFreqs);
108
95
 
109
 
  YN98(const YN98& yn98) : AbstractReversibleSubstitutionModel(yn98),
110
 
                           pmodel_(yn98.pmodel_),
111
 
                           mapParNamesFromPmodel_(yn98.mapParNamesFromPmodel_),
112
 
                           lParPmodel_(yn98.lParPmodel_) {}
113
 
  ~YN98() {}
114
 
  
 
96
  YN98(const YN98& yn98);
 
97
 
 
98
  YN98& operator=(const YN98&);
 
99
 
 
100
  ~YN98();
 
101
 
115
102
  YN98* clone() const { return new YN98(*this); }
116
103
 
117
104
public:
118
 
 
119
105
  std::string getName() const { return "YN98"; }
120
 
        
121
 
  const Vdouble& getFrequencies() const { return pmodel_.getFrequencies(); }
122
 
       
123
 
  const Matrix<double>& getGenerator() const { return pmodel_.getGenerator(); }
124
 
    
125
 
  const Vdouble& getEigenValues() const { return pmodel_.getEigenValues(); }
126
 
    
127
 
  const Matrix<double>& getRowLeftEigenVectors() const { return pmodel_.getRowLeftEigenVectors(); }
128
 
  
129
 
  const Matrix<double>& getColumnRightEigenVectors() const { return pmodel_.getColumnRightEigenVectors(); }
130
 
    
131
 
  double freq(unsigned int i) const { return pmodel_.freq(i); }
132
 
    
133
 
  double Qij(unsigned int i, unsigned int j) const { return pmodel_.Qij(i,j); }
134
 
    
135
 
  double Pij_t    (unsigned int i, unsigned int j, double t) const { return pmodel_.Pij_t(i, j, t); }
136
 
  double dPij_dt  (unsigned int i, unsigned int j, double t) const { return pmodel_.dPij_dt(i, j, t); }
137
 
  double d2Pij_dt2(unsigned int i, unsigned int j, double t) const { return pmodel_.d2Pij_dt2(i, j, t); }
138
 
 
139
 
  const Matrix<double>& getPij_t    (double d) const { return pmodel_.getPij_t(d);  }
140
 
  const Matrix<double>& getdPij_dt  (double d) const { return pmodel_.getdPij_dt(d);  }
141
 
  const Matrix<double>& getd2Pij_dt2(double d) const { return pmodel_.getd2Pij_dt2(d);  }
142
 
 
143
 
  void setFreq(std::map<int, double>& m);
144
 
  
145
 
  unsigned int getNumberOfStates() const  { return pmodel_.getNumberOfStates();  }
146
 
 
147
 
  double getInitValue(unsigned int i, int state) const throw (BadIntException) { return pmodel_.getInitValue(i,state); }
148
 
 
149
 
  void enableEigenDecomposition(bool yn) { eigenDecompose_ = 1; }
150
 
 
151
 
  bool enableEigenDecomposition() { return pmodel_.enableEigenDecomposition(); }
152
 
 
153
 
  const FrequenciesSet& getFreq() const { return pmodel_.getFreq(); }
154
 
 
155
 
  double getRate() const { return pmodel_.getRate();}
156
 
  
157
 
  void setRate(double rate) { pmodel_.setRate(rate);}
158
 
 
159
 
  void addRateParameter();
160
 
  
161
 
protected:
162
 
  void updateMatrices();
163
 
 
 
106
 
 
107
  const AbstractSubstitutionModel* getModel() const { return pmodel_; }
 
108
 
 
109
  AbstractSubstitutionModel* getModel() { return pmodel_; }
 
110
 
 
111
  const FrequenciesSet& getFreq() const { return pmodel_->getFreq(); }
164
112
};
165
113
 
166
 
} //end of namespace bpp.
 
114
} // end of namespace bpp.
167
115
 
168
 
#endif  //_YN98_H_
 
116
#endif  // _YN98_H_
169
117