bpp-phyl3  3.0.0
SequencePhyloLikelihood.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_SEQUENCEPHYLOLIKELIHOOD_H
6 #define BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_SEQUENCEPHYLOLIKELIHOOD_H
7 
8 
9 // From bpp-seq:
12 
13 #include "PhyloLikelihood.h"
16 #include "../SequenceEvolution.h"
17 
18 namespace bpp
19 {
31 {
32 protected:
34 
35  SequencePhyloLikelihoodInterface* clone() const override = 0;
36 
37 public:
42  virtual const SequenceEvolution& sequenceEvolution() const = 0;
43 
44  virtual std::shared_ptr<const SequenceEvolution> getSequenceEvolution() const = 0;
45 
46  virtual const size_t getSequenceEvolutionNumber() const = 0;
47 };
48 
50  public virtual SequencePhyloLikelihoodInterface,
52 {
53 protected:
57  std::shared_ptr<SequenceEvolution> seqEvol_;
58 
62  size_t nSeqEvol_;
63 
64 public:
67  std::shared_ptr<SequenceEvolution> se,
68  size_t nSE = 0,
69  size_t nData = 0) :
72  context, 0,
73  (se->getSubstitutionProcessNumbers().size() != 0) ? se->substitutionProcess(se->getSubstitutionProcessNumbers()[0]).getNumberOfStates() : 0, nData),
74  seqEvol_(se),
75  nSeqEvol_(nSE)
76  {}
77 
80  seqEvol_(aspl.seqEvol_),
81  nSeqEvol_(aspl.nSeqEvol_)
82  {}
83 
85  {
87  seqEvol_ = aspl.seqEvol_;
88  nSeqEvol_ = aspl.nSeqEvol_;
89  return *this;
90  }
91 
92 public:
97  const SequenceEvolution& sequenceEvolution() const override
98  {
99  return *seqEvol_;
100  }
101 
102  std::shared_ptr<const SequenceEvolution> getSequenceEvolution() const override
103  {
104  return seqEvol_;
105  }
106 
107  const size_t getSequenceEvolutionNumber() const override
108  {
109  return nSeqEvol_;
110  }
111 
116  std::shared_ptr<const Alphabet> getAlphabet() const override
117  {
118  if (seqEvol_->getSubstitutionProcessNumbers().size() == 0)
119  return NULL;
120  else
121  return seqEvol_->substitutionProcess(seqEvol_->getSubstitutionProcessNumbers()[0]).getModel(0, 0)->getAlphabet();
122  }
123 };
124 
125 
127  public virtual AbstractSequencePhyloLikelihood,
128  public virtual AbstractParametrizable
129 {
130 public:
132  Context& context,
133  std::shared_ptr<SequenceEvolution> se,
134  size_t nSE = 0,
135  size_t nData = 0) :
137  AbstractSequencePhyloLikelihood(context, se, nSE, nData),
139  {
140  // initialize INDEPENDENT parameters:
141  addParameters_(se->getIndependentParameters());
142  }
143 
147  {}
148 
150  {
152  AbstractParametrizable::operator=(apspl);
153  return *this;
154  }
155 
156 protected:
157  virtual void fireParameterChanged(const ParameterList& parameters) override
158  {
159  seqEvol_->matchParametersValues(parameters);
160  }
161 
162 public:
163  void setData(std::shared_ptr<const AlignmentDataInterface> sites, size_t nData = 0) override
164  {
166  }
167 
168  void setNamespace(const std::string& nameSpace) override
169  {
170  seqEvol_->setNamespace(nameSpace);
171  }
172 
173 
175  {
176  return seqEvol_->getNonDerivableParameters();
177  }
178 
180  {
181  return seqEvol_->getBranchLengthParameters(true);
182  }
183 
185  {
186  return seqEvol_->getBranchLengthParameters(true);
187  }
188 
190  {
191  return seqEvol_->getRootFrequenciesParameters(true);
192  }
193 
195  {
196  return seqEvol_->getRateDistributionParameters(true);
197  }
198 
200  {
201  return seqEvol_->getSubstitutionModelParameters(true);
202  }
203 
205  {
206  return seqEvol_->getSubstitutionProcessParameters(true);
207  }
208 };
209 } // end of namespace bpp.
210 #endif // BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_SEQUENCEPHYLOLIKELIHOOD_H
ParameterList getRootFrequenciesParameters() const override
Get the independent parameters associated to the root frequencies(s).
virtual void fireParameterChanged(const ParameterList &parameters) override
AbstractParametrizableSequencePhyloLikelihood(Context &context, std::shared_ptr< SequenceEvolution > se, size_t nSE=0, size_t nData=0)
void setData(std::shared_ptr< const AlignmentDataInterface > sites, size_t nData=0) override
Set the dataset for which the likelihood must be evaluated.
ParameterList getBranchLengthParameters() const override
Get the independent branch lengths parameters.
void setNamespace(const std::string &nameSpace) override
AbstractParametrizableSequencePhyloLikelihood(const AbstractParametrizableSequencePhyloLikelihood &apspl)
ParameterList getSubstitutionModelParameters() const override
Get the independent parameters associated to substitution model(s).
ParameterList getRateDistributionParameters() const override
Get the independent parameters associated to the rate distribution(s).
AbstractParametrizableSequencePhyloLikelihood & operator=(const AbstractParametrizableSequencePhyloLikelihood &apspl)
virtual void addParameters_(const ParameterList &parameters)
const Context & context() const override
size_t nSeqEvol_
the Sequence Evolution number
AbstractSequencePhyloLikelihood & operator=(const AbstractSequencePhyloLikelihood &aspl)
AbstractSequencePhyloLikelihood(const AbstractSequencePhyloLikelihood &aspl)
std::shared_ptr< const Alphabet > getAlphabet() const override
Get the alphabet associated to the dataset.
const SequenceEvolution & sequenceEvolution() const override
The Sequence Evolution.
AbstractSequencePhyloLikelihood(Context &context, std::shared_ptr< SequenceEvolution > se, size_t nSE=0, size_t nData=0)
const size_t getSequenceEvolutionNumber() const override
std::shared_ptr< const SequenceEvolution > getSequenceEvolution() const override
std::shared_ptr< SequenceEvolution > seqEvol_
the Sequence Evolution
AbstractSingleDataPhyloLikelihood & operator=(const AbstractSingleDataPhyloLikelihood &asdpl)
virtual void setData(std::shared_ptr< const AlignmentDataInterface > sites, size_t nData=0)
Set the dataset for which the likelihood must be evaluated.
size_t getNumberOfStates() const
Get the number the states.
Context for dataflow node construction.
Definition: DataFlow.h:527
This interface describes the evolution process of a sequence.
PhyloLikelihoods based on Sequence Evolution class, ie for which there is a (set of) processes able t...
virtual const size_t getSequenceEvolutionNumber() const =0
virtual const SequenceEvolution & sequenceEvolution() const =0
The Sequence Evolution.
SequencePhyloLikelihoodInterface * clone() const override=0
virtual std::shared_ptr< const SequenceEvolution > getSequenceEvolution() const =0
The SingleDataPhyloLikelihood interface, for phylogenetic likelihood.
Defines the basic types of data flow nodes.