bpp-seq3  3.0.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)
 This checks that all characters in the alphabet are coded by a string of same length. More...
 
static bool checkAlphabetCodingSize (const Alphabet *alphabet)
 This checks that all characters in the alphabet are coded by a string of same length. More...
 
static unsigned int getAlphabetCodingSize (const Alphabet &alphabet)
 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)
 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 isIntegerAlphabet (const Alphabet &alphabet)
 
static bool isDefaultAlphabet (const Alphabet &alphabet)
 
static bool isAllelicAlphabet (const Alphabet &alphabet)
 
static bool match (std::shared_ptr< const Alphabet > alphabet, int i, int j)
 Tell if two characters match according to a given alphabet. More...
 

Static Public Attributes

static std::shared_ptr< const DNADNA_ALPHABET = make_shared<const DNA>()
 
static std::shared_ptr< const RNARNA_ALPHABET = make_shared<const RNA>()
 
static std::shared_ptr< const CodonAlphabetDNA_CODON_ALPHABET = make_shared<const CodonAlphabet>(dynamic_pointer_cast<const NucleicAlphabet>(DNA_ALPHABET))
 
static std::shared_ptr< const CodonAlphabetRNA_CODON_ALPHABET = make_shared<const CodonAlphabet>(dynamic_pointer_cast<const NucleicAlphabet>(RNA_ALPHABET))
 
static std::shared_ptr< const ProteicAlphabetPROTEIN_ALPHABET = make_shared<const ProteicAlphabet>()
 
static std::shared_ptr< const DefaultAlphabetDEFAULT_ALPHABET = make_shared<const DefaultAlphabet>()
 

Static Private Member Functions

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

Detailed Description

Utilitary functions dealing with alphabets.

Definition at line 31 of file AlphabetTools.h.

Constructor & Destructor Documentation

◆ AlphabetTools()

bpp::AlphabetTools::AlphabetTools ( )
inline

Definition at line 42 of file AlphabetTools.h.

◆ ~AlphabetTools()

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

Definition at line 43 of file AlphabetTools.h.

Member Function Documentation

◆ alphabetInheritsFrom()

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

Definition at line 201 of file AlphabetTools.h.

◆ checkAlphabetCodingSize() [1/2]

bool AlphabetTools::checkAlphabetCodingSize ( const Alphabet alphabet)
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 57 of file AlphabetTools.cpp.

References bpp::AlphabetState::getNum(), bpp::Alphabet::getNumberOfChars(), bpp::Alphabet::getNumberOfTypes(), bpp::Alphabet::getStateAt(), and bpp::Alphabet::intToChar().

◆ checkAlphabetCodingSize() [2/2]

bool AlphabetTools::checkAlphabetCodingSize ( const Alphabet alphabet)
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 73 of file AlphabetTools.cpp.

◆ getAlphabetCodingSize() [1/2]

unsigned int AlphabetTools::getAlphabetCodingSize ( const Alphabet alphabet)
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 80 of file AlphabetTools.cpp.

References bpp::Alphabet::intToChar().

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

◆ getAlphabetCodingSize() [2/2]

unsigned int AlphabetTools::getAlphabetCodingSize ( const Alphabet alphabet)
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 89 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 28 of file AlphabetTools.cpp.

References bpp::TextTools::toString().

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

◆ isAllelicAlphabet()

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

Definition at line 171 of file AlphabetTools.h.

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

◆ isBinaryAlphabet()

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

Definition at line 153 of file AlphabetTools.h.

◆ isCodonAlphabet()

◆ isDefaultAlphabet()

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

Definition at line 165 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 instantiation of the DNA class.
Parameters
alphabetThe alphabet to check.

Definition at line 117 of file AlphabetTools.h.

Referenced by bpp::SequenceTools::complement(), bpp::SequenceTools::getComplement(), bpp::SequenceTools::invertComplement(), bpp::RNY::RNY(), bpp::SequenceTools::RNYslice(), and bpp::SequenceTools::transcript().

◆ isIntegerAlphabet()

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

Definition at line 159 of file AlphabetTools.h.

◆ isNucleicAlphabet()

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

Definition at line 111 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

◆ isRNAAlphabet()

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

Definition at line 123 of file AlphabetTools.h.

Referenced by bpp::SequenceTools::complement(), bpp::SequenceTools::getComplement(), bpp::SequenceTools::invertComplement(), bpp::SequenceTools::reverseTranscript(), and bpp::RNY::RNY().

◆ isRNYAlphabet()

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

Definition at line 147 of file AlphabetTools.h.

Referenced by bpp::SequenceApplicationTools::getProbabilisticSiteContainer(), and bpp::SequenceApplicationTools::getSiteContainer().

◆ isWordAlphabet()

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

Definition at line 141 of file AlphabetTools.h.

◆ match()

static bool bpp::AlphabetTools::match ( std::shared_ptr< 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 191 of file AlphabetTools.h.

References bpp::VectorTools::vectorIntersection().

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

Member Data Documentation

◆ DEFAULT_ALPHABET

shared_ptr< const DefaultAlphabet > AlphabetTools::DEFAULT_ALPHABET = make_shared<const DefaultAlphabet>()
static

Definition at line 39 of file AlphabetTools.h.

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

◆ DNA_ALPHABET

shared_ptr< const DNA > AlphabetTools::DNA_ALPHABET = make_shared<const DNA>()
static

Definition at line 34 of file AlphabetTools.h.

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

◆ DNA_CODON_ALPHABET

shared_ptr< const CodonAlphabet > AlphabetTools::DNA_CODON_ALPHABET = make_shared<const CodonAlphabet>(dynamic_pointer_cast<const NucleicAlphabet>(DNA_ALPHABET))
static

Definition at line 36 of file AlphabetTools.h.

◆ PROTEIN_ALPHABET

shared_ptr< const ProteicAlphabet > AlphabetTools::PROTEIN_ALPHABET = make_shared<const ProteicAlphabet>()
static

Definition at line 38 of file AlphabetTools.h.

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

◆ RNA_ALPHABET

shared_ptr< const RNA > AlphabetTools::RNA_ALPHABET = make_shared<const RNA>()
static

Definition at line 35 of file AlphabetTools.h.

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

◆ RNA_CODON_ALPHABET

shared_ptr< const CodonAlphabet > AlphabetTools::RNA_CODON_ALPHABET = make_shared<const CodonAlphabet>(dynamic_pointer_cast<const NucleicAlphabet>(RNA_ALPHABET))
static

Definition at line 37 of file AlphabetTools.h.


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