bpp-seq3  3.0.0
bpp::DNA Class Reference

This alphabet is used to deal with DNA sequences. More...

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

+ Inheritance diagram for bpp::DNA:
+ Collaboration diagram for bpp::DNA:

Public Member Functions

 DNA (bool exclamationMarkCountsAsGap=false)
 
 DNA (const DNA &bia)
 
DNAoperator= (const DNA &bia)
 
DNAclone () const
 
virtual ~DNA ()
 
bool isResolvedIn (int state1, int state2) const
 Tells if a given (potentially unresolved) state can be resolved in another resolved state. More...
 
std::vector< int > getAlias (int state) const
 Get all resolved states that match a generic state. More...
 
std::vector< std::string > getAlias (const std::string &state) const
 Get all resolved states that match a generic state. More...
 
int getGeneric (const std::vector< int > &states) const
 Get the generic state that match a set of states. More...
 
std::string getGeneric (const std::vector< std::string > &states) const
 Get the generic state that match a set of states. More...
 
std::string getAlphabetType () const
 Identification method. More...
 
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
 Give the int description of a state given its string description. More...
 
Specific methods to access AlphabetState
AlphabetStategetState (const std::string &letter)
 
AlphabetStategetState (int num)
 
int getIntCodeAt (size_t stateIndex) const
 
const std::string & getCharCodeAt (size_t stateIndex) const
 
size_t getStateIndex (int state) const
 
size_t getStateIndex (const std::string &state) const
 
Specific methods
const NucleicAlphabetStategetStateByBinCode (int code) const
 Get a state by its binary representation. More...
 
int subtract (int s1, int s2) const
 Subtract states. More...
 
std::string subtract (const std::string &s1, const std::string &s2) const
 Subtract states. More...
 
int getOverlap (int s1, int s2) const
 Get the overlap between to states. More...
 
std::string getOverlap (const std::string &s1, const std::string &s2) const
 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
 Get the complete name of a state given its string description. More...
 
std::string getName (int state) const
 Get the complete name of a state given its int description. More...
 
std::string intToChar (int state) const
 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...
 
const std::vector< int > & getSupportedInts () const
 
const std::vector< std::string > & getSupportedChars () const
 
const std::vector< std::string > & getResolvedChars () const
 
int getGapCharacterCode () const
 
bool isGap (int state) const
 
bool isGap (const std::string &state) const
 

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)
 
void updateMaps_ (size_t pos, const AlphabetState &st)
 Update the private maps letters_ and nums_ when adding a state. More...
 

Private Attributes

std::map< int, size_t > binCodes_
 
std::vector< int > letters_
 
bool caseSensitive_
 
std::vector< AlphabetState * > alphabet_
 Alphabet: vector of AlphabetState. More...
 
maps used to quick search for letter and num.
std::map< int, size_t > nums_
 

Static Private Attributes

static const int LETTER_UNDEF_VALUE = -99
 

Overloaded methods from AbstractAlphabet

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

Detailed Description

This alphabet is used to deal with DNA sequences.

It supports all 4 nucleotides (A, T, G and C) with their standard denomination. Gaps are coded by '-', unresolved characters are coded by 'X, N, O, 0 or ?'. Extensive support for generic characters (e.g. 'P', 'Y', etc.) is provided.

Definition at line 24 of file DNA.h.

Constructor & Destructor Documentation

◆ DNA() [1/2]

DNA::DNA ( bool  exclamationMarkCountsAsGap = false)
Parameters
exclamationMarkCountsAsGapIf yes, '!' characters are replaced by gaps. Otherwise, they are counted as unknown characters.

Definition at line 20 of file DNA.cpp.

Referenced by clone().

◆ DNA() [2/2]

bpp::DNA::DNA ( const DNA bia)
inline

Definition at line 34 of file DNA.h.

◆ ~DNA()

virtual bpp::DNA::~DNA ( )
inlinevirtual

Definition at line 47 of file DNA.h.

Member Function Documentation

◆ charToInt()

