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