bpp-seq  2.2.0
bpp::AlphabetTools Class Reference

Utilitary functions dealing with alphabets. More...

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

+ Collaboration diagram for bpp::AlphabetTools:

Public Member Functions

 AlphabetTools ()
 
virtual ~AlphabetTools ()
 

Static Public Member Functions

static int getType (char state)
 Character identification method for sequence's alphabet identification. More...
 
static bool checkAlphabetCodingSize (const Alphabet &alphabet) throw (AlphabetException)
 This checks that all characters in the alphabet are coded by a string of same length. More...
 
static bool checkAlphabetCodingSize (const Alphabet *alphabet) throw (AlphabetException)
 This checks that all characters in the alphabet are coded by a string of same length. More...
 
static unsigned int getAlphabetCodingSize (const Alphabet &alphabet) throw (AlphabetException)
 In case that all states in the given alphabet have a string description of same length, send this length; e.g. 3 for codon alphabets. More...
 
static unsigned int getAlphabetCodingSize (const Alphabet *alphabet) throw (AlphabetException)
 In case that all states in the given alphabet have a string description of same length, send this length; e.g. 3 for codon alphabets. More...
 
static bool isNucleicAlphabet (const Alphabet *alphabet)
 
static bool isDNAAlphabet (const Alphabet *alphabet)
 
static bool isRNAAlphabet (const Alphabet *alphabet)
 
static bool isProteicAlphabet (const Alphabet *alphabet)
 
static bool isCodonAlphabet (const Alphabet *alphabet)
 
static bool isWordAlphabet (const Alphabet *alphabet)
 
static bool isRNYAlphabet (const Alphabet *alphabet)
 
static bool isBinaryAlphabet (const Alphabet *alphabet)
 
static bool isDefaultAlphabet (const Alphabet *alphabet)
 
static bool match (const Alphabet *alphabet, int i, int j)
 Tell if two characters match according to a given alphabet. More...
 

Static Public Attributes

static const DNA DNA_ALPHABET
 
static const RNA RNA_ALPHABET
 
static const ProteicAlphabet PROTEIN_ALPHABET
 
static const DefaultAlphabet DEFAULT_ALPHABET
 

Static Private Member Functions

template<class Y >
static bool alphabetInheritsFrom (const Alphabet *alphabet)
 

Detailed Description

Utilitary functions dealing with alphabets.

Definition at line 59 of file AlphabetTools.h.

Constructor & Destructor Documentation

◆ AlphabetTools()

bpp::AlphabetTools::AlphabetTools ( )
inline

Definition at line 68 of file AlphabetTools.h.

◆ ~AlphabetTools()

virtual bpp::AlphabetTools::~AlphabetTools ( )
inlinevirtual

Definition at line 69 of file AlphabetTools.h.

Member Function Documentation

◆ alphabetInheritsFrom()

template<class Y >
static bool bpp::AlphabetTools::alphabetInheritsFrom ( const Alphabet alphabet)
inlinestaticprivate

Definition at line 215 of file AlphabetTools.h.

◆ checkAlphabetCodingSize() [1/2]

bool AlphabetTools::checkAlphabetCodingSize ( const Alphabet alphabet)
throw (AlphabetException
)
static

This checks that all characters in the alphabet are coded by a string of same length.

This method is used when states are coded by more than one character, typically: codon alphabets.

Parameters
alphabetThe alphabet to check.
Returns
True if all text description have the same length (e.g. 3 for codon alphabet).

Definition at line 89 of file AlphabetTools.cpp.

◆ checkAlphabetCodingSize() [2/2]

bool AlphabetTools::checkAlphabetCodingSize ( const Alphabet alphabet)
throw (AlphabetException
)
static

This checks that all characters in the alphabet are coded by a string of same length.

This function performs the same work as the previous one, but deals with pointers instead of reference. This may be more convenient since we often use pointers on alphabets.

Parameters
alphabeta pointer toward the alphabet to check.
Returns
True if all text description have the same length (e.g. 3 for codon alphabet).

Definition at line 104 of file AlphabetTools.cpp.

◆ getAlphabetCodingSize() [1/2]

unsigned int AlphabetTools::getAlphabetCodingSize ( const Alphabet alphabet)
throw (AlphabetException
)
static

In case that all states in the given alphabet have a string description of same length, send this length; e.g. 3 for codon alphabets.

Parameters
alphabetThe alphabet to analyse.
Returns
The common size of all text descriptionif there is one. Else throws an AlphabetException.

Definition at line 111 of file AlphabetTools.cpp.

Referenced by bpp::StringSequenceTools::codeSequence().

◆ getAlphabetCodingSize() [2/2]

unsigned int AlphabetTools::getAlphabetCodingSize ( const Alphabet alphabet)
throw (AlphabetException
)
static

