bpp-phyl3 3.0.0
DRHomogeneousMixedTreeLikelihood.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: The Bio++ Development Group
2//
3// SPDX-License-Identifier: CECILL-2.1
4
5#ifndef BPP_PHYL_LEGACY_LIKELIHOOD_DRHOMOGENEOUSMIXEDTREELIKELIHOOD_H
6#define BPP_PHYL_LEGACY_LIKELIHOOD_DRHOMOGENEOUSMIXEDTREELIKELIHOOD_H
7
10
11#include "../../Model/MixedTransitionModel.h"
12#include "../../Model/SubstitutionModel.h"
14
15namespace bpp
16{
27{
28private:
29 std::vector<DRHomogeneousTreeLikelihood*> treeLikelihoodsContainer_;
30 std::vector<double> probas_;
31
32 // true if the root Array should be computed (for ancestral
33 // reconstruction)
34
36
37public:
57 const Tree& tree,
58 std::shared_ptr<TransitionModelInterface> model,
59 std::shared_ptr<DiscreteDistributionInterface> rDist,
60 bool checkRooted = true,
61 bool verbose = true,
62 bool rootArray = false);
63
81 const Tree& tree,
83 std::shared_ptr<TransitionModelInterface> model,
84 std::shared_ptr<DiscreteDistributionInterface> rDist,
85 bool checkRooted = true,
86 bool verbose = true,
87 bool rootArray = false);
88
90
92
94
96
97public:
105 double getLikelihood() const;
106 double getLogLikelihood() const;
107
108 void setData(const AlignmentDataInterface& sites);
109 double getLikelihoodForASite (size_t site) const;
110 double getLogLikelihoodForASite(size_t site) const;
119 double getLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
120 double getLogLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
121 double getLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const;
122 double getLogLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const;
130 double getFirstOrderDerivative(const std::string& variable) const;
138 double getSecondOrderDerivative(const std::string& variable) const;
139 double getSecondOrderDerivative(const std::string& variable1, const std::string& variable2) const { return 0; } // Not implemented for now.
142public:
143 // Specific methods:
144 void initialize();
145
146 void fireParameterChanged(const ParameterList& params);
147
149
150 virtual void computeTreeDLikelihoods();
151
152protected:
153 virtual void computeLikelihoodAtNode_(const Node* node, VVVdouble& likelihoodArray, const Node* sonNode = 0) const;
154
160 virtual void computeSubtreeLikelihoodPostfix(const Node* node);
161
162 virtual void computeSubtreeLikelihoodPrefix(const Node* node);
163
164 virtual void computeRootLikelihood();
165
166 virtual void computeTreeD2LikelihoodAtNode(const Node*);
167 virtual void computeTreeD2Likelihoods();
168
169 void resetLikelihoodArrays(const Node* node);
170
176 virtual void displayLikelihood(const Node* node);
177};
178} // end of namespace bpp.
179#endif // BPP_PHYL_LEGACY_LIKELIHOOD_DRHOMOGENEOUSMIXEDTREELIKELIHOOD_H
const AlignmentDataInterface & data() const
Get the dataset for which the likelihood must be evaluated.
const Tree & tree() const
Get the tree (topology and branch lengths).
A class to compute the average of several DRHomogeneousTreeLikelihood defined from a Mixed Substituti...
virtual void displayLikelihood(const Node *node)
This method is mainly for debugging purpose.
double getSecondOrderDerivative(const std::string &variable) const
double getLogLikelihoodForASite(size_t site) const
Get the logarithm of the likelihood for a site.
double getLogLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
Get the logarithm of the likelihood for a site knowing its rate class.
double getFirstOrderDerivative(const std::string &variable) const
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.
std::vector< DRHomogeneousTreeLikelihood * > treeLikelihoodsContainer_
double getLikelihood() const
Get the likelihood for the whole dataset.
double getLogLikelihood() const
Get the logarithm of the likelihood for the whole dataset.
virtual void computeLikelihoodAtNode_(const Node *node, VVVdouble &likelihoodArray, const Node *sonNode=0) const
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.
void fireParameterChanged(const ParameterList &params)
DRHomogeneousMixedTreeLikelihood * clone() const
DRHomogeneousMixedTreeLikelihood & operator=(const DRHomogeneousMixedTreeLikelihood &lik)
void setData(const AlignmentDataInterface &sites)
Set the dataset for which the likelihood must be evaluated.
virtual void computeSubtreeLikelihoodPrefix(const Node *node)
double getLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
Get the likelihood for a site knowing its rate class.
double getSecondOrderDerivative(const std::string &variable1, const std::string &variable2) const
virtual void computeSubtreeLikelihoodPostfix(const Node *node)
Compute the likelihood for a subtree defined by the Tree::Node node.
double getLikelihoodForASite(size_t site) const
Get the likelihood for a site.
This class implements the likelihood computation for a tree using the double-recursive algorithm.
The phylogenetic node class.
Definition: Node.h:59
Interface for phylogenetic tree objects.
Definition: Tree.h:115
Defines the basic types of data flow nodes.
std::vector< VVdouble > VVVdouble