Bioruby-Name error: uninitialized constant

C

Carl Olme

I'm very new to both programming in general and to programming in Ruby.

I have tried to write a programme in BioRuby:

require 'bio'

fasta = open('../sequence.fasta')
fasta_string = fasta.read

a = Bio::Alignment::MultiFastaFormat.new(fasta_string).alignment

a.each_site do|bases_at_site|
puts bases_at_site.join('')


When I run the programme in irb, I get the following output:

irb(main):001:0> require 'bio'
=> true
irb(main):002:0>

irb(main):003:0* fasta = open('../sequence.fasta')
=> #<File:../sequence.fasta>

irb(main):004:0> fasta_string = fasta.read
=> ">ref|NT_039674.7|Mm18_39714_37:58262030-58293988 Mus musculus
chromosome 18 genomic contig, strain
C57BL/6J\r\nTTTCTATTTCAGCAGAAAAAAAAAAAGACGACTAGTCTTTGGGTT
#I cut out the rest of the file since it's very long.

irb(main):005:0>
irb(main):006:0* a =
Bio::Alignment::MultiFastaFormat.new(fasta_string).alignment
NameError: uninitialized constant Bio::Alignment::MultiFastaFormat
from (irb):6

irb(main):007:0>
irb(main):008:0* a.each_site do|bases_at_site|
irb(main):009:1* puts bases_at_site.join('')

The solution is probably very simple, but I have played around with the
code for half a day now and can't get any further. I realise that the
problem is with how I have used Bio::Alignment, but not sure where I
have gone wrong.
 
T

Thomas Wieczorek

I'm very new to both programming in general and to programming in Ruby.
The solution is probably very simple, but I have played around with the
code for half a day now and can't get any further. I realise that the
problem is with how I have used Bio::Alignment, but not sure where I
have gone wrong.

I don't know anything about BioRuby, but I took nonetheless a look at
the gem. Did you take a look at the tutorial? You can view it with the
gem server. Just type
gem server
in you console and you can access the RDocs of all your installed gems
at http://localhost:8808/. Maybe you can find your solution there.


Regards, Thomas
 
C

Christopher Dicely

I get the same problem if I install with "gem install bioruby" (which
installs bioruby 0.6.4). If I do "gem install bio", which installs
bioruby 1.2.1, I don't have the problem.

(I didn't actually try loading anything, but
Bio::Alignment::MultiFastaFormat produces an uninitialized constant
error in the first case, and refers to a real class in the second.)
 
C

Carl Olme

Christopher said:
I get the same problem if I install with "gem install bioruby" (which
installs bioruby 0.6.4). If I do "gem install bio", which installs
bioruby 1.2.1, I don't have the problem.

(I didn't actually try loading anything, but
Bio::Alignment::MultiFastaFormat produces an uninitialized constant
error in the first case, and refers to a real class in the second.)

I managed to get rid of the error message by just adding the line:

require 'rubygems'

as a first line in the code. I'm not sure exactly why this works, but
the advice was given by one of my supervisors. I don't have
administrator's access to my computer so I cannot install any updates
without going via the IT department, something that usually takes a
couple of days.
 
J

Justin Collins

Carl said:
I managed to get rid of the error message by just adding the line:

require 'rubygems'

as a first line in the code. I'm not sure exactly why this works, but
the advice was given by one of my supervisors. I don't have
administrator's access to my computer so I cannot install any updates
without going via the IT department, something that usually takes a
couple of days.

You must require 'rubygems' for any libraries that are installed as gems.

-Justin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top