From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Bioruby package logo.png
A BioRuby shell on Rails
A BioRuby shell on Rails
Stable release
1.5.0 / 1 July 2015; 3 years ago (2015-07-01)
Repository Edit this at Wikidata
Written in Ruby
Type Bioinformatics
License GPL

BioRuby is a collection of open-source Ruby code, comprising classes for computational molecular biology and bioinformatics. It contains classes for DNA and protein sequence analysis, sequence alignment, biological database parsing, structural biology and other bioinformatics tasks.[1]

BioRuby is released under the GNU GPL version 2 or Ruby licence[2] and is one of a number of Bio* projects, designed to reduce code duplication.[3]

In 2011, the BioRuby project introduced the Biogem software plugin system[4] and are listed on, with two or three new plugins added every month.

BioRuby is managed via the website and BioRuby GitHub repository.



The BioRuby project was first started in 2000 by Toshiaki Katayama as a Ruby implementation of similar bioinformatics packages such as BioPerl and BioPython. The initial release of version 0.1 has been frequently updated by contributors both informally and at organised “hackathon” events, with the most recent release of version in May 2013.[5]

In June 2005, BioRuby was funded by IPA as an Exploratory Software Project,[6] culminating with the release of version 1.0.0 in February 2006.[7]

BioRuby has been the focus of a number of Google Summer of Code projects, including;

Version history[8][edit]

  • 0.7.0 December 18, 2005 (438 KB)
  • 1.0.0 February 26, 2006 (528 KB)
  • May 24, 2013 (1.42 MB)

The above list of releases is abbreviated; the full list can be found here.


BioRuby is able to be installed onto any instance of Ruby; as Ruby is a highly cross platform language, BioRuby is available on most modern operating systems.[9]

It is required that Ruby be installed prior to BioRuby installation.

Installation of BioRuby[edit]

Mac OS X/Unix/Linux[edit]

Mac OS X has Ruby and RubyGems installed by default and for Unix/Linux installation of RubyGems is recommended.

If Ruby and RubyGems are installed, BioRuby can be installed using this command via the terminal;

% sudo gem install bio

If you need to install from the source code distribution, obtain the latest package from the archive and in the bioruby source directory, run the following commands;

% su 
# ruby setup.rb


Installation via RubyGems is highly recommended; this requires Ruby and RubyGems be installed, then the following command run at the command prompt;

> gem install bio


BioRuby can be accessed via the terminal, Ruby IDEs or via a BioRubyOnRails implementation. Instructions for the installation and use of BioRubyOnRails can be found at

Basic Syntax[10][edit]

The following are examples of basic sequence manipulations using BioRuby. You can find more syntax examples at

Basic Sequence Manipulation[edit]

String to Bio::Sequence object[edit]

Parsing a string into Bio::Sequence object.

#!/usr/bin/env ruby
require 'bio'

# create a DNA sequence object from a String
dna ="atcggtcggctta")

# create an RNA sequence object from a String
rna ="auugccuacauaggc")

# create a Protein sequence from a String
# you can check if the sequence contains illegal characters
# that is not an accepted IUB character for that symbol
# (should prepare a Bio::Sequence::AA#illegal_symbols method also)
puts dna.illegal_bases

# translate and concatenate a DNA sequence to Protein sequence
newseq = aa + dna.translate
puts newseq # => "AGFAVENDSAIGRL"

Bio::Sequence object to String[edit]

This an example that showcases the simplicity of BioRuby. It does not require any method call to convert the sequence object to a string.

Parsing a sequence object into a string.

#!/usr/bin/env ruby
# you can use Bio::Sequence object as a String object to print, seamlessly
dna ="atgc")
puts dna        # => "atgc"
str = dna.to_s
puts str        # => "atgc"


Translating a DNA or RNA Sequence or SymbolList to Protein[edit]

There is no need to convert DNA sequence to RNA sequence or vice versa before its translation in BioRuby. You can simply call a translate method for Bio::Sequence::NA object.

