2
// File: AbstractWordSubstitutionModel.h
3
// Created by: Laurent Gueguen
4
// Created on: Jan 2009
8
Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
10
This software is a computer program whose purpose is to provide classes
11
for phylogenetic data analysis.
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".
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
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.
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.
40
#ifndef _ABSTRACTWORDSUBSTITUTIONMODEL_H_
41
#define _ABSTRACTWORDSUBSTITUTIONMODEL_H_
43
#include "AbstractSubstitutionModel.h"
51
* @brief Abstract Basal class for words of substitution models.
52
* @author Laurent Guéguen
54
* Objects of this class are built from several substitution models.
55
* Each model corresponds to a position in the word. No model is
56
* directly accessible. </p>
58
* Only substitutions with one letter changed are accepted. </p>
60
* There is one substitution per word per unit of time
61
* on the equilibrium frequency, and each position has its specific rate.
62
* For example, if there are @f$n@f$ models and \f$\rho_i\f$ is the rate of
63
* model i (@f$\sum_{i=1}^{n} \rho_i = 1@f$):
65
* Q_{abc \rightarrow abd} &=& \rho_2 Q^{(2)}_{c \rightarrow d}\\
66
* Q_{abc \rightarrow aed} &=& 0\\
67
* Q_{abc \rightarrow abc} &=& \rho_0 Q^{(0)}_{a \rightarrow a} + \rho_1 Q^{(1)}_{b \rightarrow b} + \rho_2 Q^{(2)}_{c \rightarrow c})
70
* The parameters of this word model are the same as the ones of the
71
* models used. Their names have a new suffix, "phi_" where i stands
72
* for the position (i.e. the phase) in the word.
75
class AbstractWordSubstitutionModel :
76
public virtual AbstractSubstitutionModel
80
* @ brief boolean flag to check if a specific WordAlphabet has been built
85
std::vector<SubstitutionModel*> VSubMod_;
86
std::vector<std::string> VnestedPrefix_;
88
std::vector<double> Vrate_;
91
static Alphabet* extractAlph(const std::vector<SubstitutionModel*>& modelVector);
94
void updateMatrices();
97
* @brief Called by updateMatrices to handle specific modifications
98
* for inheriting classes
100
virtual void completeMatrices() = 0;
104
* @brief Build a new AbstractWordSubstitutionModel object from a
105
* vector of pointers to SubstitutionModels.
107
* @param modelVector the vector of substitution models to use, in
108
* the order of the positions in the words from left to right. All
109
* the models must be different objects to avoid parameters
110
* redundancy, otherwise only the first model is used. The used models
111
* are owned by the instance.
112
* @param st the Namespace.
114
AbstractWordSubstitutionModel(
115
const std::vector<SubstitutionModel*>& modelVector,
116
const std::string& st);
119
* @brief Build a new AbstractWordSubstitutionModel object from a
120
* pointer to an SubstitutionModel and a number of
123
* @param pmodel A pointer to the substitution model to use in all
124
* the positions. It will be owned by the instance.
125
* @param num The number of models involved.
126
* @param st the Namespace.
128
AbstractWordSubstitutionModel(
129
SubstitutionModel* pmodel,
131
const std::string& st);
133
AbstractWordSubstitutionModel(const AbstractWordSubstitutionModel&);
135
AbstractWordSubstitutionModel& operator=(const AbstractWordSubstitutionModel&);
137
virtual ~AbstractWordSubstitutionModel();
139
void setNamespace(const std::string& prefix);
143
*@brief Constructor for the derived classes only
145
AbstractWordSubstitutionModel(const Alphabet* alph, const std::string&);
148
virtual unsigned int getNumberOfStates() const;
151
*@brief Estimation of the parameters of the models so that the
152
*equilibrium frequencies match the given ones.
154
*@param freqs map of the frequencies
156
* When there is one submodel for all the positions, the submodel
157
* parameters are fit on the means of the frequencies on each
158
* position. Otherwise, each model is fit on the frequencies on its
159
* corresponding position in the word.
163
virtual void setFreq(std::map<int, double>& freqs);
165
} // end of namespace bpp.
167
#endif // ABSTRACTWORDSUBSTITUTIONMODEL_