bpp-phyl3 3.0.0
TreeLikelihood.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_TREELIKELIHOOD_H
6#define BPP_PHYL_LEGACY_LIKELIHOOD_TREELIKELIHOOD_H
7
12
13#include "../../Model/SubstitutionModel.h"
14#include "TreeLikelihoodData.h"
15
16// From bpp-seq:
19
20namespace bpp
21{
29 public virtual SecondOrderDerivable
30{
31public:
36 {
37public:
38 virtual ~BranchIterator() {}
39
40public:
44 virtual int next() = 0;
48 virtual bool hasNext() const = 0;
49 };
50
57 {
58public:
59 virtual ~SiteIterator() {}
60
61public:
65 virtual size_t next() = 0;
69 virtual bool hasNext() const = 0;
70 };
71
76 {
77public:
79
80public:
81 virtual const TransitionModelInterface& model() const = 0;
82 virtual std::shared_ptr<const TransitionModelInterface> getModel() const = 0;
83
85 virtual std::shared_ptr<const SubstitutionModelInterface> getSubstitutionModel() const = 0;
86
87 virtual SiteIterator* getNewSiteIterator() const = 0;
88 };
89
94 {
95public:
97
98public:
100 virtual bool hasNext() const = 0;
101 };
102
107 {
108public:
110
111public:
112 virtual const TransitionModelInterface& model() const = 0;
113 virtual std::shared_ptr<const TransitionModelInterface> getModel() const = 0;
114
116 virtual std::shared_ptr<const SubstitutionModelInterface> getSubstitutionModel() const = 0;
117
119 };
120
125 {
126public:
128
129public:
131 virtual bool hasNext() const = 0;
132 };
133
134public:
137
138 TreeLikelihoodInterface* clone() const override = 0;
139
140public:
146 virtual void setData(const AlignmentDataInterface& sites) = 0;
147
153 virtual const AlignmentDataInterface& data() const = 0;
154
163 virtual void initialize() = 0;
164
168 virtual bool isInitialized() const = 0;
169
173 virtual bool hasLikelihoodData() const = 0;
174
179
183 virtual const TreeLikelihoodData& likelihoodData() const = 0;
184
191 virtual double getLikelihoodForASite(size_t site) const = 0;
192
199 virtual double getLogLikelihoodForASite(size_t site) const = 0;
200
208 virtual double getLikelihoodForASiteForAState(size_t site, int state) const = 0;
209
217 virtual double getLogLikelihoodForASiteForAState(size_t site, int state) const = 0;
218
224 virtual Vdouble getLikelihoodPerSite() const = 0;
225
231 virtual Vdouble getLogLikelihoodPerSite() const = 0;
232
239
246
252 virtual double getLikelihood() const = 0;
253
259 virtual double getLogLikelihood() const = 0;
260
266 virtual const Tree& tree() const = 0;
267
273 virtual size_t getNumberOfSites() const = 0;
274
278 virtual size_t getNumberOfStates() const = 0;
279
283 virtual int getAlphabetStateAsInt(size_t i) const = 0;
284
288 virtual std::string getAlphabetStateAsChar(size_t i) const = 0;
289
293 virtual const std::vector<int>& getAlphabetStates() const = 0;
294
300 virtual std::shared_ptr<const Alphabet> getAlphabet() const = 0;
301
314
321
330 virtual std::shared_ptr<const TransitionModelInterface> getModelForSite(int nodeId, size_t siteIndex) const = 0;
331
341 virtual std::shared_ptr<TransitionModelInterface> getModelForSite(int nodeId, size_t siteIndex) = 0;
342
353 virtual VVdouble getTransitionProbabilities(int nodeId, size_t siteIndex) const = 0;
354
356
357 virtual ConstSiteModelIterator* getNewSiteModelIterator(size_t siteIndex) const = 0;
358
365 virtual size_t getSiteIndex(size_t site) const = 0;
366
380 virtual const std::vector<double>& getRootFrequencies(size_t siteIndex) const = 0;
381
391 virtual void enableDerivatives(bool yn) = 0;
392
401
410};
411} // end of namespace bpp.
412#endif // BPP_PHYL_LEGACY_LIKELIHOOD_TREELIKELIHOOD_H
Interface for all substitution models.
Interface for all transition models.
TreeLikelihood data structure.
An iterator over a set of branches, specified by their node ids.
A pair of SubstitutionModel / SiteIterator.
virtual std::shared_ptr< const TransitionModelInterface > getModel() const =0
virtual std::shared_ptr< const SubstitutionModelInterface > getSubstitutionModel() const =0
virtual const TransitionModelInterface & model() const =0
virtual const SubstitutionModelInterface & substitutionModel() const =0
virtual SiteIterator * getNewSiteIterator() const =0
Iterates through all models used for all sites on a given branch.
virtual ConstBranchModelDescription * next()=0
A pair of SubstitutionModel / BranchIterator.
virtual std::shared_ptr< const SubstitutionModelInterface > getSubstitutionModel() const =0
virtual BranchIterator * getNewBranchIterator() const =0
virtual const SubstitutionModelInterface & substitutionModel() const =0
virtual const TransitionModelInterface & model() const =0
virtual std::shared_ptr< const TransitionModelInterface > getModel() const =0
Iterates through all models used for all branches on a given site.
virtual ConstSiteModelDescription * next()=0
An iterator over a set of sites, specified by their position.
The TreeLikelihood interface.
virtual const TreeLikelihoodData & likelihoodData() const =0
virtual size_t getNumberOfStates() const =0
virtual const std::vector< double > & getRootFrequencies(size_t siteIndex) const =0
Get the values of the frequencies for each state in the alphabet at the root node.
virtual bool isInitialized() const =0
virtual double getLikelihoodForASiteForAState(size_t site, int state) const =0
Get the likelihood for a site and for a state.
virtual size_t getNumberOfSites() const =0
Get the number of sites in the dataset.
virtual double getLogLikelihoodForASite(size_t site) const =0
Get the logarithm of the likelihood for a site.
virtual Vdouble getLikelihoodPerSite() const =0
Get the likelihood for each site.
virtual const Tree & tree() const =0
Get the tree (topology and branch lengths).
virtual ParameterList getSubstitutionModelParameters() const =0
Get the parameters associated to substitution model(s).
virtual bool hasLikelihoodData() const =0
virtual int getAlphabetStateAsInt(size_t i) const =0
virtual double getLikelihoodForASite(size_t site) const =0
Get the likelihood for a site.
virtual double getLogLikelihood() const =0
Get the logarithm of the likelihood for the whole dataset.
virtual std::shared_ptr< TransitionModelInterface > getModelForSite(int nodeId, size_t siteIndex)=0
Get the substitution model associated to a given node and alignment column.
virtual ParameterList getDerivableParameters() const =0
All derivable parameters.
virtual const AlignmentDataInterface & data() const =0
Get the dataset for which the likelihood must be evaluated.
virtual void initialize()=0
Init the likelihood object.
virtual double getLogLikelihoodForASiteForAState(size_t site, int state) const =0
Get the logarithm of the likelihood for a site and for a state.
virtual std::shared_ptr< const TransitionModelInterface > getModelForSite(int nodeId, size_t siteIndex) const =0
Get the substitution model associated to a given node and alignment column.
virtual size_t getSiteIndex(size_t site) const =0
Get the index (used for inner computations) of a given site (original alignment column).
virtual VVdouble getLogLikelihoodPerSitePerState() const =0
Get the logarithm of the likelihood for each site and for each state.
virtual ConstBranchModelIterator * getNewBranchModelIterator(int nodeId) const =0
virtual TreeLikelihoodData & likelihoodData()=0
virtual const std::vector< int > & getAlphabetStates() const =0
virtual std::string getAlphabetStateAsChar(size_t i) const =0
virtual std::shared_ptr< const Alphabet > getAlphabet() const =0
Get the alphabet associated to the dataset.
virtual ParameterList getNonDerivableParameters() const =0
All non derivable parameters.
virtual void setData(const AlignmentDataInterface &sites)=0
Set the dataset for which the likelihood must be evaluated.
virtual double getLikelihood() const =0
Get the likelihood for the whole dataset.
virtual void enableDerivatives(bool yn)=0
Tell if derivatives must be computed.
virtual Vdouble getLogLikelihoodPerSite() const =0
Get the logarithm of the likelihood for each site.
virtual ParameterList getBranchLengthsParameters() const =0
Get the branch lengths parameters.
virtual VVdouble getTransitionProbabilities(int nodeId, size_t siteIndex) const =0
Retrieves all Pij(t) for a particular branch, defined by the upper node and site.
virtual ConstSiteModelIterator * getNewSiteModelIterator(size_t siteIndex) const =0
virtual VVdouble getLikelihoodPerSitePerState() const =0
Get the likelihood for each site and for each state.
TreeLikelihoodInterface * clone() const override=0
Interface for phylogenetic tree objects.
Definition: Tree.h:115
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
std::vector< Vdouble > VVdouble