bpp-phyl  2.2.0
AbstractBiblioMixedSubstitutionModel.h
Go to the documentation of this file.
1 //
2 // File: AbstractBiblioMixedSubstitutionModel.h
3 // Created by: Laurent Gueguen
4 // Created on: lundi 18 juillet 2011, à 15h 17
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 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 _ABSTRACTBIBLIOMIXEDSUBSTITUTIONMODEL_H_
41 #define _ABSTRACTBIBLIOMIXEDSUBSTITUTIONMODEL_H_
42 
44 #include "MixedSubstitutionModel.h"
45 
46 namespace bpp
47 {
54  public virtual MixedSubstitutionModel,
56 {
57 public:
58  AbstractBiblioMixedSubstitutionModel(const std::string& prefix);
59 
61 
63 
65 
66 #ifndef NO_VIRTUAL_COV
67  virtual AbstractBiblioMixedSubstitutionModel* clone() const = 0;
68 #endif
69 
70 public:
71  virtual const MixedSubstitutionModel& getMixedModel() const = 0;
72 
73  /*
74  *@brief Returns the submodel from the mixture.
75  *
76  */
77 
78  const SubstitutionModel* getNModel(size_t i) const
79  {
80  return getMixedModel().getNModel(i);
81  }
82 
84  {
85  return getMixedModel().getNModel(i);
86  }
87 
91  double getNProbability(size_t i) const
92  {
93  return getMixedModel().getNProbability(i);
94  }
95 
102  const std::vector<double>& getProbabilities() const
103  {
104  return getMixedModel().getProbabilities();
105  }
106 
111  void setNProbability(size_t i, double prob)
112  {
113  getMixedModel().setNProbability(i, prob);
114  }
115 
120  size_t getNumberOfModels() const
121  {
122  return getMixedModel().getNumberOfModels();
123  }
124 
129  void setVRates(const Vdouble& vd)
130  {
131  getMixedModel().setVRates(vd);
132  }
133 
139  {
141  }
142 
147  const std::vector<double>& getVRates() const
148  {
149  return getMixedModel().getVRates();
150  }
151 
155  double getNRate(size_t i) const
156  {
157  return getMixedModel().getNRate(i);
158  }
159 
160  /*
161  *@brief Returns the vector of numbers of the submodels in the
162  *mixture that match a description.
163  *
164  */
165  Vint getSubmodelNumbers(std::string& desc) const;
166 
167 private:
168  virtual MixedSubstitutionModel& getMixedModel() = 0;
169 
170 };
171 } // end of namespace bpp.
172 
173 #endif // _AbstractBiblioMixedSubstitutionModel_H_
174 
void setVRates(const Vdouble &vd)
sets the rates of the submodels.
Interface for all substitution models.
Abstract class for mixture models based on the bibliography.
void normalizeVRates()
normalizes the rates of the submodels.
virtual double getNProbability(size_t i) const =0
Returns the probability of a specific model from the mixture.
virtual AbstractBiblioMixedSubstitutionModel * clone() const =0
Partial implementation of the SubstitutionModel interface for models that are set for matching the bi...
const std::vector< double > & getProbabilities() const
Returns the vector of the probabilities of the submodels of the mixture.
const SubstitutionModel * getNModel(size_t i) const
Returns a specific model from the mixture.
double getNRate(size_t i) const
Returns the rate of a specific model from the mixture.
virtual const std::vector< double > & getVRates() const =0
Returns the rates of the submodels.
void setNProbability(size_t i, double prob)
Sets the probabilities of the submodels of the mixture.
virtual void normalizeVRates()=0
Normalizes the rates of the submodels so that the mean rate of the mixture equals rate_...
AbstractBiblioMixedSubstitutionModel & operator=(const AbstractBiblioMixedSubstitutionModel &model)
virtual void setNProbability(size_t i, double prob)=0
Sets the probability of a specific model from the mixture.
virtual const std::vector< double > & getProbabilities() const =0
double getNProbability(size_t i) const
Returns the probability of a specific model from the mixture.
const std::vector< double > & getVRates() const
Returns the vector of all the rates of the mixture.
virtual void setVRates(const Vdouble &vd)=0
Sets the rates of the submodels to be proportional to a given vector, and normalizes them so that the...
virtual double getNRate(size_t i) const =0
Returns the rate of a specific submodel.
virtual const MixedSubstitutionModel & getMixedModel() const =0
virtual size_t getNumberOfModels() const =0
size_t getNumberOfModels() const
Returns the number of submodels.
virtual const SubstitutionModel * getNModel(size_t i) const =0
Returns a specific model from the mixture.
Interface for Substitution models, defined as a mixture of "simple" substitution models.