int bpp::LetterAlphabet::charToInt ( const std::string &  state) const
inlinevirtualinherited

Give the int description of a state given its string description.

Parameters
stateThe string description.
Returns
The int description.
Exceptions
BadCharExceptionWhen state is not a valid char description.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 60 of file LetterAlphabet.h.

References bpp::LetterAlphabet::isCharInAlphabet(), and bpp::LetterAlphabet::letters_.

Referenced by bpp::CaseMaskedAlphabet::getMaskedEquivalentState(), bpp::NucleicAlphabet::getOverlap(), bpp::NucleicAlphabet::isUnresolved(), bpp::ProteicAlphabet::isUnresolved(), and bpp::NucleicAlphabet::subtract().

◆ clone()

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

Implements bpp::NucleicAlphabet.

Definition at line 42 of file DNA.h.

References DNA().

◆ 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 243 of file AbstractAlphabet.h.

References bpp::Alphabet::getAlphabetType().

◆ getAlias() [1/2]

std::vector< std::string > DNA::getAlias ( const std::string &  state) const
virtual

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.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 107 of file DNA.cpp.

References bpp::TextTools::toUpper().

◆ getAlias() [2/2]

std::vector< int > DNA::getAlias ( int  state) const
virtual

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.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 85 of file DNA.cpp.

References bpp::NucleicAlphabetState::getBinaryCode().

◆ getAlphabetType()

std::string bpp::DNA::getAlphabetType ( ) const
inlinevirtual

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.

Implements bpp::Alphabet.

Definition at line 56 of file DNA.h.

◆ getCharCodeAt()

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

Implements bpp::Alphabet.

Definition at line 192 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 130 of file AbstractAlphabet.h.

◆ getGeneric() [1/2]

int DNA::getGeneric ( const std::vector< int > &  states) const
virtual

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.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 123 of file DNA.cpp.

◆ getGeneric() [2/2]

std::string DNA::getGeneric ( const std::vector< std::string > &  states) const
virtual

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.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 137 of file DNA.cpp.

◆ getIntCodeAt()

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

Implements bpp::Alphabet.

Definition at line 187 of file AbstractAlphabet.h.

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

◆ getName() [1/2]

std::string AbstractAlphabet::getName ( const std::string &  state) const
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 139 of file AbstractAlphabet.cpp.

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

◆ getName() [2/2]

std::string AbstractAlphabet::getName ( int  state) const
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 146 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 115 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

Referenced by bpp::LexicalAlphabet::getNumberOfTypes(), bpp::AllelicAlphabet::getNumberOfTypes(), bpp::WordAlphabet::getNumberOfTypes(), bpp::LexicalAlphabet::getSize(), bpp::AllelicAlphabet::getSize(), bpp::WordAlphabet::getSize(), and bpp::NucleicAlphabet::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 function is typically used il loops over all states of an alphabet.

Implements bpp::Alphabet.

Definition at line 114 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

Referenced by bpp::LexicalAlphabet::getAlphabetType().

◆ getNumberOfTypes()

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

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 236 of file NucleicAlphabet.h.

◆ getOverlap() [1/2]

std::string bpp::NucleicAlphabet::getOverlap ( const std::string &  s1,
const std::string &  s2 
) const
inlineinherited

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 224 of file NucleicAlphabet.h.

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

◆ getOverlap() [2/2]

int bpp::NucleicAlphabet::getOverlap ( int  s1,
int  s2 
) const
inlineinherited

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 199 of file NucleicAlphabet.h.

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

Referenced by bpp::NucleicAlphabet::getOverlap().

◆ getResolvedChars()

const std::vector< std::string > & AbstractAlphabet::getResolvedChars ( ) const
virtualinherited
Returns
A list of all resolved 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 327 of file AbstractAlphabet.cpp.

◆ getSize()

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

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 233 of file NucleicAlphabet.h.

◆ getState() [1/4]

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

Definition at line 101 of file AbstractAlphabet.cpp.

◆ getState() [2/4]

