bpp-phyl  2.2.0
RHomogeneousMixedTreeLikelihood.h
Go to the documentation of this file.
1 //
2 // File: RHomogeneousMixedTreeLikelihood.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 _RHOMOGENEOUSMIXEDTREELIKELIHOOD_H_
40 #define _RHOMOGENEOUSMIXEDTREELIKELIHOOD_H_
41 
43 #include "../Model/SubstitutionModel.h"
44 #include "../Model/MixedSubstitutionModel.h"
45 
46 #include <Bpp/Numeric/VectorTools.h>
47 #include <Bpp/Numeric/Prob/DiscreteDistribution.h>
48 
49 namespace bpp
50 {
62 {
63 private:
64  std::vector<RHomogeneousTreeLikelihood*> treeLikelihoodsContainer_;
65  std::vector<double> probas_;
66 
67 public:
86  const Tree& tree,
87  SubstitutionModel* model,
88  DiscreteDistribution* rDist,
89  bool checkRooted = true,
90  bool verbose = true,
91  bool usePatterns = true)
92  throw (Exception);
93 
110  const Tree& tree,
111  const SiteContainer& data,
112  SubstitutionModel* model,
113  DiscreteDistribution* rDist,
114  bool checkRooted = true,
115  bool verbose = true,
116  bool usePatterns = true)
117  throw (Exception);
118 
120 
122 
124 
126 
127 public:
135  void setData(const SiteContainer& sites) throw (Exception);
136 
145  double getLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
146  double getLogLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
147  double getLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const;
148  double getLogLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const;
151 public:
152  // Specific methods:
153  void initialize() throw (Exception);
154 
155  void fireParameterChanged(const ParameterList& params);
156 
157  void computeTreeLikelihood();
158 
159  virtual double getDLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
160 
161  virtual void computeTreeDLikelihood(const std::string& variable);
162 
163  virtual double getD2LikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
164 
165  virtual void computeTreeD2Likelihood(const std::string& variable);
166 
167 protected:
173  virtual void computeSubtreeLikelihood(const Node* node); // Recursive method.
174 
175  virtual void computeDownSubtreeDLikelihood(const Node*);
176 
177  virtual void computeDownSubtreeD2Likelihood(const Node*);
178 
189 
195  virtual void displayLikelihood(const Node* node);
196 
197  virtual void setMinimumBranchLength(double brlen) throw (Exception) {
199  for (size_t i = 0; i < treeLikelihoodsContainer_.size(); ++i)
201  }
202  virtual void setMaximumBranchLength(double brlen) throw (Exception) {
204  for (size_t i = 0; i < treeLikelihoodsContainer_.size(); ++i)
206  }
207 };
208 } // end of namespace bpp.
209 
210 #endif // _RHOMOGENEOUSMIXEDTREELIKELIHOOD_H_
211 
virtual void computeTreeDLikelihood(const std::string &variable)
double getLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const
Get the likelihood for a site knowing its rate class and its ancestral state.
Interface for all substitution models.
double getLogLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
Get the logarithm of the likelihood for a site knowing its rate class.
STL namespace.
Interface for phylogenetic tree objects.
Definition: Tree.h:148
std::vector< RHomogeneousTreeLikelihood * > treeLikelihoodsContainer_
This class implement the &#39;traditional&#39; way of computing likelihood for a tree.
virtual double getD2LikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
void setData(const SiteContainer &sites)
Set the dataset for which the likelihood must be evaluated.
void computeAllTransitionProbabilities()
This method is used by fireParameterChanged method.
double getLogLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const
Get the logarithm of the likelihood for a site knowing its rate class and its ancestral state...
virtual double getDLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
void fireParameterChanged(const ParameterList &params)
RHomogeneousMixedTreeLikelihood(const Tree &tree, SubstitutionModel *model, DiscreteDistribution *rDist, bool checkRooted=true, bool verbose=true, bool usePatterns=true)
Build a new RHomogeneousMixedTreeLikelihood object without data.
double getLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
Get the likelihood for a site knowing its rate class.
The phylogenetic node class.
Definition: Node.h:90
virtual void displayLikelihood(const Node *node)
This method is mainly for debugging purpose.
void computeTransitionProbabilitiesForNode(const Node *node)
This method is used by fireParameterChanged method.
virtual void computeTreeD2Likelihood(const std::string &variable)
virtual void computeSubtreeLikelihood(const Node *node)
Compute the likelihood for a subtree defined by the Tree::Node node.
RHomogeneousMixedTreeLikelihood * clone() const