bpp-phyl3  3.0.0
bpp::NaiveSubstitutionCount Class Reference

Naive substitution count. More...

#include <Bpp/Phyl/Mapping/NaiveSubstitutionCount.h>

+ Inheritance diagram for bpp::NaiveSubstitutionCount:
+ Collaboration diagram for bpp::NaiveSubstitutionCount:

Public Member Functions

 NaiveSubstitutionCount (std::shared_ptr< const SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, bool allowSelf=false, std::shared_ptr< const AlphabetIndex2 > weights=nullptr)
 Build a new simple substitution count. More...
 
 NaiveSubstitutionCount (std::shared_ptr< const StateMapInterface > stateMap, std::shared_ptr< const SubstitutionRegisterInterface > reg, bool allowSelf=false, std::shared_ptr< const AlphabetIndex2 > weights=nullptr)
 
virtual ~NaiveSubstitutionCount ()
 
NaiveSubstitutionCountclone () const override
 
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 length. More...
 
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 branch length. More...
 
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, and given the branch length. More...
 
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, given the branch length. More...
 
void setSubstitutionModel (std::shared_ptr< const SubstitutionModelInterface > model) override
 Set the substitution model associated with this count, if relevant. More...
 
bool hasSubstitutionRegister () const
 
void setSubstitutionRegister (std::shared_ptr< const SubstitutionRegisterInterface > reg)
 attribution of a SubstitutionRegister More...
 
std::shared_ptr< const SubstitutionRegisterInterfacegetSubstitutionRegister () const
 
virtual size_t getNumberOfSubstitutionTypes () const
 Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes(). More...
 
virtual std::shared_ptr< const AlphabetgetAlphabet () const
 Short cut function, equivalent to getSubstitutionRegister()->getAlphabet(). More...
 
virtual size_t getNumberOfStates () const
 Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize(). More...
 
void setWeights (std::shared_ptr< const AlphabetIndex2 > weights)
 
bool hasWeights () const
 
std::shared_ptr< const AlphabetIndex2getWeights () const
 

Protected Attributes

std::shared_ptr< const SubstitutionRegisterInterfaceregister_
 
std::shared_ptr< const AlphabetIndex2weights_
 

Private Member Functions

void substitutionRegisterHasChanged () override
 
void weightsHaveChanged () override
 

Private Attributes

bool allowSelf_
 
std::vector< int > supportedChars_
 

Detailed Description

Naive substitution count.

This substitution count is defined as follow:

  • 0 if $i = j$,
  • 1 if $i \neq j $.

Reference (for instance): Tufféry P, Darlu P. Exploring a phylogenetic approach for the detection of correlated substitutions in proteins. Mol Biol Evol. 2000 Nov;17(11):1753-9

Author
Julien Dutheil

Definition at line 28 of file NaiveSubstitutionCount.h.

Constructor & Destructor Documentation

◆ NaiveSubstitutionCount() [1/2]

bpp::NaiveSubstitutionCount::NaiveSubstitutionCount ( std::shared_ptr< const SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
bool  allowSelf = false,
std::shared_ptr< const AlphabetIndex2 weights = nullptr 
)
inline

Build a new simple substitution count.

Parameters
modelThe substitution model for which this substitution count is parametrized. The model is not used in the calculation, only for specifying the modeled states.
regA pointer toward a substitution register object which describes the type of substitutions to map.
allowSelfTells if "self" mutations, from X to X should be counted together with the ones of type X to Y where X and Y are in the same category, if relevant. The default is "no", to be consistent with other types of substitution counts which account for multiple substitutions, in which case it does not make sense to count "X to X".
weightsthe weights of the counts

Definition at line 47 of file NaiveSubstitutionCount.h.

Referenced by clone().

◆ NaiveSubstitutionCount() [2/2]

bpp::NaiveSubstitutionCount::NaiveSubstitutionCount ( std::shared_ptr< const StateMapInterface stateMap,
std::shared_ptr< const SubstitutionRegisterInterface reg,
bool  allowSelf = false,
std::shared_ptr< const AlphabetIndex2 weights = nullptr 
)
inline

Definition at line 57 of file NaiveSubstitutionCount.h.

◆ ~NaiveSubstitutionCount()

virtual bpp::NaiveSubstitutionCount::~NaiveSubstitutionCount ( )
inlinevirtual

Definition at line 67 of file NaiveSubstitutionCount.h.

Member Function Documentation

◆ clone()

NaiveSubstitutionCount* bpp::NaiveSubstitutionCount::clone ( ) const
inlineoverridevirtual

Implements bpp::SubstitutionCountInterface.

Definition at line 69 of file NaiveSubstitutionCount.h.

References NaiveSubstitutionCount().

◆ getAllNumbersOfSubstitutions()

unique_ptr< Matrix< double > > NaiveSubstitutionCount::getAllNumbersOfSubstitutions ( double  length,
size_t  type = 1 
) const
overridevirtual

Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.

Parameters
lengthThe length of the branch.
typeThe type of susbstitution to count.
Returns
A matrix with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 10 of file NaiveSubstitutionCount.cpp.

◆ getAlphabet()

virtual std::shared_ptr<const Alphabet> bpp::SubstitutionCountInterface::getAlphabet ( ) const
inlinevirtualinherited

Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().

Returns
The alphabet associated to this substitution count.

Definition at line 78 of file SubstitutionCount.h.

References bpp::SubstitutionCountInterface::getSubstitutionRegister().

