bpp-seq  2.2.0
bpp::NucleicAlphabet Class Referenceabstract

The abstract base class for nucleic alphabets. More...

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

+ Inheritance diagram for bpp::NucleicAlphabet:
+ Collaboration diagram for bpp::NucleicAlphabet:

Public Member Functions

 NucleicAlphabet ()
 
 NucleicAlphabet (const NucleicAlphabet &bia)
 
NucleicAlphabetoperator= (const NucleicAlphabet &bia)
 
virtual NucleicAlphabetclone () const =0
 
virtual ~NucleicAlphabet ()
 
unsigned int getSize () const
 Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet). This is the method you'll need in most cases. More...
 
unsigned int getNumberOfTypes () const
 Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number of integers used for state description. More...
 
int getUnknownCharacterCode () const
 
bool isUnresolved (int state) const
 
bool isUnresolved (const std::string &state) const
 
bool isCharInAlphabet (char state) const
 
bool isCharInAlphabet (const std::string &state) const
 Tell if a state (specified by its string description) is allowed by the the alphabet. More...
 
int charToInt (const std::string &state) const throw (BadCharException)
 Give the int description of a state given its string description. More...
 
virtual std::string getAlphabetType () const =0
 Identification method. More...
 
Specific methods
const NucleicAlphabetStategetStateByBinCode (int code) const throw (BadIntException)
 Get a state by its binary representation. More...
 
int subtract (int s1, int s2) const throw (BadIntException)
 Subtract states. More...
 
std::string subtract (const std::string &s1, const std::string &s2) const throw (BadCharException)
 Subtract states. More...
 
int getOverlap (int s1, int s2) const throw (BadIntException)
 Get the overlap between to states. More...
 
std::string getOverlap (const std::string &s1, const std::string &s2) const throw (BadCharException)
 Get the overlap between to states. More...
 
Implement these methods from the Alphabet interface.
size_t getNumberOfStates () const
 This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int. More...
 
unsigned int getNumberOfChars () const
 Get the number of supported characters in this alphabet, including generic characters (e.g. return 20 for DNA alphabet). More...
 
std::string getName (const std::string &state) const throw (BadCharException)
 Get the complete name of a state given its string description. More...
 
std::string getName (int state) const throw (BadIntException)
 Get the complete name of a state given its int description. More...
 
std::string intToChar (int state) const throw (BadIntException)
 Give the string description of a state given its int description. More...
 
bool isIntInAlphabet (int state) const
 Tell if a state (specified by its int description) is allowed by the the alphabet. More...
 
std::vector< int > getAlias (int state) const throw (BadIntException)
 Get all resolved states that match a generic state. More...
 
std::vector< std::string > getAlias (const std::string &state) const throw (BadCharException)
 Get all resolved states that match a generic state. More...
 
int getGeneric (const std::vector< int > &states) const throw (BadIntException)
 Get the generic state that match a set of states. More...
 
std::string getGeneric (const std::vector< std::string > &states) const throw (AlphabetException)
 Get the generic state that match a set of states. More...
 
const std::vector< int > & getSupportedInts () const
 
const std::vector< std::string > & getSupportedChars () const
 
int getGapCharacterCode () const
 
bool isGap (int state) const
 
bool isGap (const std::string &state) const
 
Specific methods to access AlphabetState
AlphabetStategetState (const std::string &letter) throw (BadCharException)
 
AlphabetStategetState (int num) throw (BadIntException)
 
int getIntCodeAt (size_t stateIndex) const throw (IndexOutOfBoundsException)
 
const std::string & getCharCodeAt (size_t stateIndex) const throw (IndexOutOfBoundsException)
 
size_t getStateIndex (int state) const throw (BadIntException)
 
size_t getStateIndex (const std::string &state) const throw (BadCharException)
 

Protected Member Functions

void resize (size_t size)
 Resize the private alphabet_ vector. More...
 
