BioRuby + KEGG API + KEGG DAS =wiring knowledge for genome and pathway
Toshiaki Katayama <k@bioruby.org>
Human Genome Center, University of Tokyo, Japan
http://bioruby.org/
http://www.genome.jp/kegg/soap/
http://das.hgc.jp/

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

 Mainly developed in Japan including supports for Japanese resources like KEGG

© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo1

What is Ruby?
 Created by Japanese author 'matz'
 Scripting language clean syntax, easy to learn, powerful enough Purely object oriented
 Integer, String, Regexp, Exception etc. w/o exception

 Sufficient libraries
 You can use most of the BioRuby functionallity
without install additional libraries.

© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

What you can do with BioRuby?
 Biological sequence manipulation
 Database entry retrieval and parsing
 Running and parsing usual applications
 Graph computation© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo2

Sequence manipulations
 Splicing
 Reverse complement#!/usr/bin/env#!/usr/bin/env rubyruby
 Translation
 Compositionrequire
require 'bio''bio' Molecular weightseq
seq == Bio::Sequence::NA.new(ARGF.read)
Bio::Sequence::NA.new(ARGF.read) Window searchputs
puts seq.subseq(1,3)
seq.subseq(1,3)## print
print inin FASTA
FASTA format
formatputs
puts seq.to_fasta("foo",
seq.to_fasta("foo", 60)
60)## forfor selenoproteins
selenoproteinsct
ct =Bio::CodonTable.copy(1)=Bio::CodonTable.copy(1)ct['tga']ct['tga'] == 'U''U'
puts
puts seq.translate
seq.translate
puts
puts seq.translate(1,seq.translate(1, ct)ct)

puts
puts seq.splicing("join(1..23,45..67)")
seq.splicing("join(1..23,45..67)")
puts
puts seq.complement
seq.complementputs
puts seq.translate
seq.translate
puts
puts seq.gc_percent
seq.gc_percent
puts
puts seq.composition
seq.composition
seq.window_search(15,seq.window_search(15, 3)3) do
do |subseq||subseq|
peptidepeptide == subseq.translate
subseq.translate
puts
puts peptide.molecular_weight
peptide.molecular_weightend
end© 2004 Toshiaki Katayama, Human Genome Center, University of TokyoEntry parsers
 GenBank, GenPept, RefSeq, DDBJ EMBL, UniProt (TrEMBL, SwissProt)
 PDB
 KEGG/GenomeNet
 GENES, GENOME, ENZYME, COMPOUND, KO,BRITE, CELL, Expression, Keggtab, AAindex
 GFF#!/usr/bin/env#!/usr/bin/env rubyruby## Usage:
Usage:
 GO## %% auto.rb
auto.rb dbfile
dbfile FANTOM
requirerequire 'bio''bio' Transfac, Prosite
Bio::FlatFile.auto(ARGF)
Bio::FlatFile.auto(ARGF) do
do |ff||ff|
ff.each LITDB, MEDLINE
ff.each do
do |entry||entry|## dodo something
something NBRF, PIR
endendendend FASTA format© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo3

Database access OBDA (Open Bio* Database Access) BioRegistry BioFlat BioFetch
 BioSQL PubMed
 DAS
 Ensembl, WormBase etc.
 KEGG DAS SOAP KEGG API
 DDBJ XML NCBI ESOAP© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

OBDA configuration
 ~/.bioinformatics/seqdatabase.ini
 /etc/bioinformatics/seqdatabase.ini http://www.open-bio.org/registry/seqdatabase.ini
