class Nucleotide::Translate

Public Class Methods

new(table) click to toggle source

Table can be either an id (integer) or a Biolib::Emboss TrnTable

# File lib/bigbio/sequence/translate.rb, line 13
def initialize table 
  table = 0 if table == nil
  if table.kind_of? Numeric
    @trn_table = Bio::Big::TranslationAdapter.translation_table(table)
  else
    @trn_table = table
  end
end

Public Instance Methods

aa_6_frames(seq) click to toggle source

Return all six reading frames as an Array - ordered as frames [1,2,3,-1,-2,-3] with as tuples [frame, AAsequence].

Note that the nucleotide sequence does not get modified.

# File lib/bigbio/sequence/translate.rb, line 27
def aa_6_frames seq
  res = []
  # remove white space
  seq = seq.gsub(/\s/,'')
  [1,2,3,-1,-2,-3].each do | frame |
    aa = Bio::Big::TranslationAdapter.translate(@trn_table,frame,seq)
    res.push({:frame => frame, :sequence => aa})
  end
  res
end
aa_forward_frames(seq) click to toggle source

Return all forward reading frames as an Array - ordered as frames [1,2,3] with as tuples [frame, AAsequence]

# File lib/bigbio/sequence/translate.rb, line 40
def aa_forward_frames seq
  res = []
  # remove white space
  seq = seq.gsub(/\s/,'')
  [1,2,3].each do | frame |
    aa = Bio::Big::TranslationAdapter.translate(@trn_table,frame,seq)
    res.push({:frame => frame, :sequence => aa})
  end
  res
end