Bioruby offers a very easy and simple way to translate nucleotide sequences.
We know that there are six posible reading frames for any given nucleotide sequence. Generally the longests Open reading frame is taken to be the correct frame, when we do not have information about the possible protein that is encoded by a given gene. By default the translate method performs translation in the first frame but it can take an argument that defines the translation frame
seq.translate(2) #translate using the second reading frame.
Given a long list of sequences how do we quickly determine the correct reading frame. We would want to have method to translate a given sequence in all frames and pick the longest reading frame. Assuming that the correct reading frame has no stop codons, we can write a quick method to perform the six frame translation.
def longest_reading_frame(sequence) orfs =  #a container for orfs(open reading frames) #translate a sequence in all 6 frames 6.times do |frame| translated = Bio::Sequence::NA.new(sequence).translate(frame + 1) stop_codons = translated.scan(/\*/).size orfs << translated if stop_codons == 0 end orfs end
This method uses an array to collect all translated sequences that contain no stop codons and returns the first sequence in the array. This might not scale very well for very long sequences but that will be a post for another day!