bpp-phyl  2.2.0
AbstractWordSubstitutionModel.h
Go to the documentation of this file.
1 //
2 // File: AbstractWordSubstitutionModel.h
3 // Created by: Laurent Gueguen
4 // Created on: Jan 2009
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 _ABSTRACTWORDSUBSTITUTIONMODEL_H_
41 #define _ABSTRACTWORDSUBSTITUTIONMODEL_H_
42 
44 
45 // From the STL:
46 #include <vector>
47 
48 namespace bpp
49 {
77 {
78 private:
83 
84 protected:
85  std::vector<SubstitutionModel*> VSubMod_;
86  std::vector<std::string> VnestedPrefix_;
87 
88  std::vector<double> Vrate_;
89 
90 protected:
91  static Alphabet* extractAlph(const std::vector<SubstitutionModel*>& modelVector);
92 
93 protected:
94  void updateMatrices();
95 
100  virtual void completeMatrices() = 0;
101 
102 public:
115  const std::vector<SubstitutionModel*>& modelVector,
116  const std::string& prefix);
117 
129  SubstitutionModel* pmodel,
130  unsigned int num,
131  const std::string& prefix);
132 
134 
136 
138 
139  void setNamespace(const std::string& prefix);
140 
141 protected:
145  AbstractWordSubstitutionModel(const Alphabet* alph, StateMap* stateMap, const std::string& prefix);
146 
147 public:
148  virtual size_t getNumberOfStates() const;
149 
155  const SubstitutionModel* getNModel(size_t i) const {
156  if (i < VSubMod_.size())
157  return dynamic_cast<const SubstitutionModel*>(VSubMod_[i]);
158  else
159  return 0;
160  }
161 
162  size_t getNumberOfModels() const {
163  return VSubMod_.size();
164  }
165 
179  virtual void setFreq(std::map<int, double>& freqs);
180 };
181 } // end of namespace bpp.
182 
183 #endif // ABSTRACTWORDSUBSTITUTIONMODEL_
184 
Interface for all substitution models.
static Alphabet * extractAlph(const std::vector< SubstitutionModel *> &modelVector)
virtual size_t getNumberOfStates() const
Get the number of states.
Partial implementation of the SubstitutionModel interface.
AbstractWordSubstitutionModel(const std::vector< SubstitutionModel *> &modelVector, const std::string &prefix)
Build a new AbstractWordSubstitutionModel object from a vector of pointers to SubstitutionModels.
Abstract Basal class for words of substitution models.
AbstractWordSubstitutionModel & operator=(const AbstractWordSubstitutionModel &)
virtual void completeMatrices()=0
Called by updateMatrices to handle specific modifications for inheriting classes. ...
const SubstitutionModel * getNModel(size_t i) const
returns the ith model, or Null if i is not a valid number.
virtual void setFreq(std::map< int, double > &freqs)
Estimation of the parameters of the models so that the equilibrium frequencies match the given ones...
void updateMatrices()
Diagonalize the matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVe...
bool new_alphabet_
boolean flag to check if a specific WordAlphabet has been built
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:58
std::vector< SubstitutionModel * > VSubMod_