#!/usr/bin/env ruby

require 'bio'

# create a DNA sequence
seq ="atggccattgaatga")
# translate to protein
prot = seq.translate
# prove that it worked
puts seq   # => "atggccattgaatga"
puts prot  # => "MAIE*"

Translating a single codon to a single amino acid[edit]

The general translation example shows how to use the translate method of Bio::Sequence::NA object but most of what goes on is hidden behind the convenience method. If you only want to translate a single codon into a single amino acid you get exposed to a bit more of the gory detail but you also get a chance to figure out more of what is going on under the hood.

#!/usr/bin/env ruby
require 'bio'
# make a 'codon'
codon ="uug")
# you can translate the codon as described in the previous section.
puts codon.translate  # => "L"

Another way to do this is the following

#!/usr/bin/env ruby
require 'bio'
# make a 'codon'
codon ="uug")
# select the standard codon table
codon_table = Bio::CodonTable[1]
# You need to convert RNA codon to DNA alphabets because the
# CodonTable in BioRuby is implemented as a static Hash with keys
# expressed in DNA alphabets (not RNA alphabets).
codon2 = codon.dna
# get the representation of that codon and translate to amino acid.
amino_acid = codon_table[codon2]
puts amino_acid        # => "L"

Sequence I/O[edit]

Writing Sequences in Fasta format[edit]

To print out any Bio::Sequence object in FASTA format, All you need is to call is "puts objectName.is_fasta()"

#!/usr/bin/env ruby
require 'bio'
# Generates a sample 100bp sequence.
seq1 ="aatgacccgt" * 10)
# Naming this sequence as "testseq" and print in FASTA format
# (folded by 60 chars per line).
puts seq1.to_fasta("testseq", 60)

Reading in a Fasta file[edit]

This program opens FASTA format file for reading and iterates on each sequence in the file.

#!/usr/bin/env ruby
require 'bio'
file =
file.each do |entry|
# do something on each fasta sequence entry

This program automatically detects and reads FASTA format files given as its arguments.

#!/usr/bin/env ruby
require 'bio' do |ff|
ff.each do |entry|
  # do something on each fasta sequence entry

Similar but specify FASTA format explicitly.

#!/usr/bin/env ruby
require 'bio', ARGV[0]) do |ff|
  ff.each do |entry|
    # do something on each fasta sequence entry

See more syntax examples on SampleCodes

Classes and Modules[edit]

Major Classes[edit]

The below classes have been identified by a group of major code contributors as major classes.[11]

Basic Data Structure[edit]

These classes allow you to natively store complicated biological data structure effectively.[11]

Class names Description
Bio::Sequence::NA, Bio::Sequence::AA Nucleic and amino acid sequences
Bio::Locations, Bio::Features Locations / Annotations
Bio::Reference, Bio::PubMed Literatures
Bio::Pathway, Bio::Relation Graphs
Bio::Alignment Alignments

Databases and sequence file formats[edit]

Accesses online biological databases and reads from common file-formats.

Class names Description
Bio::GenBank, Bio::EMBL GenBank / EMBL
Bio::SPTR, Bio::NBRF, Bio::PDB SwissProt and TrEMBL / PIR / PDB
Bio::FANTOM FANTOM DB (Functional annotation of mouse)
Bio::KEGG KEGG database parsers
Bio::GO, Bio::GFF Bio::PROSITE FASTA format / PROSITE motifs
Bio::FastaFormat, Bio::PROSITE FASTA format / PROSITE motifs

Wrapper and parsers for bioinformatics tool[edit]

These classes allow for easy access to commonly used bioinformatics tools.

Class names Description
Bio::Blast, Bio::Fasta, Bio::HMMER Sequence similarity (BLAST / FASTA / HMMER)
Bio::ClustalW, Bio::MAFFT Multiple sequence alignment (ClustalW / MAFFT)
Bio::PSORT, Bio::TargetP Protein subcellular localization (PSORT / TargetP)
Bio::SOSUI, Bio::TMHMM Transmembrane helix prediction (SOSUI / TMHMM)
Bio::GenScan Gene finding (GenScan)