VERSION=1.00
VERSION=1.00[genbank][genbank]
protcol=flat
protcol=flat
location=/export/database/location=/export/database/dbname=genbank
dbname=genbank#!/usr/bin/env#!/usr/bin/env rubyrubyrequirerequire 'bio'
'bio'
reg
reg == Bio::Registry.new
Bio::Registry.new[swissprot][swissprot]
protocol=biosql
protocol=biosql
location=db.bioruby.org
location=db.bioruby.org
dbname=biosql
dbname=biosql
driver=mysql
driver=mysql
biodbname=sp
biodbname=spsp
sp == reg.get_database('swissprot')
reg.get_database('swissprot')puts
puts sp.get_by_id('CYC_BOVIN')
sp.get_by_id('CYC_BOVIN')gb
gb == reg.get_database('genbank')
reg.get_database('genbank')
puts
puts gb.get_by_id('AA2CG')
gb.get_by_id('AA2CG')[embl][embl]
protocol=biofetch
protocol=biofetch
location=http://bioruby.org/cgi-bin/biofetch.rb
location=http://bioruby.org/cgi-bin/biofetch.rb© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyodbname=embl
dbname=embl

4

Running applications Bio::Blast, Fasta, HMMER, EMBOSS Bio::ClustalW, MAFFT
 Bio::Genscan
 Bio::PSORT, TargetP Bio::SOSUI, TMHMM#!/usr/bin/env#!/usr/bin/env rubyrubyrequirerequire 'bio''bio'File.open("my_blast_output.xml")
File.open("my_blast_output.xml") do
do |file||file|
Bio::Blast.reports(file)
Bio::Blast.reports(file) do
do |report||report|report.hits
report.hits do
do |hit||hit|
hit.eachhit.each do
do |hsp||hsp|
puts
puts hsp.query_id,hsp.query_id, hsp.target_id,
hsp.target_id,
hsp.bit_score,hsp.bit_score, hsp.evalue,hsp.evalue, hsp.overlap
hsp.overlap
end
end
end
end
© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo
end
end

What is KEGG? Kyoto Encyclopedia of Genes and Genomes http://www.genome.jp/kegg/
 PATHWAY LIGAND GENES, GENOME
 KO
 SSDB Expression
 Glycan etc.

© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

5

KEGG PATHWAY© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

KEGG GENES© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo6KEGG SSDB and OC

Eukaryotes
9576

996

153
658

Bacteria
25226

1440

Archaea3099

Number of OCs across 3 kingdoms© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

KEGG standardization
 KGML ISMB2004 poster C-45

 KEGG API
 ISMB2004 poster G-17

 KEGG DAS ISMB2004 poster E-29

© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo7

KGML© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

KEGG APIhttp://www.genome.jp/kegg/soap/
SOAP/WSDL based web service
XML, HTTP
Can be accessed by any language

Proteome and pathway analysis
KEGG GENES, SSDB, PATHWAYDBGET, LinkDB

Updated to v3.0 (May 2004)© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

8

Example: obtain homologs and motifs by SSDB#!/usr/bin/env#!/usr/bin/env rubyrubyrequirerequire 'bio''bio'
serv
serv == Bio::KEGG::API.new
Bio::KEGG::API.new
homologs
homologs == serv.get_all_best_neighbors_by_gene("hsa:7368")
serv.get_all_best_neighbors_by_gene("hsa:7368")
homologs.each
homologs.each do
do |hit||hit|
gene
gene == hit.genes_id2
hit.genes_id2
ifif motifs
motifs == serv.get_motifs_by_gene(gene,serv.get_motifs_by_gene(gene, "pfam")"pfam")
motifs.each
motifs.each do
do |motif||motif|namename == motif.motif_id
motif.motif_id
desc
desc == motif.definition
motif.definition
puts
puts "#{gene}:"#{gene}: #{name}#{name} #{desc}"#{desc}"
end
end
end
end
end
end

© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

