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

« back to all changes in this revision

Viewing changes to src/Bpp/Phyl/Model/CodonNeutralReversibleSubstitutionModel.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: CodonNeutralReversibleSubstitutionModel.h
 
3
// Created by: Laurent Gueguen
 
4
// Created on: Tue Dec 24 11:03:53 2003
 
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 _CODONNEUTRALREVERSIBLESUBSTITUTIONMODEL_H_
 
41
#define _CODONNEUTRALREVERSIBLESUBSTITUTIONMODEL_H_
 
42
 
 
43
#include "AbstractCodonReversibleSubstitutionModel.h"
 
44
#include "NucleotideSubstitutionModel.h"
 
45
 
 
46
// From SeqLib:
 
47
#include <Bpp/Seq/Alphabet/CodonAlphabet.h>
 
48
 
 
49
namespace bpp
 
50
{
 
51
/**
 
52
 * @brief Class for reversible substitution models on non stop codons.
 
53
 *
 
54
 * Objects of this class are built from three reversible substitution
 
55
 * models of NucleicAlphabets. No model is directly accessible. </p>
 
56
 *
 
57
 * Only substitutions with one letter changed are accepted. </p>
 
58
 *
 
59
 * There is one substitution per word per unit of time
 
60
 * on the equilibrium frequency, and each position has its specific rate.
 
61
 *
 
62
 * The generator is constructed in two steps:
 
63
 * First, if @f$\rho_i@f$ is the rate of model i (@f$\sum_{i=1}^{3} \rho_i = 1@f$):
 
64
 * @f[
 
65
 * Q_{abc \rightarrow abd} = \rho_3 Q^{(2)}_{c \rightarrow d}
 
66
 * Q_{abc \rightarrow aed} = 0
 
67
 * Q_{abc \rightarrow abc} = \rho_1 Q^{(0)}_{a \rightarrow a} + \rho_2 Q^{(1)}_{b \rightarrow b} + \rho_3 Q^{(2)}_{c \rightarrow c})
 
68
 * @f]
 
69
 *
 
70
 * Second, the substitution between STOP codons and non-STOP codons are
 
71
 * nullified, and the lines of Q are normalized in accordance.
 
72
 *
 
73
 * The parameters of this word model are the same as the ones of the
 
74
 * models used. Their names have a new suffix, "_phi" where i stands
 
75
 * for the position (i.e. the phase) in the word.
 
76
 *
 
77
 * The rates are defined by relative rates parameters @f$r_i@f$
 
78
 * (called "relrate_i") with:
 
79
 * @f[
 
80
 * 1 <= i < n, \rho_i = (1-r_1).(1-r_2)...(1-r_{i-1}).r_{i}
 
81
 * \rho_n = (1-r_1).(1-r_2)...(1-r_{n-1})
 
82
 * @f]
 
83
 * and
 
84
 * @f[
 
85
 * \forall 1 <= i < n, r_i = \frac{\rho_i}{1-(\rho_0+...\rho_{i-1})}
 
86
 * @f]
 
87
 *
 
88
 * The parameters of this codon model are the same as the ones of the
 
89
 * models used. Their names have a new suffix, "_phi" where i stands
 
90
 * for the position (i.e. the phase) in the word.
 
91
 */
 
92
 
 
93
class CodonNeutralReversibleSubstitutionModel :
 
94
  public AbstractCodonReversibleSubstitutionModel
 
95
{
 
96
public:
 
97
  /**
 
98
   *@brief Build a new CodonNeutralReversibleSubstitutionModel object from
 
99
   *a pointer to NucleotideSubstitutionModels.
 
100
   * @author Laurent Guéguen
 
101
   *
 
102
   *@param palph pointer to a CodonAlphabet
 
103
   *@param pmod1 pointer to the NucleotideSubstitutionModel to use in the
 
104
   *       three positions. It is owned by the instabce.
 
105
   */
 
106
 
 
107
  CodonNeutralReversibleSubstitutionModel(const CodonAlphabet* palph,
 
108
                                          NucleotideSubstitutionModel* pmod1);
 
109
 
 
110
  /**
 
111
   *@brief Build a new CodonNeutralReversibleSubstitutionModel object
 
112
   *from three pointers to NucleotideSubstitutionModels.
 
113
   *
 
114
   *@param palph pointer to a CodonAlphabet
 
115
   *@param pmod1, pmod2, pmod3 pointers to the
 
116
   *   NucleotideSubstitutionModel to use in the three positions.
 
117
   *   All the models must be different objects to avoid parameters
 
118
   *   redondancy, otherwise only the first model is used. The used models
 
119
   *   are owned by the instance.
 
120
   */
 
121
 
 
122
  CodonNeutralReversibleSubstitutionModel(const CodonAlphabet* palph,
 
123
                                          NucleotideSubstitutionModel* pmod1,
 
124
                                          NucleotideSubstitutionModel* pmod2,
 
125
                                          NucleotideSubstitutionModel* pmod3);
 
126
 
 
127
  ~CodonNeutralReversibleSubstitutionModel(){}
 
128
 
 
129
#ifndef NO_VIRTUAL_COV
 
130
  CodonNeutralReversibleSubstitutionModel*
 
131
#else
 
132
  Clonable*
 
133
#endif
 
134
  clone() const { return new CodonNeutralReversibleSubstitutionModel(*this); }
 
135
 
 
136
public:
 
137
  void completeMatrices();
 
138
  void updateMatrices();
 
139
  std::string getName() const;
 
140
};
 
141
} // end of namespace bpp.
 
142
 
 
143
#endif
 
144