[BioRuby] getting started with BioRuby
bio scientist
pathoquest at gmail.com
Sun Apr 6 17:54:49 UTC 2008
Dear All,
This is my first mail to the group. YARN (yet another ruby nuby). :-)
Ever since Ruby has taken over the programming world, an increasing number
of biologists have also adapted Ruby as a language of their choice. Among
these is a generation of biologists whose first programming language is
Ruby: the so-called 'people-who-don't-know
-the-pain-of-programming-in-Java/Perl'. I belong to this category and am
trying to learn Ruby, BioRuby and Rails for my work. I wish to learn more by
interacting with the BioRuby Gurus and give back to the community what I
have learnt. That prologue was to make the point that my questions are of
the basic kind, while most posts here seem to be coming from and for coders.
So, please bear with me and have the patience to clear my doubts.
Thanks a ton to Katayama, Goto and Prins for the tutorials.
---------------------------------------------------------------------------------------------------------------
I have installed Ruby 1.8.6 and followed the instructions to install 'bio'
and 'bioruby' via gems. Now, I can see the '*bioruby>*' prompt and am able
to do the simple examples like translation, complement, GC% etc. However, I
am unable to work with a saved program as in the example copy -pasted below
from http://dev.bioruby.org/wiki/en/?Tutorial.rd:
In most cases, sequences are read from files or retrieved from databases.
For example:
require 'bio'
input_seq = ARGF.read # reads all files in arguments
my_naseq = Bio::Sequence::NA.new(input_seq)
my_aaseq = my_naseq.translate
puts my_aaseq
Save the program as na2aa.rb. Prepare a nucleic acid sequence described
below and saves it as my_naseq.txt:
gtggcgatctttccgaaagcgatgactggagcgaagaaccaaagcagtgacatttgtctg
atgccgcacgtaggcctgataagacgcggacagcgtcgcatcaggcatcttgtgcaaatg
tcggatgcggcgtga
na2aa.rb translates a nucleic acid sequence to a protein sequence. For
example, translates my_naseq.txt:
% ruby na2aa.rb my_naseq.txt
---------------------------------------------------------------------------------------------------------
I saved the files as per the example, but when I try to open the file using
bioruby>na2aa.rb, it gives me an error message saying '* undefined local
variable or method'na2aa'* for main:Object.
Can you please tell me what I should do?
--------------------------------------------------------------------------------------------------------
Also, could you please throw some more light on saving .seq sequences from
NCBI's ftp site? This is in reference to the Parsing example in the tutorial
:
Parsing GenBank data (Bio::GenBank class)
We assume that you already have some GenBank data files. (If you don't,
download some .seq files from ftp://ftp.ncbi.nih.gov/genbank/).As an example
we fetch the ID, definition and sequence of each entry from the GenBank
format and convert it to FASTA. This is also an example script in the
BioRuby distribution.
A first attempt could be to use the Bio::GenBank class for reading in the
data:
#!/usr/bin/env ruby
require 'bio'
# Read all lines from STDIN split by the GenBank delimiter
while entry = gets(Bio::GenBank::DELIMITER)
gb = Bio::GenBank.new(entry) # creates GenBank object
print ">#{gb.accession} " # Accession
puts gb.definition # Definition
puts gb.naseq # Nucleic acid sequence
# (Bio::Sequence::NA object)
end
----------------------------------------------------------------------------------------------------------
Thanks in advance,
KK
More information about the BioRuby
mailing list