Version 4.0.0
Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

Translator Class Reference

Alphabet designer tool. More...

#include <seqpp/Translator.h>

List of all members.

Public Member Functions

 Translator (const string &alpha_file)
 Constructor from a configuration file.
 Translator (const string &line2parse, short mode, bool case_sensivity=true)
 Constructor from an expression.
 Translator (const Translator &t)
 Copy constructor.
 Translator ()
 Default constructor.
 ~Translator ()
 Destructor.
short tell_alphabet_size () const
 Returns alphabet size.
short tell_nb_inv () const
 Return the number of invalid code.
short tell_alphabet_mode () const
 Return alphabet mode, the number of characters of a token.
bool is_complementary_ok () const
 Checks if complementary codes are defined.
bool is_label_ok () const
 Checks if labels are defined.
short int char_to_int (const char *source) const
 Returns the int code for a given char *.
short int str_to_int (const string &source) const
 Returns the int code for a given string.
short complementary_char_to_int (const char *source) const
 Returns the complementary int code for a given char *.
short int complementary_str_to_int (const string &source) const
 Returns the complementary int code for a given string.
short complementary_int (short source) const
 Returns the complementary int code for a given code.
void int_to_char (char *dest, short source) const
 Initialize dest to the word corresponding to the int source.
string int_to_str (short source) const
 returns the word corresponding to the int source
void complementary_char (char *dest, const char *source) const
 Initialize dest to the word corresponding to the complementary of word source.
string complementary_str (const string &source) const
 returns the token corresponding to the inverse complementary of a token source
string complementary_int_to_str (short source) const
 returns the string corresponding to the complementary of int source
string complementary_strw (const string &wordsource) const
 returns the inverse complementary string-word of source
void vect_to_word (char *worddest, const short *vectsource, short sizeword) const
 a char-word <- an int-vect
void vect_to_word (char *worddest, const vector< short > &vectsource) const
 a char-word <- an int-vect
string vect_to_strw (const short *vectsource, short sizeword) const
 a string-word <- an int-vect
string vect_to_strw (const vector< short > &vectsource) const
 a string-word <- an int-vect
void word_to_vect (short *vectdest, const char *wordsource, short sizeword) const
 a char-word -> an int-vect
void word_to_vect (vector< short > &vectdest, const char *wordsource) const
 a char-word -> an int-vect
void strw_to_vect (vector< short > &vectdest, const string &wordsource) const
 a char-word -> an int-vect
long word_to_coded_int (const char *wordsource, int &l) const
 a char-word -> an int code (base alphabet_size)
long strw_to_coded_int (const string &wordsource) const
 a string-word -> an int code (base alphabet_size)
long complementary_coded_int (long codesource, short sizeword) const
 Returns the complementary int code for a given coded int.
short isInvalid (const char *source) const
 checks if source is invalid
short isInvalid (const string &source) const
 checks if source is invalid
string int_to_label (short source) const
 returns the label corresponding to the source
string vect_to_labelstrw (const vector< short > &vectsource) const
 a string-word of label <- an int-vect

Protected Attributes

short _alphabet_size
 number of tokens describing the alphabet
short _alphabet_mode
 number of characters of each token
short _nb_inv
 number of invalid tokens
bool _complementary_ok
 checks if complementary is defined
bool _label_ok
 checks if labels are defined


Detailed Description

Alphabet designer tool.

The key of the seq++ flexibility is the translator object. It defines a mapping between the alphabet and integer values. In seq++, a letter of an alphabet, called a token, can be made of one or more characters, for instance to manage n-uplets like codons. It is associated to its rank integer position in the alphabet.
A simple configuration file is required, containing synonymous tokens, complementary tokens (if exist) and labels. A label aims to be the explicit name of a token. Moreover, invalid tokens can be declared and associated to negative values.

Use a initial file containing same size(alphabet_mode characters) tokens (the letters of the alphabet)

exple :

  #codons
  ttt TTT -> F1
  ttc TTC -> F2
  tta TTA -> L1
  ...
  ggg GGG -> G4
  ? taa TAA tag TAG tga TGA  
  #dna
  a A : t T
  g G : c C
  c C : g G
  t T : a A
  ? n N
#secondary structures
  H -> HELIX
  B -> BETA
  C -> COIL
OR
Use an expression to parse ("line2parse") where all the same size ("mode") tokens are concatened, with a ":" to define the inverse complementary with same size tokens. No synonyms supported. exple :
  acgt:tgca         # dna alphabet, mode = 1
  R1R2T1T2T3X1Y1Y2  # other alphabet, with mode = 2 (R1 is the first token...)


Constructor & Destructor Documentation

Translator::Translator const string &  alpha_file  ) 
 

Constructor from a configuration file.

Parameters:
alpha_file configuration file

Translator::Translator const string &  line2parse,
short  mode,
bool  case_sensivity = true
 

Constructor from an expression.

Parameters:
line2parse alphabet expression
mode number of characters of a token
case_sensivity false if no case sensitivity required


Member Function Documentation

short int Translator::char_to_int const char *  source  )  const
 

Returns the int code for a given char *.

Parameters:
source pointer to the first character of a token to translate in int Beware that source must be the beginning of a word of size _alphabet_mode, or -1 is returned

void Translator::complementary_char char *  dest,
const char *  source
const [inline]
 

Initialize dest to the word corresponding to the complementary of word source.

Parameters:
dest must be allocated with _alphabet_mode+1 space, empty word if bad query.
source pointer to the first position of the source token

short int Translator::complementary_char_to_int const char *  source  )  const
 

Returns the complementary int code for a given char *.

Parameters:
source pointer to the first character of a token to complementary translate in int Beware that source must be the beginning of a word of size _alphabet_mode, or -1 is returned

short Translator::complementary_int short  source  )  const [inline]
 

Returns the complementary int code for a given code.

Parameters:
source integer code

short int Translator::complementary_str_to_int const string &  source  )  const
 

Returns the complementary int code for a given string.

Parameters:
source string-token to complementary translate in int

void Translator::int_to_char char *  dest,
short  source
const
 

Initialize dest to the word corresponding to the int source.

Parameters:
dest must be allocated with _alphabet_mode+1 space, empty word if bad query.
source integer to translate

short int Translator::str_to_int const string &  source  )  const
 

Returns the int code for a given string.

Parameters:
source string-token to translate in int

long Translator::strw_to_coded_int const string &  wordsource  )  const
 

a string-word -> an int code (base alphabet_size)

Parameters:
wordsource word to code

void Translator::strw_to_vect vector< short > &  vectdest,
const string &  wordsource
const
 

a char-word -> an int-vect

a string-word -> an int-vect

void Translator::vect_to_word char *  worddest,
const short *  vectsource,
short  sizeword
const
 

a char-word <- an int-vect

Parameters:
worddest word (must be allocated sizeword*_alphabet_mode + 1 space) corresponding to the sequential translation of source
vectsource vector of integer to translate
sizeword size of the vectsource to translate

long Translator::word_to_coded_int const char *  wordsource,
int &  l
const
 

a char-word -> an int code (base alphabet_size)

Parameters:
wordsource pointer to the character word to code
l its length

void Translator::word_to_vect short *  vectdest,
const char *  wordsource,
short  sizeword
const
 

a char-word -> an int-vect

Parameters:
vectdest integer vector (must be sizeword-allocated)
wordsource character word to sequentially translate
sizeword size of the word


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



Download seq++ 4.0.0
Download previous versions
Statistique & Genome Home


Generated on Sun Apr 3 14:16:10 2005 for seqpp by doxygen 1.3.9.1