11 #include "../../PatternTools.h"
21 std::shared_ptr<TransitionModelInterface> model,
22 std::shared_ptr<DiscreteDistributionInterface> rDist,
27 treeLikelihoodsContainer_(),
30 shared_ptr<MixedTransitionModelInterface> mixedmodel;
31 if ((mixedmodel = dynamic_pointer_cast<MixedTransitionModelInterface>(
model_)) ==
nullptr)
32 throw Exception(
"Bad model: RHomogeneousMixedTreeLikelihood needs a MixedTransitionModel.");
33 size_t s = mixedmodel->getNumberOfModels();
34 for (
size_t i = 0; i < s; ++i)
37 make_shared<RHomogeneousTreeLikelihood>(
39 unique_ptr<TransitionModelInterface>(mixedmodel->nModel(i).clone()),
44 probas_.push_back(mixedmodel->getNProbability(i));
51 std::shared_ptr<TransitionModelInterface> model,
52 std::shared_ptr<DiscreteDistributionInterface> rDist,
57 treeLikelihoodsContainer_(),
60 shared_ptr<MixedTransitionModelInterface> mixedmodel;
62 if ((mixedmodel = dynamic_pointer_cast<MixedTransitionModelInterface>(
model_)) ==
nullptr)
63 throw Exception(
"Bad model: RHomogeneousMixedTreeLikelihood needs a MixedTransitionModel.");
65 size_t s = mixedmodel->getNumberOfModels();
66 for (
size_t i = 0; i < s; i++)
69 make_shared<RHomogeneousTreeLikelihood>(
71 unique_ptr<TransitionModelInterface>(mixedmodel->nModel(i).clone()),
76 probas_.push_back(mixedmodel->getNProbability(i));
100 treeLikelihoodsContainer_(lik.treeLikelihoodsContainer_.size()),
101 probas_(lik.probas_.size())
137 bool modelC =
model_->getParameters().testParametersValues(params);
140 auto mixedmodel = dynamic_pointer_cast<MixedTransitionModelInterface>(
model_);
141 size_t s = mixedmodel->getNumberOfModels();
143 for (
size_t i = 0; i < s; ++i)
157 probas_ = mixedmodel->getProbabilities();
virtual void applyParameters()
All parameters are stored in a parameter list. This function apply these parameters to the substituti...
std::shared_ptr< TransitionModelInterface > model_
void initialize()
Init the likelihood object.
const ParameterList & getParameters() const override
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).
The phylogenetic node class.
virtual void addParameters(const ParameterList ¶ms)
virtual void includeParameters(const ParameterList ¶ms)
virtual double getDLikelihoodForASiteForARateClass(size_t site, size_t rateClass) 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.
virtual ~RHomogeneousMixedTreeLikelihood()
void computeTransitionProbabilitiesForNode(const Node *node)
This method is used by fireParameterChanged method.
virtual void computeTreeD2Likelihood(const std::string &variable)
virtual void computeSubtreeLikelihood(const Node *node)
Compute the likelihood for a subtree defined by the Tree::Node node.
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.
void computeAllTransitionProbabilities()
This method is used by fireParameterChanged method.
virtual double getD2LikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
RHomogeneousMixedTreeLikelihood & operator=(const RHomogeneousMixedTreeLikelihood &lik)
virtual void computeDownSubtreeD2Likelihood(const Node *)
void fireParameterChanged(const ParameterList ¶ms)
virtual void computeDownSubtreeDLikelihood(const Node *)
std::vector< std::shared_ptr< RHomogeneousTreeLikelihood > > treeLikelihoodsContainer_
void setData(const AlignmentDataInterface &sites)
Set the dataset for which the likelihood must be evaluated.
void initialize()
Init the likelihood object.
std::vector< double > probas_
double getLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
Get the likelihood for a site knowing its rate class.
void computeTreeLikelihood()
virtual void displayLikelihood(const Node *node)
This method is mainly for debugging purpose.
virtual void computeTreeDLikelihood(const std::string &variable)
double getLogLikelihoodForASiteForARateClass(size_t site, size_t rateClass) const
Get the logarithm of the likelihood for a site knowing its rate class.
This class implement the 'traditional' way of computing likelihood for a tree.
RHomogeneousTreeLikelihood & operator=(const RHomogeneousTreeLikelihood &lik)
void setData(const AlignmentDataInterface &sites)
Set the dataset for which the likelihood must be evaluated.
double getLogLikelihood() const
Get the logarithm of the likelihood for the whole dataset.
friend class RHomogeneousMixedTreeLikelihood
Interface for phylogenetic tree objects.
Defines the basic types of data flow nodes.
double log(const ExtendedFloat &ef)