translate: Translate DNA or RNA

Description Usage Arguments Format Details Value Examples

Description

Translate a vector of nucleotide sequences into a vector of protein sequences.

Usage

1
2
3
4
translate(x, type = Biostrings::DNAStringSet, translation = TRANSLATION,
  start = "ATG", ambiguities = "solve")

TRANSLATION

Arguments

x

[character]

Sequences to translate. Must only contain valid IUPAC DNA or RNA characters.

type

[function]

Used to coerce x to a class compatible with Biostrings::translate. Typically one of Biostrings::DNAStringSet, or Biostrings::RNAStringSet. Defaults to Biostrings::DNAStringSet.

translation

[named:character(64)]

Amino acid letters with names corresponding to each of the 64 possible DNA codons. Defaults to TRANSLATION.

start

[character]

Start codons. The first occurence of one of these codons will be translated to 'M', and further occurences will be translated to that defined by translation. Defaults to 'ATG'.

abiguities

['solve'|'error'|'error.if.X'|'X']

How ambiguities be handled. See Biostrings::translate for more details. Defaults to 'solve' which will translate to the appropriate amino acid, and will translate to 'X' if not possible to unambiguously translate to a single amino acid.

Format

TRANSLATION - A named character vector with length 64. Names correspond to codons, values correspond to single letter amino acid codes, and '*' for stop.

Details

This function is a simple wrapper around Biostrings::translate that takes a character vector as input and a returns a character vector. The default behavior is slightly different in that ambiguous bases will be solved rather than causing an error, and alternative start codons are not used without being explicitly specified with the start parameter. This prevents a common "gotcha" when translating a subsequence with Biostrings::translate using the default Biostrings::GENETIC_CODE where it would unexpectedly translate "TTG", or "CTG" to "M" rather than "L" without any warning. To reproduce this behavior, simply specify start = c('ATG', 'TTG', 'CTG') which is only sensible if you are translating an entire coding sequence.

Value

Returns a character vector with the same length as x.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
  # Default settings assume DNA input and will attempt to solve ambiguity
  translate(c('ATGAAAGGRTGA', 'ATGGGRRAATAA'))

  # RNA can also be translated
  translate('AUGAAAGGRUGA', type = Biostrings::RNAStringSet)

  # Alternative start codons may be specified
  translate(c('AAAATGAAA', 'ATGAAAAAA'), start = c('ATG', 'AAA'))

  # Alternative translation code can be specified
  codon_code <- TRANSLATION
  codon_code['TGG'] <- 'R'
  translate(c('AAATGGTGG', 'ATGTGGTGG'), translation = codon_code)

  # Other common translation tables
  Biostrings::GENETIC_CODE_TABLE
  Biostrings::getGeneticCode('Yeast Mitochondrial', full.search = TRUE)

EricEdwardBryant/mutagenesis documentation built on May 14, 2019, 6:13 p.m.