void remap ()
 Re-update the maps using the alphabet_ vector content. More...
 
unsigned int getStateCodingSize () const
 Get the size of the string coding a state. More...
 
bool equals (const Alphabet &alphabet) const
 Comparison of alphabets. More...
 

Protected Attributes

Available codes

These vectors will be computed the first time you call the getAvailableInts or getAvailableChars method.

std::vector< std::string > charList_
 
std::vector< int > intList_
 

Private Member Functions

void updateBinMaps_ (size_t pos, const NucleicAlphabetState &st)
 

Private Attributes

std::map< int, size_t > binCodes_
 

Overloaded methods from AbstractAlphabet

const NucleicAlphabetStategetStateAt (size_t stateIndex) const throw (IndexOutOfBoundsException)
 Get a state at a position in the alphabet_ vector. More...
 
NucleicAlphabetStategetStateAt (size_t stateIndex) throw (IndexOutOfBoundsException)
 Get a state at a position in the alphabet_ vector. More...
 
const NucleicAlphabetStategetState (const std::string &letter) const throw (BadCharException)
 Get a state by its letter. More...
 
const NucleicAlphabetStategetState (int num) const throw (BadIntException)
 Get a state by its num. More...
 
void registerState (AlphabetState *st) throw (Exception)
 Add a state to the Alphabet. More...
 
void setState (size_t pos, AlphabetState *st) throw (Exception, IndexOutOfBoundsException)
 Set a state in the Alphabet. More...
 

Detailed Description

The abstract base class for nucleic alphabets.

This class only implements a few methods, it is mainly designed for methods/classes that will require to work with both RNA and DNA.

Definition at line 61 of file NucleicAlphabet.h.

Constructor & Destructor Documentation

◆ NucleicAlphabet() [1/2]

bpp::NucleicAlphabet::NucleicAlphabet ( )
inline

Definition at line 72 of file NucleicAlphabet.h.

◆ NucleicAlphabet() [2/2]

bpp::NucleicAlphabet::NucleicAlphabet ( const NucleicAlphabet bia)
inline

Definition at line 74 of file NucleicAlphabet.h.

◆ ~NucleicAlphabet()

virtual bpp::NucleicAlphabet::~NucleicAlphabet ( )
inlinevirtual

Definition at line 87 of file NucleicAlphabet.h.

Member Function Documentation

◆ charToInt()

◆ clone()

virtual NucleicAlphabet* bpp::NucleicAlphabet::clone ( ) const
pure virtual

Implements bpp::LetterAlphabet.

Implemented in bpp::DNA, and bpp::RNA.

◆ equals()

bool bpp::AbstractAlphabet::equals ( const Alphabet alphabet) const
inlineprotectedvirtualinherited

Comparison of alphabets.

Returns
true If the two instances are of the same class.

Implements bpp::Alphabet.

Definition at line 268 of file AbstractAlphabet.h.

References bpp::Alphabet::getAlphabetType().

◆ getAlias() [1/2]

std::vector< int > AbstractAlphabet::getAlias ( int  state) const
throw (BadIntException
)
virtualinherited

Get all resolved states that match a generic state.

If the given state is not a generic code then the output vector will contain this unique code.

Parameters
stateThe alias to resolve.
Returns
A vector of resolved states.
Exceptions
BadIntExceptionWhen state is not a valid integer.

Implements bpp::Alphabet.

Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::DNA, and bpp::RNA.

Definition at line 212 of file AbstractAlphabet.cpp.

◆ getAlias() [2/2]

std::vector< std::string > AbstractAlphabet::getAlias ( const std::string &  state) const
throw (BadCharException
)
virtualinherited

Get all resolved states that match a generic state.

If the given state is not a generic code then the output vector will contain this unique code.

Parameters
stateThe alias to resolve.
Returns
A vector of resolved states.
Exceptions
BadCharExceptionWhen state is not a valid char description.