Example: KO, OC, PC#!/usr/bin/env#!/usr/bin/env rubyrubyrequirerequire 'bio''bio'
serv
serv == Bio::KEGG::API.new
Bio::KEGG::API.new
ko_listko_list == serv.get_ko_by_gene("eco:b0002")
serv.get_ko_by_gene("eco:b0002")## listlist ofof genes
genes assigned
assigned same
same KO
KO (KEGG(KEGG orthology)
orthology)
ko_genes
ko_genes == serv.get_ko_members(ko_list.first)
serv.get_ko_members(ko_list.first)## listlist ofof genes
genes assigned
assigned toto samesame OC
OC (ortholog(ortholog cluster)cluster)
oc_genes
oc_genes == serv.get_all_oc_members_by_gene("hsa:7368")
serv.get_all_oc_members_by_gene("hsa:7368")## listlist ofof genes
genes assigned
assigned toto same
same PC
PC (paralog(paralog cluster)cluster)
pc_genes
pc_genes == serv.get_all_pc_members_by_gene("hsa:7368")
serv.get_all_pc_members_by_gene("hsa:7368")
puts
puts "#"# KO",
KO", ko_genes,
ko_genes, "#"# OC",
OC", oc_genes,
oc_genes, "#"# PC",
PC", pc_genes
pc_genes© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

