bpp-phyl3  3.0.0
AbstractDiscreteRatesAcrossSitesTreeLikelihood.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_ABSTRACTDISCRETERATESACROSSSITESTREELIKELIHOOD_H
6 #define BPP_PHYL_LEGACY_LIKELIHOOD_ABSTRACTDISCRETERATESACROSSSITESTREELIKELIHOOD_H
7 
8 
9 #include "../../Model/SubstitutionModel.h"
10 #include "AbstractTreeLikelihood.h"
12 
13 namespace bpp
14 {
24 {
25 protected:
26  std::shared_ptr<DiscreteDistributionInterface> rateDistribution_;
27 
28 public:
30  std::shared_ptr<DiscreteDistributionInterface> rDist,
31  bool verbose = true
32  );
33 
38  {}
39 
42  {
45  return *this;
46  }
47 
49 
50 public:
58  double getLikelihoodForASiteForAState (size_t site, int state) const;
59  double getLogLikelihoodForASiteForAState(size_t site, int state) const;
62  VVdouble getTransitionProbabilities(int nodeId, size_t siteIndex) const;
70  std::shared_ptr<const DiscreteDistributionInterface> getRateDistribution() const
71  {
72  return rateDistribution_;
73  }
74 
75  std::shared_ptr<DiscreteDistributionInterface> getRateDistribution()
76  {
77  return rateDistribution_;
78  }
79 
81  {
82  return *rateDistribution_;
83  }
84 
86  {
87  return *rateDistribution_;
88  }
89 
90  size_t getNumberOfClasses() const
91  {
92  return rateDistribution_->getNumberOfCategories();
93  }
94 
102  std::vector<size_t> getRateClassWithMaxPostProbPerSite() const;
117  static void resetLikelihoodArray(VVVdouble& likelihoodArray);
118 
124  static void displayLikelihoodArray(const VVVdouble& likelihoodArray);
125 
127 };
128 } // end of namespace bpp.
129 #endif // BPP_PHYL_LEGACY_LIKELIHOOD_ABSTRACTDISCRETERATESACROSSSITESTREELIKELIHOOD_H
Partial implementation of the DiscreteRatesAcrossSitesTreeLikelihood interface.
Vdouble getPosteriorRatePerSite() const
Get the posterior rate, i.e. averaged over all classes and weighted with posterior probabilities,...
ParameterList getRateDistributionParameters() const
Get the parameters associated to the rate distribution.
Vdouble getRateWithMaxPostProbPerSite() const
Get the posterior rate (the one with maximum posterior probability) for each site.
VVdouble getLogLikelihoodPerSitePerRateClass() const
Get the logarithm of the likelihood for each site and each rate class.
std::shared_ptr< const DiscreteDistributionInterface > getRateDistribution() const
Get the rate distribution used for the computation.
VVdouble getTransitionProbabilities(int nodeId, size_t siteIndex) const
Retrieves all Pij(t) for a particular branch, defined by the upper node and site.
AbstractDiscreteRatesAcrossSitesTreeLikelihood & operator=(const AbstractDiscreteRatesAcrossSitesTreeLikelihood &tl)
double getLikelihoodForASiteForAState(size_t site, int state) const
Get the likelihood for a site and for a state.
AbstractDiscreteRatesAcrossSitesTreeLikelihood(std::shared_ptr< DiscreteDistributionInterface > rDist, bool verbose=true)
ParameterList getNonDerivableParameters() const
All non derivable parameters.
VVdouble getPosteriorProbabilitiesPerRate() const
Get the posterior probability for each site of belonging to a particular rate class.
AbstractDiscreteRatesAcrossSitesTreeLikelihood(const AbstractDiscreteRatesAcrossSitesTreeLikelihood &tl)
VVVdouble getLogLikelihoodPerSitePerRateClassPerState() const
Get the logarithm of the likelihood for each site and each rate class and each state.
double getLogLikelihoodForASiteForAState(size_t site, int state) const
Get the logarithm of the likelihood for a site and for a state.
static void displayLikelihoodArray(const VVVdouble &likelihoodArray)
Print the likelihood array to terminal (debugging tool).
static void resetLikelihoodArray(VVVdouble &likelihoodArray)
Set all conditional likelihoods to 1.
VVdouble getLikelihoodPerSitePerRateClass() const
Get the likelihood for each site and each rate class.
std::vector< size_t > getRateClassWithMaxPostProbPerSite() const
Get the posterior rate class (the one with maximum posterior probability) for each site.
const DiscreteDistributionInterface & rateDistribution() const
Get the rate distribution used for the computation.
DiscreteDistributionInterface & rateDistribution()
Get the rate distribution used for the computation.
std::shared_ptr< DiscreteDistributionInterface > getRateDistribution()
Get the rate distribution used for the computation.
VVVdouble getLikelihoodPerSitePerRateClassPerState() const
Get the likelihood for each site and each rate class and each state.
Partial implementation of the TreeLikelihood interface.
AbstractTreeLikelihood & operator=(const AbstractTreeLikelihood &lik)
Interface for rate across sites (RAS) implementation.
Defines the basic types of data flow nodes.
std::vector< double > Vdouble
std::vector< VVdouble > VVVdouble
std::vector< Vdouble > VVdouble