biorubySequence.rb :
require 'rubygems'
require 'bio'
nucs = ['a','t','g','c']
nucs += nucs.map{|xx| xx.upcase}
seq1Str = ""
numNucs = (rand(200) + 100)
numNucs.times { |xx|
nucIndex = rand(nucs.size)
theNuc = nucs[nucIndex]
seq1Str << theNuc
}
puts "TEST SEQ:\n#{seq1Str}\n\n"
bioNaSeq = Bio::Sequence::NA.new(seq1Str)
puts "SEQ INFO:\n %GC: #{bioNaSeq.gc_percent}\n composition: #{bioNaSeq.composition.inspect}"
puts "TRANSLATED (3 frames):"
3.times { |ii|
puts " #{ii}. #{bioNaSeq.translate(ii+1)}"
}
puts "AA Composition of 1st frame translation:\n #{bioNaSeq.translate.composition.inspect}"
firstFrame = bioNaSeq.translate
if(firstFrame =~ /\*/)
frameRange = 0...firstFrame.index("*")
firstFrame = firstFrame[frameRange]
end
puts "Mol. Weight of 1st frame translation up to first termination codon:\n #{firstFrame.molecular_weight}"