File, network and database I/O[edit]

Class names Description
Bio::Registry OBDA Registry service
Bio::SQL OBDA BioSQL RDB schema
Bio::Fetch OBDA BioFetch via HTTP
Bio::FlatFileIndex OBDA flat file indexing system
OBDA flat file indexing system Flat file reader with data format autodetection
Bio::DAS Distributed Annotation System (DAS)
Bio::KEGG::API SOAP/WSDL intarface for KEGG

A full list of classes and modules can be found at


Biogem provides a set of tools for bioinformaticians who want to code an application or library that uses or extends BioRuby's core library, as well as share the code as a gem on Any gem published via the Biogem framework is also listed at

The aim of Biogem is to promote a modular approach to the BioRuby package and simplify the creation of modules by automating process of setting up directory/file scaffolding, a git repository and releasing online package databases.[12]

Biogem makes use of and and requires the setup of unique accounts on these websites.

Popular Biogems[edit]

# Biogem Description Version
1 bio Bioinformatics Library
2 biodiversity Parser of scientific names 3.1.5
3 Simple Spreadsheet extractor Basic spreadsheet content extraction using Apache poi 0.13.3
4 Bio gem Software generator for Ruby 1.36
5 Bio samtools Binder of samtools for Ruby 2.1.0
6 t2 server Support for interacting with the taverna 2 server 1.1.0
7 bio ucsc api The Ruby ucsc api 0.6.2
8 entrez http request to entrez e-utilities
9 bio gadget Gadget for bioinformatics 0.4.8
10 sequenceserver Blast search made easy! 0.8.7


BioRuby will have a completed plugin system at the 1.5 release.[13]

See also[14][edit]


Ruby/bioinformatics links[edit]

Sister projects[edit]



  1. ^ Goto N, Prins P, Nakao M, Bonnal R, Aerts J, Katayama T (October 2010). "BioRuby: bioinformatics software for the Ruby programming language". Bioinformatics. 26 (20): 2617–9. doi:10.1093/bioinformatics/btq475. PMC 2951089. PMID 20739307.
  2. ^ "bioruby/README.rdoc at master · bioruby/bioruby". 2014-05-08. Retrieved 2014-11-09.
  3. ^ Mangalam H (2002). "The Bio* toolkits--a brief overview". Brief Bioinform. 3 (3): 296–302. doi:10.1093/bib/3.3.296. PMID 12230038.
  4. ^ Bonnal R, Aerts J, Githinji G, Goto N, MacLean D, Miller C, Mishima H, Pagani M, Ramirez-Gonzalez R, Smant G, Strozzi F, Syme R, Vos R, Wennblom T, Woodcroft B, Katayama T, Prins P (April 2012). "Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics". Bioinformatics. 28 (7): 1035–7. doi:10.1093/bioinformatics/bts080. PMC 3315718. PMID 22332238.
  5. ^ "History - BioRuby". 2014-05-30. Retrieved 2014-09-10.
  6. ^ "IPA Information-technology Promotion Agency, Japan : IPA:Exploratory IT Human Resources Project (The MITOH Program)".
  7. ^ "[BioRuby] BioRuby 1.0.0 released". 2006-02-27. Retrieved 2014-09-10.
  8. ^ "History - BioRuby". 2014-05-30. Retrieved 2014-09-11.
  9. ^ Ruby (programming language)#Platform support
  10. ^ "SampleCodes - BioRuby".
  11. ^ a b "BioRuby: Open-Source Bioinformatics Library" (PDF).
  12. ^ "Plugins - BioRuby".
  13. ^ "BioRuby - Plugins". 2012-03-20. Retrieved 2014-11-09.
  14. ^ "Links - BioRuby". 2012-12-28. Retrieved 2014-10-09.

External links[edit]