9Example: getting database info/entries#!/usr/bin/env#!/usr/bin/env rubyrubyrequirerequire 'bio''bio'
serv
serv == Bio::KEGG::API.new
Bio::KEGG::API.new## lists
lists available
available organisms
organisms inin KEGG
KEGG
orgs
orgs == serv.list_organisms
serv.list_organismsorgs.eachorgs.each do
do |entry||entry|puts
puts "#{entry.entry_id}"#{entry.entry_id} #{entry.definition}"#{entry.definition}"endend## lists
lists available
available pathways
pathways in
in KEGGKEGG
list
list == serv.list_pathways("hsa")
serv.list_pathways("hsa")
list.eachlist.each do
do |entry||entry|puts
puts "#{entry.entry_id}"#{entry.entry_id} #{entry.definition}"#{entry.definition}"endend## getting
getting EMBL
EMBL entry
entry
puts
puts serv.bget("embl:BUM")
serv.bget("embl:BUM")## getting
getting entries
entries fromfrom KEGG
KEGG GENES
GENES
puts
puts serv.bget("hsa:7368
serv.bget("hsa:7368 hsa:7369")
hsa:7369")© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

Example: using PATHWAY#!/usr/bin/env#!/usr/bin/env rubyrubyrequire
require 'bio''bio'
serv
serv == Bio::KEGG::API.new
Bio::KEGG::API.new## lists
lists gene
gene ids
ids onon pathway
pathwaygenes
genes == serv.get_genes_by_pathway("path:hsa00020")
serv.get_genes_by_pathway("path:hsa00020")
puts
puts "#"# genes
genes onon human's
human's pathway
pathway 00020"
00020"
genes.each
genes.each do
do |gene||gene|
puts
puts gene
geneendend## converts
converts ECEC numbers
numbers toto genes
genes
list
list == ["ec:1.1.1.1",["ec:1.1.1.1", "ec:1.2.1.1"]"ec:1.2.1.1"]
list.eachlist.each do
do |ec||ec|
puts
puts "#"# E.
E. colicoli genes
genes forfor #{ec}"#{ec}"
puts
puts serv.get_genes_by_enzyme(ec,serv.get_genes_by_enzyme(ec, "eco")"eco")
end
end© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

10

Example: coloring PATHWAY#!/usr/bin/env#!/usr/bin/env rubyrubyrequirerequire 'bio''bio'serv
serv == Bio::KEGG::API.new
Bio::KEGG::API.new## markmark pathway
pathway
objs
objs == ['eco:b0002',['eco:b0002', 'cpd:C00263']'cpd:C00263']
url1
url1 == serv.mark_pathway_by_objects('path:eco00260',
serv.mark_pathway_by_objects('path:eco00260', objs)
objs)## color
color pathway
pathwayfg_listfg_list == ['blue',['blue', 'green']'green']bg_list=['#ff0000',bg_list = ['#ff0000', 'yellow']'yellow']
url2
url2 == serv.color_pathway_by_objects('path:eco00260',serv.color_pathway_by_objects('path:eco00260',objs,objs, fg_list,fg_list, bg_list)
bg_list)## savesave thethe result
result images
imagesserv.save_image(url1,serv.save_image(url1, "marked_pathway.gif")"marked_pathway.gif")serv.save_image(url2,serv.save_image(url2, "colored_pathway.gif")"colored_pathway.gif")© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

Example: gene expression and pathway analysis
serv
serv == Bio::KEGG::API.new
Bio::KEGG::API.new
list
list == serv.get_genes_by_pathway("path:bsu00020")
serv.get_genes_by_pathway("path:bsu00020")
fg_colors
fg_colors == Array.new
Array.new
bg_colors
bg_colors == Array.new
Array.newlist.eachlist.each do
do |gene||gene|
fg_colors
fg_colors <<<< "black""black"bg_colors
bg_colors <<<< ratio2rgb(gene)ratio2rgb(gene)
end
end
url
url == serv.color_pathway_by_objects(serv.color_pathway_by_objects("path:bsu00020","path:bsu00020", list,list, fg_colors,
fg_colors, bg_colors)
bg_colors)© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

11

Example: mapping PDB on pathway#!/usr/bin/env rubyrequire 'bio'
serv = Bio::KEGG::API.new# list of genes on specified pathway
path = ARGV.shift || "path:eco00010"
genes = serv.get_genes_by_pathway(path)# search DB links to PDB using LinkDB
results = Hash.new
genes.each do |gene|
if pdb_links = serv.get_all_linkdb_by_entry(gene, "pdb")
pdb_links.each do |link|
results[gene] = trueendendend# generates colored image
url = serv.mark_pathway_by_objects(path, results.keys)# save the image
serv.save_image(url, "linked_to_pdb.gif")© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

KEGG DAS http://das.hgc.jp/
 Currently including 188 organisms
 Data from KEGG GENOME and GENES Build on to of the GMOD/GBrowse© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

12

Organisms in KEGG DAS© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

KEGG ana© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

13

DAS view© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo

Example: sequence and annotations by DAS#!/usr/bin/env#!/usr/bin/env rubyrubyrequirerequire 'bio''bio'
serv
serv == Bio::DAS.new("http://das.hgc.jp/cgi-bin/")
Bio::DAS.new("http://das.hgc.jp/cgi-bin/")segment
segment == Bio::DAS::SEGMENT.region("I",
Bio::DAS::SEGMENT.region("I", 1001,1001, 2000)
2000)## getget DNADNA sequence
sequence fromfrom S.
S. cerevisiae
cerevisiae
list
list == serv.get_dna("sce",
serv.get_dna("sce", segment)
segment)
list.eachlist.each dodo |dna|
|dna|
puts
puts dna.sequencedna.sequenceend
end## getget featuresfeatures
list
list == serv.get_features("sce",serv.get_features("sce", segment)
segment)
list.segments.each
list.segments.each do
do |segment||segment|
segment.features.each
segment.features.each do
do |feature||feature|puts
puts feature.entry_id
feature.entry_id
puts
puts feature.startfeature.start
end
end
end
end
© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo14

Acknowledgements
BioRuby developers
Naohisa Goto, Mitsuteru Nakao, Yoshinori Okuji,Shuichi Kawashima, Masumi Itoh, Alex Gutteridge andsome other contributors on the net.

KEGG curators and KEGG API developers
Bioinformatics center, Human genome center
Yoko Sato, Miho Matsubayashi, Satoshi MiyazakiKEGG DASMayumi Takashio, Mari Watanabe

Open Bio* community© 2004 Toshiaki Katayama, Human Genome Center, University of TokyoURL BioRuby http://bioruby.org/
 CVS, ML - hosted at open-bio.org

 KEGG API
 http://www.genome.jp/kegg/soap/

 KEGG DAS
 http://das.hgc.jp/

 ISMB posters at E-29 G-17 C-45
© 2004 Toshiaki Katayama, Human Genome Center, University of Tokyo15