bpp-phyl3 3.0.0
SubstitutionCount.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_SUBSTITUTIONCOUNT_H
6#define BPP_PHYL_MAPPING_SUBSTITUTIONCOUNT_H
7
9
10#include "../Model/SubstitutionModel.h"
13
14// From the STL:
15#include <vector>
16
17namespace bpp
18{
42 public virtual Clonable
43{
44public:
47 virtual SubstitutionCountInterface* clone() const = 0;
48
49public:
53 virtual bool hasSubstitutionRegister() const = 0;
54
58 virtual std::shared_ptr<const SubstitutionRegisterInterface> getSubstitutionRegister() const = 0;
59
64 virtual void setSubstitutionRegister(std::shared_ptr<const SubstitutionRegisterInterface> reg) = 0;
65
71 virtual size_t getNumberOfSubstitutionTypes() const { return getSubstitutionRegister()->getNumberOfSubstitutionTypes(); }
72
78 virtual std::shared_ptr<const Alphabet> getAlphabet() const { return getSubstitutionRegister()->getAlphabet(); }
79
85 virtual size_t getNumberOfStates() const { return getSubstitutionRegister()->getAlphabet()->getSize(); }
86
87
98 virtual double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type) const = 0;
99
107 virtual std::unique_ptr< Matrix<double>> getAllNumbersOfSubstitutions(double length, size_t type) const = 0;
108
119 virtual void storeAllNumbersOfSubstitutions(double length, size_t type, Eigen::MatrixXd& mat) const = 0;
120
129 virtual std::vector<double> getNumberOfSubstitutionsPerType(size_t initialState, size_t finalState, double length) const = 0;
130
136 virtual void setSubstitutionModel(std::shared_ptr<const SubstitutionModelInterface> model) = 0;
137};
138
143 public virtual SubstitutionCountInterface
144{
145protected:
146 std::shared_ptr<const SubstitutionRegisterInterface> register_;
147
148public:
149 AbstractSubstitutionCount(std::shared_ptr<const SubstitutionRegisterInterface> reg) :
150 register_(reg)
151 {}
152
154
155public:
156 bool hasSubstitutionRegister() const { return register_.get() != nullptr; }
157
164 void setSubstitutionRegister(std::shared_ptr<const SubstitutionRegisterInterface> reg)
165 {
166 register_ = reg;
168 }
169
170 std::shared_ptr<const SubstitutionRegisterInterface> getSubstitutionRegister() const { return register_; }
171
172protected:
174};
175} // end of namespace bpp.
176#endif // BPP_PHYL_MAPPING_SUBSTITUTIONCOUNT_H
Partial implementation of the SubstitutionCount interface.
std::shared_ptr< const SubstitutionRegisterInterface > getSubstitutionRegister() const
std::shared_ptr< const SubstitutionRegisterInterface > register_
AbstractSubstitutionCount(std::shared_ptr< const SubstitutionRegisterInterface > reg)
void setSubstitutionRegister(std::shared_ptr< const SubstitutionRegisterInterface > reg)
attribution of a SubstitutionRegister
virtual void substitutionRegisterHasChanged()=0
The SubstitutionsCount interface.
virtual double getNumberOfSubstitutions(size_t initialState, size_t finalState, double length, size_t type) const =0
Get the number of susbstitutions on a branch, given the initial and final states, and the branch leng...
virtual SubstitutionCountInterface * clone() const =0
virtual std::shared_ptr< const Alphabet > getAlphabet() const
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().
virtual bool hasSubstitutionRegister() const =0
virtual std::shared_ptr< const SubstitutionRegisterInterface > getSubstitutionRegister() const =0
virtual size_t getNumberOfSubstitutionTypes() const
Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes().
virtual std::unique_ptr< Matrix< double > > getAllNumbersOfSubstitutions(double length, size_t type) const =0
Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branc...
virtual size_t getNumberOfStates() const
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().
virtual std::vector< double > getNumberOfSubstitutionsPerType(size_t initialState, size_t finalState, double length) const =0
Get the numbers of susbstitutions on a branch for all types, for an initial and final states,...
virtual void setSubstitutionModel(std::shared_ptr< const SubstitutionModelInterface > model)=0
Set the substitution model associated with this count, if relevant.
virtual void setSubstitutionRegister(std::shared_ptr< const SubstitutionRegisterInterface > reg)=0
virtual void storeAllNumbersOfSubstitutions(double length, size_t type, Eigen::MatrixXd &mat) const =0
Stores the numbers of susbstitutions on a branch, for each initial and final states,...
Defines the basic types of data flow nodes.