bpp-phyl3 3.0.0
UniformizationSubstitutionCount.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_MAPPING_UNIFORMIZATIONSUBSTITUTIONCOUNT_H
6#define BPP_PHYL_MAPPING_UNIFORMIZATIONSUBSTITUTIONCOUNT_H
7
9
12
13namespace bpp
14{
26{
27private:
28 std::shared_ptr<const SubstitutionModelInterface> model_;
29 size_t nbStates_;
30 std::vector< RowMatrix<double>> bMatrices_;
31 mutable std::vector< RowMatrix<double>> power_;
32 mutable std::vector< std::vector< RowMatrix<double>>> s_;
33 double miu_;
34 mutable std::vector< RowMatrix<double>> counts_;
35 mutable double currentLength_;
36
37public:
39 std::shared_ptr<const SubstitutionModelInterface> model,
40 std::shared_ptr<const SubstitutionRegisterInterface> reg,
41 std::shared_ptr<const AlphabetIndex2> weights = nullptr,
42 std::shared_ptr<const AlphabetIndex2> distances = nullptr);
43
45 const StateMapInterface& stateMap,
46 std::shared_ptr<const SubstitutionRegisterInterface> reg,
47 std::shared_ptr<const AlphabetIndex2> weights = nullptr,
48 std::shared_ptr<const AlphabetIndex2> distances = nullptr);
49
54 model_(usc.model_),
57 power_(usc.power_),
58 s_(usc.s_),
59 miu_(usc.miu_),
60 counts_(usc.counts_),
62 {}
63
65 {
66 AbstractSubstitutionCount::operator=(usc);
69 model_ = usc.model_;
70 nbStates_ = usc.nbStates_;
72 power_ = usc.power_;
73 s_ = usc.s_;
74 miu_ = usc.miu_;
75 counts_ = usc.counts_;
77 return *this;
78 }
79
81
83
84public:
85 double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type = 1) const override;
86
87 std::unique_ptr< Matrix<double>> getAllNumbersOfSubstitutions(double length, size_t type = 1) const override;
88
89 void storeAllNumbersOfSubstitutions(double length, size_t type, Eigen::MatrixXd& mat) const override;
90
91 std::vector<double> getNumberOfSubstitutionsPerType(size_t initialState, size_t finalState, double length) const override;
92
93 void setSubstitutionModel(std::shared_ptr<const SubstitutionModelInterface> model) override;
94
95protected:
96 void computeCounts_(double length) const;
97 void substitutionRegisterHasChanged() override;
98 void weightsHaveChanged() override;
99 void distancesHaveChanged() override;
100
101private:
102 void resetBMatrices_();
103 void initBMatrices_();
104 void fillBMatrices_();
105
107};
108} // end of namespace bpp.
109#endif // BPP_PHYL_MAPPING_UNIFORMIZATIONSUBSTITUTIONCOUNT_H
Partial implementation of the SubstitutionCount interface.
Partial implementation of the SubstitutionDistance interface.
AbstractSubstitutionDistance & operator=(const AbstractSubstitutionDistance &index)
Partial implementation of the WeightedSubstitutionCount interface.
AbstractWeightedSubstitutionCount & operator=(const AbstractWeightedSubstitutionCount &index)
Map the states of a given alphabet which have a model state.
Definition: StateMap.h:25
Analytical (weighted) substitution count using the uniformization method.
double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type=1) const override
Get the number of susbstitutions on a branch, given the initial and final states, and the branch leng...
UniformizationSubstitutionCount & operator=(const UniformizationSubstitutionCount &usc)
std::vector< RowMatrix< double > > bMatrices_
void storeAllNumbersOfSubstitutions(double length, size_t type, Eigen::MatrixXd &mat) const override
Stores the numbers of susbstitutions on a branch, for each initial and final states,...
UniformizationSubstitutionCount(std::shared_ptr< const SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=nullptr, std::shared_ptr< const AlphabetIndex2 > distances=nullptr)
void setSubstitutionModel(std::shared_ptr< const SubstitutionModelInterface > model) override
Set the substitution model associated with this count, if relevant.
std::vector< std::vector< RowMatrix< double > > > s_
std::unique_ptr< Matrix< double > > getAllNumbersOfSubstitutions(double length, size_t type=1) const override
Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branc...
UniformizationSubstitutionCount * clone() const override
UniformizationSubstitutionCount(const UniformizationSubstitutionCount &usc)
std::vector< RowMatrix< double > > counts_
std::vector< double > getNumberOfSubstitutionsPerType(size_t initialState, size_t finalState, double length) const override
Get the numbers of susbstitutions on a branch for all types, for an initial and final states,...
std::shared_ptr< const SubstitutionModelInterface > model_
Defines the basic types of data flow nodes.