SlideShare a Scribd company logo
1 of 13
Download to read offline
The Ruby UCSC API:
 accessing the UCSC Genome
 Database using Ruby
                Hiroyuki Mishima(1, Jan Aerts(2, Toshiaki Katayama(3,
                Raoul J.P. Bonnal(4, Koh-ichiro Yoshiura(1
                                      1)Nagasaki University, Japan;
                                      2)Leuven University, Belgium;
                                      3)DBCLS, ROIS, Japan;
                                      4)Instituto Nazionale Genetica Molecolare, Italy

20th Annual International Conference on Integrate Systems for Molecular Biology
2012 July 15-17, @Long Beach, CA, USA
Background:
The University of California, Santa Cruz (UCSC) genome database is among the most used
sources of genomic annotation in human and other organisms. The database offers excellent
web-based graphical user interface (the UCSC genome browser) and several means for
programmatic queries. A simple application programming interface (API) in a scripting
language aimed at the biologist was however not yet available. Here, we present the Ruby
UCSC API, a library to access the UCSC genome database using Ruby.
Results:
The API is designed as a BioRuby plug-in (Biogem) and built on the ActiveRecord 3 framework
for the object-relational mapping, making writing SQL statements unnecessary. The current
version of the API supports databases of all organisms in the UCSC genome database including
human, mammals, vertebrates, deuterostomes, insects, nematodes, and yeast.
The API uses the bin index—if available—when querying for genomic intervals. The API also
supports genomic sequence queries using locally downloaded *.2bit files that are not stored
in the official MySQL database. The API is implemented in pure Ruby and is therefore available
in different environments and with different Ruby interpreters (including JRuby).
Conclusions:
Assisted by the straightforward object-oriented design of Ruby and ActiveRecord, the Ruby
UCSC API will facilitate biologists to query the UCSC genome database programmatically. The
API is available through the RubyGem system. Source codes and documentations are available
at https://github.com/misshie/bioruby-ucsc-api/                                         2
The UCSC genome database
• UCSC genome database is among the most used
  sources of genomic annotation in human and
  other organisms.
• Excellent web-based graphical user interface
  (the UCSC genome browser) and several means
  for programmatic queries.
• A simple application programming interface
  (API) in a scripting language aimed at the
  biologist was however not yet available.
• Supporting a large number of tables (>40,000) is
  still challenging.                            3
Ruby UCSC API
• A Ruby library to access
  the UCSC genome
  database.
• Designed as a Biogem -
  BioRuby plug-in
• Built on the ActiveRecord
  3 framework for an
  object-relational mapping.
• Written in pure Ruby –
  supporting MRI Ruby          Design structure of
  1.9/1.8 and JRuby            the Ruby UCSC API
                                                     4
Dynamic Table Class Definition

• The UCSC database is optimized to serve the genome
  browser, resulting in a very large number of tables
   • > 41,840 tables as MySQL *.MYD files
• Database components are updated frequently.
• Ruby UCSC API adopts dynamic class definition to
  handle many table classes.
• When a table class referred for the first time, the API
  prefetch fields of the table to detect a table type and
  define appropriate table class. Additionally, this lazy
  evaluation of class definition makes API initialization
  much faster.
                                                            5
Availability and Installation
  Installation via RubyGems

        $ gem install bio-ucsc-api

  GitHub
  https://github.com/misshie/bioruby-ucsc-api
  Support Forum
  http://rubyucscapi.userecho.com/
  RubyGems.org
  https://rubygems.org/gems/bio-ucsc-api
                                                6
Sample Codes and Features
    require 'bio-ucsc‘
    Bio::Ucsc::Hg19.connect
    result =
      Bio::Ucsc::Hg19::Snp131.
      find_by_name("rs56289060")
    puts result.chrom # => "chr1"
  • Supporting all organisms and at least newest
    assemblies
  • Supporting UCSC’s official MySQL server and local
    mirror MySQL servers
  • ActiveRecord’s object-relation mapping              7
region = "chr17:7,579,614-7,579,700"
    condition =
      Bio::Ucsc::Hg19::Snp131.
      with_interval(region).select(:name)
    puts condition.to_sql


    SELECT name FROM `snp131`
    WHERE (chrom = 'chr17' AND bin in (642,80,9,1,0)
     AND ( (chromStart BETWEEN 7579613 AND 7579700)
        OR (chromEnd BETWEEN 7579613 AND 7579700)
        OR (chromStart <= 7579613 AND
            chromEND >= 7579700) ));

• Generating complex SQL statements using relations
• The bin index is, if available, used to accelerate queries.
                                                          8
# declaration of the table association
  Ucsc::Hg19::KnownGene.class_eval do
    has_one :knownToEnsembl, {:primary_key => :name,
                              :foreign_key => :name}
  end
  # reference to an associated field
  puts Ucsc::Hg19::KnownGene.first.name
    # => “uc001aaa3”
  puts Ucsc::Hg19::KnownGene.first.knownToEnsembl.value
    # => "ENST00000456328"


• The user can define table associations.
• Associated tables can be accessed like fields of the
  table.
                                                         9
1: # load a locally-stored sequence file,
      and extract partial seqence
 2: seq = Ucsc::File::Twobit.open("hg19.2bit")
 3: puts seq.subseq("chr1:9990-10009")
      # => "NNNNNNNNNNNTAACCCTAA"

• In the UCSC genome database, genomic sequences are
  not stored in the MySQL databases but in *.2bit files.
• Reference sequence objects are generated by the
  File::Twobit.open class methods, and sequences
  can be retrieved by the File::Twobit#subseq
  method.
                                                    10
Supported Databases
clade/organism     databases
human              Hg19, Hg18
mammals            chimp (PanTro3), orangutan (PonAbe2), rhesus (RheMac2), marmoset (CalJac3),
                   mouse (Mm9), rat (Rn4), guinea pig (CavPor3), rabbit (OryCun2), cat (FelCat4),
                   panda (AilMel1), dog (CanFam2), horse (EquCab2), pig (SusScr2), sheep
                   (OviAri1), cow (BosTau4), elephant (LoxAfr3), opossum (MonDom5), platypus
                   (OrnAna1)
vertebrates        chicken (GalGal3), zebra finch (TaeGut1), lizard (AnoCar2), X. tropicalis
                   (XenTro2), zebrafish (DanRer7), tetraodon (TetNig2), fugu (Fr2), stickleback
                   (GasAcu1), medaka (OryLat2), lamprey (PetMar1)
deuterostomes      lancelet (BraFlo1), sea squirt (Ci2), sea urchin (StrPur2)
insects            D.melanogaster (Dm3), D.simulans (DroSim1), D.sechellia (DroSec1), D.yakuba
                   (DroYak2), D.erecta (DroEre1), D.ananassae (DroAna2), D.pseudoobscura (Dp3),
                   D.persimilis (DroPer1), D.virilis (DroVir2), D.mojavensis (DroMoj2), D.grimshawi
                   (DroGri1), Anopheles mosquito (AnoGam1), honey bee (ApiMel2)
nematodes          C.elegans (Ce6), C.brenneri (CaePb3), C.briggsae (Cb3), C.remanei (CaeRem3),
                   C.japonica (CaeJap1), P.pacificus (PriPac1)
others             sea hare (AplCal1), yeast (SacCer2)
common databases   Go, HgFixed, Proteome, UniProt, VisiGene                                   11
Current Limitations

• Table associations are not defined automatically.
• For some tables including subsets of the
  ENCODE tables, the actual data are not stored in
  the MySQL database itself but are stored as
  references to BigWig, BigBed and BAM files. To
  date, the Ruby UCSC API does not support them
  yet. Instead, a Biogem, “bio-samtools”, suppots
  BAM file handlings.
                                                12
Conclusions

 • UCSC’s official executables and C libraries are
   the most comprehensive and fastest API for the
   UCSC genome database.
 • However, APIs for scripting languages still have
   significant advantages for the user because
   their concern is not only runtime speed but also
   total time from programming to results.
 • The Ruby UCSC API can therefore have a
   significant impact in the field.
                                                 13

More Related Content

Similar to The Ruby UCSC API @ISMB2012

Biological Database (1)pptxpdfpdfpdf.pdf
Biological Database (1)pptxpdfpdfpdf.pdfBiological Database (1)pptxpdfpdfpdf.pdf
Biological Database (1)pptxpdfpdfpdf.pdfBioinformaticsCentre
 
Danis biosystematics2011
Danis biosystematics2011Danis biosystematics2011
Danis biosystematics2011Bruno Danis
 
Databases_CSS2.pptx
Databases_CSS2.pptxDatabases_CSS2.pptx
Databases_CSS2.pptxSilpa87
 
Introduction to Galaxy and RNA-Seq
Introduction to Galaxy and RNA-SeqIntroduction to Galaxy and RNA-Seq
Introduction to Galaxy and RNA-SeqEnis Afgan
 
2016 bioinformatics i_databases_wim_vancriekinge
2016 bioinformatics i_databases_wim_vancriekinge2016 bioinformatics i_databases_wim_vancriekinge
2016 bioinformatics i_databases_wim_vancriekingeProf. Wim Van Criekinge
 
The Pacific Research Platform
 Two Years In
The Pacific Research Platform
 Two Years InThe Pacific Research Platform
 Two Years In
The Pacific Research Platform
 Two Years InLarry Smarr
 
2015 10-7-11am-reproducible research
2015 10-7-11am-reproducible research2015 10-7-11am-reproducible research
2015 10-7-11am-reproducible researchYannick Wurm
 
SeqinR - biological data handling
SeqinR - biological data handlingSeqinR - biological data handling
SeqinR - biological data handlingpau_corral
 
How to be a bioinformatician
How to be a bioinformaticianHow to be a bioinformatician
How to be a bioinformaticianChristian Frech
 
Role of bioinformatics in life sciences research
Role of bioinformatics in life sciences researchRole of bioinformatics in life sciences research
Role of bioinformatics in life sciences researchAnshika Bansal
 
Computational Resources In Infectious Disease
Computational Resources In Infectious DiseaseComputational Resources In Infectious Disease
Computational Resources In Infectious DiseaseJoão André Carriço
 
Using Supercomputers and Supernetworks to Explore the Ocean of Life
Using Supercomputers and Supernetworks to Explore the Ocean of LifeUsing Supercomputers and Supernetworks to Explore the Ocean of Life
Using Supercomputers and Supernetworks to Explore the Ocean of LifeLarry Smarr
 
E-Utilities
E-UtilitiesE-Utilities
E-Utilitiesmkim8
 
NCBI API - Integration into analysis code
NCBI API - Integration into analysis codeNCBI API - Integration into analysis code
NCBI API - Integration into analysis codeJiwoong Kim
 
BioThings API: Building a FAIR API Ecosystem for Biomedical Knowledge
BioThings API: Building a FAIR API Ecosystem for Biomedical KnowledgeBioThings API: Building a FAIR API Ecosystem for Biomedical Knowledge
BioThings API: Building a FAIR API Ecosystem for Biomedical KnowledgeChunlei Wu
 

Similar to The Ruby UCSC API @ISMB2012 (20)

Bio2RDF @ W3C HCLS2009
Bio2RDF @ W3C HCLS2009Bio2RDF @ W3C HCLS2009
Bio2RDF @ W3C HCLS2009
 
NGS: Mapping and de novo assembly
NGS: Mapping and de novo assemblyNGS: Mapping and de novo assembly
NGS: Mapping and de novo assembly
 
Biological Database (1)pptxpdfpdfpdf.pdf
Biological Database (1)pptxpdfpdfpdf.pdfBiological Database (1)pptxpdfpdfpdf.pdf
Biological Database (1)pptxpdfpdfpdf.pdf
 
Danis biosystematics2011
Danis biosystematics2011Danis biosystematics2011
Danis biosystematics2011
 
Databases_CSS2.pptx
Databases_CSS2.pptxDatabases_CSS2.pptx
Databases_CSS2.pptx
 
Introduction to Galaxy and RNA-Seq
Introduction to Galaxy and RNA-SeqIntroduction to Galaxy and RNA-Seq
Introduction to Galaxy and RNA-Seq
 
2013 oct 2 rna sequencing
2013 oct 2 rna sequencing2013 oct 2 rna sequencing
2013 oct 2 rna sequencing
 
2016 bioinformatics i_databases_wim_vancriekinge
2016 bioinformatics i_databases_wim_vancriekinge2016 bioinformatics i_databases_wim_vancriekinge
2016 bioinformatics i_databases_wim_vancriekinge
 
Major databases in bioinformatics
Major databases in bioinformaticsMajor databases in bioinformatics
Major databases in bioinformatics
 
The Pacific Research Platform
 Two Years In
The Pacific Research Platform
 Two Years InThe Pacific Research Platform
 Two Years In
The Pacific Research Platform
 Two Years In
 
2015 10-7-11am-reproducible research
2015 10-7-11am-reproducible research2015 10-7-11am-reproducible research
2015 10-7-11am-reproducible research
 
SeqinR - biological data handling
SeqinR - biological data handlingSeqinR - biological data handling
SeqinR - biological data handling
 
How to be a bioinformatician
How to be a bioinformaticianHow to be a bioinformatician
How to be a bioinformatician
 
Bio2RDF@BH2010
Bio2RDF@BH2010Bio2RDF@BH2010
Bio2RDF@BH2010
 
Role of bioinformatics in life sciences research
Role of bioinformatics in life sciences researchRole of bioinformatics in life sciences research
Role of bioinformatics in life sciences research
 
Computational Resources In Infectious Disease
Computational Resources In Infectious DiseaseComputational Resources In Infectious Disease
Computational Resources In Infectious Disease
 
Using Supercomputers and Supernetworks to Explore the Ocean of Life
Using Supercomputers and Supernetworks to Explore the Ocean of LifeUsing Supercomputers and Supernetworks to Explore the Ocean of Life
Using Supercomputers and Supernetworks to Explore the Ocean of Life
 
E-Utilities
E-UtilitiesE-Utilities
E-Utilities
 
NCBI API - Integration into analysis code
NCBI API - Integration into analysis codeNCBI API - Integration into analysis code
NCBI API - Integration into analysis code
 
BioThings API: Building a FAIR API Ecosystem for Biomedical Knowledge
BioThings API: Building a FAIR API Ecosystem for Biomedical KnowledgeBioThings API: Building a FAIR API Ecosystem for Biomedical Knowledge
BioThings API: Building a FAIR API Ecosystem for Biomedical Knowledge
 

Recently uploaded

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

The Ruby UCSC API @ISMB2012

  • 1. The Ruby UCSC API: accessing the UCSC Genome Database using Ruby Hiroyuki Mishima(1, Jan Aerts(2, Toshiaki Katayama(3, Raoul J.P. Bonnal(4, Koh-ichiro Yoshiura(1 1)Nagasaki University, Japan; 2)Leuven University, Belgium; 3)DBCLS, ROIS, Japan; 4)Instituto Nazionale Genetica Molecolare, Italy 20th Annual International Conference on Integrate Systems for Molecular Biology 2012 July 15-17, @Long Beach, CA, USA
  • 2. Background: The University of California, Santa Cruz (UCSC) genome database is among the most used sources of genomic annotation in human and other organisms. The database offers excellent web-based graphical user interface (the UCSC genome browser) and several means for programmatic queries. A simple application programming interface (API) in a scripting language aimed at the biologist was however not yet available. Here, we present the Ruby UCSC API, a library to access the UCSC genome database using Ruby. Results: The API is designed as a BioRuby plug-in (Biogem) and built on the ActiveRecord 3 framework for the object-relational mapping, making writing SQL statements unnecessary. The current version of the API supports databases of all organisms in the UCSC genome database including human, mammals, vertebrates, deuterostomes, insects, nematodes, and yeast. The API uses the bin index—if available—when querying for genomic intervals. The API also supports genomic sequence queries using locally downloaded *.2bit files that are not stored in the official MySQL database. The API is implemented in pure Ruby and is therefore available in different environments and with different Ruby interpreters (including JRuby). Conclusions: Assisted by the straightforward object-oriented design of Ruby and ActiveRecord, the Ruby UCSC API will facilitate biologists to query the UCSC genome database programmatically. The API is available through the RubyGem system. Source codes and documentations are available at https://github.com/misshie/bioruby-ucsc-api/ 2
  • 3. The UCSC genome database • UCSC genome database is among the most used sources of genomic annotation in human and other organisms. • Excellent web-based graphical user interface (the UCSC genome browser) and several means for programmatic queries. • A simple application programming interface (API) in a scripting language aimed at the biologist was however not yet available. • Supporting a large number of tables (>40,000) is still challenging. 3
  • 4. Ruby UCSC API • A Ruby library to access the UCSC genome database. • Designed as a Biogem - BioRuby plug-in • Built on the ActiveRecord 3 framework for an object-relational mapping. • Written in pure Ruby – supporting MRI Ruby Design structure of 1.9/1.8 and JRuby the Ruby UCSC API 4
  • 5. Dynamic Table Class Definition • The UCSC database is optimized to serve the genome browser, resulting in a very large number of tables • > 41,840 tables as MySQL *.MYD files • Database components are updated frequently. • Ruby UCSC API adopts dynamic class definition to handle many table classes. • When a table class referred for the first time, the API prefetch fields of the table to detect a table type and define appropriate table class. Additionally, this lazy evaluation of class definition makes API initialization much faster. 5
  • 6. Availability and Installation Installation via RubyGems $ gem install bio-ucsc-api GitHub https://github.com/misshie/bioruby-ucsc-api Support Forum http://rubyucscapi.userecho.com/ RubyGems.org https://rubygems.org/gems/bio-ucsc-api 6
  • 7. Sample Codes and Features require 'bio-ucsc‘ Bio::Ucsc::Hg19.connect result = Bio::Ucsc::Hg19::Snp131. find_by_name("rs56289060") puts result.chrom # => "chr1" • Supporting all organisms and at least newest assemblies • Supporting UCSC’s official MySQL server and local mirror MySQL servers • ActiveRecord’s object-relation mapping 7
  • 8. region = "chr17:7,579,614-7,579,700" condition = Bio::Ucsc::Hg19::Snp131. with_interval(region).select(:name) puts condition.to_sql SELECT name FROM `snp131` WHERE (chrom = 'chr17' AND bin in (642,80,9,1,0) AND ( (chromStart BETWEEN 7579613 AND 7579700) OR (chromEnd BETWEEN 7579613 AND 7579700) OR (chromStart <= 7579613 AND chromEND >= 7579700) )); • Generating complex SQL statements using relations • The bin index is, if available, used to accelerate queries. 8
  • 9. # declaration of the table association Ucsc::Hg19::KnownGene.class_eval do has_one :knownToEnsembl, {:primary_key => :name, :foreign_key => :name} end # reference to an associated field puts Ucsc::Hg19::KnownGene.first.name # => “uc001aaa3” puts Ucsc::Hg19::KnownGene.first.knownToEnsembl.value # => "ENST00000456328" • The user can define table associations. • Associated tables can be accessed like fields of the table. 9
  • 10. 1: # load a locally-stored sequence file, and extract partial seqence 2: seq = Ucsc::File::Twobit.open("hg19.2bit") 3: puts seq.subseq("chr1:9990-10009") # => "NNNNNNNNNNNTAACCCTAA" • In the UCSC genome database, genomic sequences are not stored in the MySQL databases but in *.2bit files. • Reference sequence objects are generated by the File::Twobit.open class methods, and sequences can be retrieved by the File::Twobit#subseq method. 10
  • 11. Supported Databases clade/organism databases human Hg19, Hg18 mammals chimp (PanTro3), orangutan (PonAbe2), rhesus (RheMac2), marmoset (CalJac3), mouse (Mm9), rat (Rn4), guinea pig (CavPor3), rabbit (OryCun2), cat (FelCat4), panda (AilMel1), dog (CanFam2), horse (EquCab2), pig (SusScr2), sheep (OviAri1), cow (BosTau4), elephant (LoxAfr3), opossum (MonDom5), platypus (OrnAna1) vertebrates chicken (GalGal3), zebra finch (TaeGut1), lizard (AnoCar2), X. tropicalis (XenTro2), zebrafish (DanRer7), tetraodon (TetNig2), fugu (Fr2), stickleback (GasAcu1), medaka (OryLat2), lamprey (PetMar1) deuterostomes lancelet (BraFlo1), sea squirt (Ci2), sea urchin (StrPur2) insects D.melanogaster (Dm3), D.simulans (DroSim1), D.sechellia (DroSec1), D.yakuba (DroYak2), D.erecta (DroEre1), D.ananassae (DroAna2), D.pseudoobscura (Dp3), D.persimilis (DroPer1), D.virilis (DroVir2), D.mojavensis (DroMoj2), D.grimshawi (DroGri1), Anopheles mosquito (AnoGam1), honey bee (ApiMel2) nematodes C.elegans (Ce6), C.brenneri (CaePb3), C.briggsae (Cb3), C.remanei (CaeRem3), C.japonica (CaeJap1), P.pacificus (PriPac1) others sea hare (AplCal1), yeast (SacCer2) common databases Go, HgFixed, Proteome, UniProt, VisiGene 11
  • 12. Current Limitations • Table associations are not defined automatically. • For some tables including subsets of the ENCODE tables, the actual data are not stored in the MySQL database itself but are stored as references to BigWig, BigBed and BAM files. To date, the Ruby UCSC API does not support them yet. Instead, a Biogem, “bio-samtools”, suppots BAM file handlings. 12
  • 13. Conclusions • UCSC’s official executables and C libraries are the most comprehensive and fastest API for the UCSC genome database. • However, APIs for scripting languages still have significant advantages for the user because their concern is not only runtime speed but also total time from programming to results. • The Ruby UCSC API can therefore have a significant impact in the field. 13