[BioRuby] getting started with BioRuby

Pjotr Prins pjotr2008 at thebird.nl
Sun Apr 6 21:21:19 UTC 2008


On Sun, Apr 06, 2008 at 10:54:49AM -0700, bio scientist wrote:
> 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.

What doubts ;-). There should be no doubts - there is only one true
gospel.

> Thanks a ton to Katayama, Goto and Prins for the tutorials.

Well, we do what we can... and perhaps, we could do a little more!

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

The bioruby shell is correct. You are trying something that is not
ruby, or Ruby shell, but rather a shell command. That may sound
weird, and I guess we should make the Tutorial more accurate.

You can run Ruby from the command line - and feed it na2aa.rb as a
command. So not from within the Ruby shell, but from the Unix (or
cygwin) command prompt.

> 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

again, this is a shell thing. When you have .seq files on your file
system you can parse them with these commands. Download .seq files
from NCBI - maybe someone has a link - and run the Ruby program from
the command line.

The command line is king - there is a tutorial here:

  http://www.linuxcommand.org/learning_the_shell.php

you can run Ruby from the command line - that is the missing link.

Pj (aka prins)

> _______________________________________________
> BioRuby mailing list
> BioRuby at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioruby



More information about the BioRuby mailing list