bpp-phyl3 3.0.0
MultiProcessSequencePhyloLikelihood.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_LIKELIHOOD_PHYLOLIKELIHOODS_MULTIPROCESSSEQUENCEPHYLOLIKELIHOOD_H
6#define BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_MULTIPROCESSSEQUENCEPHYLOLIKELIHOOD_H
7
9
10#include "../DataFlow/LikelihoodCalculationSingleProcess.h"
11#include "../MultiProcessSequenceEvolution.h"
13
14// From bpp-seq:
16
17using namespace std;
18
19namespace bpp
20{
34{
35private:
39 std::shared_ptr<MultiProcessSequenceEvolution> mSeqEvol_;
40
41protected:
46 mutable std::vector<std::shared_ptr<LikelihoodCalculationSingleProcess>> vLikCal_;
47
48public:
50 std::shared_ptr<const AlignmentDataInterface> data,
51 std::shared_ptr<MultiProcessSequenceEvolution> processSeqEvol,
52 std::shared_ptr<CollectionNodes> collNodes,
53 size_t nSeqEvol = 0,
54 size_t nData = 0);
55
56protected:
59 mSeqEvol_(mpspl.mSeqEvol_),
60 vLikCal_(mpspl.vLikCal_)
61 {}
62
64 {
66 mSeqEvol_ = mpspl.mSeqEvol_;
67 vLikCal_ = mpspl.vLikCal_;
68 return *this;
69 }
70
71public:
73
74public:
80 std::shared_ptr<const AlignmentDataInterface> getData() const override
81 {
82 return vLikCal_[0]->getData();
83 }
84
85 std::shared_ptr<const Alphabet> getAlphabet() const override
86 {
87 return vLikCal_[0]->stateMap().getAlphabet();
88 }
89
94public:
95 std::shared_ptr<LikelihoodCalculationSingleProcess> getLikelihoodCalculationForAProcess(size_t p)
96 {
97 return vLikCal_[p];
98 }
99
107 DataLik getLikelihoodForASiteForAProcess(size_t site, size_t p) const
108 {
109 return vLikCal_[p]->getLikelihoodForASite(site);
110 }
111
113
114 /*
115 *@brief return the posterior probabilities of subprocess on each site.
116 *
117 *@return 2D-vector sites x states
118 */
119
121
122 bool isInitialized() const override
123 {
124 for (auto& lik : vLikCal_)
125 {
126 if (!lik->isInitialized())
127 return false;
128 }
129
130 return true;
131 }
132
140 void setData(std::shared_ptr<const AlignmentDataInterface> sites, size_t nData = 0) override;
141
145 size_t getNumberOfSubstitutionProcess() const { return vLikCal_.size(); }
146};
147} // end of namespace bpp.
148#endif // BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_MULTIPROCESSSEQUENCEPHYLOLIKELIHOOD_H
AbstractParametrizableSequencePhyloLikelihood & operator=(const AbstractParametrizableSequencePhyloLikelihood &apspl)
Partial implementation of the Likelihood interface for multiple processes.
std::vector< std::shared_ptr< LikelihoodCalculationSingleProcess > > vLikCal_
std::shared_ptr< const AlignmentDataInterface > getData() const override
Get the dataset for which the likelihood must be evaluated.
MultiProcessSequencePhyloLikelihood(const MultiProcessSequencePhyloLikelihood &mpspl)
size_t getNumberOfSubstitutionProcess() const
Return the number of process used for computation.
bool isInitialized() const override
Sets the computeLikelihoods_ to true.
void setData(std::shared_ptr< const AlignmentDataInterface > sites, size_t nData=0) override
Set the dataset for which the likelihood must be evaluated.
virtual VVdouble getPosteriorProbabilitiesPerSitePerProcess() const =0
std::shared_ptr< MultiProcessSequenceEvolution > mSeqEvol_
to avoid the dynamic casts
MultiProcessSequencePhyloLikelihood & operator=(const MultiProcessSequencePhyloLikelihood &mpspl)
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to the dataset.
std::shared_ptr< LikelihoodCalculationSingleProcess > getLikelihoodCalculationForAProcess(size_t p)
DataLik getLikelihoodForASiteForAProcess(size_t site, size_t p) const
Get the likelihood for a site for a process.
MultiProcessSequencePhyloLikelihood(std::shared_ptr< const AlignmentDataInterface > data, std::shared_ptr< MultiProcessSequenceEvolution > processSeqEvol, std::shared_ptr< CollectionNodes > collNodes, size_t nSeqEvol=0, size_t nData=0)
Defines the basic types of data flow nodes.
std::vector< Vdouble > VVdouble