const NucleicAlphabetState& bpp::NucleicAlphabet::getState ( const std::string &  letter) const
inlinevirtualinherited

Get a state by its letter.

This method must be overloaded in specialized classes to send back a reference of the correct 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 92 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getState().

Referenced by bpp::NucleicAlphabet::getOverlap(), and bpp::NucleicAlphabet::subtract().

◆ getState() [3/4]

AlphabetState & AbstractAlphabet::getState ( int  num)
inherited

Definition at line 111 of file AbstractAlphabet.cpp.

◆ getState() [4/4]

const NucleicAlphabetState& bpp::NucleicAlphabet::getState ( int  num) const
inlinevirtualinherited

Get a state by its num.

This method must be overloaded in specialized classes to send back a reference of the correct 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 98 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getState().

◆ getStateAt() [1/2]

NucleicAlphabetState& bpp::NucleicAlphabet::getStateAt ( size_t  stateIndex)
inlinevirtualinherited

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 correct type.

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

Reimplemented from bpp::AbstractAlphabet.

Definition at line 86 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getStateAt().

◆ getStateAt() [2/2]

const NucleicAlphabetState& bpp::NucleicAlphabet::getStateAt ( size_t  stateIndex) const
inlinevirtualinherited

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 correct type.

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

Reimplemented from bpp::AbstractAlphabet.

Definition at line 80 of file NucleicAlphabet.h.

References bpp::AbstractAlphabet::getStateAt().

Referenced by bpp::NucleicAlphabet::getStateByBinCode().

◆ getStateByBinCode()

const NucleicAlphabetState& bpp::NucleicAlphabet::getStateByBinCode ( int  code) const
inlineinherited

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 valid state.
Author
Sylvain Gaillard

Definition at line 119 of file NucleicAlphabet.h.

References bpp::NucleicAlphabet::binCodes_, and bpp::NucleicAlphabet::getStateAt().

Referenced by bpp::NucleicAlphabet::getOverlap(), and bpp::NucleicAlphabet::subtract().

◆ getStateCodingSize()

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

Get the size of the string coding a state.

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

Implements bpp::Alphabet.

Reimplemented in bpp::WordAlphabet, bpp::CodonAlphabet, and bpp::AllelicAlphabet.

Definition at line 241 of file AbstractAlphabet.h.

◆ getStateIndex() [1/2]

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

Implements bpp::Alphabet.

Definition at line 71 of file AbstractAlphabet.cpp.

◆ getStateIndex() [2/2]

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

Implements bpp::Alphabet.

Definition at line 91 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 310 of file AbstractAlphabet.cpp.

Referenced by bpp::AllelicAlphabet::getAlias().

◆ 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 293 of file AbstractAlphabet.cpp.

Referenced by bpp::AllelicAlphabet::getAlias().

◆ getUnknownCharacterCode()

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

Implements bpp::Alphabet.

Definition at line 238 of file NucleicAlphabet.h.

◆ intToChar()

std::string AbstractAlphabet::intToChar ( int  state) const
virtualinherited

Give the string description of a state given its int description.

Parameters
stateThe int description.
Returns
The string description.
Exceptions
BadIntExceptionWhen state is not a valid integer.

Implements bpp::Alphabet.

Reimplemented in bpp::RNY.

Definition at line 160 of file AbstractAlphabet.cpp.

Referenced by bpp::RNY::getAlias(), bpp::WordAlphabet::getAlias(), bpp::CaseMaskedAlphabet::getMaskedEquivalentState(), bpp::WordAlphabet::getNPosition(), bpp::NucleicAlphabet::getOverlap(), bpp::WordAlphabet::getPositions(), bpp::WordAlphabet::getWord(), bpp::BinaryAlphabet::isResolvedIn(), and bpp::NucleicAlphabet::subtract().

◆ 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 56 of file LetterAlphabet.h.

References bpp::LetterAlphabet::isCharInAlphabet().

