bpp-phyl  2.2.0
MixtureOfASubstitutionModel.h
Go to the documentation of this file.
1 //
2 // File: MixtureOfASubstitutionModel.h
3 // Created by: David Fournier, Laurent Gueguen
4 //
5 
6 /*
7  Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
8 
9  This software is a computer program whose purpose is to provide classes
10  for phylogenetic data analysis.
11 
12  This software is governed by the CeCILL license under French law and
13  abiding by the rules of distribution of free software. You can use,
14  modify and/ or redistribute the software under the terms of the CeCILL
15  license as circulated by CEA, CNRS and INRIA at the following URL
16  "http://www.cecill.info".
17 
18  As a counterpart to the access to the source code and rights to copy,
19  modify and redistribute granted by the license, users are provided only
20  with a limited warranty and the software's author, the holder of the
21  economic rights, and the successive licensors have only limited
22  liability.
23 
24  In this respect, the user's attention is drawn to the risks associated
25  with loading, using, modifying and/or developing or reproducing the
26  software by the user in light of its specific status of free software,
27  that may mean that it is complicated to manipulate, and that also
28  therefore means that it is reserved for developers and experienced
29  professionals having in-depth computer knowledge. Users are therefore
30  encouraged to load and test the software's suitability as regards their
31  requirements in conditions enabling the security of their systems and/or
32  data to be ensured and, more generally, to use and operate it in the
33  same conditions as regards security.
34 
35  The fact that you are presently reading this means that you have had
36  knowledge of the CeCILL license and that you accept its terms.
37  */
38 
39 #ifndef _MIXTUREOFASUBSTITUTIONMODEL_H_
40 #define _MIXTUREOFASUBSTITUTIONMODEL_H_
41 
43 
44 #include <Bpp/Numeric/Prob/DiscreteDistribution.h>
45 #include <Bpp/Numeric/VectorTools.h>
46 
47 #include <vector>
48 #include <string>
49 #include <map>
50 #include <cstring> // C lib for string copy
51 
52 namespace bpp
53 {
105 {
106 private:
107  std::map<std::string, DiscreteDistribution*> distributionMap_;
108  int from_, to_;
109 
110 public:
112  const Alphabet* alpha,
113  SubstitutionModel* model,
114  std::map<std::string, DiscreteDistribution*> parametersDistributionsList,
115  int ffrom = -1, int tto = -1) throw (Exception);
116 
118 
120 
121  virtual ~MixtureOfASubstitutionModel();
122 
124 
125 public:
126  std::string getName() const { return "MixedModel"; }
127 
128  void updateMatrices();
129 
130  /*
131  *@brief Returns the vector of numbers of the submodels in the
132  *mixture that match a description of the parameters numbers.
133  *
134  **@param desc is the description of the class indexes of the mixed
135  **parameters. Syntax is like: kappa_1,gamma_3,delta_2
136  *
137  */
138 
139  Vint getSubmodelNumbers(std::string& desc) const;
140 
148  void setFreq(std::map<int, double>&);
149 
156  const DiscreteDistribution* getDistribution(std::string& parName) const;
157 
164  int from() const { return from_; }
165  int to() const { return to_; }
166 };
167 } // end of namespace bpp.
168 
169 #endif // _MIXTUREOFASUBSTITUTIONMODEL_H_
Vint getSubmodelNumbers(std::string &desc) const
Interface for all substitution models.
MixtureOfASubstitutionModel * clone() const
int from() const
Numbers of the states between which the substitution rates of all the submodels must be equal...
std::map< std::string, DiscreteDistribution * > distributionMap_
Partial implementation for Mixed Substitution models, defined as a mixture of "simple" substitution m...
void updateMatrices()
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
Substitution models defined as a mixture of nested substitution models.
std::string getName() const
Get the name of the model.
const DiscreteDistribution * getDistribution(std::string &parName) const
returns the DiscreteDistribution associated with a given parameter name.
MixtureOfASubstitutionModel(const Alphabet *alpha, SubstitutionModel *model, std::map< std::string, DiscreteDistribution *> parametersDistributionsList, int ffrom=-1, int tto=-1)
void setFreq(std::map< int, double > &)
sets the eq frequencies of the first nested model, and adapts the parameters at best to it (surely th...