bpp-phyl  2.2.0
bpp::CategorySubstitutionRegister Class Referenceabstract

Gather states into defined categories, and count the changes between categories. More...

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

+ Inheritance diagram for bpp::CategorySubstitutionRegister:
+ Collaboration diagram for bpp::CategorySubstitutionRegister:

Public Member Functions

 CategorySubstitutionRegister (const SubstitutionModel *model, bool within=false)
 Build a new substitution register with categories. This class is meant to be inherited. More...
 
virtual size_t getCategory (size_t state) const
 
virtual size_t getCategoryFrom (size_t type) const
 
virtual size_t getCategoryTo (size_t type) const
 
virtual std::string getCategoryName (size_t category) const
 
virtual bool allowWithin () const
 
size_t getNumberOfCategories () const
 
size_t getNumberOfSubstitutionTypes () const
 
virtual size_t getType (size_t fromState, size_t toState) const
 Get the substitution type far a given pair of model states. More...
 
std::string getTypeName (size_t type) const
 Get the name of a given substitution type. More...
 
const SubstitutionModelgetSubstitutionModel () const
 
const Alphabet * getAlphabet () const
 
virtual SubstitutionRegisterclone () const =0
 

Protected Member Functions

template<class T >
void setCategories (const std::map< int, T > &categories)
 

Protected Attributes

bool within_
 
size_t nbCategories_
 
std::map< int, size_t > categories_
 
std::vector< std::string > categoryNames_
 
std::vector< std::vector< size_t > > index_
 
std::vector< std::vector< size_t > > revIndex_
 
const SubstitutionModelmodel_
 

Detailed Description

Gather states into defined categories, and count the changes between categories.

Optionally allows for within categories substitutions.

Definition at line 155 of file SubstitutionRegister.h.

Constructor & Destructor Documentation

◆ CategorySubstitutionRegister()

bpp::CategorySubstitutionRegister::CategorySubstitutionRegister ( const SubstitutionModel model,
bool  within = false 
)
inline

Build a new substitution register with categories. This class is meant to be inherited.

Parameters
modelThe model defining the states.
withinSpecifies if within categories substitutions should be counted as well.

Definition at line 173 of file SubstitutionRegister.h.

Member Function Documentation

◆ allowWithin()

virtual bool bpp::CategorySubstitutionRegister::allowWithin ( ) const
inlinevirtual

Definition at line 289 of file SubstitutionRegister.h.

References within_.

◆ clone()

◆ getAlphabet()

const Alphabet* bpp::AbstractSubstitutionRegister::getAlphabet ( ) const
inlinevirtualinherited
Returns
The alphabet associated to this instance.

Implements bpp::SubstitutionRegister.

Definition at line 147 of file SubstitutionRegister.h.

References bpp::SubstitutionModel::getAlphabet(), and bpp::AbstractSubstitutionRegister::model_.

◆ getCategory()

virtual size_t bpp::CategorySubstitutionRegister::getCategory ( size_t  state) const
inlinevirtual

◆ getCategoryFrom()

virtual size_t bpp::CategorySubstitutionRegister::getCategoryFrom ( size_t  type) const
inlinevirtual

◆ getCategoryName()

virtual std::string bpp::CategorySubstitutionRegister::getCategoryName ( size_t  category) const
inlinevirtual

Definition at line 284 of file SubstitutionRegister.h.

References categoryNames_.

Referenced by getTypeName().

◆ getCategoryTo()

virtual size_t bpp::CategorySubstitutionRegister::getCategoryTo ( size_t  type) const
inlinevirtual

Definition at line 269 of file SubstitutionRegister.h.

References nbCategories_, revIndex_, and within_.

Referenced by getTypeName().

◆ getNumberOfCategories()

size_t bpp::CategorySubstitutionRegister::getNumberOfCategories ( ) const
inline

◆ getNumberOfSubstitutionTypes()

size_t bpp::CategorySubstitutionRegister::getNumberOfSubstitutionTypes ( ) const
inlinevirtual
Returns
The number of substitution types supported by this class.

Implements bpp::SubstitutionRegister.

Reimplemented in bpp::GCSynonymousSubstitutionRegister.

Definition at line 293 of file SubstitutionRegister.h.

References nbCategories_, and within_.

◆ getSubstitutionModel()

const SubstitutionModel* bpp::AbstractSubstitutionRegister::getSubstitutionModel ( ) const
inlinevirtualinherited
Returns
The substitution model associated to this instance.

Implements bpp::SubstitutionRegister.

Definition at line 145 of file SubstitutionRegister.h.

References bpp::AbstractSubstitutionRegister::model_.

◆ getType()

virtual size_t bpp::CategorySubstitutionRegister::getType ( size_t  fromState,
size_t  toState 
) const
inlinevirtual

Get the substitution type far a given pair of model states.

Parameters
fromStateInitial state (should be a state supported by the specified alphabet).
toStateFinal state (should be a state supported by the specified alphabet).
Returns
The index of the corresponding substitution type, ranging from 0 to 'getNumberOfSubstitutionTypes' + 1, as non-substitution (that is when fromState == toState) will always return 0.

Implements bpp::SubstitutionRegister.

Reimplemented in bpp::GCSynonymousSubstitutionRegister.

Definition at line 295 of file SubstitutionRegister.h.

References categories_, bpp::SubstitutionModel::getAlphabetStateAsInt(), index_, and bpp::AbstractSubstitutionRegister::model_.

◆ getTypeName()

std::string bpp::CategorySubstitutionRegister::getTypeName ( size_t  type) const
inlinevirtual

Get the name of a given substitution type.

This method is only used for user-friendlyness purposes, not computational goal. I can therefore be left unimplemented in some cases.

Parameters
typeIndex of the substitution (should be an size_t contained in the register).
Returns
A string describing the substitution type.

Implements bpp::SubstitutionRegister.

Reimplemented in bpp::GCSynonymousSubstitutionRegister.

Definition at line 305 of file SubstitutionRegister.h.

References getCategoryFrom(), getCategoryName(), and getCategoryTo().

◆ setCategories()

template<class T >
void bpp::CategorySubstitutionRegister::setCategories ( const std::map< int, T > &  categories)
inlineprotected

Member Data Documentation

◆ categories_

std::map<int, size_t> bpp::CategorySubstitutionRegister::categories_
mutableprotected

◆ categoryNames_

std::vector<std::string> bpp::CategorySubstitutionRegister::categoryNames_
protected

Definition at line 162 of file SubstitutionRegister.h.

Referenced by getCategoryName(), and setCategories().

◆ index_

std::vector< std::vector<size_t> > bpp::CategorySubstitutionRegister::index_
protected

◆ model_

◆ nbCategories_

size_t bpp::CategorySubstitutionRegister::nbCategories_
protected

◆ revIndex_

std::vector< std::vector<size_t> > bpp::CategorySubstitutionRegister::revIndex_
protected

Definition at line 164 of file SubstitutionRegister.h.

Referenced by getCategoryFrom(), getCategoryTo(), and setCategories().

◆ within_

bool bpp::CategorySubstitutionRegister::within_
protected

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