Implements bpp::Alphabet.

Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::DNA, and bpp::RNA.

Definition at line 222 of file AbstractAlphabet.cpp.

◆ getAlphabetType()

virtual std::string bpp::Alphabet::getAlphabetType ( ) const
pure virtualinherited

Identification method.

Used to tell if two alphabets describe the same type of sequences. For instance, this method is used by sequence containers to compare two alphabets and allow or deny addition of sequences.

Returns
A text describing the alphabet.

Implemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::RNY, bpp::NumericAlphabet, bpp::CodonAlphabet, bpp::DNA, bpp::DefaultAlphabet, bpp::RNA, bpp::CaseMaskedAlphabet, bpp::IntegerAlphabet, and bpp::BinaryAlphabet.

Referenced by bpp::SiteTools::areSitesIdentical(), bpp::AbstractAlphabet::equals(), and bpp::SequenceTools::invertComplement().

◆ getCharCodeAt()

const std::string& bpp::AbstractAlphabet::getCharCodeAt ( size_t  stateIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited
Returns
The char code of a given state.
Parameters
stateIndexThe index of the state to fetch.

Implements bpp::Alphabet.

Definition at line 220 of file AbstractAlphabet.h.

References bpp::AlphabetState::getLetter(), and bpp::AbstractAlphabet::getStateAt().

◆ getGapCharacterCode()

int bpp::AbstractAlphabet::getGapCharacterCode ( ) const
inlinevirtualinherited
Returns
The int code for gap characters.

Implements bpp::Alphabet.

Definition at line 159 of file AbstractAlphabet.h.

Referenced by bpp::SequenceTools::replaceStopsWithGaps().

◆ getGeneric() [1/2]

int AbstractAlphabet::getGeneric ( const std::vector< int > &  states) const
throw (BadIntException
)
virtualinherited

Get the generic state that match a set of states.

If the given states contain generic code, each generic code is first resolved and then the new generic state is returned. If only a single resolved state is given the function return this state.

Parameters
statesA vector of states to resolve.
Returns
A int code for the computed state.
Exceptions
BadIntExceptionWhen a state is not a valid integer.

Implements bpp::Alphabet.

Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::DNA, and bpp::RNA.

Definition at line 232 of file AbstractAlphabet.cpp.

◆ getGeneric() [2/2]

std::string AbstractAlphabet::getGeneric ( const std::vector< std::string > &  states) const
throw (AlphabetException
)
virtualinherited

Get the generic state that match a set of states.

If the given states contain generic code, each generic code is first resolved and then the new generic state is returned. If only a single resolved state is given the function return this state.

Parameters
statesA vector of states to resolve.
Returns
A string code for the computed state.
Exceptions
BadCharExceptionwhen a state is not a valid char description.
CharStateNotSupportedExceptionwhen the alphabet does not support Char state for unresolved state.

Implements bpp::Alphabet.

Reimplemented in bpp::WordAlphabet, bpp::ProteicAlphabet, bpp::DNA, and bpp::RNA.

Definition at line 258 of file AbstractAlphabet.cpp.

◆ getIntCodeAt()

int bpp::AbstractAlphabet::getIntCodeAt ( size_t  stateIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtualinherited
Returns
The int code of a given state.
Parameters
stateIndexThe index of the state to fetch.

Implements bpp::Alphabet.

Definition at line 216 of file AbstractAlphabet.h.

References bpp::AlphabetState::getNum(), and bpp::AbstractAlphabet::getStateAt().

◆ getName() [1/2]

std::string AbstractAlphabet::getName ( const std::string &  state) const
throw (BadCharException
)
virtualinherited

Get the complete name of a state given its string description.

In case of several states with identical number (i.e. N and X for nucleic alphabets), this method will return the name of the first found in the vector.

Parameters
stateThe string description of the given state.
Returns
The name of the state.
Exceptions
BadCharExceptionWhen state is not a valid char description.

Implements bpp::Alphabet.

Reimplemented in bpp::WordAlphabet.

Definition at line 164 of file AbstractAlphabet.cpp.

Referenced by bpp::WordAlphabet::getName().

◆ getName() [2/2]

std::string AbstractAlphabet::getName ( int  state) const
throw (BadIntException
)
virtualinherited

Get the complete name of a state given its int description.

In case of several states with identical number (i.e. N and X for nucleic alphabets), this method returns the name of the first found in the vector.

Parameters
stateThe int description of the given state.
Returns
The name of the state.
Exceptions
BadIntExceptionWhen state is not a valid integer.

Implements bpp::Alphabet.

Definition at line 171 of file AbstractAlphabet.cpp.

◆ getNumberOfChars()

unsigned int bpp::AbstractAlphabet::getNumberOfChars ( ) const
inlinevirtualinherited

Get the number of supported characters in this alphabet, including generic characters (e.g. return 20 for DNA alphabet).

Returns
The total number of supported character descriptions.

Implements bpp::Alphabet.

Definition at line 146 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

Referenced by bpp::WordAlphabet::getNumberOfTypes(), bpp::WordAlphabet::getSize(), and registerState().

◆ getNumberOfStates()

size_t bpp::AbstractAlphabet::getNumberOfStates ( ) const
inlinevirtualinherited

This is a convenient alias for getNumberOfChars(), returning a size_t instead of unsigned int.

This funcion is typically used il loops over all states of an alphabet.

Implements bpp::Alphabet.

Definition at line 145 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

◆ getNumberOfTypes()

unsigned int bpp::NucleicAlphabet::getNumberOfTypes ( ) const
inlinevirtual

Get the number of distinct states in alphabet (e.g. return 15 for DNA alphabet). This is the number of integers used for state description.

Returns
The number of distinct states.

Implements bpp::Alphabet.

Definition at line 269 of file NucleicAlphabet.h.

◆ getOverlap() [1/2]

int bpp::NucleicAlphabet::getOverlap ( int  s1,
int  s2 
) const
throw (BadIntException
)
inline

Get the overlap between to states.

Get the overlapping states between two steps.

int m = alpha->charToInt("M");
int r = alpha->charToInt("R");
int a = alpha->getOverlap(m, r);
cout << alpha->intToChar(a) << endl;
// should print A because M = A/C and R = A/G
Parameters
s1the first state as an int
s2the second state as an int
Exceptions
BadIntExceptionif one of the states is not valid
Returns
The overlapping state
Author
Sylvain Gaillard

Definition at line 234 of file NucleicAlphabet.h.

References bpp::AlphabetState::getNum(), getState(), and getStateByBinCode().

Referenced by getOverlap().

◆ getOverlap() [2/2]

std::string bpp::NucleicAlphabet::getOverlap ( const std::string &  s1,
const std::string &  s2 
) const
throw (BadCharException
)
inline

Get the overlap between to states.

Get the overlapping states between two steps.

string m = "M";
string r = R;
cout << alpha->getOverlap(m, r) << endl;
// should print A because M = A/C and R = A/G
Parameters
s1the first state as a string
s2the second state as a string
Exceptions
BadCharExceptionif one of the states is not valid
Returns
The overlapping state
Author
Sylvain Gaillard

Definition at line 258 of file NucleicAlphabet.h.

References bpp::LetterAlphabet::charToInt(), getOverlap(), and bpp::AbstractAlphabet::intToChar().

◆ getSize()

unsigned int bpp::NucleicAlphabet::getSize ( ) const
inlinevirtual

Get the number of resolved states in the alphabet (e.g. return 4 for DNA alphabet). This is the method you'll need in most cases.

Returns
The number of resolved states.

Implements bpp::Alphabet.

Definition at line 266 of file NucleicAlphabet.h.

◆ getState() [1/4]

const NucleicAlphabetState& bpp::NucleicAlphabet::getState ( const std::string &  letter) const
throw (BadCharException
)
inlinevirtual

Get a state by its letter.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
letterThe letter of the state to find.
Exceptions
BadCharExceptionIf the letter is not in the Alphabet.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 129 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getState().

Referenced by getOverlap(), and subtract().

◆ getState() [2/4]

const NucleicAlphabetState& bpp::NucleicAlphabet::getState ( int  num) const
throw (BadIntException
)
inlinevirtual

Get a state by its num.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
numThe num of the state to find.
Exceptions
BadIntExceptionIf the num is not in the Alphabet.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 135 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getState().

◆ getState() [3/4]

AlphabetState & AbstractAlphabet::getState ( const std::string &  letter)
throw (BadCharException
)
inherited

Definition at line 130 of file AbstractAlphabet.cpp.

◆ getState() [4/4]

AlphabetState & AbstractAlphabet::getState ( int  num)
throw (BadIntException
)
inherited

Definition at line 139 of file AbstractAlphabet.cpp.

◆ getStateAt() [1/2]

const NucleicAlphabetState& bpp::NucleicAlphabet::getStateAt ( size_t  stateIndex) const
throw (IndexOutOfBoundsException
)
inlinevirtual

Get a state at a position in the alphabet_ vector.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
stateIndexThe index of the state in the alphabet_ vector.
Exceptions
IndexOutOfBoundsExceptionIf the index is invalid.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 117 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getStateAt().

Referenced by getStateByBinCode().

◆ getStateAt() [2/2]

NucleicAlphabetState& bpp::NucleicAlphabet::getStateAt ( size_t  stateIndex)
throw (IndexOutOfBoundsException
)
inlinevirtual

Get a state at a position in the alphabet_ vector.

This method must be overloaded in specialized classes to send back a reference of the corect type.

Parameters
stateIndexThe index of the state in the alphabet_ vector.
Exceptions
IndexOutOfBoundsExceptionIf the index is invalid.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 123 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getStateAt().

◆ getStateByBinCode()

const NucleicAlphabetState& bpp::NucleicAlphabet::getStateByBinCode ( int  code) const
throw (BadIntException
)
inline

Get a state by its binary representation.

Parameters
codeThe binary representation as an unsigned char.
Returns
The NucleicAlphabetState.
Exceptions
BadIntExceptionIf the code is not a valide state.
Author
Sylvain Gaillard

Definition at line 156 of file NucleicAlphabet.h.

References binCodes_, and getStateAt().

Referenced by getOverlap(), and subtract().

◆ getStateCodingSize()

unsigned int bpp::AbstractAlphabet::getStateCodingSize ( ) const
inlineprotectedvirtualinherited

Get the size of the string coding a state.

Returns
The size of the tring coding each states in the Alphabet.
Author
Sylvain Gaillard

Implements bpp::Alphabet.

Reimplemented in bpp::WordAlphabet.

Definition at line 266 of file AbstractAlphabet.h.

◆ getStateIndex() [1/2]

size_t AbstractAlphabet::getStateIndex ( int  state) const
throw (BadIntException
)
virtualinherited
Returns
The indices of the states with corresponding int code.

Implements bpp::Alphabet.

Definition at line 121 of file AbstractAlphabet.cpp.

Referenced by bpp::AAIndex2Entry::getIndex().

◆ getStateIndex() [2/2]

size_t AbstractAlphabet::getStateIndex ( const std::string &  state) const
throw (BadCharException
)
virtualinherited
Returns
The index of the state with corresponding char code.

Implements bpp::Alphabet.

Definition at line 103 of file AbstractAlphabet.cpp.

◆ getSupportedChars()

const std::vector< std::string > & AbstractAlphabet::getSupportedChars ( ) const
virtualinherited
Returns
A list of all supported character codes.

Note for developers of new alphabets: we return a const reference here since the list is supposed to be stored within the class and should not be modified outside the class.

Implements bpp::Alphabet.

Definition at line 301 of file AbstractAlphabet.cpp.

Referenced by bpp::CaseMaskedAlphabet::CaseMaskedAlphabet().

◆ getSupportedInts()

const std::vector< int > & AbstractAlphabet::getSupportedInts ( ) const
virtualinherited
Returns
A list of all supported int codes.

Note for developers of new alphabets: we return a const reference here since the list is supposed to be stored within the class and should not be modified outside the class.

Implements bpp::Alphabet.

Definition at line 284 of file AbstractAlphabet.cpp.

◆ getUnknownCharacterCode()

int bpp::NucleicAlphabet::getUnknownCharacterCode ( ) const
inlinevirtual
Returns
The int code for unknown characters.

Implements bpp::Alphabet.

Definition at line 271 of file NucleicAlphabet.h.

◆ intToChar()

◆ isCharInAlphabet() [1/2]

bool bpp::LetterAlphabet::isCharInAlphabet ( char  state) const
inlineinherited

◆ isCharInAlphabet() [2/2]

bool bpp::LetterAlphabet::isCharInAlphabet ( const std::string &  state) const
inlinevirtualinherited

Tell if a state (specified by its string description) is allowed by the the alphabet.

Parameters
stateThe string description.
Returns
'true' if the state in known.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 90 of file LetterAlphabet.h.

References bpp::LetterAlphabet::isCharInAlphabet().

◆ isGap() [1/2]

bool bpp::AbstractAlphabet::isGap ( int  state) const
inlinevirtualinherited
Parameters
stateThe state to test.
Returns
'True' if the state is a gap.

Implements bpp::Alphabet.

Reimplemented in bpp::RNY, and bpp::NumericAlphabet.

Definition at line 160 of file AbstractAlphabet.h.

◆ isGap() [2/2]

bool bpp::AbstractAlphabet::isGap ( const std::string &  state) const
inlinevirtualinherited
Parameters
stateThe state to test.
Returns
'True' if the state is a gap.

Implements bpp::Alphabet.

Definition at line 161 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::charToInt().

◆ isIntInAlphabet()

bool AbstractAlphabet::isIntInAlphabet ( int  state) const
virtualinherited

Tell if a state (specified by its int description) is allowed by the the alphabet.

Parameters
stateThe int description.
Returns
'true' if the state in known.

Implements bpp::Alphabet.

Definition at line 192 of file AbstractAlphabet.cpp.

◆ isUnresolved() [1/2]

bool bpp::NucleicAlphabet::isUnresolved ( int  state) const
inlinevirtual
Parameters
stateThe state to test.
Returns
'True' if the state is unresolved.

Implements bpp::Alphabet.

Definition at line 273 of file NucleicAlphabet.h.

◆ isUnresolved() [2/2]

bool bpp::NucleicAlphabet::isUnresolved ( const std::string &  state) const
inlinevirtual
Parameters
stateThe state to test.
Returns
'True' if the state is unresolved.

Implements bpp::Alphabet.

Definition at line 274 of file NucleicAlphabet.h.

References bpp::LetterAlphabet::charToInt().

◆ operator=()

NucleicAlphabet& bpp::NucleicAlphabet::operator= ( const NucleicAlphabet bia)
inline

Definition at line 76 of file NucleicAlphabet.h.

References binCodes_, and bpp::LetterAlphabet::operator=().

Referenced by bpp::RNA::operator=(), and bpp::DNA::operator=().

◆ registerState()

void bpp::NucleicAlphabet::registerState ( AlphabetState st)
throw (Exception
)
inlineprotectedvirtual

Add a state to the Alphabet.

Parameters
stThe state to add.
Exceptions
ExceptionIf a wrong alphabet state is provided.

Reimplemented from bpp::LetterAlphabet.

Definition at line 94 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getNumberOfChars(), bpp::LetterAlphabet::registerState(), and updateBinMaps_().

◆ remap()

void bpp::AbstractAlphabet::remap ( )
inlineprotectedinherited

Re-update the maps using the alphabet_ vector content.

Definition at line 258 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_, bpp::AbstractAlphabet::letters_, bpp::AbstractAlphabet::nums_, and bpp::AbstractAlphabet::updateMaps_().

Referenced by bpp::NumericAlphabet::remap().

◆ resize()

void bpp::AbstractAlphabet::resize ( size_t  size)
inlineprotectedinherited

Resize the private alphabet_ vector.

Parameters
sizeThe new size of the Alphabet.

Definition at line 253 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

Referenced by bpp::IntegerAlphabet::IntegerAlphabet().

◆ setState()

void bpp::NucleicAlphabet::setState ( size_t  pos,
AlphabetState st 
)
throw (Exception,
IndexOutOfBoundsException
)
inlineprotectedvirtual

Set a state in the Alphabet.

Parameters
posThe index of the state in the alphabet_ vector.
stThe new state to put in the Alphabet.
Exceptions
ExceptionIf a wrong alphabet state is provided.
IndexOutOfBoundsExceptionIf an incorrect index is provided.

Reimplemented from bpp::LetterAlphabet.

Definition at line 102 of file NucleicAlphabet.h.

References bpp::LetterAlphabet::setState(), and updateBinMaps_().

◆ subtract() [1/2]

int bpp::NucleicAlphabet::subtract ( int  s1,
int  s2 
) const
throw (BadIntException
)
inline

Subtract states.

Get the remaining state when subtracting one state to another.

int a = alpha->charToInt("A");
int m = alpha->charToInt("M");
int c = alpha->subtract(m, a);
cout << alpha->intToChar(c) << endl;
// should print C because M - A = C
Parameters
s1the first state as an int
s2the second state as an int
Exceptions
BadIntExceptionif one of the states is not valide.
Returns
The remaining state as an int
Author
Sylvain Gaillard

Definition at line 185 of file NucleicAlphabet.h.

References bpp::AlphabetState::getNum(), getState(), and getStateByBinCode().

Referenced by subtract().

◆ subtract() [2/2]

std::string bpp::NucleicAlphabet::subtract ( const std::string &  s1,
const std::string &  s2 
) const
throw (BadCharException
)
inline

Subtract states.

Get the remaining state when subtracting one state to another.

string a = "A";
string m = "M";
cout << alpha->subtract(m, a) << endl;
// should print C because M - A = C
Parameters
s1the first state as a string
s2the second state as a string
Exceptions
BadCharExceptionif one of the states is not valide.
Returns
The remaining state as a string
Author
Sylvain Gaillard

Definition at line 209 of file NucleicAlphabet.h.

References bpp::LetterAlphabet::charToInt(), bpp::AbstractAlphabet::intToChar(), and subtract().

◆ updateBinMaps_()

void bpp::NucleicAlphabet::updateBinMaps_ ( size_t  pos,
const NucleicAlphabetState st 
)
inlineprivate

Definition at line 66 of file NucleicAlphabet.h.

References binCodes_, and bpp::NucleicAlphabetState::getBinaryCode().

Referenced by registerState(), and setState().

Member Data Documentation

◆ binCodes_

std::map<int, size_t> bpp::NucleicAlphabet::binCodes_
private

Definition at line 65 of file NucleicAlphabet.h.

Referenced by getStateByBinCode(), operator=(), and updateBinMaps_().

◆ charList_

std::vector<std::string> bpp::AbstractAlphabet::charList_
mutableprotectedinherited

Definition at line 99 of file AbstractAlphabet.h.

Referenced by bpp::AbstractAlphabet::operator=().

◆ intList_

std::vector<int> bpp::AbstractAlphabet::intList_
mutableprotectedinherited

Definition at line 100 of file AbstractAlphabet.h.

Referenced by bpp::AbstractAlphabet::operator=().


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