BioRuby and the KEGG API
Toshiaki Katayama
k@bioruby.org
Bioinformatics center, Kyoto U., Japan

Use the source!

http://bioruby.org/BOSC 2003

What is BioRuby?
Yet another BioPerl written in Ruby
 since Nov 2000

Developed in Japan includes support for Japanese resources like KEGG

http://bioruby.org/BOSC 2003

So, what is Ruby?
Scripting language clean syntax, v. easy to use/read/write

Everything is object
 Integer, String, Regexp, Exception etc. w/o exception

Created by Japanese author 'matz'
http://bioruby.org/BOSC 2003

So, what is Ruby?
Pre-installed in Mac OS X !

http://bioruby.org/BOSC 2003

What the Ruby code looks like?
#!/usr/bin/rubyputs "Hello world!"

http://bioruby.org/BOSC 2003

What the BioRuby code lookslike?
#!/usr/bin/env rubyrequire 'bio'
gene = Bio::Seq::NA.new("catgaattattgtagannntgataaagacttgac")
prot = gene.translate# => "HELL*XW*RLD" (Bio::Seq::AA object)puts prot.split('X').join(' ').capitalize.gsub(/\*/, 'o') << '!'# => "Hello World!"

http://bioruby.org/BOSC 2003

Bio::Sequence Bio::Sequence (aliased to Bio::Seq) seq.composition
 seq.window_search seq.randomize seq.to_fasta

 Bio::Sequence::NA seq.complement
 seq.splicing
 seq.translate seq.to_re#!/usr/bin/env rubyrequire 'bio'
seq = Bio::Seq::NA.new("atggcttcagt..
seq.window_search(15, 3) do |sub|puts sub.translate.molecular_weightend Bio::Sequence::AA seq.molecular_weight

http://bioruby.org/BOSC 2003

What BioRuby can do more?
Biological sequence manipulations
Run applications (Blast etc.) and parse its reportDatabase entry retrieval, parsing
PubMed reference DB search, reformatting
Accessing OBDA, DAS, KEGG API

http://bioruby.org/BOSC 2003

Bio::Applications
Bio::Blast, Fasta, HMMER, EMBOSSBio::Genscan
Bio::PSORT, TargetP
Bio::SOSUI, TMHMM
 each contains Report class for parsing the results

http://bioruby.org/BOSC 2003

example#!/usr/bin/env rubyrequire 'bio'File.open("my_blast_output.xml") do |file|
Bio::Blast.reports(file) do |report|
report.hits do |hit|
puts hit.num, hit.query_id, hit.target_id,hit.bit_score, hit.evalue, hit.overlap
end
end
end
http://bioruby.org/

BOSC 2003

Bio::DB
Bio::GenBank, EMBL, SwissProt, ...
Bio::FastaFormat, GFF, GO
Bio::MEDLINE, LITDB
Bio::TRANSFAC, PROSITEBio::FANTOM
Bio::KEGG::GENES, ENZYME, Microarray, ...
Bio::AAindex
http://bioruby.org/

BOSC 2003

OBDA -- Open Bio* DB AccessBio::RegistryBio::Fetch
Bio::FlatFile
Bio::SQL+
Bio::DAS

http://bioruby.org/

BOSC 2003

OBDA example
 ~/.bioinformatics/seqdatabase.ini[embl]
protocol=biofetch
location=http://bioruby.org/cgi-bin/biofetch.rb
dbname=embl[swissprot]
protocol=biosql
location=db.bioruby.org
dbname=biosql
driver=mysql
biodbname=sp[genbank]
protcol=flat
location=/export/database/dbname=genbank
http://bioruby.org/#!/usr/bin/env rubyrequire 'bio'
reg = Bio::Registry.new
sp = reg.get_database('swissprot')puts sp.get_by_id('CYC_BOVIN')
gb = reg.get_database('genbank')
puts gb.get_by_id('AA2CG')

BOSC 2003

What is KEGG?
GENOME, GENES
PATHWAYSSDBetc.

http://bioruby.org/

BOSC 2003

KEGG in GMOD
 http://gmod.bioruby.org
 Import KEGG/GENESand KEGG/PATHWAY
into GMOD browser(converted by BioRuby)
 Over 100 organisms inunified form
 linked to GENES andPATHWAY database
http://bioruby.org/

BOSC 2003

KEGG API http://www.genome.ad.jp/kegg/soap/
 SOAP/WSDL based web service
 XML, HTTP

 Proteome and pathway analysis
 KEGG/GENES KEGG/SSDB
 KEGG/PATHWAY

http://bioruby.org/

BOSC 2003

example
ISMB poster D-25#!/usr/bin/env rubyrequire 'bio'
serv = Bio::KEGG::API.new
puts serv.get_best_neighbors_by_gene('eco:b0002')# serv.get_best_neighbors_by_gene('eco:b0002', 500)
# serv.get_best_neighbors_by_gene('eco:b0002', 500, ['hin', 'syn'])list = ['ec:1.1.1.1', 'ec:1.2.1.1']
puts serv.get_genes_by_enzymes(list, ['eco', 'syn'])list = ['eco:b0600', 'eco:b1190']
puts serv.mark_all_pathways_by_genes('eco', list)
http://bioruby.org/

BOSC 2003

Example : Ortholog cluster andcommon motif#!/usr/bin/rubyrequire 'bio'
serv = Bio::KEGG::API.new
homologs = serv.get_all_neighbors_by_gene('hsa:7368', 500)
pfams = {}homologs.each do |g|motifs = serv.get_common_motifs_by_genes(g[0])motifs.each do |m|
if m[0] =~ /pf:/
if pfams.key?(m)pfams[m] << g[0]elsepfams[m] = [g[0]]
end
end
end
end
pfams.each do |m|pm
end

http://bioruby.org/

BOSC 2003

Example: Gene expression and
Pathway analysis by KEGG API
serv = Bio::KEGG::API.new
regulated_genes.each do |gene|
map_id = serv.get_pathways_by_genes(["bsu:#{gene[0]}"])
map_id.each do |entry|
entry.gsub!('map', 'bsu')
entry.gsub!('path', 'map')
if map_gene.key?(entry)
map_gene[entry] << gene[0]else
map_gene[entry] = [gene[0]]
end
end
end
map_gene.each do |k, v|
colors = []v.each do |g|colors << "##{ma.orf2rgb[g]}"endp serv.color_pathway_by_genes("bsu:#{k}", v, colors)end

http://bioruby.org/BOSC 2003

Acknowledgement
 BioRuby developers
 Naohisa Goto, Mitsuteru Nakao, Yoshinori Okuji, Shuichi

Kawashima, Masumi Itoh and many more.
 KEGG and KEGG API curators / developers
 Bioinformatics center, Kyoto University, Japan
 Yoko Sato, Shuichi Kawashima, Minoru Kanehisa

 Open Bio* community
http://bioruby.org/

BOSC 2003http://bioruby.org/

BioRuby 0.5.0 isout!
25 Jun 2003

http://bioruby.org/

BOSC 2003