bpp-seq3  3.0.0
bpp::NucleicAlphabetState Class Reference

This is the base class to describe states in a NucleicAlphabet. More...

#include <Bpp/Seq/Alphabet/NucleicAlphabetState.h>

+ Inheritance diagram for bpp::NucleicAlphabetState:
+ Collaboration diagram for bpp::NucleicAlphabetState:

Public Member Functions

 NucleicAlphabetState (int num, const std::string &letter, unsigned char code, const std::string &name)
 
virtual ~NucleicAlphabetState ()
 
NucleicAlphabetStateclone () const
 
int getBinaryCode () const
 Get the state's binary representation. More...
 
void setBinaryCode (int code)
 Set the state's binary representation. More...
 
int getNum () const
 Get the state's number. More...
 
void setNum (int num)
 Set the state's number. More...
 
const std::string & getLetter () const
 Get the letter(s) corresponding to the state. More...
 
void setLetter (const std::string &letter)
 Set the letter(s) of the state. More...
 
const std::string & getName () const
 Get the name of the state. More...
 
void setName (const std::string &name)
 Set the name of the state. More...
 
bool operator== (AlphabetState &l2)
 operator == More...
 

Private Attributes

int binCode_
 
int num_
 
std::string letter_
 
std::string name_
 

Detailed Description

This is the base class to describe states in a NucleicAlphabet.

This class store a binary code for each state. This binary code is of length 4, one bit per nucleotid. For DNA alphabet, this code looks like this:

LetterBinary codeint value
-00000
A00011
C00102
G01004
T10008
N111115
...
M00113
W10019
...
V01117

This notation allows the use of bitwize operations like:

  • build a generic state from to states
    A | G = R <=> 0001 | 0100 = 0101
  • extract a state from an unresolved one by subtraction of an other state
    S & ~ C = G <=> 0110 & ~ 0010 = 0100

The binary code is stored as a char because it's the smallest memory word that can be allocated. A char is 8 bits long allowing the use of this class with Alphabet of at least 8 resolved states (enough for known nucleic alphabets!).

Author
Sylvain Gaillard

Definition at line 52 of file NucleicAlphabetState.h.

Constructor & Destructor Documentation

◆ NucleicAlphabetState()

bpp::NucleicAlphabetState::NucleicAlphabetState ( int  num,
const std::string &  letter,
unsigned char  code,
const std::string &  name 
)
inline

Definition at line 58 of file NucleicAlphabetState.h.

Referenced by clone().

◆ ~NucleicAlphabetState()

virtual bpp::NucleicAlphabetState::~NucleicAlphabetState ( )
inlinevirtual

Definition at line 62 of file NucleicAlphabetState.h.

Member Function Documentation

◆ clone()

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

Reimplemented from bpp::AlphabetState.

Definition at line 65 of file NucleicAlphabetState.h.

References NucleicAlphabetState().

◆ getBinaryCode()

int bpp::NucleicAlphabetState::getBinaryCode ( ) const
inline

Get the state's binary representation.

Returns
The state's binary representation.

Definition at line 74 of file NucleicAlphabetState.h.

References binCode_.

Referenced by bpp::DNA::getAlias(), bpp::RNA::getAlias(), bpp::DNA::isResolvedIn(), bpp::RNA::isResolvedIn(), and bpp::NucleicAlphabet::updateBinMaps_().

◆ getLetter()

const std::string& bpp::AlphabetState::getLetter ( ) const
inlineinherited

Get the letter(s) corresponding to the state.

The letter is a string because it may more than one char (for instance: codon).

Returns
The state's letter.

Definition at line 63 of file AlphabetState.h.

References bpp::AlphabetState::letter_.

Referenced by bpp::CaseMaskedAlphabet::CaseMaskedAlphabet(), bpp::LexicalAlphabet::getAlphabetType(), bpp::AbstractAlphabet::getCharCodeAt(), bpp::RNY::intToChar(), bpp::LetterAlphabet::registerState(), bpp::LetterAlphabet::setState(), and bpp::AbstractAlphabet::updateMaps_().

◆ getName()

const std::string& bpp::AlphabetState::getName ( ) const
inlineinherited

Get the name of the state.

Returns
The full name of the state (i.e. Adenine).

Definition at line 76 of file AlphabetState.h.

References bpp::AlphabetState::name_.

Referenced by bpp::CaseMaskedAlphabet::CaseMaskedAlphabet(), and bpp::WordAlphabet::getName().

◆ getNum()

◆ operator==()

bool bpp::AlphabetState::operator== ( AlphabetState l2)
inlineinherited

operator ==

Comparison is done on state num

Definition at line 89 of file AlphabetState.h.

References bpp::AlphabetState::getNum().

◆ setBinaryCode()

void bpp::NucleicAlphabetState::setBinaryCode ( int  code)
inline

Set the state's binary representation.

Parameters
codeThe state's binary representation.

Definition at line 80 of file NucleicAlphabetState.h.

References binCode_.

◆ setLetter()

void bpp::AlphabetState::setLetter ( const std::string &  letter)
inlineinherited

Set the letter(s) of the state.

Parameters
letterThe state's letter.

Definition at line 69 of file AlphabetState.h.

References bpp::AlphabetState::letter_.

◆ setName()

void bpp::AlphabetState::setName ( const std::string &  name)
inlineinherited

Set the name of the state.

Parameters
nameThe state's name

Definition at line 82 of file AlphabetState.h.

References bpp::AlphabetState::name_.

◆ setNum()

void bpp::AlphabetState::setNum ( int  num)
inlineinherited

Set the state's number.

Parameters
numThe state's number.

Definition at line 53 of file AlphabetState.h.

References bpp::AlphabetState::num_.

Member Data Documentation

◆ binCode_

int bpp::NucleicAlphabetState::binCode_
private

Definition at line 55 of file NucleicAlphabetState.h.

Referenced by getBinaryCode(), and setBinaryCode().

◆ letter_

std::string bpp::AlphabetState::letter_
privateinherited

Definition at line 25 of file AlphabetState.h.

Referenced by bpp::AlphabetState::getLetter(), and bpp::AlphabetState::setLetter().

◆ name_

std::string bpp::AlphabetState::name_
privateinherited

Definition at line 26 of file AlphabetState.h.

Referenced by bpp::AlphabetState::getName(), and bpp::AlphabetState::setName().

◆ num_

int bpp::AlphabetState::num_
privateinherited

Definition at line 24 of file AlphabetState.h.

Referenced by bpp::AlphabetState::getNum(), and bpp::AlphabetState::setNum().


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