Ruby is a great programming language for developing web applications with the Ruby on Rails framework. What most people might not have realised yet is that this simple object-oriented scripting language also has a great potential in bioinformatics.
I came up with the the following points to summarise the strengths of Ruby for bioinformaticians:
- Ruby is simple, elegant and easy. The description at ruby-lang.org puts it well:[Ruby is] a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.
- There are lots of useful libraries available in a public repository at RubyForge (2978 and counting). Bioinformatics geeks might for example like BioRuby (self-explanatory), Ensembl(the Ensembl Core API for Ruby), RSRuby (R-Ruby bridge) and of course ActiveRecord (a powerful database access and persistence API that's part of Ruby on Rails).
- It's dead-easy to install both the interpreter and extra libraries in both Windows, Linux and OS X. This is because Ruby has a nice package manager called RubyGems. Unlike the hair loss, heart burn and depression inducing CPAN in the Perl world, RubyGems actually Just Works and handles dependencies and uninstalling.
- Getting started is easy because there are excellent learning resources available online. I personally got started using the online tutorial Try Ruby!, then went on to read the online edition of Programming Ruby, after which googling has been enough to solve most of my Ruby issues.
Below is a quick taster of using the Ensembl API in Ruby. The example is grabbed from the Ensembl tutorial included with the Ruby Ensembl API docs.
require 'ensembl-api'
include Ensembl::Core
slice = Slice.fetch_by_region('chromosome','X',1000000,10000000)
puts slice.display_name
slice.genes.each do |gene|
puts "\t" + gene.stable_id
gene.transcripts.each do |transcript|
puts "\t\t" + transcript.stable_id
transcript.exons.each do |exon|
puts "\t\t\t" + exon.id.to_s
end
end
end
And Python
This just begs another post about python here :)
Go ahead
Go ahead then :) Language-wise there's very little difference between what you can express easily in Ruby and Python. I think the difference between these two boils down to the libraries that are available to each: Ensembl and ActiveRecord make Ruby stand out for certain bioinformatics related tasks, whereas all the numeric maths related coolness that's available for Python makes it better for other tasks (I haven't found any good maths libraries for Ruby).