bpp-phyl3 3.0.0
RHomogeneousTreeLikelihood.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_RHOMOGENEOUSTREELIKELIHOOD_H
6#define BPP_PHYL_LEGACY_LIKELIHOOD_RHOMOGENEOUSTREELIKELIHOOD_H
7
10
11#include "../../Model/SubstitutionModel.h"
14
15namespace bpp
16{
48{
49private:
51
52protected:
54
55public:
72 const Tree& tree,
73 std::shared_ptr<TransitionModelInterface> model,
74 std::shared_ptr<DiscreteDistributionInterface> rDist,
75 bool checkRooted = true,
76 bool verbose = true,
77 bool usePatterns = true);
78
95 const Tree& tree,
97 std::shared_ptr<TransitionModelInterface> model,
98 std::shared_ptr<DiscreteDistributionInterface> rDist,
99 bool checkRooted = true,
100 bool verbose = true,
101 bool usePatterns = true);
102
104
106
108
110
111private:
115 void init_(bool usePatterns);
116
117public:
125 void setData(const AlignmentDataInterface& sites);
126 double getLikelihood() const;
127 double getLogLikelihood() const;
128 double getLikelihoodForASite (size_t site) const;
129 double getLogLikelihoodForASite(size_t site) const;
138 double getLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
139 double getLogLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
140 double getLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const;
141 double getLogLikelihoodForASiteForARateClassForAState(size_t site, size_t rateClass, int state) const;
157 void setParameters(const ParameterList& parameters);
158 double getValue() const;
159
160 size_t getSiteIndex(size_t site) const { return likelihoodData_->getRootArrayPosition(site); }
161
167 double getFirstOrderDerivative(const std::string& variable) const;
175 double getSecondOrderDerivative(const std::string& variable) const;
176 double getSecondOrderDerivative(const std::string& variable1, const std::string& variable2) const { return 0; } // Not implemented for now.
179public:
180 // Specific methods:
181
183
185
187
188 virtual double getDLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
189
190 virtual double getDLikelihoodForASite(size_t site) const;
191
192 virtual double getDLogLikelihoodForASite(size_t site) const;
193
194 virtual double getDLogLikelihood() const;
195
196 virtual void computeTreeDLikelihood(const std::string& variable);
197
198 virtual double getD2LikelihoodForASiteForARateClass(size_t site, size_t rateClass) const;
199
200 virtual double getD2LikelihoodForASite(size_t site) const;
201
202 virtual double getD2LogLikelihoodForASite(size_t site) const;
203
204 virtual double getD2LogLikelihood() const;
205
206 virtual void computeTreeD2Likelihood(const std::string& variable);
207
208protected:
214 virtual void computeSubtreeLikelihood(const Node* node); // Recursive method.
215 virtual void computeDownSubtreeDLikelihood(const Node*);
216
217 virtual void computeDownSubtreeD2Likelihood(const Node*);
218
219 void fireParameterChanged(const ParameterList& params);
220
226 virtual void displayLikelihood(const Node* node);
227
229};
230} // end of namespace bpp.
231#endif // BPP_PHYL_LEGACY_LIKELIHOOD_RHOMOGENEOUSTREELIKELIHOOD_H
Partial implementation for homogeneous model of the TreeLikelihood interface.
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).
discrete Rate Across Sites, (simple) Recursive likelihood data structure.
size_t getRootArrayPosition(size_t currentPosition) const
The phylogenetic node class.
Definition: Node.h:59
This class implement the 'traditional' way of computing likelihood for a tree.
virtual double getD2LikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
virtual double getDLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
void setParameters(const ParameterList &parameters)
Implements the Function interface.
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.
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.
double getLogLikelihoodForASite(size_t site) const
Get the logarithm of the likelihood for a site.
RHomogeneousTreeLikelihood & operator=(const RHomogeneousTreeLikelihood &lik)
virtual void displayLikelihood(const Node *node)
This method is mainly for debugging purpose.
const DRASRTreeLikelihoodData & likelihoodData() const
virtual void computeSubtreeLikelihood(const Node *node)
Compute the likelihood for a subtree defined by the Tree::Node node.
DRASRTreeLikelihoodData & likelihoodData()
double getSecondOrderDerivative(const std::string &variable) const
double getLikelihoodForASite(size_t site) const
Get 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.
void setData(const AlignmentDataInterface &sites)
Set the dataset for which the likelihood must be evaluated.
virtual double getD2LikelihoodForASite(size_t site) const
virtual void computeTreeDLikelihood(const std::string &variable)
virtual void computeTreeD2Likelihood(const std::string &variable)
RHomogeneousTreeLikelihood(const Tree &tree, std::shared_ptr< TransitionModelInterface > model, std::shared_ptr< DiscreteDistributionInterface > rDist, bool checkRooted=true, bool verbose=true, bool usePatterns=true)
Build a new RHomogeneousTreeLikelihood object without data.
virtual double getDLikelihoodForASite(size_t site) const
double getLikelihood() const
Get the likelihood for the whole dataset.
double getFirstOrderDerivative(const std::string &variable) const
size_t getSiteIndex(size_t site) const
Get the index (used for inner computations) of a given site (original alignment column).
double getSecondOrderDerivative(const std::string &variable1, const std::string &variable2) const
virtual double getD2LogLikelihoodForASite(size_t site) const
double getLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
Get the likelihood for a site knowing its rate class.
virtual double getDLogLikelihoodForASite(size_t site) const
double getLogLikelihood() const
Get the logarithm of the likelihood for the whole dataset.
RHomogeneousTreeLikelihood * clone() const
void init_(bool usePatterns)
Method called by constructors.
DRASRTreeLikelihoodData * likelihoodData_
virtual void computeDownSubtreeD2Likelihood(const Node *)
void fireParameterChanged(const ParameterList &params)
virtual void computeDownSubtreeDLikelihood(const Node *)
Interface for phylogenetic tree objects.
Definition: Tree.h:115
Defines the basic types of data flow nodes.