BioRuby


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.
BioRuby is released under the GNU GPL version 2 or Ruby licence and is one of a number of Bio* projects, designed to reduce code duplication.
In 2011, the BioRuby project introduced the Biogem software plugin system and are listed on , with two or three new plugins added every month.
BioRuby is managed via the website and .

History

BioRuby

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 1.4.3.0001 in May 2013.
In June 2005, BioRuby was funded by IPA as an Exploratory Software Project, culminating with the release of version 1.0.0 in February 2006.
BioRuby has been the focus of a number of Google Summer of Code projects, including;
The above list of releases is abbreviated; the full list can be found .

Installation

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.
It is required that Ruby be installed prior to BioRuby installation.

Installation of BioRuby

macOS/Unix/Linux

macOS 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 and in the bioruby source directory, run the following commands;

% su
  1. ruby setup.rb

Windows

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

Usage

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

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

https://web.archive.org/web/20140911100526/http://bioruby.open-bio.org/wiki/SampleCodes#Basic_Sequence_Manipulation Basic Sequence Manipulation

String to Bio::Sequence object

Parsing a string into Bio::Sequence object.

  1. !/usr/bin/env ruby
require 'bio'
  1. create a DNA sequence object from a String
dna = Bio::Sequence::NA.new
  1. create an RNA sequence object from a String
rna = Bio::Sequence::NA.new
  1. create a Protein sequence from a String
aa = Bio::Sequence::AA.new
  1. you can check if the sequence contains illegal characters
  2. that is not an accepted IUB character for that symbol
puts dna.illegal_bases
  1. translate and concatenate a DNA sequence to Protein sequence
newseq = aa + dna.translate
puts newseq # => "AGFAVENDSAIGRL"

Bio::Sequence object to String

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
  1. you can use Bio::Sequence object as a String object to print, seamlessly
dna = Bio::Sequence::NA.new
puts dna # => "atgc"
str = dna.to_s
puts str # => "atgc"

https://web.archive.org/web/20140911100526/http://bioruby.open-bio.org/wiki/SampleCodes#Translation Translation

Translating a DNA or RNA sequence or SymbolList to orotein

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'
  1. create a DNA sequence
seq = Bio::Sequence::NA.new
  1. translate to protein
prot = seq.translate
  1. prove that it worked
puts seq # => "atggccattgaatga"
puts prot # => "MAIE*"

Translating a single codon to a single amino acid

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'
  1. make a 'codon'
codon = Bio::Sequence::NA.new
  1. 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'
  1. make a 'codon'
codon = Bio::Sequence::NA.new
  1. select the standard codon table
codon_table = Bio::CodonTable
  1. You need to convert RNA codon to DNA alphabets because the
  2. CodonTable in BioRuby is implemented as a static Hash with keys
  3. expressed in DNA alphabets.
codon2 = codon.dna
  1. get the representation of that codon and translate to amino acid.
amino_acid = codon_table
puts amino_acid # => "L"

https://web.archive.org/web/20140911100526/http://bioruby.open-bio.org/wiki/SampleCodes#Sequence_I.2FO Sequence I/O

Writing sequences in Fasta format

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'
  1. Generates a sample 100bp sequence.
seq1 = Bio::Sequence::NA.new
  1. Naming this sequence as "testseq" and print in FASTA format
  2. .
puts seq1.to_fasta

Reading in a Fasta file

This program opens FASTA format file for reading and iterates on each sequence in the file.
#!/usr/bin/env ruby
require 'bio'
file = Bio::FastaFormat.open
file.each do |entry|
  1. do something on each fasta sequence entry
end

This program automatically detects and reads FASTA format files given as its arguments.
#!/usr/bin/env ruby
require 'bio'
Bio::FlatFile.auto do |ff|
ff.each do |entry|
# do something on each fasta sequence entry
end
end

Similar but specify FASTA format explicitly.
#!/usr/bin/env ruby
require 'bio'
Bio::FlatFile.open do |ff|
ff.each do |entry|
# do something on each fasta sequence entry
end
end

See more syntax examples on

Classes and modules

Major classes

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

Basic data structure

These classes allow you to natively store complicated biological data structure effectively.
Class namesDescription
, Nucleic and amino acid sequences
, Locations / Annotations
, Literatures
, Bio::RelationGraphs
Alignments

Databases and sequence file formats

Accesses online biological databases and reads from common file-formats.
Class namesDescription
, GenBank / EMBL
, , SwissProt and TrEMBL / PIR / PDB
FANTOM DB
KEGG database parsers
, Bio::PROSITE FASTA format / PROSITE motifs
, FASTA format / PROSITE motifs

Wrapper and parsers for bioinformatics tool

These classes allow for easy access to commonly used bioinformatics tools.
Class namesDescription
, , Sequence similarity
, Multiple sequence alignment
, Protein subcellular localization
, Transmembrane helix prediction
Gene finding

File, network and database I/O

A full list of classes and modules can be found at .

Biogem

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.
Biogem makes use of github.com and rubygems.org and requires the setup of unique accounts on these websites.

Popular Biogems

Plugins

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

BioRuby