bpp-phyl  2.1.0
 All Classes Namespaces Files Functions Variables Friends Pages
SubstitutionModel.h
Go to the documentation of this file.
1 //
2 // File: SubstitutionModel.h
3 // Created by: Julien Dutheil
4 // Created on: Mon May 26 14:52:34 2003
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 _SUBSTITUTIONMODEL_H_
41 #define _SUBSTITUTIONMODEL_H_
42 
43 #include <cstdlib>
44 #include <map>
45 #include <string>
46 
47 #include <Bpp/Exceptions.h>
48 #include <Bpp/Numeric/Parameter.h>
53 
54 //From Seqlib:
58 
59 namespace bpp
60 {
61 class SubstitutionModel;
62 
69  public Exception
70 {
71 protected:
73 
74 public:
75  SubstitutionModelException(const std::string& text, const SubstitutionModel* sm = 0);
76 
78  Exception(sme), model_(sme.model_) {}
79 
81  {
82  Exception::operator=(sme);
83  model_ = sme.model_;
84  return *this;
85  }
86 
87  ~SubstitutionModelException() throw ();
88 
89 public:
95  virtual const SubstitutionModel* getSubstitutionModel() const { return model_; }
96 };
97 
196  public virtual ParameterAliasable
197 {
198 public:
200  virtual ~SubstitutionModel() {}
201 
202 #ifndef NO_VIRTUAL_COV
203  SubstitutionModel* clone() const = 0;
204 #endif
205 
206 public:
212  virtual std::string getName() const = 0;
213 
219  virtual const std::vector<int>& getAlphabetChars() const = 0;
220 
230  virtual int getAlphabetChar(size_t i) const = 0;
231 
238  virtual std::vector<size_t> getModelStates(int i) const = 0;
239 
244  virtual double freq(size_t i) const = 0;
245 
251  virtual double Qij(size_t i, size_t j) const = 0;
252 
257  virtual double Pij_t(size_t i, size_t j, double t) const = 0;
258 
264  virtual double dPij_dt(size_t i, size_t j, double t) const = 0;
265 
271  virtual double d2Pij_dt2(size_t i, size_t j, double t) const = 0;
272 
277  virtual const Vdouble& getFrequencies() const = 0;
278 
294  virtual const Matrix<double>& getGenerator() const = 0;
295 
301  virtual const Matrix<double>& getExchangeabilityMatrix() const = 0;
302 
309  virtual double Sij(size_t i, size_t j) const = 0;
314  virtual const Matrix<double>& getPij_t(double t) const = 0;
315 
321  virtual const Matrix<double>& getdPij_dt(double t) const = 0;
322 
328  virtual const Matrix<double>& getd2Pij_dt2(double t) const = 0;
329 
333  virtual void enableEigenDecomposition(bool yn) = 0;
334 
338  virtual bool enableEigenDecomposition() = 0;
339 
343  virtual const Vdouble& getEigenValues() const = 0;
344 
348  virtual const Vdouble& getIEigenValues() const = 0;
349 
353  virtual bool isDiagonalizable() const = 0;
354 
358  virtual bool isNonSingular() const = 0;
359 
364  virtual const Matrix<double>& getRowLeftEigenVectors() const = 0;
365 
370  virtual const Matrix<double>& getColumnRightEigenVectors() const = 0;
371 
375  virtual const Alphabet* getAlphabet() const = 0;
376 
384  virtual size_t getNumberOfStates() const = 0;
385 
399  virtual double getInitValue(size_t i, int state) const throw (IndexOutOfBoundsException, BadIntException) = 0;
400 
409  virtual double getScale() const = 0;
410 
420  virtual void setScale(double scale) = 0;
421 
425  virtual double getRate() const = 0;
426 
432  virtual void setRate(double rate) = 0;
433 
434  virtual void addRateParameter() = 0;
435 
448  virtual void setFreqFromData(const SequenceContainer& data, double pseudoCount = 0) = 0;
449 
455  virtual void setFreq(std::map<int, double>& frequencies) {}
456 
463  virtual const FrequenciesSet* getFrequenciesSet() const {return NULL;}
464 };
465 
466 
479  public virtual SubstitutionModel
480 {
481 public:
484 
485 #ifndef NO_VIRTUAL_COV
486  ReversibleSubstitutionModel* clone() const = 0;
487 #endif
488 };
489 
490 } //end of namespace bpp.
491 
492 #endif //_SUBSTITUTIONMODEL_H_
493