In case that all states in the given alphabet have a string description of same length, send this length; e.g. 3 for codon alphabets.

This function performs the same work as the previous one, but deals with pointers instead of reference. This may be more convenient since we often use pointers on alphabets.

Parameters
alphabeta pointer toward the alphabet to analyse.
Returns
The common size of all text descriptionif there is one. Else throws an AlphabetException.

Definition at line 120 of file AlphabetTools.cpp.

◆ getType()

int AlphabetTools::getType ( char  state)
static

Character identification method for sequence's alphabet identification.

Return :

  • -1 gap
  • 1 DNA specific (no character!)
  • 2 RNA specific (U)
  • 3 Protein specific (characters E, F, I, L, P, Q)
  • 4 Nucleotide specific (no character)
  • 5 DNA or Protein specific (T)
  • 6 RNA or Protein specific (no character)
  • 7 Any alphabet (A, B, C, D, G, H, J, K, M, N, O, R, S, V, W, X, Y, Z, 0)
  • 0 Unknown character
Parameters
stateThe character to test.
Returns
The type code.

Definition at line 60 of file AlphabetTools.cpp.

Referenced by bpp::StringSequenceTools::getAlphabetFromSequence().

◆ isBinaryAlphabet()

static bool bpp::AlphabetTools::isBinaryAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the BinaryAlphabet class.
Parameters
alphabetThe alphabet to check.

Definition at line 179 of file AlphabetTools.h.

◆ isCodonAlphabet()

◆ isDefaultAlphabet()

static bool bpp::AlphabetTools::isDefaultAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the DefaultAlphabet class.
Parameters
alphabetThe alphabet to check.

Definition at line 185 of file AlphabetTools.h.

Referenced by bpp::SiteContainerTools::resolveDottedAlignment().

◆ isDNAAlphabet()

static bool bpp::AlphabetTools::isDNAAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the DNA class.
Parameters
alphabetThe alphabet to check.

Definition at line 143 of file AlphabetTools.h.

Referenced by bpp::RNY::RNY().

◆ isNucleicAlphabet()

static bool bpp::AlphabetTools::isNucleicAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the NucleicAlphabet class.
Parameters
alphabetThe alphabet to check.

Definition at line 137 of file AlphabetTools.h.

Referenced by bpp::SequenceApplicationTools::getAlphabet(), bpp::GeneticCode::getCodingSequence(), and bpp::RNY::getRNY().

◆ isProteicAlphabet()

static bool bpp::AlphabetTools::isProteicAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the ProteicAlphabet class.
Parameters
alphabetThe alphabet to check.

Definition at line 155 of file AlphabetTools.h.

Referenced by bpp::BppOAlphabetIndex1Format::read(), and bpp::BppOAlphabetIndex2Format::read().

◆ isRNAAlphabet()

static bool bpp::AlphabetTools::isRNAAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the RNA class.
Parameters
alphabetThe alphabet to check.

Definition at line 149 of file AlphabetTools.h.

◆ isRNYAlphabet()

static bool bpp::AlphabetTools::isRNYAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the RNY class.
Parameters
alphabetThe alphabet to check.

Definition at line 173 of file AlphabetTools.h.

Referenced by bpp::SequenceApplicationTools::getSiteContainer().

◆ isWordAlphabet()

static bool bpp::AlphabetTools::isWordAlphabet ( const Alphabet alphabet)
inlinestatic
Returns
True if the alphabet is an instanciation of the WordAlphabet class.
Parameters
alphabetThe alphabet to check.

Definition at line 167 of file AlphabetTools.h.

◆ match()

static bool bpp::AlphabetTools::match ( const Alphabet alphabet,
int  i,
int  j 
)
inlinestatic

Tell if two characters match according to a given alphabet.

Example (DNA):

* A,T: false
* A,A: true
* A,N: true
* A,Y: false
* N,Y: true
* N,N: true
* 
Returns
True if the two characters are identical, or are compatible if at least one of them is a generic character.
Parameters
alphabetThe alphabet to use.
iFirst character to check.
jSecondt character to check.

Definition at line 205 of file AlphabetTools.h.

References bpp::Alphabet::getAlias().

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

Member Data Documentation

◆ DEFAULT_ALPHABET

const DefaultAlphabet AlphabetTools::DEFAULT_ALPHABET
static

Definition at line 65 of file AlphabetTools.h.

Referenced by bpp::NexusIOSequence::appendAlignmentFromStream().

◆ DNA_ALPHABET

const DNA AlphabetTools::DNA_ALPHABET
static

Definition at line 62 of file AlphabetTools.h.

◆ PROTEIN_ALPHABET

◆ RNA_ALPHABET

const RNA AlphabetTools::RNA_ALPHABET
static

Definition at line 63 of file AlphabetTools.h.


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