bpp-phyl3  3.0.0
PartitionProcessPhyloLikelihood.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_PARTITIONPROCESSPHYLOLIKELIHOOD_H
6 #define BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_PARTITIONPROCESSPHYLOLIKELIHOOD_H
7 
8 
9 #include "../PartitionSequenceEvolution.h"
13 
14 // From bpp-seq:
16 
17 namespace bpp
18 {
26 struct ProcPos
27 {
28  size_t nProc;
29  size_t pos;
30 };
31 
32 
36 {
37 private:
41  std::shared_ptr<PartitionSequenceEvolution> mSeqEvol_;
42 
47  std::vector<ProcPos> vProcPos_;
48 
52  std::map<size_t, std::shared_ptr<AlignmentDataInterface>> mData_;
53 
57  mutable std::shared_ptr<AlignedLikelihoodCalculation> likCal_;
58 
59 public:
62  std::shared_ptr<PartitionSequenceEvolution> processSeqEvol,
63  size_t nSeqEvol = 0);
64 
67  std::shared_ptr<const AlignmentDataInterface> data,
68  std::shared_ptr<PartitionSequenceEvolution> processSeqEvol,
69  size_t nSeqEvol = 0,
70  size_t nData = 0);
71 
73  std::shared_ptr<const AlignmentDataInterface> data,
74  std::shared_ptr<PartitionSequenceEvolution> processSeqEvol,
75  std::shared_ptr<CollectionNodes> collNodes,
76  size_t nSeqEvol = 0,
77  size_t nData = 0);
78 
79 protected:
87  mSeqEvol_(lik.mSeqEvol_),
88  vProcPos_(lik.vProcPos_),
89  mData_(lik.mData_),
90  likCal_(lik.likCal_)
91  {}
92 
94  {
97  mSeqEvol_ = lik.mSeqEvol_;
98  vProcPos_ = lik.vProcPos_;
99  mData_ = lik.mData_;
100  likCal_ = lik.likCal_;
101  return *this;
102  }
103 
105 
106 public:
108 
116  void setData(std::shared_ptr<const AlignmentDataInterface> data, size_t nData = 0) override;
117 
118  /*
119  * @brief Get PhyloLikelihood Number for a given site.
120  * @param siteIndex the index of the site
121  *
122  */
123  std::shared_ptr<const SingleProcessPhyloLikelihood> getPhyloLikelihoodForASite(size_t siteIndex) const
124  {
125  return dynamic_pointer_cast<const SingleProcessPhyloLikelihood>(getPhyloLikelihood(vProcPos_[siteIndex].nProc));
126  }
127 
128  /*
129  * @brief Get LikelihoodCaluclationSingleProcess for a given site.
130  * @param siteIndex the index of the site
131  *
132  */
133  std::shared_ptr<LikelihoodCalculationSingleProcess> getLikelihoodCalculationForASite(size_t siteIndex) const
134  {
135  return dynamic_pointer_cast<const SingleProcessPhyloLikelihood>(getPhyloLikelihood(vProcPos_[siteIndex].nProc))->getLikelihoodCalculationSingleProcess();
136  }
137 
143  std::shared_ptr<const AlignmentDataInterface> getData() const override
144  {
146  }
147 
148  const std::vector<ProcPos>& getProcessSiteRelations() const
149  {
150  return vProcPos_;
151  }
152 
154  {
155  return *likCal_;
156  }
157 
158  std::shared_ptr<LikelihoodCalculation> getLikelihoodCalculation() const override
159  {
160  return likCal_;
161  }
162 
164  {
165  return *likCal_;
166  }
167 
168  std::shared_ptr<AlignedLikelihoodCalculation> getAlignedLikelihoodCalculation() const override
169  {
170  return likCal_;
171  }
172 
173  size_t getNumberOfSites() const override
174  {
175  return mSeqEvol_->getNumberOfSites();
176  }
177 
178  std::shared_ptr<PartitionSequenceEvolution> getPartitionSequenceEvolution() const
179  {
180  return mSeqEvol_;
181  }
182 
183 private:
184  void makeLikCal_();
185 };
186 } // end of namespace bpp.
187 #endif // BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_PARTITIONPROCESSPHYLOLIKELIHOOD_H
The PhyloLikelihoodSet class, to manage a subset of PhyloLikelihoods from a given PhyloLikelihoodCont...
std::shared_ptr< const PhyloLikelihoodInterface > getPhyloLikelihood(size_t nPhyl) const override
std::shared_ptr< PhyloLikelihoodContainer > getPhyloContainer() override
const std::vector< size_t > & getNumbersOfPhyloLikelihoods() const override
AbstractPhyloLikelihoodSet & operator=(const AbstractPhyloLikelihoodSet &sd)
const Context & context() const override
AbstractSequencePhyloLikelihood & operator=(const AbstractSequencePhyloLikelihood &aspl)
Context for dataflow node construction.
Definition: DataFlow.h:527
std::shared_ptr< const AlignmentDataInterface > getData() const override
Get the dataset for which the likelihood must be evaluated.
std::shared_ptr< const SingleProcessPhyloLikelihood > getPhyloLikelihoodForASite(size_t siteIndex) const
PartitionProcessPhyloLikelihood(Context &context, std::shared_ptr< PartitionSequenceEvolution > processSeqEvol, size_t nSeqEvol=0)
const std::vector< ProcPos > & getProcessSiteRelations() const
std::shared_ptr< LikelihoodCalculationSingleProcess > getLikelihoodCalculationForASite(size_t siteIndex) const
PartitionProcessPhyloLikelihood & operator=(const PartitionProcessPhyloLikelihood &lik)
PartitionProcessPhyloLikelihood * clone() const override
std::shared_ptr< AlignedLikelihoodCalculation > likCal_
void setData(std::shared_ptr< const AlignmentDataInterface > data, size_t nData=0) override
Set the dataset for which the likelihood must be evaluated.
size_t getNumberOfSites() const override
Get the number of sites in the dataset.
std::shared_ptr< LikelihoodCalculation > getLikelihoodCalculation() const override
std::map< size_t, std::shared_ptr< AlignmentDataInterface > > mData_
AlignedLikelihoodCalculation & alignedLikelihoodCalculation() const override
LikelihoodCalculation & likelihoodCalculation() const override
std::shared_ptr< PartitionSequenceEvolution > mSeqEvol_
to avoid the dynamic casts
PartitionProcessPhyloLikelihood(const PartitionProcessPhyloLikelihood &lik)
std::shared_ptr< AlignedLikelihoodCalculation > getAlignedLikelihoodCalculation() const override
std::shared_ptr< PartitionSequenceEvolution > getPartitionSequenceEvolution() const
Defines the basic types of data flow nodes.
Likelihood framework based on a partition of a sequence in simple likelihoods.