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 
17 using namespace std;
18 
19 namespace bpp
20 {
34 {
35 private:
39  std::shared_ptr<MultiProcessSequenceEvolution> mSeqEvol_;
40 
41 protected:
46  mutable std::vector<std::shared_ptr<LikelihoodCalculationSingleProcess>> vLikCal_;
47 
48 public:
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 
56 protected:
59  mSeqEvol_(mpspl.mSeqEvol_),
60  vLikCal_(mpspl.vLikCal_)
61  {}
62 
64  {
65  AbstractParametrizableSequencePhyloLikelihood::operator=(mpspl);
66  mSeqEvol_ = mpspl.mSeqEvol_;
67  vLikCal_ = mpspl.vLikCal_;
68  return *this;
69  }
70 
71 public:
73 
74 public:
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 
94 public:
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 
112  VVdouble getLikelihoodPerSitePerProcess() const;
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 };
148 } // end of namespace bpp.
149 #endif // BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_MULTIPROCESSSEQUENCEPHYLOLIKELIHOOD_H
Partial implementation of the Likelihood interface for multiple processes.
std::vector< std::shared_ptr< LikelihoodCalculationSingleProcess > > vLikCal_
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.
std::shared_ptr< const AlignmentDataInterface > getData() const override
Get the dataset for which the likelihood must be evaluated.
std::shared_ptr< LikelihoodCalculationSingleProcess > getLikelihoodCalculationForAProcess(size_t p)
virtual VVdouble getPosteriorProbabilitiesPerSitePerProcess() const =0
std::shared_ptr< MultiProcessSequenceEvolution > mSeqEvol_
to avoid the dynamic casts
MultiProcessSequencePhyloLikelihood & operator=(const MultiProcessSequencePhyloLikelihood &mpspl)
DataLik getLikelihoodForASiteForAProcess(size_t site, size_t p) const
Get the likelihood for a site for a process.
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to the dataset.
Defines the basic types of data flow nodes.
std::vector< Vdouble > VVdouble