◆ isGap() [1/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 132 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::charToInt().

◆ isGap() [2/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 131 of file AbstractAlphabet.h.

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

◆ 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 167 of file AbstractAlphabet.cpp.

Referenced by bpp::BinaryAlphabet::getAlias(), bpp::RNY::getAlias(), bpp::AllelicAlphabet::getAlias(), bpp::WordAlphabet::getAlias(), bpp::CaseMaskedAlphabet::getMaskedEquivalentState(), bpp::BinaryAlphabet::isResolvedIn(), bpp::RNY::isResolvedIn(), bpp::AllelicAlphabet::isResolvedIn(), and bpp::WordAlphabet::isResolvedIn().

◆ isResolvedIn()

bool DNA::isResolvedIn ( int  state1,
int  state2 
) const
virtual

Tells if a given (potentially unresolved) state can be resolved in another resolved state.

Parameters
state1The alias to resolve.
state2The candidate for resolution.
Returns
A boolean
Exceptions
BadIntExceptionWhen state is not a valid integer.

Reimplemented from bpp::AbstractAlphabet.

Definition at line 52 of file DNA.cpp.

References bpp::NucleicAlphabetState::getBinaryCode().

◆ isUnresolved() [1/2]

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

Implements bpp::Alphabet.

Definition at line 241 of file NucleicAlphabet.h.

References bpp::LetterAlphabet::charToInt().

◆ isUnresolved() [2/2]

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

Implements bpp::Alphabet.

Definition at line 240 of file NucleicAlphabet.h.

◆ operator=()

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

Definition at line 36 of file DNA.h.

References bpp::NucleicAlphabet::operator=().

◆ registerState()

void bpp::NucleicAlphabet::registerState ( AlphabetState st)
inlineprotectedvirtualinherited

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 55 of file NucleicAlphabet.h.

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

◆ remap()

void bpp::AbstractAlphabet::remap ( )
inlineprotectedinherited

Re-update the maps using the alphabet_ vector content.

Definition at line 231 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 226 of file AbstractAlphabet.h.

References bpp::AbstractAlphabet::alphabet_.

◆ setState()

void bpp::NucleicAlphabet::setState ( size_t  pos,
AlphabetState st 
)
inlineprotectedvirtualinherited

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

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

◆ subtract() [1/2]

std::string bpp::NucleicAlphabet::subtract ( const std::string &  s1,
const std::string &  s2 
) const
inlineinherited

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 valid.
Returns
The remaining state as a string
Author
Sylvain Gaillard

Definition at line 173 of file NucleicAlphabet.h.

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

◆ subtract() [2/2]

int bpp::NucleicAlphabet::subtract ( int  s1,
int  s2 
) const
inlineinherited

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 valid.
Returns
The remaining state as an int
Author
Sylvain Gaillard

Definition at line 148 of file NucleicAlphabet.h.

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

Referenced by bpp::NucleicAlphabet::subtract().

◆ updateBinMaps_()

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

◆ updateMaps_()

void AbstractAlphabet::updateMaps_ ( size_t  pos,
const AlphabetState st 
)
privateinherited

Update the private maps letters_ and nums_ when adding a state.

Parameters
posThe index of the state in the alphabet_ vector.
stThe state that has been added or modified

Definition at line 22 of file AbstractAlphabet.cpp.

References bpp::AlphabetState::getLetter(), and bpp::AlphabetState::getNum().

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

Member Data Documentation

◆ alphabet_

◆ binCodes_

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

◆ caseSensitive_

bool bpp::LetterAlphabet::caseSensitive_
privateinherited

◆ charList_

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

Definition at line 63 of file AbstractAlphabet.h.

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

◆ intList_

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

Definition at line 64 of file AbstractAlphabet.h.

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

◆ LETTER_UNDEF_VALUE

const int LetterAlphabet::LETTER_UNDEF_VALUE = -99
staticprivateinherited

Definition at line 29 of file LetterAlphabet.h.

Referenced by bpp::LetterAlphabet::isCharInAlphabet().

◆ letters_

◆ nums_

std::map<int, size_t> bpp::AbstractAlphabet::nums_
privateinherited

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