bpp-phyl3  3.0.0
PhyloLikelihoodSet.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_SETOFPHYLOLIKELIHOOD_H
6 #define BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_SETOFPHYLOLIKELIHOOD_H
7 
8 
10 #include "PhyloLikelihood.h"
12 
13 namespace bpp
14 {
21  public virtual PhyloLikelihoodInterface
22 {
23 public:
24  virtual PhyloLikelihoodSetInterface* clone() const = 0;
25 
26 public:
27  virtual std::shared_ptr<PhyloLikelihoodContainer> getPhyloContainer() = 0;
28 
29  virtual std::shared_ptr<const PhyloLikelihoodContainer> getPhyloContainer() const = 0;
30 
31  virtual const std::vector<size_t>& getNumbersOfPhyloLikelihoods() const = 0;
32 
44  virtual bool addPhyloLikelihood(size_t nPhyl, const std::string& suff = "") = 0;
45 
52  virtual bool hasPhyloLikelihood(size_t nPhyl) = 0;
53 
54  virtual std::shared_ptr<const PhyloLikelihoodInterface> getPhyloLikelihood(size_t nPhyl) const = 0;
55 
56  virtual std::shared_ptr<PhyloLikelihoodInterface> getPhyloLikelihood(size_t nPhyl) = 0;
57 };
58 
59 
66  public virtual PhyloLikelihoodSetInterface,
67  public virtual AbstractPhyloLikelihood,
68  public virtual AbstractParametrizable
69 {
70 protected:
74  std::shared_ptr<PhyloLikelihoodContainer> pPhyloCont_;
75 
79  std::vector<size_t> nPhylo_;
80 
85  mutable std::vector<std::shared_ptr<LikelihoodCalculation>> vLikCal_;
86 
87 public:
96  std::shared_ptr<PhyloLikelihoodContainer> pC,
97  bool inCollection = true,
98  const std::string& prefix = "");
99 
101  Context& context,
102  std::shared_ptr<PhyloLikelihoodContainer> pC,
103  const std::vector<size_t>& nPhylo,
104  bool inCollection = true,
105  const std::string& prefix = "");
106 
108 
109 protected:
114  nPhylo_(sd.nPhylo_),
115  vLikCal_(sd.vLikCal_)
116  {}
117 
119  {
121  AbstractParametrizable::operator=(sd);
123  nPhylo_ = sd.nPhylo_;
124  vLikCal_ = sd.vLikCal_;
125  return *this;
126  }
127 
128 public:
129  std::shared_ptr<PhyloLikelihoodContainer> getPhyloContainer() override
130  {
131  return pPhyloCont_;
132  }
133 
134  std::shared_ptr<const PhyloLikelihoodContainer> getPhyloContainer() const override
135  {
136  return pPhyloCont_;
137  }
138 
139  const std::vector<size_t>& getNumbersOfPhyloLikelihoods() const override
140  {
141  return nPhylo_;
142  }
143 
156  virtual bool addPhyloLikelihood(size_t nPhyl, const std::string& suff = "") override;
157 
164  bool hasPhyloLikelihood(size_t nPhyl) override
165  {
166  return std::find(nPhylo_.begin(), nPhylo_.end(), nPhyl) != nPhylo_.end();
167  }
168 
169  std::shared_ptr<const PhyloLikelihoodInterface> getPhyloLikelihood(size_t nPhyl) const override
170  {
171  return (*pPhyloCont_)[nPhyl];
172  }
173 
174 
175  std::shared_ptr<PhyloLikelihoodInterface> getPhyloLikelihood(size_t nPhyl) override
176  {
177  return (*pPhyloCont_)[nPhyl];
178  }
179 
197  bool isInitialized() const override
198  {
199  for (auto nPhylo: nPhylo_)
200  {
201  if (!getPhyloLikelihood(nPhylo)->isInitialized())
202  return false;
203  }
204  return true;
205  }
206 
207 public:
208  virtual void fireParameterChanged(const ParameterList& params) override
209  {
210  for (auto nPhylo: nPhylo_)
211  {
212  getPhyloLikelihood(nPhylo)->matchParametersValues(params);
213 
214  // to ensure each phylolikelihood is recomputed, such as in
215  // case of total aliasing
216  // getAbstractPhyloLikelihood(nPhylo_[i])->update();
217  }
218  }
219 
227  ParameterList getNonDerivableParameters() const override;
228 
229  ParameterList getDerivableParameters() const override;
230 
236  ParameterList getBranchLengthParameters() const override;
237 
244 
252 
260 
262 };
263 } // end of namespace bpp.
264 #endif // BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_SETOFPHYLOLIKELIHOOD_H
The PhyloLikelihoodSet class, to manage a subset of PhyloLikelihoods from a given PhyloLikelihoodCont...
std::shared_ptr< PhyloLikelihoodContainer > pPhyloCont_
pointer to a PhyloLikelihoodContainer
ParameterList getRootFrequenciesParameters() const override
Get the parameters associated to the root frequencies(s).
std::shared_ptr< PhyloLikelihoodInterface > getPhyloLikelihood(size_t nPhyl) override
virtual void fireParameterChanged(const ParameterList &params) override
ParameterList getSubstitutionModelParameters() const override
Get the parameters associated to substitution model(s).
std::vector< size_t > nPhylo_
vector of AbstractPhyloLikelihood numbers
bool hasPhyloLikelihood(size_t nPhyl) override
ParameterList getRateDistributionParameters() const override
Get the parameters associated to the rate distribution(s).
ParameterList getDerivableParameters() const override
ParameterList getNonDerivableParameters() const override
ParameterList getBranchLengthParameters() const override
Get the branch lengths parameters.
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(Context &context, std::shared_ptr< PhyloLikelihoodContainer > pC, bool inCollection=true, const std::string &prefix="")
AbstractPhyloLikelihoodSet & operator=(const AbstractPhyloLikelihoodSet &sd)
bool isInitialized() const override
std::vector< std::shared_ptr< LikelihoodCalculation > > vLikCal_
AbstractPhyloLikelihoodSet(const AbstractPhyloLikelihoodSet &sd)
virtual bool addPhyloLikelihood(size_t nPhyl, const std::string &suff="") override
adds a PhyloLikelihood already stored in the PhyloLikelihoodContainer, iff it is an AbstractPhyloLike...
std::shared_ptr< const PhyloLikelihoodContainer > getPhyloContainer() const override
const Context & context() const override
AbstractPhyloLikelihood & operator=(const AbstractPhyloLikelihood &apl)
Context for dataflow node construction.
Definition: DataFlow.h:527
The PhyloLikelihood interface, for phylogenetic likelihood.
The PhyloLikelihoodSet interface, to manage a subset of PhyloLikelihoods from a given PhyloLikelihood...
virtual const std::vector< size_t > & getNumbersOfPhyloLikelihoods() const =0
virtual std::shared_ptr< PhyloLikelihoodInterface > getPhyloLikelihood(size_t nPhyl)=0
virtual PhyloLikelihoodSetInterface * clone() const =0
virtual bool hasPhyloLikelihood(size_t nPhyl)=0
virtual std::shared_ptr< const PhyloLikelihoodContainer > getPhyloContainer() const =0
virtual bool addPhyloLikelihood(size_t nPhyl, const std::string &suff="")=0
adds a PhyloLikelihood already stored in the PhyloLikelihoodContainer, iff it is an AbstractPhyloLike...
virtual std::shared_ptr< PhyloLikelihoodContainer > getPhyloContainer()=0
virtual std::shared_ptr< const PhyloLikelihoodInterface > getPhyloLikelihood(size_t nPhyl) const =0
Defines the basic types of data flow nodes.