Cheminformatics for Ruby: Getting Started with Rubidium

Posted by Rich Apodaca Tue, 06 Nov 2007 16:17:00 GMT

Cheminformatics has seen the introduction of a diverse array of new open source software over the last few years. Using it all to its fullest potential is not always easy; differing languages, dependencies, interfaces, and varying levels of documentation make the job especially difficult. Rubidium is a new open source project aimed at changing that.

Rubidium is a full-featured cheminformatics scripting environment for Ruby. When complete, Rubidium will offer a single well-tested and well-documented Ruby interface to the best open source cheminformatics software. Rubidium-0.1.0 is now available for download.

Downloading and Installing Rubidium

Rubidium runs on JRuby, a pure Java implementation of the Ruby language. After installing JRuby on your system, you should be ready to install Rubidium.

Installation is most conveniently done with the Ruby package manager RubyGems.

The Rubidium RubyGem can be downloaded from RubyForge (large file). The gem command is all we need:

$ ll rbtk-0.1.0-jruby.gem
-rw-r--r-- 1 rich rich 12955136 Nov  6 07:56 rbtk-0.1.0-jruby.gem
$ jruby -S gem install rbtk-0.1.0.gem

Note: at the time of this writing, my installation of JRuby 1.0.1 was reporting an out of memory error when attempting to use the RubyForge RubyGems repository directly. Downloading Gems separately and then installing the local copy is a workaround.

Testing the Installation

Rubidium can be tested with the following code run in interactive JRuby (jirb):

$ jirb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> gem 'rbtk'
=> true
irb(main):003:0> require 'rubidium/lang'
=> true
irb(main):004:0> c=Rubidium::Converter.new
=> #<Rubidium::Converter:0xbd4e3c ... >
irb(main):005:0> c.set_formats 'smi', 'mol'
=> true
irb(main):006:0> c.convert 'c1ccccc1'
=> "\n  CDK    11/6/07,8:41\n\n  6  6  0  0  0  0  0  0  0  0999 V2000\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n  2  1  2  0  0  0  0 \n  3  2  1  0  0  0  0 \n  4  3  2  0  0  0  0 \n  5  4  1  0  0  0  0 \n  6  5  2  0  0  0  0 \n  6  1  1  0  0  0  0 \nM  END\n"

Low-Level Interface

There's not much yet to Rubidium itself beyond molecular language interconversions offered by the Chemistry Development Kit (CDK). But the CDK offers a wide range of cheminformatics functionality that is immediately accessible in raw form via JRuby itself. For example, we can calculate the TPSA of oxazepam:

$ jirb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> gem 'rbtk'
=> true
irb(main):003:0> require 'cdk/lang'
=> true
irb(main):004:0> import 'org.openscience.cdk.qsar.descriptors.molecular.TPSADescriptor'
=> ["org.openscience.cdk.qsar.descriptors.molecular.TPSADescriptor"]
irb(main):005:0> reader=CDK::SmilesReader.new
=> #<CDK::SmilesReader:0x1088a1b ... > 
irb(main):006:0> mol=reader.read 'O=C3Nc1ccc(Cl)cc1C(c2ccccc2)=NC3O'
=> #<Java::OrgOpenscienceCdk::Molecule:0x174f02c ... >
irb(main):007:0> tpsa = TPSADescriptor.new
=> #<Java::OrgOpenscienceCdkQsarDescriptorsMolecular::TPSADescriptor:0x14596d5 ...>
irb(main):008:0> result = tpsa.calculate mol
=> #<Java::OrgOpenscienceCdkQsar::DescriptorValue:0x171120a ..>
irb(main):009:0> result.value.double_value
=> 61.69

Conclusions

There's much more to be done with Rubidium. As more software packages and their Ruby interfaces are added, a major challenge will be to maintain a simple yet powerful interface to the underlying capabilities.

How Would Your Cheminformatics Tool Do This? 2

Posted by Rich Apodaca Mon, 05 Nov 2007 13:27:00 GMT

Reference: Dai, Liu, Zhou, and Nagle J. Nat. Prod.

Casual Saturdays: Wikipedia in 2001

Posted by Rich Apodaca Sat, 03 Nov 2007 14:12:00 GMT

Welcome to Wikipedia! We're writing a complete encyclopedia from scratch, collaboratively. We started work in January 2001. We've got over 6,000 pages already. We want to make over 100,000. So, let's get to work! Write a little (or a lot) about what you know. Read our welcome message here: Welcome, newcomers!

Eolas and jActivating: Working Around a Workaround

Posted by Rich Apodaca Fri, 02 Nov 2007 12:28:00 GMT

If you've spent any time using Java applets, you may have run across an annoying little "feature" of Internet Explorer 6/7. Before interacting with an applet, it's outlined in gray and displays the mouseover message "Click to activate and use this control."

This may not seem like much of an inconvenience, but it seems wrong to waste precious time explaining this kind of thing away to hundreds of perplexed users. Web applications should work intuitively; clicking to activate something is just counterintuitive.

Earlier versions of IE lacked this feature. It was added as the result of a patent lawsuit that Microsoft lost (and I was actually rooting for them that time!). The suit was filed by a company called Eolas who were granted patent number 5,838,906 in 1998 for the invention of:

A system allowing a user of a browser program on a computer connected to an open distributed hypermedia system to access and execute an embedded program object."

In other words, browser plugins.

As a result of losing the Eolas suit, Microsoft was forced to cripple IE with the bizarre "click to activate" workaround.

Regardless of your thoughts on the validity or utility of software patents, the Eolas case has very real effects for Web developers everywhere.

Fortunately, there are a variety of workarounds to this problem. Two of the most effective are:

  1. Replace all <applet> or <object> tags with JavaScript calls to document.write. This function must be called from a file separate from the HTML file itself.

  2. Use the excellent jActivating library.

While both solutions work, jActivating does so without requiring you to touch your HTML markup. Simply include a small JavaScript file in your <head> tag and be done with it.

Behind the scenes, jActivating strips out your <applet> and <object> tags, replacing them with dynamically-generated tags that apparently fall outside the scope of the Eolas Patent.

Let's hear it for workarounds!

How Would Your Cheminformatics Tool Do This?

Posted by Rich Apodaca Thu, 01 Nov 2007 13:10:00 GMT

Reference: Higham, Muldoon, Kelly, Corr, Mueller-Bunz, and Gilheany J. Org. Chem.

Older posts: 1 ... 3 4 5