Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Compound Members File Members

# gnTranslator Class Reference

The gnTranslator class facilitates the translation of ambiguous DNA and RNA sequences to protein sequence. More...

`#include <gnTranslator.h>`

Inheritance diagram for gnTranslator:

List of all members.

## Public Types
enum | gnTranslatorType { ProteinDNATranslatorType, ProteinRNATranslatorType, DNAProteinTranslatorType, RNAProteinTranslatorType }
## Public Member Functions
| gnTranslator ()
| gnTranslator (gnTranslatorType t_type)
| gnTranslator (const gnTranslator &sf)
gnTranslator * | Clone () const
virtual gnSeqC | Filter (const gnSeqC ch) const
| Filter the given character.
virtual void | Filter (gnSeqC **seq, uint32 &len) const
| Filter the given character array.
virtual void | Filter (string &seq) const
| Filters the given string.
void | SetDefaultChar (const gnSeqC ch1)
| Sets the default character to insert when no valid translation exists.
gnSeqC | GetDefaultChar () const
| Gets the default character which is inserted into the destination sequence when no valid translation exists.
void | UseDefaultChar (const boolean use=true)
| Set whether the default character is inserted upon translation failure.
void | SetDefaultInputWidth (const uint32 defaultInputWidth)
| Set the expected number of characters in each unit of translation.
uint32 | GetDefaultInputWidth () const
| Get the expected number of characters in each unit of translation.
void | SetPair (const string &input, const string &output)
| Set a translation mapping.
void | RemovePair (const string &input)
| Removes a translation mapping.
void | SetCompare (const gnCompare *comp)
| Set the comparator to use.
virtual string | GetName () const
| Gets the name of this filter.
virtual void | SetName (string name)
| Sets the name of this filter.
## Static Public Member Functions
const gnTranslator * | ProteinDNATranslator ()
const gnTranslator * | ProteinRNATranslator ()
const gnTranslator * | DNAProteinTranslator ()
const gnTranslator * | RNAProteinTranslator ()
## Protected Attributes
string | m_name
## Private Member Functions
void | CreateProteinDNATranslator ()
void | CreateProteinRNATranslator ()
void | CreateDNAProteinTranslator ()
void | CreateRNAProteinTranslator ()
## Private Attributes
vector< string > | m_inputTable
vector< string > | m_outputTable
const gnCompare * | compare
boolean | use_default
gnSeqC | m_defaultChar
uint32 | m_defaultInputWidth

## Detailed Description

The gnTranslator class facilitates the translation of ambiguous DNA and RNA sequences to protein sequence.

It can also perform reverse translation from Protein to RNA or DNA though the utility of this functionality is somewhat questionable since it does not assign nucleotides probabilistically. Do not attempt to instantiate this class unless you are defining a new translation type. Instead use the static member access functions ProteinDNATranslator(), ProteinRNATranslator(), DNAProteinTranslator(), and RNAProteinTranslator() In general, the gnFastTranslator class should be used instead of this one.

See also:
  gnFastTranslator

Definition at line 36 of file gnTranslator.h.

## Member Enumeration Documentation

enum gnTranslator::gnTranslatorType

  | Enumeration values:
  ProteinDNATranslatorType |
  ProteinRNATranslatorType |
  DNAProteinTranslatorType |
  RNAProteinTranslatorType |
Definition at line 45 of file gnTranslator.h.

## Constructor & Destructor Documentation

gnTranslator::gnTranslator | ( |  | ) |

| Definition at line 34 of file gnTranslator.cpp. References m_defaultChar, m_defaultInputWidth, and use_default. Referenced by Clone(), DNAProteinTranslator(), ProteinDNATranslator(), ProteinRNATranslator(), and RNAProteinTranslator().

gnTranslator::gnTranslator | ( | gnTranslatorType | t_type | ) |

| Definition at line 51 of file gnTranslator.cpp. References CreateDNAProteinTranslator(), CreateProteinDNATranslator(), CreateProteinRNATranslator(), CreateRNAProteinTranslator(), DNAProteinTranslatorType, m_defaultChar, ProteinDNATranslatorType, ProteinRNATranslatorType, RNAProteinTranslatorType, and use_default.

gnTranslator::gnTranslator | ( | const gnTranslator & | sf | ) |

| Definition at line 41 of file gnTranslator.cpp. References compare, m_defaultChar, m_defaultInputWidth, m_inputTable, gnBaseFilter::m_name, m_outputTable, and use_default.

## Member Function Documentation

gnTranslator * gnTranslator::Clone | ( |  | ) | const`[inline, virtual]`

| Implements gnBaseFilter. Definition at line 134 of file gnTranslator.h. References gnTranslator().

