bpp-phyl  2.2.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 (const SubstitutionModel *model, SubstitutionRegister *reg, bool allowSelf=false, const AlphabetIndex2 *weights=0)
 Build a new simple substitution count. More...
 
virtual ~NaiveSubstitutionCount ()
 
NaiveSubstitutionCountclone () const
 
double getNumberOfSubstitutions (size_t initialState, size_t finalState, double length, size_t type=1) const
 Get the number of susbstitutions on a branch, given the initial and final states, and the branch length. More...
 
Matrix< double > * getAllNumbersOfSubstitutions (double length, size_t type=1) const
 Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length. More...
 
std::vector< double > getNumberOfSubstitutionsForEachType (size_t initialState, size_t finalState, double length) const
 Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length. More...
 
void setSubstitutionModel (const SubstitutionModel *model)
 Set the substitution model associated with this count, if relevent. More...
 
bool hasSubstitutionRegister () const
 
void setSubstitutionRegister (SubstitutionRegister *reg)
 attribution of a SubstitutionRegister More...
 
const SubstitutionRegistergetSubstitutionRegister () const
 
SubstitutionRegistergetSubstitutionRegister ()
 
virtual size_t getNumberOfSubstitutionTypes () const
 Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes(). More...
 
virtual const Alphabet * getAlphabet () 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 (const AlphabetIndex2 *weights, bool ownWeights)
 
bool hasWeights () const
 
const AlphabetIndex2 * getWeights () const
 

Protected Attributes

std::auto_ptr< SubstitutionRegisterregister_
 
const AlphabetIndex2 * weights_
 
bool ownWeights_
 

Private Member Functions

void substitutionRegisterHasChanged ()
 
void weightsHaveChanged ()
 

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 64 of file NaiveSubstitutionCount.h.

Constructor & Destructor Documentation

◆ NaiveSubstitutionCount()

bpp::NaiveSubstitutionCount::NaiveSubstitutionCount ( const SubstitutionModel model,
SubstitutionRegister reg,
bool  allowSelf = false,
const AlphabetIndex2 *  weights = 0 
)
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 discribes 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 relevent. 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 83 of file NaiveSubstitutionCount.h.

Referenced by clone().

◆ ~NaiveSubstitutionCount()

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

Definition at line 89 of file NaiveSubstitutionCount.h.

Member Function Documentation

◆ clone()

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

Implements bpp::SubstitutionCount.

Definition at line 91 of file NaiveSubstitutionCount.h.

References NaiveSubstitutionCount().

◆ getAllNumbersOfSubstitutions()

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

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::SubstitutionCount.

Definition at line 44 of file NaiveSubstitutionCount.cpp.

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

◆ getAlphabet()

virtual const Alphabet* bpp::SubstitutionCount::getAlphabet ( ) const
inlinevirtualinherited

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

Returns
The alphabet associated to this substitution count.

Definition at line 112 of file SubstitutionCount.h.

References bpp::SubstitutionRegister::getAlphabet(), and bpp::SubstitutionCount::getSubstitutionRegister().

◆ getNumberOfStates()

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

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

Returns
The number of states in the model/alphabet.

Definition at line 119 of file SubstitutionCount.h.

References bpp::SubstitutionRegister::getAlphabet(), and bpp::SubstitutionCount::getSubstitutionRegister().

◆ getNumberOfSubstitutions()

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

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::SubstitutionCount.

Definition at line 94 of file NaiveSubstitutionCount.h.

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

Referenced by getNumberOfSubstitutionsForEachType().

◆ getNumberOfSubstitutionsForEachType()

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

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::SubstitutionCount.

Definition at line 107 of file NaiveSubstitutionCount.h.

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

◆ getNumberOfSubstitutionTypes()

◆ getSubstitutionRegister() [1/2]

const SubstitutionRegister* 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::SubstitutionCount.

Definition at line 206 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ getSubstitutionRegister() [2/2]

SubstitutionRegister* bpp::AbstractSubstitutionCount::getSubstitutionRegister ( )
inlinevirtualinherited
Returns
The SubstitutionRegister object associated to this instance. The register contains the description of the various substitutions types that are mapped.

Implements bpp::SubstitutionCount.

Definition at line 208 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ getWeights()

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::SubstitutionCount.

Definition at line 192 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ hasWeights()

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

◆ setSubstitutionModel()

void bpp::NaiveSubstitutionCount::setSubstitutionModel ( const SubstitutionModel model)
inlinevirtual

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

Parameters
modelThe substitution model to use with this count.

Implements bpp::SubstitutionCount.

Definition at line 116 of file NaiveSubstitutionCount.h.

References bpp::SubstitutionModel::getAlphabetStates(), and supportedChars_.

◆ setSubstitutionRegister()

void bpp::AbstractSubstitutionCount::setSubstitutionRegister ( SubstitutionRegister reg)
inlinevirtualinherited

◆ setWeights()

void AbstractWeightedSubstitutionCount::setWeights ( const AlphabetIndex2 *  weights,
bool  ownWeights 
)
virtualinherited

◆ substitutionRegisterHasChanged()

void bpp::NaiveSubstitutionCount::substitutionRegisterHasChanged ( )
inlineprivatevirtual

Implements bpp::AbstractSubstitutionCount.

Definition at line 122 of file NaiveSubstitutionCount.h.

◆ weightsHaveChanged()

void bpp::NaiveSubstitutionCount::weightsHaveChanged ( )
inlineprivatevirtual

Implements bpp::AbstractWeightedSubstitutionCount.

Definition at line 123 of file NaiveSubstitutionCount.h.

Member Data Documentation

◆ allowSelf_

bool bpp::NaiveSubstitutionCount::allowSelf_
private

Definition at line 69 of file NaiveSubstitutionCount.h.

Referenced by getNumberOfSubstitutions().

◆ ownWeights_

◆ register_

◆ supportedChars_

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

◆ weights_


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