bpp-phyl  2.2.0
CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.cpp
Go to the documentation of this file.
1 //
2 // File: CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.cpp
3 // Created by: Fanny Pouyet
4 // Created on: February 2012
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 developi_ng 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 
42 using namespace bpp;
43 using namespace std;
44 
46  const GeneticCode* gCode,
48  FrequenciesSet* pfit,
49  FrequenciesSet* pfreq,
50  const AlphabetIndex2* pdist) :
51  AbstractParameterAliasable("CodonDistFitPhasFreq."),
52  AbstractCodonSubstitutionModel(gCode, pmod, "CodonDistFitPhasFreq."),
53  AbstractCodonDistanceSubstitutionModel(pdist, "CodonDistFitPhasFreq."),
54  AbstractCodonPhaseFrequenciesSubstitutionModel(pfreq, "CodonDistFitPhasFreq."),
55  AbstractCodonFitnessSubstitutionModel(pfit, "CodonDistFitPhasFreq.")
56 {
58 }
59 
61  const GeneticCode* gCode,
65  FrequenciesSet* pfit,
66  FrequenciesSet* pfreq,
67  const AlphabetIndex2* pdist) :
68  AbstractParameterAliasable("CodonDistFitPhasFreq."),
69  AbstractCodonSubstitutionModel(gCode, pmod1, pmod2, pmod3, "CodonDistFitPhasFreq."),
70  AbstractCodonDistanceSubstitutionModel(pdist, "CodonDistFitPhasFreq."),
71  AbstractCodonPhaseFrequenciesSubstitutionModel(pfreq, "CodonDistFitPhasFreq."),
72  AbstractCodonFitnessSubstitutionModel(pfit,"CodonDistFitPhasFreq.")
73 {
75 }
76 
78 {
79  return ("CodonDistFitPhasFreq");
80 }
81 
83 {
87 
89 }
90 
92 {
97 }
98 
100 {
101  AbstractParameterAliasable::setNamespace(st);
103  AbstractCodonDistanceSubstitutionModel::setNamespace(st);
106 }
107 
109 {
112 
113  map<int, double> freq2;
114  double s=0;
115  map<int, double>::iterator it;
116 
117  for (it=frequencies.begin();it!=frequencies.end();it++)
118  {
119  freq2[it->first]=(freq1[it->first] != 0 ? it->second/freq1[it->first] : 0);
120  s += freq2[it->first];
121  }
122 
123  for (it = freq2.begin(); it != freq2.end(); it++)
124  freq2[it->first] /= s;
125 
127 
128  updateMatrices();
129 }
130 
131 
double getCodonsMulRate(size_t i, size_t j) const
Returns the multiplicative rate specific to two codons specified by their number. The respective gene...
Abstract Class for substitution models on codons parametrized by a frequency.
virtual void fireParameterChanged(const ParameterList &parameters)
Tells the model that a parameter value has changed.
const FrequenciesSet * getFrequenciesSet() const
If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0.
STL namespace.
Parametrize a set of state frequencies.
CodonDistanceFitnessPhaseFrequenciesSubstitutionModel(const GeneticCode *gCode, NucleotideSubstitutionModel *pmod, FrequenciesSet *pfit, FrequenciesSet *pfreq, const AlphabetIndex2 *pdist=0)
Abstract class for modelling of non-synonymous abd synonymous substitution rates in codon models...
void fireParameterChanged(const ParameterList &parameterlist)
Tells the model that a parameter value has changed.
Abstract class for modelling of ratios of substitution rates between codons, whatever they are synony...
void updateMatrices()
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
void setFreq(std::map< int, double > &frequencies)
Set equilibrium frequencies.
Specialisation interface for nucleotide substitution model.
virtual const std::map< int, double > getAlphabetStatesFrequencies() const =0
void setFreq(std::map< int, double > &frequencies)
Set equilibrium frequencies.
double getCodonsMulRate(size_t i, size_t j) const
Returns the multiplicative rate specific to two codons specified by their number. The respective gene...
void setFreq(std::map< int, double > &frequencies)
Set equilibrium frequencies.
Abstract class for substitution models on codons.
double getCodonsMulRate(size_t i, size_t j) const
Returns the multiplicative rate specific to two codons specified by their number. The respective gene...
virtual double getCodonsMulRate(size_t i, size_t j) const
Method inherited from CodonSubstitutionModel.
double getCodonsMulRate(size_t, size_t) const
Returns the multiplicative rate specific to two codons specified by their number. The respective gene...