void gnTranslator::CreateDNAProteinTranslator | ( |  | ) | `[private]`

| Definition at line 224 of file gnTranslator.cpp. References m_defaultInputWidth, SetCompare(), SetDefaultChar(), gnBaseFilter::SetName(), SetPair(), and use_default. Referenced by gnTranslator().

void gnTranslator::CreateProteinDNATranslator | ( |  | ) | `[private]`

| Definition at line 160 of file gnTranslator.cpp. References m_defaultInputWidth, SetCompare(), SetDefaultChar(), gnBaseFilter::SetName(), and SetPair(). Referenced by gnTranslator().

void gnTranslator::CreateProteinRNATranslator | ( |  | ) | `[private]`

| Definition at line 192 of file gnTranslator.cpp. References m_defaultInputWidth, SetCompare(), SetDefaultChar(), gnBaseFilter::SetName(), and SetPair(). Referenced by gnTranslator().

void gnTranslator::CreateRNAProteinTranslator | ( |  | ) | `[private]`

| Definition at line 287 of file gnTranslator.cpp. References m_defaultInputWidth, SetCompare(), SetDefaultChar(), gnBaseFilter::SetName(), SetPair(), and use_default. Referenced by gnTranslator().

const gnTranslator * gnTranslator::DNAProteinTranslator | ( |  | ) | `[static]`

| Definition at line 24 of file gnTranslator.cpp. References gnTranslator().

void gnTranslator::Filter | ( | string & | seq | ) | const`[virtual]`

  | Filters the given string. Parameters:
  seq | The string to filter
Implements gnBaseFilter. Definition at line 112 of file gnTranslator.cpp. References compare, gnCompare::Contains(), m_defaultChar, m_defaultInputWidth, m_inputTable, m_outputTable, and uint32.

void gnTranslator::Filter | ( | gnSeqC ** | seq,
|  | uint32 & | len
| ) | const`[virtual]`

  | Filter the given character array. Parameters:
  seq | A pointer to the character array
  len | the length of the character array to filter
Returns: The filtered character Implements gnBaseFilter. Definition at line 81 of file gnTranslator.cpp. References compare, gnCompare::Contains(), gnSeqC, m_defaultChar, m_defaultInputWidth, m_inputTable, m_outputTable, and uint32.

gnSeqC gnTranslator::Filter | ( | const gnSeqC | ch | ) | const`[virtual]`

  | Filter the given character. Parameters:
  ch | The character to filter
Returns: The filtered character Implements gnBaseFilter. Definition at line 72 of file gnTranslator.cpp. References compare, gnCompare::Contains(), gnSeqC, m_defaultChar, m_inputTable, m_outputTable, and uint32. Referenced by gnFastTranslator::CacheTranslator().

gnSeqC gnTranslator::GetDefaultChar | ( |  | ) | const`[inline]`

| Gets the default character which is inserted into the destination sequence when no valid translation exists. Returns: The default character Definition at line 146 of file gnTranslator.h. References gnSeqC, and m_defaultChar.

uint32 gnTranslator::GetDefaultInputWidth | ( |  | ) | const`[inline]`

| Get the expected number of characters in each unit of translation. For DNA to Protein, for instance, this is 3 because each codon is 3 characters of input. Returns: The expected input width Definition at line 163 of file gnTranslator.h. References m_defaultInputWidth, and uint32.

string gnBaseFilter::GetName | ( |  | ) | const`[inline, virtual, inherited]`

| Gets the name of this filter. Returns: the filter name Definition at line 65 of file gnBaseFilter.h. References gnBaseFilter::m_name.

const gnTranslator * gnTranslator::ProteinDNATranslator | ( |  | ) | `[static]`

| Definition at line 16 of file gnTranslator.cpp. References gnTranslator().

const gnTranslator * gnTranslator::ProteinRNATranslator | ( |  | ) | `[static]`

| Definition at line 20 of file gnTranslator.cpp. References gnTranslator().

void gnTranslator::RemovePair | ( | const string & | input | ) |

  | Removes a translation mapping. RemovePair removes the translation mapping corresponding to the given input string. Parameters:
  input | The input string to delete
Definition at line 149 of file gnTranslator.cpp. References m_inputTable, m_outputTable, and uint32.

const gnTranslator * gnTranslator::RNAProteinTranslator | ( |  | ) | `[static]`

| Definition at line 28 of file gnTranslator.cpp. References gnTranslator().

void gnTranslator::SetCompare | ( | const gnCompare * | comp | ) | `[inline]`

  | Set the comparator to use. Ambiguous base matching is facilitated using a gnCompare object. This must be set to allow sequences to be compared. Parameters:
  comp | A pointer to the gnCompare object to use.
