bpp-phyl3 3.0.0
HmmPhyloAlphabet.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_HMMPHYLOALPHABET_H
6#define BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_HMMPHYLOALPHABET_H
7
8
9// From Numeric
11
15
16namespace bpp
17{
25 public virtual HmmStateAlphabet,
27{
28private:
30
35 std::vector<std::shared_ptr<AlignedPhyloLikelihoodInterface>> vAP_;
36
37 size_t nbSites_;
38
39public:
42 context_(soap.context()),
43 vAP_(),
44 nbSites_(0)
45 {
46 const std::vector<size_t>& nphyl = soap.getNumbersOfPhyloLikelihoods();
47
48 for (size_t i = 0; i < nphyl.size(); ++i)
49 {
50 auto ap = soap.getAlignedPhyloLikelihood(nphyl[i]);
51 vAP_.push_back(ap);
52 includeParameters_(ap->getParameters());
53 }
54
56 }
57
60 context_(mpsp.context()),
61 vAP_(),
62 nbSites_(0)
63 {
64 auto nb = mpsp.getNumberOfSubstitutionProcess();
66 for (size_t i = 0; i < nb; i++)
67 {
68 // no parameters for each SingleProcessPhyloLikelihood
69 auto spl = make_shared<SingleProcessPhyloLikelihood>(getContext(), mpsp.getLikelihoodCalculationForAProcess(i), pl);
70
71 if (!nbSites_)
72 nbSites_ = spl->getNumberOfSites();
73 else if (nbSites_ != spl->getNumberOfSites())
74 throw BadSizeException("HmmPhyloAlphabet::HmmPhyloAlphabet : different numbers of sites", spl->getNumberOfSites(), nbSites_);
75
76 vAP_.push_back(spl);
77 }
78
80 }
81
82
85 context_(hpa.context_),
86 vAP_(hpa.vAP_),
88 {}
89
90 HmmPhyloAlphabet* clone() const override { return new HmmPhyloAlphabet(*this);}
91
92 virtual ~HmmPhyloAlphabet() {}
93
95
101 const Clonable& getState(size_t stateIndex) const override
102 {
103 return *vAP_[stateIndex];
104 }
105
107 {
108 return *vAP_[stateIndex];
109 }
110
111 std::shared_ptr<const AlignedPhyloLikelihoodInterface> getAlignedPhyloLikelihood(size_t stateIndex) const
112 {
113 return vAP_[stateIndex];
114 }
115
116 size_t getNumberOfStates() const override
117 {
118 return vAP_.size();
119 }
120
121 size_t getNumberOfSites() const
122 {
123 return nbSites_;
124 }
125
134 bool worksWith(const HmmStateAlphabet& stateAlphabet) const override
135 {
136 return &stateAlphabet == this;
137 }
138};
139}
140#endif // BPP_PHYL_LIKELIHOOD_PHYLOLIKELIHOODS_HMMPHYLOALPHABET_H
virtual void includeParameters_(const ParameterList &parameters)
const ParameterList & getParameters() const override
The AlignedPhyloLikelihood interface, for phylogenetic likelihood.
virtual size_t getNumberOfSites() const =0
Get the number of sites in the dataset.
Joint interface SetOf+Aligned PhylLikelihood.
virtual std::shared_ptr< const AlignedPhyloLikelihoodInterface > getAlignedPhyloLikelihood(size_t nPhyl) const =0
Context for dataflow node construction.
Definition: DataFlow.h:527
Hidden states alphabet.
const Clonable & getState(size_t stateIndex) const override
bool worksWith(const HmmStateAlphabet &stateAlphabet) const override
Tell if this instance can work with the instance of alphabet given as input.
const AlignedPhyloLikelihoodInterface & alignedPhyloLikelihood(size_t stateIndex) const
HmmPhyloAlphabet(const HmmPhyloAlphabet &hpa)
size_t getNumberOfSites() const
HmmPhyloAlphabet * clone() const override
HmmPhyloAlphabet(AlignedPhyloLikelihoodSetInterface &soap)
std::shared_ptr< const AlignedPhyloLikelihoodInterface > getAlignedPhyloLikelihood(size_t stateIndex) const
HmmPhyloAlphabet(MultiProcessSequencePhyloLikelihood &mpsp)
std::vector< std::shared_ptr< AlignedPhyloLikelihoodInterface > > vAP_
vector of aligned phylolikelihoods. These phylolikelihoods are not owned by the alphabet.
size_t getNumberOfStates() const override
Partial implementation of the Likelihood interface for multiple processes.
size_t getNumberOfSubstitutionProcess() const
Return the number of process used for computation.
std::shared_ptr< LikelihoodCalculationSingleProcess > getLikelihoodCalculationForAProcess(size_t p)
virtual const std::vector< size_t > & getNumbersOfPhyloLikelihoods() const =0
Defines the basic types of data flow nodes.