building a restful structure resource using ruby on rails - chemaxon

24
Building a RESTful Structure Resource Using Ruby on Rails Craig Knox - September 16, 2009 University of Alberta Outline 1. Backstory/Motivation 2. Goal 3. Ingredients 4. Results and Future Work

Upload: others

Post on 11-Feb-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Building a RESTful Structure Resource Using Ruby on Rails

Craig Knox - September 16, 2009University of Alberta

Outline

1. Backstory/Motivation

2. Goal

3. Ingredients

4. Results and Future Work

Motivation

• DrugBank - 6568 structures (www.drugbank.ca)

• HMDB - 7982 structures (www.hmdb.ca)

• FooDB - ~2000 structures (www.foodbs.org/foodb)

• T3DB - ~3000 structures (www.t3db.org)

DrugBank Structure Update Process

• Update a structure by changing the mol file

• LIMS program tries to catch this change and update the other fields by doing system calls (black box, high failure rate)

• Out of sync with DrugBank until update (file links no longer work on DrugBank)

• Update:

• Detect structure changed, re-upload to structure server

• Get resultant chemical ID and update DrugBank

• Re-run index file on other parameters

• What about other databases (HMDB)?

• Passes through 3 code bases before update complete

Motivation

• Structure search

• Synchronization

• Structure feature prediction/elucidation

• Centralized, standard access

Goal

Structure Hub

DrugBank

MetaboLIMST3DB

FooDBDrugBank

HMDB BioSpider

SMPDB

Goal

• Structure Hub:

• Support CRUD (Create, Read, Update, Delete)

• Searchable (sub/super structure, similarity, exact)

• Fast/dependable

• Standard interface

Ingredients

Database

Server (application

gateway)

Remote

JChem Base

JChem

• JChem is a sophisticated cheminformatics tool written in Java

• Allows for storage of structures and structural descriptors in a backend database

• Supports advanced and fast structure search

JChem Base

• Stores structures in MySQL

• Allows for automatic calculation of an unlimited number of “chemical terms” following database insert/update

Chemical Terms• Examples:

• logp

• pka or pKa("acidic", "2") (second strongest acidic pKa)

• tautomer(0) - first tautomer

• solubility(“7.4”) -- solubility at pH 7.4

• vanDerWaalsSurfaceArea(“7.4”) --van der

Chemical Terms

• exact_mass

• formula

• ring_count

• isoelectricPoint

• iupac_name

Chemical Terms

• Bioavailability:

(mass() <= 500) +(logP() <= 5) +(donorCount() <= 5) +(acceptorCount() <= 10) +(rotatableBondCount() <= 10) +(PSA() <= 200) +(fusedAromaticRingCount() <= 5) >= 6

Chemical Terms

• Lipinsky Rule of 5:

(mass() <= 500) && (logP() <= 5) && (donorCount() <= 5) && (acceptorCount() <= 10)

Chemical Terms

• http://www.chemaxon.com/marvin/help/chemicalterms/ChemicalTerms.html

• http://www.chemaxon.com/marvin/help/chemicalterms/EvaluatorTables.html

Ingredients

Database

Server (application

gateway)

Remote

jRuby on Rails

JChem Base

• Designed in Japan in 1995

• Syntax inspired by Perl, Python

• Open-source, cross-platform

• Purely object oriented: everything is an object

• Enforces principles of good user interface design

• Follows the principle of least surprise

Ruby

Ruby

• “Often people, especially computer engineers, focus on the machines. They think, "By doing this, the machine will run faster. By doing this, the machine will run more effectively. By doing this, the machine will something something something." They are focusing on machines. But in fact we need to focus on humans, on how humans care about doing programming or operating the application of the machines. We are the masters. They are the slaves.”

Ruby on Rails

• Open-source, full-stack web-framework

• MVC

• Convention Over Configuration

• Don’t Repeat Yourself (DRY)

• JRuby is an implementation of the Ruby programming language atop the Java Virtual Machine.

• Runs Ruby on Rails

• Runs Java code embedded in Ruby code

• Why?

jRuby

jRuby and jChem

• jChem is a java toolkit

• Using jRuby, we can use it from with Ruby and Ruby on Rails

jRuby on Rails

• jRuby runs Ruby on Rails faster than regular MRI Ruby (for now)

• Glassfish server - Apache

REST Support

• Ruby on Rails supports REST right out of the box

Ingredients

Database

Server (application

gateway)

Remote REST

jRuby on Rails

JChem Base

REST!

• REST - Representational State Transfer

• Fielding, Roy Thomas. Architectural Styles and the Design of Network-based Software Architectures. Doctoral dissertation, University of California, Irvine, 2000.

• Data is a set of resources accessed by URLs

• Data created, read, updated, and deleted (CRUD) via 4 simple nouns:

• POST, GET, PUT, DELETE

REST and structures

• POST

• Post an XML form containing the new structure (no ID) to:

• http://structures.drugbank.ca/structures

• Create a new structure and return the ID

REST and structures

• GET

• http://structures.drugbank.ca/structures/1.xml

• Read the structure with ID 1

REST and structures

• PUT

• Put an XML form containing the updated structure (has an ID of 1) to:

• http://structures.drugbank.ca/structures/1

• Update structure 1 with new information

REST and structures

• DELETE

• Send a delete request for the structure with ID 1:

• http://structures.drugbank.ca/structures/1

• Delete the structure with ID 1

REST

• We can now create, read, update, and delete structures using an extremely simple set of actions

• We can call these methods from the command line (curl/wget), scripts, programs, and databases

ActiveResource

• Rails has built-in support for accessing RESTful resources

• Just tell it the URL and you get the rest for free

DrugBank

MetaboLIMST3DB LIMS

FooDB

DrugBank

HMDB BioSpider

GET

GET GET

GET

GETGET

GET

POST/PUT/DELETE

POST/PUT/DELETE

POST/PUT/DELETE

POST/PUT/DELETE

Structure Hub

Structure Hub

Database

Server (application

gateway)

Remote REST

jRuby on Rails

JChem Base

Results

• DrugBank LIMS - Ruby on Rails application

• DrugBank Public Site - Perl/CGI

• Structure database

Future Work

Structure Hub

In House

Internet

Conclusion

• Structures can now be accessed from any database

• Hub supports CRUD (Create, Read, Update, Delete)

• Structure search

• Synchronization

• Drawbacks

Credits

• David Wishart

• Joseph Cruz

• Emilia Lim and Allison Pon

• Genome Alberta

Thanks!Questions