bpp-phyl3  3.0.0
bpp::AbstractStateMap Class Referenceabstract

A convenience partial implementation of the StateMap interface. More...

#include <Bpp/Phyl/Model/StateMap.h>

+ Inheritance diagram for bpp::AbstractStateMap:
+ Collaboration diagram for bpp::AbstractStateMap:

Public Member Functions

 AbstractStateMap (std::shared_ptr< const Alphabet > alphabet)
 
 AbstractStateMap (const AbstractStateMap &absm)
 
AbstractStateMapoperator= (const AbstractStateMap &absm)
 
const Alphabetalphabet () const override
 
std::shared_ptr< const AlphabetgetAlphabet () const override
 
size_t getNumberOfModelStates () const override
 
const std::vector< int > & getAlphabetStates () const override
 
int getAlphabetStateAsInt (size_t index) const override
 
std::string getAlphabetStateAsChar (size_t index) const override
 
std::vector< size_t > getModelStates (int code) const override
 
std::vector< size_t > getModelStates (const std::string &code) const override
 
bool operator== (const StateMapInterface &sm) const override
 Comparison operator==. More...
 
bool operator!= (const StateMapInterface &sm) const override
 Comparison operator!=. More...
 
virtual StateMapInterfaceclone () const override=0
 
virtual std::string getStateDescription (size_t index) const =0
 

Protected Attributes

std::shared_ptr< const Alphabetalphabet_
 
std::vector< int > states_
 

Detailed Description

A convenience partial implementation of the StateMap interface.

Model states are stored as their corresponding int codes, stored in a vector 'states_'. This vector has to be initialized and filled by the derived class.

Definition at line 104 of file StateMap.h.

Constructor & Destructor Documentation

◆ AbstractStateMap() [1/2]

bpp::AbstractStateMap::AbstractStateMap ( std::shared_ptr< const Alphabet alphabet)
inline

Definition at line 112 of file StateMap.h.

◆ AbstractStateMap() [2/2]

bpp::AbstractStateMap::AbstractStateMap ( const AbstractStateMap absm)
inline

Definition at line 117 of file StateMap.h.

Member Function Documentation

◆ alphabet()

const Alphabet& bpp::AbstractStateMap::alphabet ( ) const
inlineoverridevirtual
Returns
The associated alphabet.

Implements bpp::StateMapInterface.

Definition at line 130 of file StateMap.h.

References alphabet_.

Referenced by bpp::CanonicalStateMap::CanonicalStateMap().

◆ clone()

virtual StateMapInterface* bpp::StateMapInterface::clone ( ) const
overridepure virtualinherited

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::AbstractStateMap::getAlphabet ( ) const
inlineoverridevirtual
Returns
A shared_ptr towards the associated alphabet.

Implements bpp::StateMapInterface.

Definition at line 131 of file StateMap.h.

References alphabet_.

◆ getAlphabetStateAsChar()

std::string bpp::AbstractStateMap::getAlphabetStateAsChar ( size_t  index) const
inlineoverridevirtual
Parameters
indexThe model state.
Returns
The corresponding alphabet state as character code.

Implements bpp::StateMapInterface.

Definition at line 135 of file StateMap.h.

References alphabet_, and states_.

Referenced by bpp::CanonicalStateMap::getStateDescription(), and bpp::MarkovModulatedStateMap::getStateDescription().

◆ getAlphabetStateAsInt()

int bpp::AbstractStateMap::getAlphabetStateAsInt ( size_t  index) const
inlineoverridevirtual
Parameters
indexThe model state.
Returns
The corresponding alphabet state as int code.

Implements bpp::StateMapInterface.

Definition at line 134 of file StateMap.h.

References states_.

◆ getAlphabetStates()

const std::vector<int>& bpp::AbstractStateMap::getAlphabetStates ( ) const
inlineoverridevirtual
Returns
A vector with the corresponding alphabet states for each model state. the size of the vector is the number of model states, not the number of supported alphabet states, as distinct model states can correspond to a single alphabet state.

Implements bpp::StateMapInterface.

Definition at line 133 of file StateMap.h.

References states_.

◆ getModelStates() [1/2]

std::vector<size_t> bpp::AbstractStateMap::getModelStates ( const std::string &  code) const
inlineoverridevirtual
Parameters
codeThe character code of the alphabet state to check.
Returns
The corresponding model states, is any.

Implements bpp::StateMapInterface.

Definition at line 140 of file StateMap.h.

References alphabet_, states_, and bpp::VectorTools::whichAll().

◆ getModelStates() [2/2]

std::vector<size_t> bpp::AbstractStateMap::getModelStates ( int  code) const
inlineoverridevirtual
Parameters
codeThe int code of the alphabet state to check.
Returns
The corresponding model states, is any.

Implements bpp::StateMapInterface.

Definition at line 136 of file StateMap.h.

References states_, and bpp::VectorTools::whichAll().

◆ getNumberOfModelStates()

size_t bpp::AbstractStateMap::getNumberOfModelStates ( ) const
inlineoverridevirtual
Returns
The number of states supported by the model.

Implements bpp::StateMapInterface.

Definition at line 132 of file StateMap.h.

References states_.

◆ getStateDescription()

virtual std::string bpp::StateMapInterface::getStateDescription ( size_t  index) const
pure virtualinherited
Returns
A string describing the model state.
Parameters
indexThe state index.

Implemented in bpp::MarkovModulatedStateMap, and bpp::CanonicalStateMap.

Referenced by bpp::CategorySubstitutionRegister::setModelCategories().

◆ operator!=()

bool bpp::AbstractStateMap::operator!= ( const StateMapInterface sm) const
inlineoverridevirtual

Comparison operator!=.

Two StateMaps are not identical if they do not share the same alphabet or states.

Implements bpp::StateMapInterface.

Definition at line 152 of file StateMap.h.

References bpp::StateMapInterface::alphabet(), alphabet_, bpp::StateMapInterface::getAlphabetStates(), bpp::Alphabet::getAlphabetType(), and states_.

◆ operator=()

AbstractStateMap& bpp::AbstractStateMap::operator= ( const AbstractStateMap absm)
inline

Definition at line 122 of file StateMap.h.

References alphabet_, and states_.

◆ operator==()

bool bpp::AbstractStateMap::operator== ( const StateMapInterface sm) const
inlineoverridevirtual

Comparison operator==.

Two StateMaps are identical if they share the same alphabet and states.

Implements bpp::StateMapInterface.

Definition at line 145 of file StateMap.h.

References bpp::StateMapInterface::alphabet(), alphabet_, bpp::StateMapInterface::getAlphabetStates(), bpp::Alphabet::getAlphabetType(), and states_.

Member Data Documentation

◆ alphabet_

std::shared_ptr<const Alphabet> bpp::AbstractStateMap::alphabet_
protected

◆ states_


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