Definition at line 168 of file gnTranslator.h. References compare. Referenced by CreateDNAProteinTranslator(), CreateProteinDNATranslator(), CreateProteinRNATranslator(), and CreateRNAProteinTranslator().

void gnTranslator::SetDefaultChar | ( | const gnSeqC | ch1 | ) | `[inline]`

  | Sets the default character to insert when no valid translation exists. Parameters:
  ch1 | The default character
Definition at line 140 of file gnTranslator.h. References m_defaultChar, and use_default. Referenced by CreateDNAProteinTranslator(), CreateProteinDNATranslator(), CreateProteinRNATranslator(), and CreateRNAProteinTranslator().

void gnTranslator::SetDefaultInputWidth | ( | const uint32 | defaultInputWidth | ) | `[inline]`

  | Set the expected number of characters in each unit of translation. For DNA to Protein, for instance, this is 3 because each codon is 3 characters of input. Parameters:
  defaultInputWidth | The expected input width
Definition at line 158 of file gnTranslator.h. References m_defaultInputWidth.

void gnBaseFilter::SetName | ( | string | name | ) | `[inline, virtual, inherited]`

  | Sets the name of this filter. Parameters:
  name | the new filter name
Definition at line 70 of file gnBaseFilter.h. References gnBaseFilter::m_name. Referenced by gnFilter::CreateAlphabetCharacterFilter(), gnFilter::CreateBasicDNAFilter(), gnFilter::CreateBasicRNAFilter(), gnFilter::CreateDNAComplementFilter(), CreateDNAProteinTranslator(), gnFilter::CreateDNAtoRNAFilter(), gnFilter::CreateFullDNAFilter(), gnFilter::CreateFullRNAFilter(), gnFilter::CreateNumberCharacterFilter(), CreateProteinDNATranslator(), gnFilter::CreateProteinFilter(), CreateProteinRNATranslator(), gnFilter::CreateRNAComplementFilter(), CreateRNAProteinTranslator(), and gnFilter::CreateRNAtoDNAFilter().

void gnTranslator::SetPair | ( | const string & | input,
|  | const string & | output
| ) |

  | Set a translation mapping. The first value is the input, the second value is the output. During translation, any occurrences of the first string will be transformed to the second string. A gnCompare object is used to facilitate ambiguity matching. Parameters:
  input | The input string
  output | The string to output every time the input string is encountered
Definition at line 140 of file gnTranslator.cpp. References m_inputTable, and m_outputTable. Referenced by CreateDNAProteinTranslator(), CreateProteinDNATranslator(), CreateProteinRNATranslator(), and CreateRNAProteinTranslator().

void gnTranslator::UseDefaultChar | ( | const boolean | use = true | ) | `[inline]`

  | Set whether the default character is inserted upon translation failure. Parameters:
  use | True if the default character should be used.
Definition at line 152 of file gnTranslator.h. References use_default.

## Member Data Documentation

const gnCompare* gnTranslator::compare`[private]`

| Definition at line 126 of file gnTranslator.h. Referenced by Filter(), gnTranslator(), and SetCompare().

gnSeqC gnTranslator::m_defaultChar`[private]`

| Definition at line 129 of file gnTranslator.h. Referenced by Filter(), GetDefaultChar(), gnTranslator(), and SetDefaultChar().

uint32 gnTranslator::m_defaultInputWidth`[private]`

| Definition at line 130 of file gnTranslator.h. Referenced by CreateDNAProteinTranslator(), CreateProteinDNATranslator(), CreateProteinRNATranslator(), CreateRNAProteinTranslator(), Filter(), GetDefaultInputWidth(), gnTranslator(), and SetDefaultInputWidth().

vector<string> gnTranslator::m_inputTable`[private]`

| Definition at line 124 of file gnTranslator.h. Referenced by Filter(), gnTranslator(), RemovePair(), and SetPair().

string gnBaseFilter::m_name`[protected, inherited]`

| Definition at line 60 of file gnBaseFilter.h. Referenced by gnBaseFilter::GetName(), gnFastTranslator::gnFastTranslator(), gnFilter::gnFilter(), gnPosSpecificTranslator::gnPosSpecificTranslator(), gnTranslator(), and gnBaseFilter::SetName().

vector<string> gnTranslator::m_outputTable`[private]`

| Definition at line 124 of file gnTranslator.h. Referenced by Filter(), gnTranslator(), RemovePair(), and SetPair().

boolean gnTranslator::use_default`[private]`

| Definition at line 128 of file gnTranslator.h. Referenced by CreateDNAProteinTranslator(), CreateRNAProteinTranslator(), gnTranslator(), SetDefaultChar(), and UseDefaultChar().

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

- gnTranslator.h
- gnTranslator.cpp