◆ getNumberOfStates()

virtual size_t bpp::SubstitutionCountInterface::getNumberOfStates ( ) const
inlinevirtualinherited

Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().

Returns
The number of states in the model/alphabet.

Definition at line 85 of file SubstitutionCount.h.

References bpp::SubstitutionCountInterface::getSubstitutionRegister().

◆ getNumberOfSubstitutions()

double bpp::NaiveSubstitutionCount::getNumberOfSubstitutions ( size_t  initialState,
size_t  finalState,
double  length,
size_t  type = 1 
) const
inlineoverridevirtual

Get the number of susbstitutions on a branch, given the initial and final states, and the branch length.

Parameters
initialStateThe initial state.
finalStateThe final state.
lengthThe length of the branch.
typeThe type of substitution to count.
Returns
The number of substitutions on a branch of specified length and according to initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 75 of file NaiveSubstitutionCount.h.

References allowSelf_, bpp::AbstractSubstitutionCount::register_, supportedChars_, and bpp::AbstractWeightedSubstitutionCount::weights_.

Referenced by getNumberOfSubstitutionsPerType().

◆ getNumberOfSubstitutionsPerType()

std::vector<double> bpp::NaiveSubstitutionCount::getNumberOfSubstitutionsPerType ( size_t  initialState,
size_t  finalState,
double  length 
) const
inlineoverridevirtual

Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length.

Parameters
initialStateThe initial state.
finalStateThe final state.
lengthThe length of the branch.
Returns
A matrix with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 91 of file NaiveSubstitutionCount.h.

References getNumberOfSubstitutions(), and bpp::SubstitutionCountInterface::getNumberOfSubstitutionTypes().

◆ getNumberOfSubstitutionTypes()

virtual size_t bpp::SubstitutionCountInterface::getNumberOfSubstitutionTypes ( ) const
inlinevirtualinherited

◆ getSubstitutionRegister()

std::shared_ptr<const SubstitutionRegisterInterface> bpp::AbstractSubstitutionCount::getSubstitutionRegister ( ) const
inlinevirtualinherited
Returns
The SubstitutionRegister object associated to this instance. The register contains the description of the various substitutions types that are mapped.

Implements bpp::SubstitutionCountInterface.

Definition at line 170 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ getWeights()

std::shared_ptr<const AlphabetIndex2> bpp::AbstractWeightedSubstitutionCount::getWeights ( ) const
inlinevirtualinherited

◆ hasSubstitutionRegister()

bool bpp::AbstractSubstitutionCount::hasSubstitutionRegister ( ) const
inlinevirtualinherited
Returns
Tell if a substitution register has been attached to this class.

Implements bpp::SubstitutionCountInterface.

Definition at line 156 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ hasWeights()

bool bpp::AbstractWeightedSubstitutionCount::hasWeights ( ) const
inlinevirtualinherited

◆ setSubstitutionModel()

void bpp::NaiveSubstitutionCount::setSubstitutionModel ( std::shared_ptr< const SubstitutionModelInterface model)
inlineoverridevirtual

Set the substitution model associated with this count, if relevant.

Parameters
modelThe substitution model to use with this count.

Implements bpp::SubstitutionCountInterface.

Definition at line 101 of file NaiveSubstitutionCount.h.

References supportedChars_.

◆ setSubstitutionRegister()

void bpp::AbstractSubstitutionCount::setSubstitutionRegister ( std::shared_ptr< const SubstitutionRegisterInterface reg)
inlinevirtualinherited

attribution of a SubstitutionRegister

Parameters
regpointer to a SubstitutionRegister

Implements bpp::SubstitutionCountInterface.

Definition at line 164 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_, and bpp::AbstractSubstitutionCount::substitutionRegisterHasChanged().

◆ setWeights()

void AbstractWeightedSubstitutionCount::setWeights ( std::shared_ptr< const AlphabetIndex2 weights)
virtualinherited

◆ storeAllNumbersOfSubstitutions()

void NaiveSubstitutionCount::storeAllNumbersOfSubstitutions ( double  length,
size_t  type,
Eigen::MatrixXd &  mat 
) const
overridevirtual

Stores the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.

Parameters
lengthThe length of the branch.
typeThe type of susbstitution to count.
matThe matrix filled with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 24 of file NaiveSubstitutionCount.cpp.

◆ substitutionRegisterHasChanged()

void bpp::NaiveSubstitutionCount::substitutionRegisterHasChanged ( )
inlineoverrideprivatevirtual

Implements bpp::AbstractSubstitutionCount.

Definition at line 108 of file NaiveSubstitutionCount.h.

◆ weightsHaveChanged()

void bpp::NaiveSubstitutionCount::weightsHaveChanged ( )
inlineoverrideprivatevirtual

Implements bpp::AbstractWeightedSubstitutionCount.

Definition at line 109 of file NaiveSubstitutionCount.h.

Member Data Documentation

◆ allowSelf_

bool bpp::NaiveSubstitutionCount::allowSelf_
private

Definition at line 33 of file NaiveSubstitutionCount.h.

Referenced by getNumberOfSubstitutions().

◆ register_

◆ supportedChars_

std::vector<int> bpp::NaiveSubstitutionCount::supportedChars_
private

Definition at line 34 of file NaiveSubstitutionCount.h.

Referenced by getNumberOfSubstitutions(), and setSubstitutionModel().

◆ weights_


The documentation for this class was generated from the following files: