Bioruby help

Can someone tell me why I am getting following error:

bio_sequence__NA.rb:15: undefined method `new’ for :NA:Symbol
(NoMethodError)

I am new to Ruby, and I will really appreciate. Thank you.

require ‘rubygems’
require ‘bio’

dna_sequence = Bio::Sequence:NA.new(File.open(‘dna.txt’).read)
puts dna_sequence

Hi,

You’re missing one colon after “Bio::Sequence:”. The line should say

dna_sequence = Bio::Sequence::NA.new …

By the way, you shouldn’t write

File.open(‘dna.txt’).read

This creates an I/O stream (via File.open) and leaves it open. Instead,
write

File.read(‘dna.txt’)

So the full line is

dna_sequence = Bio::Sequence::NA.new(File.read(‘dna.txt’))

Jacques

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs