[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Bioruby-Name error: uninitialized constant

Carl Olme

2/22/2008 10:58:00 AM

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.
--
Posted via http://www.ruby-....

5 Answers

Thomas Wieczorek

2/22/2008 12:00:00 PM

0

On Fri, Feb 22, 2008 at 11:58 AM, Carl Olme <calvin7602@hotmail.com> wrote:
> I'm very new to both programming in general and to programming in Ruby.
>
<snip>
>
> 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

Christopher Dicely

2/22/2008 3:53:00 PM

0

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.)


On Fri, Feb 22, 2008 at 2:58 AM, Carl Olme <calvin7602@hotmail.com> wrote:
> 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.
> --
> Posted via http://www.ruby-....
>
>

Carl Olme

2/25/2008 2:28:00 PM

0

Christopher Dicely wrote:
> 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.
--
Posted via http://www.ruby-....

Justin Collins

2/25/2008 10:53:00 PM

0

Carl Olme wrote:
> Christopher Dicely wrote:
>
>> 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.
>

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

-Justin

Thomas Wieczorek

2/25/2008 11:21:00 PM

0

On Mon, Feb 25, 2008 at 11:53 PM, Justin Collins <justincollins@ucla.edu> wrote:
>
> You must require 'rubygems' for any libraries that are installed as gems.
>

If you don't set the enviroment variable RUBYOPT to '-rubygems'