Generated on Tue Dec 16 12:50:02 2008 for BIU-2.2.0 by doxygen 1.5.1

biu::Alphabet Class Reference

#include <Alphabet.hh>


Detailed Description

This class handels an alphabet for the sequence.

Each member of the alphabet maps to an unique int index.

Author:
Martin Mann, Sebastian Will, Andreas Richter

Definition at line 18 of file Alphabet.hh.

Public Types

typedef size_t AlphElem
typedef unsigned char CAlphElem
typedef std::vector< CAlphElemCSequence
typedef std::vector< AlphElemSequence

Public Member Functions

 Alphabet (const std::vector< std::string > &alphabetStrings)
 Alphabet (const std::string &alphabetString, const size_t elementLength)
CSequence compress (const Alphabet::Sequence &sequence) const
CSequence compressS (const std::string &sequence) const
Sequence decompress (const CSequence &sequence, const size_t seqLength) const
std::string decompressS (const CSequence &sequence, const size_t seqLength) const
size_t getAlphabetSize () const
AlphElem getElement (const size_t index) const
AlphElem getElement (const std::string &alphElemStr) const
size_t getElementLength () const
size_t getIndex (const std::string &elemStr) const
size_t getIndex (const AlphElem &elem) const
Sequence getSequence (const std::string &seqString) const
std::string getString (const Alphabet::AlphElem &elem) const
std::string getString (const Alphabet::Sequence &sequence) const
bool isAlphabetSequence (const Sequence &seq) const
bool isAlphabetString (const std::string &str) const
bool operator!= (const Alphabet &alph2) const
bool operator== (const Alphabet &alph2) const
virtual ~Alphabet ()

Private Types

typedef __gnu_cxx::hash_map<
std::string, AlphElem, hash_string
STR2ALPH_MAP

Private Attributes

std::vector< std::string > alph2string
std::vector< int > compressBase
size_t elementLength
STR2ALPH_MAP string2alph

Data Structures

class  hash_string


Member Typedef Documentation

typedef size_t biu::Alphabet::AlphElem

The internal representation of an alphabet element.

Definition at line 22 of file Alphabet.hh.

typedef unsigned char biu::Alphabet::CAlphElem

The internal representation of a compressed alphabet element.

Definition at line 24 of file Alphabet.hh.

typedef std::vector<CAlphElem> biu::Alphabet::CSequence

The internal representation of a compressed sequence of alphabet elements.

Definition at line 30 of file Alphabet.hh.

typedef std::vector<AlphElem> biu::Alphabet::Sequence

The internal representation of a sequence of alphabet elements.

Definition at line 27 of file Alphabet.hh.

typedef __gnu_cxx::hash_map< std::string, AlphElem, hash_string > biu::Alphabet::STR2ALPH_MAP [private]

Definition at line 55 of file Alphabet.hh.


Constructor & Destructor Documentation

biu::Alphabet::Alphabet ( const std::string &  alphabetString,
const size_t  elementLength 
)

Initialises an Alphabet object with the string representations given by the alphabetString. The string is members given in alphabetString.

The string it sliced into substrings of the length elementLength_ , therefor all alphabet elements have to have the same length.

biu::Alphabet::Alphabet ( const std::vector< std::string > &  alphabetStrings  ) 

Construct an alphabet from a vector of strings

The indexing of elements in the vector has to be preserved by the alphabet

virtual biu::Alphabet::~Alphabet (  )  [virtual]


Member Function Documentation

CSequence biu::Alphabet::compress ( const Alphabet::Sequence sequence  )  const

Compresses a sequence.

Parameters:
sequence the sequence to compress
Returns:
the compressed sequence representation

CSequence biu::Alphabet::compressS ( const std::string &  sequence  )  const

Compresses a string.

Parameters:
sequence the string to compress
Returns:
the compressed sequence representation

Sequence biu::Alphabet::decompress ( const CSequence sequence,
const size_t  seqLength 
) const

Decompresses a sequence.

Parameters:
sequence the sequence to decompress
seqLength the length of the uncompressed sequence encoded
Returns:
the sequence that was compressed

std::string biu::Alphabet::decompressS ( const CSequence sequence,
const size_t  seqLength 
) const

Decompresses a sequence and generates directely a string.

Parameters:
sequence the sequence to decompress
seqLength the length of the uncompressed sequence encoded
Returns:
the string that was compressed

size_t biu::Alphabet::getAlphabetSize (  )  const

Returns the size of the alphabet.

Returns:
the number of elements in the alphabet

AlphElem biu::Alphabet::getElement ( const size_t  index  )  const

Returns the corresponding AlphElem to the index.

Parameters:
index alphabet element index (has to be < getAlphabetSize())
Returns:
the indexed element

AlphElem biu::Alphabet::getElement ( const std::string &  alphElemStr  )  const

Returns the index the alphabet member maps to.

Parameters:
alphElemStr the string to encode
Returns:
internal representation of the alphabet element string

size_t biu::Alphabet::getElementLength (  )  const

Returns the length of a alphabet element.

Returns:
the string length of one alphabet element

size_t biu::Alphabet::getIndex ( const std::string &  elemStr  )  const

Returns the internal index of the AlphElem corresponding to the string. The index starts with 0 and is < getAlphabetSize()

Parameters:
elemStr the alphabet element string to get the index for
Returns:
the index of this element

size_t biu::Alphabet::getIndex ( const AlphElem elem  )  const

Returns the internal index of the AlphElem. The index starts with 0 and is < getAlphabetSize()

Parameters:
elem the alphabet element to get the index for
Returns:
the index of this element

Sequence biu::Alphabet::getSequence ( const std::string &  seqString  )  const

Returns an internal sequence representation of the string.

Parameters:
seqString the string to encode
Returns:
the encoded sequence

std::string biu::Alphabet::getString ( const Alphabet::AlphElem elem  )  const

Returns the string representation of the alphabet member.

Parameters:
elem the internal alphabet element representation
Returns:
the string encoded by the element

std::string biu::Alphabet::getString ( const Alphabet::Sequence sequence  )  const

Converts an internal sequence representation into a string.

Parameters:
sequence the sequence to decode
Returns:
the string encoded by the sequence

bool biu::Alphabet::isAlphabetSequence ( const Sequence seq  )  const

Returns whether or not a sequencec contains only elements compatible with the alphabet or not

Parameters:
seq the sequence to check
Returns:
true if the sequence is valid for this alphabet, false otherwise

bool biu::Alphabet::isAlphabetString ( const std::string &  str  )  const

Returns whether or not a string contains only elements of the alphabet or not

Parameters:
str the string to check
Returns:
true if the string is valid for this alphabet, false otherwise

bool biu::Alphabet::operator!= ( const Alphabet alph2  )  const

bool biu::Alphabet::operator== ( const Alphabet alph2  )  const


Field Documentation

std::vector<std::string> biu::Alphabet::alph2string [private]

a mapping from alphabet elements to their string representation

Definition at line 65 of file Alphabet.hh.

std::vector<int> biu::Alphabet::compressBase [private]

Holds the multiplyer for the ith position of a sequence when compressed into a CSequence. Each CAlphElem can encode compressBase.size() many AlphElem elements.

Definition at line 73 of file Alphabet.hh.

size_t biu::Alphabet::elementLength [private]

the length of a string representation of an alphabet element.

Definition at line 68 of file Alphabet.hh.

a mapping from a string representation to the corresponding alphabet element

Definition at line 62 of file Alphabet.hh.


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