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.[1]
A BioRuby shell on Rails | |
Stable release | 1.5.2
/ 19 November 2018 |
---|---|
Repository | |
Written in | Ruby |
Type | Bioinformatics |
License | GPL |
Website | bioruby |
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 biogems.info, with two or three new plugins added every month.
BioRuby is managed via the bioruby.org website and BioRuby GitHub repository.
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.[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;
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.[9]
It is required that Ruby be installed prior to BioRuby installation.
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 archive and in the bioruby source directory, run the following commands;
% su
# 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 bioruby.open-bio.org/wiki/BioRubyOnRails.
Basic Syntax[10]
The following are examples of basic sequence manipulations using BioRuby. You can find more syntax examples at bioruby.open-bio.org/wiki/SampleCodes#.
String to Bio::Sequence object
Parsing a string into Bio::Sequence object.
#!/usr/bin/env ruby
require 'bio'
# create a DNA sequence object from a String
dna = Bio::Sequence::NA.new("atcggtcggctta")
# create an RNA sequence object from a String
rna = Bio::Sequence::NA.new("auugccuacauaggc")
# create a Protein sequence from a String
aa = Bio::Sequence::AA.new("AGFAVENDSA")
# 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
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 = Bio::Sequence::NA.new("atgc")
puts dna # => "atgc"
str = dna.to_s
puts str # => "atgc"
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'
# create a DNA sequence
seq = Bio::Sequence::NA.new("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
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 = Bio::Sequence::NA.new("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 = Bio::Sequence::NA.new("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"
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'
# Generates a sample 100bp sequence.
seq1 = Bio::Sequence::NA.new("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
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(ARGV.shift)
file.each do |entry|
# 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(ARGF) 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(Bio::FastaFormat, ARGV[0]) do |ff|
ff.each do |entry|
# do something on each fasta sequence entry
end
end
See more syntax examples on SampleCodes
Classes and modules
Major classes
The below classes have been identified by a group of major code contributors as major classes.[11]
Basic data structure
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
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
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
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 bioruby.org/rdoc/.
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 rubygems.org. Any gem published via the Biogem framework is also listed at biogems.info.
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 github.com and rubygems.org and requires the setup of unique accounts on these websites.
Popular Biogems
# | Biogem | Description | Version |
---|---|---|---|
1 | bio | Bioinformatics Library | 1.4.3.0001 |
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 | 0.5.8.1 |
9 | bio gadget | Gadget for bioinformatics | 0.4.8 |
10 | sequenceserver | Blast search made easy! | 0.8.7 |
Plugins
BioRuby will have a completed plugin system at the 1.5 release.[13]
See also[14]
Ruby/bioinformatics links
Blogs
- Saaien Tist - http://saaientist.blogspot.com.au/
- "aac".translate # => "N" - http://bioruby.g.hatena.ne.jp/nakao_mitsuteru/
- BioRelated - http://biorelated.wordpress.com/category/bioruby/
References
- 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.
- "bioruby/README.rdoc at master · bioruby/bioruby". 2014-05-08. Retrieved 2014-11-09.
- Mangalam H (2002). "The Bio* toolkits--a brief overview". Brief Bioinform. 3 (3): 296–302. doi:10.1093/bib/3.3.296. PMID 12230038.
- 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.
- "History - BioRuby". 2014-05-30. Retrieved 2014-09-10.
- "IPA Information-technology Promotion Agency, Japan : IPA:Exploratory IT Human Resources Project (The MITOH Program)".
- "[BioRuby] BioRuby 1.0.0 released". 2006-02-27. Retrieved 2014-09-10.
- "History - BioRuby". 2014-05-30. Retrieved 2014-09-11.
- Ruby (programming language)#Platform support
- "SampleCodes - BioRuby". Archived from the original on 2014-09-11.
- "BioRuby: Open-Source Bioinformatics Library" (PDF). Cite journal requires
|journal=
(help) - "Plugins - BioRuby".
- "BioRuby - Plugins". 2012-03-20. Archived from the original on 2011-10-07. Retrieved 2014-11-09.
- "Links - BioRuby". 2012-12-28. Archived from the original on 2014-10-09. Retrieved 2014-10-09.