module BioDSL::Translate
Namespace for Translate
methods.
Constants
- TRANS_TAB11
- TRANS_TAB11_START
Translation table 11 (www.ncbi.nlm.nih.gov/Taxonomy/taxonomyhome.html/index.cgi?chapter=cgencodes#SG11)
AAs = FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG
Starts = —M—————M————MMMM—————M———— Base1 = TTTTTTTTTTTTTTTTCCCCCCCCCCCCCCCCAAAAAAAAAAAAAAAAGGGGGGGGGGGGGGGG Base2 = TTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGGTTTTCCCCAAAAGGGG Base3 = TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG
Public Instance Methods
translate(trans_tab = 11)
click to toggle source
# File lib/BioDSL/seq/translate.rb, line 77 def translate(trans_tab = 11) unless @type == :dna fail SeqError, "Sequence type must be 'dna' - not #{@type}" end unless (length % 3) == 0 fail SeqError, 'Sequence length must be a multiplum of 3 - ' \ " was: #{length}" end case trans_tab when 11 codon_start_hash = TRANS_TAB11_START codon_hash = TRANS_TAB11 else fail SeqError, "Unknown translation table: #{trans_tab}" end codon = @seq[0...3].upcase aa = codon_start_hash[codon] fail SeqError, "Unknown start codon: #{codon}" if aa.nil? protein = aa.dup (3...length).step(3) do |i| codon = @seq[i...i + 3].upcase aa = codon_hash[codon] fail SeqError, "Unknown codon: #{codon}" if aa.nil? protein << aa.dup end Seq.new(seq_name: @seq_name, seq: protein[0..-2], type: :protein) end
Also aliased as: to_protein
translate!(trans_tab = 11)
click to toggle source
Method to translate a DNA sequence to protein.
# File lib/BioDSL/seq/translate.rb, line 64 def translate!(trans_tab = 11) entry = translate(trans_tab) self.seq_name = entry.seq_name ? entry.seq_name.dup : nil self.seq = entry.seq.dup self.type = entry.type self.qual = entry.qual self end
Also aliased as: to_protein!