2
// File: RHomogeneousMixedTreeLikelihood.h
3
// Created by: Davud Fournier, Laurent Gueguen
7
Copyright or � or Copr. CNRS, (November 16, 2004)
9
This software is a computer program whose purpose is to provide classes
10
for phylogenetic data analysis.
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".
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
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.
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.
39
#ifndef _RHOMOGENEOUSMIXEDTREELIKELIHOOD_H_
40
#define _RHOMOGENEOUSMIXEDTREELIKELIHOOD_H_
42
#include "RHomogeneousTreeLikelihood.h"
43
#include "../Model/SubstitutionModel.h"
44
#include "../Model/MixedSubstitutionModel.h"
46
#include <Bpp/Numeric/VectorTools.h>
47
#include <Bpp/Numeric/Prob/DiscreteDistribution.h>
52
*@ brief A class to compute the average of several
53
*RHomogeneousTreeLikelihood defined from a Mixed Substitution
56
* In all the calculs, the average of the likelihoods, probabilities
60
class RHomogeneousMixedTreeLikelihood :
61
public RHomogeneousTreeLikelihood
64
std::vector<RHomogeneousTreeLikelihood*> treeLikelihoodsContainer_;
65
std::vector<double> probas_;
69
* @brief Build a new RHomogeneousMixedTreeLikelihood object without
72
* This constructor only initialize the parameters. To compute a
73
* likelihood, you will need to call the setData() and the
74
* computeTreeLikelihood() methods.
76
* @param tree The tree to use.
77
* @param model The mixed substitution model to use.
78
* @param rDist The rate across sites distribution to use.
79
* @param checkRooted Tell if we have to check for the tree to be unrooted.
80
* If true, any rooted tree will be unrooted before likelihood computation.
81
* @param verbose Should I display some info?
82
* @param usePatterns Tell if recursive site compression should be performed.
83
* @throw Exception in an error occured.
85
RHomogeneousMixedTreeLikelihood(
87
SubstitutionModel* model,
88
DiscreteDistribution* rDist,
89
bool checkRooted = true,
91
bool usePatterns = true)
95
* @brief Build a new RHomogeneousMixedTreeLikelihood object with data.
97
* This constructor initializes all parameters, data, and likelihood arrays.
99
* @param tree The tree to use.
100
* @param data Sequences to use.
101
* @param model The mixed substitution model to use.
102
* @param rDist The rate across sites distribution to use.
103
* @param checkRooted Tell if we have to check for the tree to be unrooted.
104
* If true, any rooted tree will be unrooted before likelihood computation.
105
* @param verbose Should I display some info?
106
* @param usePatterns Tell if recursive site compression should be performed.
107
* @throw Exception in an error occured.
109
RHomogeneousMixedTreeLikelihood(
111
const SiteContainer& data,
112
SubstitutionModel* model,
113
DiscreteDistribution* rDist,
114
bool checkRooted = true,
116
bool usePatterns = true)
119
RHomogeneousMixedTreeLikelihood(const RHomogeneousMixedTreeLikelihood& lik);
121
RHomogeneousMixedTreeLikelihood& operator=(const RHomogeneousMixedTreeLikelihood& lik);
123
virtual ~RHomogeneousMixedTreeLikelihood();
125
RHomogeneousMixedTreeLikelihood* clone() const { return new RHomogeneousMixedTreeLikelihood(*this); }
129
* @name The TreeLikelihood interface.
131
* Other methods are implemented in the RHomogeneousTreeLikelihood class.
135
void setData(const SiteContainer& sites) throw (Exception);
141
* @name The DiscreteRatesAcrossSites interface implementation:
145
double getLikelihoodForASiteForARateClass(unsigned int site, unsigned int rateClass) const;
146
double getLogLikelihoodForASiteForARateClass(unsigned int site, unsigned int rateClass) const;
147
double getLikelihoodForASiteForARateClassForAState(unsigned int site, unsigned int rateClass, int state) const;
148
double getLogLikelihoodForASiteForARateClassForAState(unsigned int site, unsigned int rateClass, int state) const;
153
void initialize() throw (Exception);
155
void fireParameterChanged(const ParameterList& params);
157
void computeTreeLikelihood();
159
virtual double getDLikelihoodForASiteForARateClass(unsigned int site, unsigned int rateClass) const;
161
virtual void computeTreeDLikelihood(const std::string& variable);
163
virtual double getD2LikelihoodForASiteForARateClass(unsigned int site, unsigned int rateClass) const;
165
virtual void computeTreeD2Likelihood(const std::string& variable);
169
* @brief Compute the likelihood for a subtree defined by the Tree::Node <i>node</i>.
171
* @param node The root of the subtree.
173
virtual void computeSubtreeLikelihood(const Node* node); // Recursive method.
175
virtual void computeDownSubtreeDLikelihood(const Node*);
177
virtual void computeDownSubtreeD2Likelihood(const Node*);
180
* @brief This method is used by fireParameterChanged method.
183
void computeAllTransitionProbabilities();
185
* @brief This method is used by fireParameterChanged method.
188
void computeTransitionProbabilitiesForNode(const Node* node);
191
* @brief This method is mainly for debugging purpose.
193
* @param node The node at which likelihood values must be displayed.
195
virtual void displayLikelihood(const Node* node);
197
} // end of namespace bpp.
199
#endif // _RHOMOGENEOUSMIXEDTREELIKELIHOOD_H_