<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Depth-First: Tag jruby</title>
    <link>http://depth-first.com/articles/tag/jruby</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>CampDepict: Building a Simple SMILES Depict Web Application With JRuby, Structure CDK, and Camping</title>
      <description>&lt;p&gt;&lt;a href="http://redhanded.hobix.com/bits/campingAMicroframework.html"&gt;&lt;img src="http://depth-first.com/demo/20080423/camping.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;Today's tribute to the power of simplicity comes by way of &lt;a href="http://goeslightly.blogspot.com/"&gt;John Jaeger&lt;/a&gt;, who has built one of the simplest cheminformatics Web applications ever written. His creation, &lt;a href="http://goeslightly.blogspot.com/2008/04/campdepict-jruby-cdk-and-camping.html"&gt;CampDepict&lt;/a&gt;, interactively produces a raster image of a 2D chemical structure given a SMILES string, not unlike &lt;a href="http://www.daylight.com/daycgi/depict"&gt;Daylight's Depict application&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;CampDepict uses the Ruby Web microframework &lt;a href="http://redhanded.hobix.com/bits/campingAMicroframework.html"&gt;Camping&lt;/a&gt;. From the &lt;a href="http://camping.rubyforge.org/files/README.html"&gt;README&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Camping is a web framework which consistently stays at less than 4kb of code. You can probably view the complete source code on a single page. But, you know, it&#8216;s so small that, if you think about it, what can it really do?&lt;/p&gt;
    
    &lt;p&gt;The idea here is to store a complete fledgling web application in a single file like many small CGIs. But to organize it as a Model-View-Controller application like Rails does. You can then easily move it to Rails once you&#8216;ve got it going.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;John's application is loosely-based on the &lt;a href="http://depth-first.com/articles/2006/12/04/anatomy-of-a-cheminformatics-web-application-ajaxifying-depict"&gt;Rails Depict&lt;/a&gt; application first described in 2006 here on Depth-First. His code makes use of &lt;a href="http://cdk.sf.net"&gt;CDK&lt;/a&gt; and &lt;a href="http://sf.net/projects/structure"&gt;Structure CDK&lt;/a&gt;, and it runs on &lt;a href="http://jruby.codehaus.org/"&gt;JRuby&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you've ever been curious about what Ruby has to offer cheminformatics, CampDepict could be just the application to get your feet wet.&lt;/p&gt;</description>
      <pubDate>Wed, 23 Apr 2008 11:16:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:b831ffb0-cb0a-46ed-aaa1-a5cddc2acfcf</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/04/23/campdepict-building-a-simple-smiles-depict-web-application-with-jruby-structure-cdk-and-camping</link>
      <category>Tools</category>
      <category>camping</category>
      <category>ruby</category>
      <category>jruby</category>
      <category>campdepict</category>
      <category>structurecdk</category>
      <category>cdk</category>
      <category>webapplication</category>
    </item>
    <item>
      <title>Chempedia.net: Mashing Up PubChem and Wikipedia</title>
      <description>&lt;p&gt;&lt;a href="http://chempedia.com"&gt;&lt;img src="http://chempedia.net/images/global/logo.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://pubchem.ncbi.nlm.nih.gov/"&gt;PubChem&lt;/a&gt; and &lt;a href="http://wikipedia.net"&gt;Wikipedia&lt;/a&gt; represent two of the largest open repositories of chemical information in the world. And they complement each other very nicely. PubChem contains mainly low-level chemical structure information whereas Wikipedia contains free-text descriptions of chemical compounds in the form of &lt;a href="http://depth-first.com/articles/2008/04/02/wikipedia-for-cheminformatics-a-simple-web-api-for-finding-cas-numbers-in-compound-monographs"&gt;compound monographs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Both services offer permission and access to copy and reuse their contents. But neither service is, by itself, nearly as useful as it could be.&lt;/p&gt;

&lt;p&gt;Why not mash them up?&lt;/p&gt;

&lt;p&gt;To explore that question my company, &lt;a href="http://metamolecular.com"&gt;Metamolecular, LLC&lt;/a&gt; has launched &lt;a href="http://chempedia.com"&gt;Chempedia&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To my knowledge, Chempedia represents the first publicly-facing database of compounds to incorporate Wikipedia's collection of organic compound monographs. And it's one of the few cheminformatics services to make use of free-text descriptions generated by individual chemists.&lt;/p&gt;

&lt;p&gt;Chempedia has been somewhat selective about the compounds it includes. To date, it has spidered over 2,500 monographs, combining them with over 300,000 of the most interesting compounds from PubChem. Not every Chempedia.net molecule has a monograph, but now there's a tool that can actually make that absence apparent.&lt;/p&gt;

&lt;p&gt;Chempedia is both an experiment and a service. It's immediately useful for anyone in the business of making or doing things with organic molecules. It's created several unexpected moments of "Oh, that's actually a useful molecule!" It also will serve as a platform to test some of the ideas discussed in Depth-First over the last year or so on the advantages of the Web for collaboration in chemistry.&lt;/p&gt;

&lt;p&gt;Stay tuned for more details about how Chempedia was created and some of its applications in chemistry.&lt;/p&gt;</description>
      <pubDate>Fri, 04 Apr 2008 10:06:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:168432fb-c064-43c2-a60d-728c7c29c406</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2008/04/04/chempedia-net-mashing-up-pubchem-and-wikipedia</link>
      <category>Tools</category>
      <category>chempedia</category>
      <category>wikipedia</category>
      <category>pubchem</category>
      <category>rails</category>
      <category>ruby</category>
      <category>chemwriter</category>
      <category>applet</category>
      <category>java</category>
      <category>jruby</category>
    </item>
    <item>
      <title>Simple Installation of Rubidium</title>
      <description>&lt;p&gt;&lt;a href="http://rbtk.rubyforge.org/"&gt;&lt;img src="http://depth-first.com/demo/20071015/rubidium.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://rbtk.rubyforge.org/"&gt;Rubidium&lt;/a&gt; is a Ruby cheminformatics scripting environment. Previously, &lt;a href="http://depth-first.com/articles/2007/11/12/parsing-sd-files-with-ruby-and-rubidium"&gt;a problem&lt;/a&gt; was reported with the RubyForge gem repository that prevented the simple installation of the Rubidium gem. After filing a &lt;a href="http://rubyforge.org/tracker/index.php?func=detail&amp;amp;aid=15665&amp;amp;group_id=5&amp;amp;atid=101"&gt;bug report&lt;/a&gt;, the problem was resolved.&lt;/p&gt;

&lt;p&gt;The problem, which led to a 404 being issued when trying to install the gem from the remote RubyGems repository, was a variant of a &lt;a href="http://rubyforge.org/tracker/index.php?func=detail&amp;amp;aid=15417&amp;amp;group_id=5&amp;amp;atid=102"&gt;known RubyForge issue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can now install Rubidium like this:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jruby -S gem install rbtk
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Installation takes a few minutes due to the large size of the included &lt;a href="http://cdk.sf.net"&gt;Chemistry Development Kit&lt;/a&gt; jarfile.&lt;/p&gt;</description>
      <pubDate>Wed, 21 Nov 2007 09:26:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:f0a52354-e6aa-4a02-b329-4b5271486940</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/11/21/simple-installation-of-rubidium</link>
      <category>Tools</category>
      <category>rubidium</category>
      <category>ruby</category>
      <category>jruby</category>
      <category>cdk</category>
    </item>
    <item>
      <title>Parsing SD Files with Ruby and Rubidium</title>
      <description>&lt;p&gt;&lt;a href="http://rbtk.rubyforge.org"&gt;&lt;img src="http://depth-first.com/demo/20071015/rubidium.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;Reading SD files is a bread-and-butter cheminformatics operation. At a minimum, a cheminformatics toolkit needs to parse the individual entries of an SD file, and provide access to the embedded molfile and data hash for each.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://depth-first.com/articles/tag/rubidium"&gt;Recent articles&lt;/a&gt; have introduced &lt;a href="http://rbtk.rubyforge.org"&gt;Rubidium&lt;/a&gt;, a Ruby cheminformatics scripting environment. The Rubidium team now announces the release of &lt;a href="http://rubyforge.org/frs/?group_id=4671"&gt;Rubidium-0.1.1&lt;/a&gt;, which, among other features, introduces the ability to parse SD files.&lt;/p&gt;

&lt;h4&gt;Prerequisites&lt;/h4&gt;

&lt;p&gt;Rubidium is designed to run on &lt;a href="http://jruby.codehaus.org/"&gt;JRuby&lt;/a&gt;. Installing JRuby is straightforward on unix-like systems. First, download the &lt;a href="http://dist.codehaus.org/jruby/jruby-bin-1.1b1.tar.gz"&gt;JRuby-1.1b1 binary release&lt;/a&gt;. Then, unpack the archive to your directory of choice. Set &lt;tt&gt;$JRUBY_HOME&lt;/tt&gt; and &lt;tt&gt;$JAVA_HOME&lt;/tt&gt;. Finally, add &lt;tt&gt;$JRUBY_HOME/bin&lt;/tt&gt; to your path.&lt;/p&gt;

&lt;h4&gt;Installing Rubidium-0.1.1&lt;/h4&gt;

&lt;p&gt;Generally speaking, it should be possible to install Rubidium with a one-line command to RubyGems:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jruby -S gem install rbtk
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Unfortunately at the time of this writing, I was receiving the mysterious &lt;a href="http://www.google.com/search?q=rubygems+%22ERROR:++While+executing+gem+...+OpenURI::HTTPError%22&amp;amp;hl=en&amp;amp;pwst=1&amp;amp;start=0&amp;amp;sa=N"&gt;RubyGems 404 error&lt;/a&gt; with the RubyForge remote repository:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jruby -S gem install rbtk
Select which gem to install for your platform (java)
 1. rbtk 0.1.1 (java)
 2. rbtk 0.1.0 (java)
 3. Skip this gem
 4. Cancel installation
&gt; 1
ERROR:  While executing gem ... (OpenURI::HTTPError)
    404 Not Found
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This appears to affect only certain RubyGems on RubyForge - possibly only those with multiple versions. It seems to be an error on the RubyForge server that occasionally appears and then disappears.&lt;/p&gt;

&lt;p&gt;As a workaround, you can &lt;a href="http://rubyforge.org/frs/download.php/27819/rbtk-0.1.1-jruby.gem"&gt;download the Rubidium gem&lt;/a&gt; and install it manually:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jruby -S gem install tmp/rbtk-0.1.1-jruby.gem
&lt;/div&gt;

&lt;p&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;Because Rubidium-0.1.1 introduces an &lt;a href="http://rubyforge.org/projects/activesupport/"&gt;Active Support&lt;/a&gt; dependency, you will need to install that library before installing Rubidium:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jruby -S gem install tmp/rbtk-0.1.1-jruby.gem
ERROR:  While executing gem ... (RuntimeError)
    Error instaling tmp/rbtk-0.1.1-jruby.gem:
        rbtk requires activesupport &gt;= 1.4.2
$ jruby -S gem install activesupport
Successfully installed activesupport-1.4.4
Installing ri documentation for activesupport-1.4.4...
Installing RDoc documentation for activesupport-1.4.4...
$ jruby -S gem install tmp/rbtk-0.1.1-jruby.gem
Successfully installed rbtk, version 0.1.1
Installing ri documentation for rbtk-0.1.1-jruby...
Installing RDoc documentation for rbtk-0.1.1-jruby...
&lt;/div&gt;

&lt;p&gt;&lt;/pre&gt;&lt;/p&gt;

&lt;p&gt;It's possible that the RubyForge 404 issue will be resolved by the time you read this article, so &lt;tt&gt;jruby -S gem install rbtk&lt;/tt&gt; should be tried first.&lt;/p&gt;

&lt;h4&gt;Parsing an SD File&lt;/h4&gt;

&lt;p&gt;Let's say we'd like to extract all InChIs from a PubChem dataset. If you don't have one handy, a compilation of about 2000 PubChem benzodiazepines has been &lt;a href="http://rubyforge.org/frs/download.php/27768/pubchem_benzodiazepine_20071110.sdf.gz"&gt;deposited on RubyForge&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With our unzipped datafile in our working directory, we can now test the SD File parser by saving the following library to a file called &lt;strong&gt;parse.rb&lt;/strong&gt;:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rubygems&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;gem&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rbtk&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rubidium/sdf&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;parse_sd&lt;/span&gt; &lt;span class="ident"&gt;filename&lt;/span&gt;
  &lt;span class="ident"&gt;p&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Rubidium&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;SDF&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Parser&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt; &lt;span class="constant"&gt;File&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;filename&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;

  &lt;span class="ident"&gt;p&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;entry&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
    &lt;span class="ident"&gt;puts&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;InChI: &lt;span class="expr"&gt;#{entry['PUBCHEM_NIST_INCHI']}&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

which can be tested with &lt;tt&gt;jirb&lt;/tt&gt;:

&lt;div class="console"&gt;
&lt;pre&gt;
$ jirb
irb(main):001:0&gt; require 'parse'
=&gt; true
irb(main):002:0&gt; parse_sd 'pubchem_benzodiazepine_20071110.sdf'
InChI: InChI=1/C16H12Cl2N2O/c1-20-14-7-6-12(18)8-13(14)16(19-9-15(20)21)10-2-4-11(17)5-3-10/h2-8H,9H2,1H3

[truncated]
&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;RSpec and Behavior-Driven Development&lt;/h4&gt;

&lt;p&gt;If you &lt;a href="http://rubyforge.org/frs/download.php/27820/rbtk-0.1.1.tar.gz"&gt;check out the Rubidium source distribution&lt;/a&gt;, you'll notice that the SD parser library is tested with &lt;a href="http://rspec.rubyforge.org/"&gt;RSpec&lt;/a&gt;, the &lt;a href="http://en.wikipedia.org/wiki/Behavior_driven_development"&gt;BDD&lt;/a&gt; framework for Ruby. Ultimately, all components of Rubidium will be tested and documented this way.&lt;/p&gt;

&lt;h4&gt;Acknowledgments&lt;/h4&gt;

&lt;p&gt;Rubidium's new SD file parser was written by &lt;a href="http://www.moseshohman.com/"&gt;Moses Hohman&lt;/a&gt;. It was kindly donated by &lt;a href="http://www.collaborativedrug.com/"&gt;Collaborative Drug Discovery&lt;/a&gt;, who have built their drug discovery application using &lt;a href="http://rubyonrails.com"&gt;Ruby on Rails&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Future Directions&lt;/h4&gt;

&lt;p&gt;One problem in working with SD files is pinpointing encoding errors. A parser should not only raise an exception, but point to a line number and identify offending text to aid debugging. Rubidium's SD parser will eventually incorporate these enhancements.&lt;/p&gt;

&lt;p&gt;Because Rubidium runs on JRuby, performance gains may be achievable by re-writing select portions in Java.&lt;/p&gt;

&lt;p&gt;Parsing SD files is only the beginning of the story. Many cheminformatics applications need a convenient, fast, and robust method for &lt;em&gt;writing&lt;/em&gt; molfiles. This is also something Rubidium will attempt to provide.&lt;/p&gt;

&lt;p&gt;If your company or organization is curious about Ruby and cheminforamatics, give Rubidium a try. Rubidium is licensed under the permissive &lt;a href="http://www.opensource.org/licenses/mit-license.php"&gt;MIT License&lt;/a&gt; to make collaboration as simple as possible.&lt;/p&gt;</description>
      <pubDate>Mon, 12 Nov 2007 11:27:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:8e195fb8-22d0-4ea3-a2bd-40f44281fc8f</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/11/12/parsing-sd-files-with-ruby-and-rubidium</link>
      <category>Tools</category>
      <category>rubidium</category>
      <category>ruby</category>
      <category>cdd</category>
      <category>sdfile</category>
      <category>sdf</category>
      <category>bdd</category>
      <category>rspec</category>
      <category>jruby</category>
    </item>
    <item>
      <title>An Introduction to the Rubidium Cheminforamtics Toolkit: Interconvert SMILES, InChI, and Molfile with an Open Babel-Like Interface</title>
      <description>&lt;p&gt;&lt;img src="http://depth-first.com/demo/20071015/rubidium.png" align="right"&gt;&lt;/img&gt;Interconverting molecular languages is a very common operation in cheminformatics, so convenient conversion tools are desirable. Recent articles have discussed JRuby as a &lt;a href="http://depth-first.com/articles/tag/ruby"&gt;functional cheminformatics scripting environement&lt;/a&gt;. In this article, we'll see how this functionality can be combined with convenience for molecular language conversions.&lt;/p&gt;

&lt;p&gt;In addition to illustrating a technique, this article is the first in a series aimed at documenting a new cheminformatics toolkit for Ruby called "Rubidium". Rubidium will provide a unified set of Ruby APIs for working with diverse Open Source cheminformatics tools.&lt;/p&gt;

&lt;p&gt;Rubidium will be distributed under the highly permissive &lt;a href="http://www.opensource.org/licenses/mit-license.php"&gt;MIT License&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Prerequisites&lt;/h4&gt;

&lt;p&gt;This Rubidium library requires &lt;a href="http://jruby.codehaus.org/"&gt;JRuby&lt;/a&gt; and the &lt;a href="http://cdk.sf.net"&gt;Chemistry Development Kit&lt;/a&gt; (CDK). Copying the &lt;a href="http://downloads.sourceforge.net/cdk/cdk-1.0.1.jar?modtime=1182877138&amp;amp;big_mirror=0"&gt;CDK jarfile&lt;/a&gt; into your JRuby &lt;tt&gt;lib&lt;/tt&gt; directory is all that's needed.&lt;/p&gt;

&lt;h4&gt;The Library&lt;/h4&gt;

&lt;p&gt;The goal of this library is to provide a simple, yet flexible way to interconvert SMILES, InChI, and molfile formats. It was inspired the &lt;a href="http://openbabel.sf.net"&gt;Open Babel&lt;/a&gt; library, in which an &lt;tt&gt;OBConversion&lt;/tt&gt; object is configured with input and output formats prior to performing one or more conversions. In today's library, a similar Ruby interface is created for the CDK. Because of it's length, it won't be presented in its entirety. Instead, it can be &lt;a href="http://depth-first.com/demo/20071015/cdk.rb"&gt;downloaded here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Testing the Library&lt;/h4&gt;

&lt;p&gt;The library can be tested by saving it as a file called &lt;strong&gt;cdk.rb&lt;/strong&gt; and invoking &lt;tt&gt;jirb&lt;/tt&gt;. We can then convert a SMILES for benzene into the InChI for benzene:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jirb
irb(main):001:0&gt; require 'cdk'
=&gt; true
irb(main):002:0&gt; c=CDK::Conversion.new
=&gt; #&amp;lt;CDK::Conversion:0x4c6320 ... &amp;gt;
irb(main):003:0&gt; c.set_formats 'smi', 'inchi'
=&gt; "inchi"
irb(main):004:0&gt; c.convert 'c1ccccc1'
=&gt; "InChI=1/C6H6/c1-2-4-6-5-3-1/h1-6H"
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Upcoming articles will show more examples of interconversions using this library, and discuss some of its limitations.&lt;/p&gt;

&lt;h4&gt;An Aside&lt;/h4&gt;

&lt;p&gt;It might be useful for Rubidium to support multiple &lt;tt&gt;Conversions&lt;/tt&gt;, each using its own cheminformatics toolkit. For example, a recent article discussed &lt;a href="http://depth-first.com/articles/2007/06/25/interconvert-almost-any-smiles-and-inchi-with-ruby-open-babel"&gt;SMILES and InChI interconversion with Ruby Open Babel&lt;/a&gt;. With a little tweaking, the Ruby Open Babel &lt;tt&gt;OBConversion&lt;/tt&gt; interface could be make identical to the Ruby interface used in today's tutorial. We could also configure &lt;a href="http://joelib.sf.net"&gt;JOELib&lt;/a&gt; and &lt;a href="http://sf.net/projects/rosetta"&gt;Rosetta&lt;/a&gt; &lt;tt&gt;Conversions&lt;/tt&gt; in an analogous fashion.&lt;/p&gt;

&lt;p&gt;Rubidium would then offer a family of molecular language converters, each of which used exactly the same API. We could then pick the best converter based on the situation at hand.&lt;/p&gt;

&lt;h4&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;With just a little Ruby code, we've created a convenient Ruby interface for interconverting SMILES, InChI, and molfile formats. JRuby supports even more interconversions through the CDK as well as other Java and Java Native Interface libraries. Future articles will discuss some of the possibilities.&lt;/p&gt;</description>
      <pubDate>Mon, 15 Oct 2007 10:59:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:fbde8b22-25ba-498c-8ade-b9a74738d560</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/10/15/an-introduction-to-the-rubidium-cheminforamtics-toolkit-interconvert-smiles-inchi-and-molfile-with-an-open-babel-like-interface</link>
      <category>Tools</category>
      <category>rubidium</category>
      <category>jruby</category>
      <category>java</category>
      <category>cdk</category>
    </item>
    <item>
      <title>JRuby for Cheminformatics: Parsing IUPAC Nomenclature with OPSIN</title>
      <description>&lt;p&gt;&lt;a href="http://ruby-lang.org"&gt;&lt;img src="http://depth-first.com/files/ruby_logo_new.gif" align="right"&gt;&lt;/img&gt;&lt;/a&gt;Recent articles have discussed the use of &lt;a href="http://depth-first.com/articles/tag/rubidium"&gt;JRuby for cheminformatics&lt;/a&gt;. We've seen how to &lt;a href="http://depth-first.com/articles/2007/10/09/jruby-for-cheminformatics-parsing-smiles-simply"&gt;parse SMILES strings&lt;/a&gt;, and &lt;a href="http://depth-first.com/articles/2007/10/10/jruby-for-cheminformatics-reading-and-writing-inchis-via-the-java-native-interface"&gt;read or write InChIs&lt;/a&gt;. In this article, we'll see how easy it is to parse IUPAC nomenclature from JRuby using Peter Corbett's &lt;a href="http://depth-first.com/articles/2006/10/14/decoding-iupac-names-with-opsin"&gt;OPSIN library&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Installation&lt;/h4&gt;

&lt;p&gt;After &lt;a href="http://depth-first.com/articles/2007/10/09/jruby-for-cheminformatics-parsing-smiles-simply"&gt;installing JRuby&lt;/a&gt;, simply &lt;a href="http://prdownloads.sourceforge.net/oscar3-chem/opsin-big-0.1.0.jar?download"&gt;download the OPSIN jarfile&lt;/a&gt; and copy it to your JRuby &lt;tt&gt;lib&lt;/tt&gt; directory. You're done.&lt;/p&gt;

&lt;h4&gt;A Simple Library&lt;/h4&gt;

&lt;p&gt;We can write a simple library to convert an IUPAC name into a CML document:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;jruby&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;import&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;uk.ac.cam.ch.wwmm.opsin.NameToStructure&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;IUPAC&lt;/span&gt;
  &lt;span class="attribute"&gt;@@nts&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;NameToStructure&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;read_name&lt;/span&gt; &lt;span class="ident"&gt;name&lt;/span&gt;
    &lt;span class="ident"&gt;cml&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="attribute"&gt;@@nts&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;parse_to_cml&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;

    &lt;span class="keyword"&gt;raise&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;Could not parse '&lt;span class="expr"&gt;#{name}&lt;/span&gt;'.&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="keyword"&gt;unless&lt;/span&gt; &lt;span class="ident"&gt;cml&lt;/span&gt;

    &lt;span class="ident"&gt;cml&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;to_xml&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The &lt;tt&gt;read_name&lt;/tt&gt; method accepts an iupac name as a string and returns a CML document as a string. If the input can't be parsed, an exception is raised.&lt;/p&gt;

&lt;h4&gt;Testing the Library&lt;/h4&gt;

&lt;p&gt;We can test the library by saving it as a file called &lt;strong&gt;iupac.rb&lt;/strong&gt; and invoking &lt;tt&gt;jirb&lt;/tt&gt;:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jirb
irb(main):001:0&gt; require 'iupac'
=&gt; true
irb(main):002:0&gt; include IUPAC
=&gt; Object
irb(main):003:0&gt; read_name('4-iodobenzoic acid')
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This returns the XML shown below, which has been re-formatted for clarity:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_xml "&gt;&lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;cml&lt;/span&gt; &lt;span class="attribute"&gt;xmlns&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;http://www.xml-cml.org/schema&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;molecule&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;m1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atomArray&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;C&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;label&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;C&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;label&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a3&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;C&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;label&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;3&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a4&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;C&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;label&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;4&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a5&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;C&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;label&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;5&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a6&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;C&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;label&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;6&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a7&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;C&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a8&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;O&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a9&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;O&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt; &lt;span class="attribute"&gt;id&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a10&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;elementType&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;I&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
        &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;label&lt;/span&gt; &lt;span class="attribute"&gt;value&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atom&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;atomArray&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bondArray&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a1 a2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a2 a3&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a3 a4&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a4 a5&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a5 a6&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a6 a1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a7 a1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a7 a8&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;2&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a7 a9&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;bond&lt;/span&gt; &lt;span class="attribute"&gt;atomRefs2&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;a10 a4&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;order&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;bondArray&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;molecule&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;cml&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This simple Ruby library has parsed the name '4-iodobenzoic acid' and has returned a string containing the CML representation for the molecule. If we had wanted the &lt;tt&gt;read_name&lt;/tt&gt; method to return a traversable XML object model, we could have enabled that as well.&lt;/p&gt;

&lt;h4&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;One of the objections raised whenever the issue of "new" programming languages comes up, regardless of their merit, is the age-old refrain "Yeah, but where's the software?" With JRuby, we bypass this question altogether. We can leverage the full scope of the massive Java development effort over the last ten years, which includes several excellent cheminformatics libraries. With virtually no effort, we have a working cheminformatics platform based on a widely-used, versatile and dynamic object-oriented scripting language. Future articles will discuss extensions to this platform and some applications.&lt;/p&gt;</description>
      <pubDate>Fri, 12 Oct 2007 10:37:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:873940fd-7b22-4013-a61b-ef928eee1c8e</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/10/12/jruby-for-cheminformatics-parsing-iupac-nomenclature-with-opsin</link>
      <category>Tools</category>
      <category>opsin</category>
      <category>iupac</category>
      <category>nametostruct</category>
      <category>rubidium</category>
      <category>jruby</category>
      <category>ruby</category>
      <category>java</category>
    </item>
    <item>
      <title>JRuby for Cheminformatics: Reading and Writing InChIs Via the Java Native Interface</title>
      <description>&lt;p&gt;&lt;a href="http://ruby-lang.org"&gt;&lt;img src="http://depth-first.com/files/ruby_logo_new.gif" align="right"&gt;&lt;/img&gt;&lt;/a&gt;The increased use of the &lt;a href="http://depth-first.com/articles/2007/09/27/inchi-for-newbies"&gt;InChI identifier&lt;/a&gt; is making the reading and writing of InChIs a standard cheminformatics capability. Recent articles have discussed the &lt;a href="http://depth-first.com/articles/tag/jruby"&gt;advantages of JRuby for cheminformatics&lt;/a&gt;. One disadvantage of JRuby is that code written in C can't be directly used. The presents a potential problem for libraries, such as the InChI toolkit, that are written in C. Fortunately, the solution is simple. Today's tutorial will demonstrate how InChIs can be both read and written using the C-InChI toolkit via JRuby and the excellent &lt;a href="http://jni-inchi.sourceforge.net/"&gt;JNI-InChI library&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;About JNI-InChI&lt;/h4&gt;

&lt;p&gt;The &lt;a href="http://jni-inchi.sourceforge.net/"&gt;JNI-InChI&lt;/a&gt; library, written by Jim Downing and Sam Adams, wraps the &lt;a href="http://www.iupac.org/inchi/"&gt;C InChI toolkit&lt;/a&gt; in a Java Native Interface. This low-level toolkit is suitable for building more complex software, but lacks many features present in the C InChI toolkit. For example, JNI-InChI doesn't directly interconvert SMILES or molfile with InChI. For that you'd need to build a support library. If you're building a toolkit from scratch, this lightweight approach can be a significant advantage.&lt;/p&gt;

&lt;p&gt;The JNI-InChI binary distribution jarfile includes the compiled native InChI library. In this sense it's virtually indistinguishable from any other Java library. This simplified packaging makes it exceptionally easy to use JNI-InChI from JRuby, as we'll see below.&lt;/p&gt;

&lt;h4&gt;Installation&lt;/h4&gt;

&lt;p&gt;JRuby &lt;a href="http://depth-first.com/articles/2007/10/09/jruby-for-cheminformatics-parsing-smiles-simply"&gt;can be installed&lt;/a&gt; as described previously. To install the JNI-InChI library for JRuby, simply copy the &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=173262"&gt;current release jarfile&lt;/a&gt; into the &lt;tt&gt;lib&lt;/tt&gt; directory of your JRuby installation. That's all there is to it.&lt;/p&gt;

&lt;h4&gt;A Simple Library&lt;/h4&gt;

&lt;p&gt;We can now write a simple library to read InChIs via JRuby:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;java&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;include_class&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;net.sf.jniinchi.JniInchiInput&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;include_class&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;net.sf.jniinchi.JniInchiInputInchi&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;include_class&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;net.sf.jniinchi.JniInchiWrapper&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;IUPAC&lt;/span&gt;
  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;read_inchi&lt;/span&gt; &lt;span class="ident"&gt;inchi&lt;/span&gt;
    &lt;span class="ident"&gt;input&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;JniInchiInputInchi&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt; &lt;span class="ident"&gt;inchi&lt;/span&gt;

    &lt;span class="constant"&gt;JniInchiWrapper&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;getStructureFromInchi&lt;/span&gt; &lt;span class="ident"&gt;input&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;Testing the Library&lt;/h4&gt;

&lt;p&gt;By saving the above library to a file called &lt;strong&gt;iupac.rb&lt;/strong&gt;, we can parse InChIs via JRuby:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jirb
irb(main):001:0&gt; require 'iupac'
=&gt; true
irb(main):002:0&gt; include IUPAC
=&gt; Object
irb(main):003:0&gt; output = read_inchi 'InChI=1/C14H10/c1-3-7-13-11(5-1)9-10-12-6-2-4-8-14(12)13/h1-10H'
=&gt; #&lt;Java::NetSfJniinchi::JniInchiOutputStructure:0x1ed5459 @java_object=net.sf.jniinchi.JniInchiOutputStructure@313170&gt;
irb(main):004:0&gt; output.num_atoms
=&gt; 14
irb(main):005:0&gt; output.num_bonds
=&gt; 16
&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;Writing InChIs&lt;/h4&gt;

&lt;p&gt;Because JNI-InChI is a low-level toolkit, writing InChIs is feasible, but not trivial. We must first construct a representation, and then get the InChI for it. For example, we could get the InChI for methane as follows:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jirb
irb(main):001:0&gt; require 'java'
=&gt; true
irb(main):002:0&gt; include_class 'net.sf.jniinchi.JniInchiInput'
=&gt; ["net.sf.jniinchi.JniInchiInput"]
irb(main):003:0&gt; include_class 'net.sf.jniinchi.JniInchiAtom'
=&gt; ["net.sf.jniinchi.JniInchiAtom"]
irb(main):004:0&gt; include_class 'net.sf.jniinchi.JniInchiWrapper'
=&gt; ["net.sf.jniinchi.JniInchiWrapper"]
irb(main):005:0&gt; input = JniInchiInput.new
=&gt; #&lt;Java::NetSfJniinchi::JniInchiInput:0x2f2295 @java_object=net.sf.jniinchi.JniInchiInput@15b0333&gt;
irb(main):006:0&gt; a1 = input.add_atom JniInchiAtom.new(0,0,0, "C")
=&gt; #&lt;Java::NetSfJniinchi::JniInchiAtom:0x1b22920 @java_object=net.sf.jniinchi.JniInchiAtom@2f356f&gt;
irb(main):007:0&gt; a1.set_implicit_h(4)
=&gt; nil
irb(main):008:0&gt; output = JniInchiWrapper.get_inchi input
=&gt; #&lt;Java::NetSfJniinchi::JniInchiOutput:0xf894ce @java_object=net.sf.jniinchi.JniInchiOutput@132ae7&gt;
irb(main):009:0&gt; output.get_inchi
=&gt; "InChI=1/CH4/h1H4"
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Fortunately, we don't have to work that hard. The &lt;a href="http://cdk.sf.net"&gt;Chemistry Development Kit&lt;/a&gt;, through JNI-InChI, supports reading and writing of InChIs via a variety of molecular languages, including SMILES and molfile. More on that later, though.&lt;/p&gt;

&lt;h4&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;Provided that a Java Native Interface exists for a C library, it can be used from JRuby. Future articles will discuss the use of other cheminformatics libraries written in either C or C++ from JRuby, and their integration with pure Java and Ruby libraries.&lt;/p&gt;</description>
      <pubDate>Wed, 10 Oct 2007 08:21:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:0348fa93-7376-488d-9afc-789590ac9fcb</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/10/10/jruby-for-cheminformatics-reading-and-writing-inchis-via-the-java-native-interface</link>
      <category>Tools</category>
      <category>rubidium</category>
      <category>jruby</category>
      <category>ruby</category>
      <category>java</category>
      <category>jni</category>
      <category>inchi</category>
      <category>cdk</category>
    </item>
    <item>
      <title>JRuby for Cheminformatics: Parsing SMILES Simply</title>
      <description>&lt;p&gt;&lt;a href="http://cdk.sf.net"&gt;&lt;img src="http://depth-first.com/files/cdk_logo.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://ruby-lang.org"&gt;&lt;img src="http://depth-first.com/files/ruby_logo_new.gif" align="right"&gt;&lt;/img&gt;&lt;/a&gt;The previous article in this series outlined some &lt;a href="http://depth-first.com/articles/2007/10/08/five-reasons-to-start-using-jruby-now"&gt;reasons to consider JRuby for cheminformatics&lt;/a&gt;. Now I'll show how easy it is to get started by describing how to parse SMILES strings with the help of the &lt;a href="http://cdk.sf.net"&gt;Chemistry Development Kit&lt;/a&gt; (CDK).&lt;/p&gt;

&lt;h4&gt;What About Ruby CDK?&lt;/h4&gt;

&lt;p&gt;A number of Depth-First articles have discussed &lt;a href="http://depth-first.com/articles/2007/10/04/ruby-cdk-for-newbies"&gt;Ruby CDK&lt;/a&gt;. This library runs on top of C-Ruby, otherwise known as Matz' Ruby Implementation (MRI). &lt;a href="http://rjb.rubyforge.org/"&gt;Ruby Java Bridge&lt;/a&gt; connects MRI to a Java Virtual Machine under Ruby CDK.&lt;/p&gt;

&lt;p&gt;This article, and the others to follow, will instead discuss the use of the CDK and other Java libraries from JRuby. In contrast to MRI, JRuby is a pure Java implementation of the Ruby language. This approach offers some important advantages which will be highlighted along the way.&lt;/p&gt;

&lt;h4&gt;Installing JRuby&lt;/h4&gt;

&lt;p&gt;JRuby is not difficult to install. On Linux, the steps are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Install &lt;a href="http://java.sun.com"&gt;JDK Version 1.4 or higher&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download and unpack the most recent JRuby release - at the time of this writing, &lt;a href="http://dist.codehaus.org/jruby"&gt;version 1.0.1&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the JRuby &lt;tt&gt;bin&lt;/tt&gt; directory to your path.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is no Step 4. ;-)&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Installing CDK for JRuby&lt;/h4&gt;

&lt;p&gt;Installing CDK so that it works on JRuby is similarly quite simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Download the most recent CDK jarfile - at the time of this writing, &lt;a href="http://downloads.sourceforge.net/cdk/cdk-1.0.1.jar?modtime=1182877138&amp;amp;big_mirror=0"&gt;version 1.0.1&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Move the CDK jarfile to your JRuby &lt;tt&gt;lib&lt;/tt&gt; directory.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;Testing CDK for JRuby&lt;/h4&gt;

&lt;p&gt;You can verify that your new CDK for JRuby installation works with &lt;tt&gt;jirb&lt;/tt&gt;:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ jirb
irb(main):001:0&gt; require 'java'
=&gt; true
irb(main):002:0&gt; include_class 'org.openscience.cdk.smiles.SmilesParser'
=&gt; ["org.openscience.cdk.smiles.SmilesParser"]
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You should notice that &lt;tt&gt;jirb&lt;/tt&gt; takes a few seconds to initialize the JVM, whereas &lt;tt&gt;irb&lt;/tt&gt; starts almost instantly.&lt;/p&gt;

&lt;h4&gt;A Library to Read SMILES&lt;/h4&gt;

&lt;p&gt;We can write a short library to read SMILES strings using the CDK:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;java&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;include_class&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;org.openscience.cdk.smiles.SmilesParser&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;Daylight&lt;/span&gt;
  &lt;span class="attribute"&gt;@@smiles_parser&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;SmilesParser&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt;

  &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;read_smiles&lt;/span&gt; &lt;span class="ident"&gt;smiles&lt;/span&gt;
    &lt;span class="attribute"&gt;@@smiles_parser&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;parse_smiles&lt;/span&gt; &lt;span class="ident"&gt;smiles&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Notice the use of the Rubyesque method name &lt;tt&gt;parse_smiles&lt;/tt&gt; rather than &lt;tt&gt;parseSmiles&lt;/tt&gt;. This is just one of the built-in conveniences offered by JRuby.&lt;/p&gt;

&lt;h4&gt;Testing the Library&lt;/h4&gt;

Saving the library as a file called &lt;strong&gt;daylight.rb&lt;/strong&gt; lets us test it using interactive JRuby:

&lt;div class="console"&gt;
&lt;pre&gt;
$ jirb
irb(main):001:0&gt; require 'daylight'
=&gt; true
irb(main):002:0&gt; include Daylight
=&gt; Object
irb(main):003:0&gt; mol = read_smiles 'c1ccccc1'
=&gt; #&lt;Java::OrgOpenscienceCdk:: [truncated] ...&gt;
irb(main):004:0&gt; mol.atom_count
=&gt; 6
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;As you can see, the benzene SMILES has been parsed correctly. Again, notice the use of the Rubyesque method name &lt;tt&gt;atom_count&lt;/tt&gt;, rather than the CDK Java bean convention method name &lt;tt&gt;getAtomCount&lt;/tt&gt;. This feature makes it easy to ignore the fact you're using a Java library and get on with writing your Ruby code. Brilliant!&lt;/p&gt;

&lt;h4&gt;Conclusions&lt;/h4&gt;

&lt;p&gt;This article has shown how to install JRuby and begin to write some simple cheminformatics programs with a distinctive Ruby flavor. Although the focus was on SMILES parsing, there's much more functionality to be found within the CDK and other cheminformatics libraries written in Java. Future articles will outline some of the possibilities.&lt;/p&gt;</description>
      <pubDate>Tue, 09 Oct 2007 08:40:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:9007f034-5aa0-458c-b4e1-f9dc182d19be</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/10/09/jruby-for-cheminformatics-parsing-smiles-simply</link>
      <category>Tools</category>
      <category>jruby</category>
      <category>java</category>
      <category>ruby</category>
      <category>rubidium</category>
      <category>cdk</category>
      <category>smiles</category>
    </item>
    <item>
      <title>Five Reasons to Start Using JRuby Now</title>
      <description>&lt;p&gt;&lt;a href="http://ruby-lang.org"&gt;&lt;img src="http://depth-first.com/files/ruby_logo_new.gif" align = "right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://java.sun.com"&gt;&lt;img src="http://depth-first.com/demo/20071008/duke.gif" align="right"&gt;&lt;/img&gt;&lt;/a&gt;&lt;a href="http://jruby.codehaus.org/"&gt;JRuby&lt;/a&gt; is an implementation of the Ruby programming language on the Java Virtual Machine. Until about six months ago, JRuby was merely a technical curiosity; few seemed interested in using it for 'serious' development work. This perception has changed over the last six months, as JRuby's progress has accelerated. Here, in no particular order, are five reasons to consider using JRuby for your current or next project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JRuby Now Works.&lt;/strong&gt; With the recent &lt;a href="http://docs.codehaus.org/display/JRUBY/2007/06/12/JRuby+1.0+Released"&gt;release of JRuby 1.0&lt;/a&gt;, JRuby now does just about everything C-Ruby does. Performance is now almost at the level of the C-Ruby implementation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;JRuby on Rails Now Works.&lt;/strong&gt; For a long time, JRuby's support for Rails was limited. Not so any more. &lt;a href="http://www.google.com/search?hl=en&amp;amp;q=jruby+rails&amp;amp;btnG=Google+Search"&gt;Google JRuby Rails&lt;/a&gt; and be amazed at all of the activity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ruby Can Now Be Compiled to Java Bytecode.&lt;/strong&gt; &lt;a href="http://headius.blogspot.com/2007/09/compiler-is-complete.html"&gt;Simply amazing&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sun is Financing JRuby Development.&lt;/strong&gt; Two core JRuby developers, Charles Nutter and Thomas Enebo, &lt;a href="http://headius.blogspot.com/2006/09/jruby-steps-into-sun.html"&gt;have been hired by Sun Microsystems&lt;/a&gt; to develop JRuby. Sun gets it. They know that Java the Platform matters far more than Java the Language. Despite their own investment in &lt;a href="http://java.sun.com/javafx/"&gt;Java FX&lt;/a&gt;, Sun is taking a pragmatic approach to scripting on the JVM. If only Sun's industry peers were as pragmatic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The JVM Offers an Enterprise-Quality Platform for Ruby Applications.&lt;/strong&gt; The JVM is one of the best-tested and most reliable software platforms in existence. Ruby run on top of a JVM makes a lot more sense than Ruby run on top of metal via C. Likewise, hosting Ruby on Rails applications inside a Java application container offers a way out of the current Rails deployment conundrum. It won't be long before everyone sees it that way. For now, those who get it will have a head start.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Far from being a passing curiosity, JRuby may well become the preferred way to develop both Java and Ruby applications. The wide array of cheminformatics code already written in Java makes JRuby an especially attractive platform for chemistry software. Future articles will show how the powerful duo of Ruby and the Java Virtual Machine can be used to speed the development and deployment of cheminformatics Web applications.&lt;/p&gt;</description>
      <pubDate>Mon, 08 Oct 2007 08:27:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:3e8da9c3-de89-4141-8349-80fb05d07d86</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/10/08/five-reasons-to-start-using-jruby-now</link>
      <category>Tools</category>
      <category>jruby</category>
      <category>ruby</category>
      <category>java</category>
      <category>rails</category>
    </item>
    <item>
      <title>Scripting Java with Ruby: Yet Another Java Bridge</title>
      <description>&lt;p&gt;&lt;img src="http://depth-first.com/files/ruby_logo_new.gif" align="right"&gt;&lt;/img&gt;New technologies attempting to compete with older technologies need to provide a clear upgrade path, if they are to succeed. A case in point is Ruby. Many Java developers' reaction to this language has less to do with its capabilities and more to do with previous investments in Java. What good is a new language if the special library X that you depend on needs to be rewritten from scratch?&lt;/p&gt;

&lt;p&gt;Previous articles, starting with &lt;a href="http://depth-first.com/articles/2006/08/26/scripting-java-libraries-with-ruby-java-bridge"&gt;this one&lt;/a&gt;, have discussed &lt;a href="http://rjb.rubyforge.org"&gt;Ruby Java Bridge&lt;/a&gt; (RJB) as a Java-Ruby integration tool. Two additional articles discussed RJB in the context of &lt;a href="http://depth-first.com/articles/2006/10/24/metaprogramming-with-ruby-mapping-java-packages-onto-ruby-modules"&gt;mapping Java packages onto Ruby modules&lt;/a&gt; and &lt;a href="http://depth-first.com/articles/2006/10/12/running-ruby-java-bridge-on-windows"&gt;Java-Ruby integration on Windows&lt;/a&gt;. RJB currently provides the mechanism whereby the full &lt;a href="http://cdk.sf.net"&gt;Chemistry Development Kit&lt;/a&gt; (CDK) API can be used in Ruby with &lt;a href="http://rubyforge.org/projects/rcdk"&gt;Ruby CDK&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Another option for Java-Ruby integration is &lt;a href="http://jruby.codehaus.org/"&gt;JRuby&lt;/a&gt;, a Java implementation of the Ruby interpreter. JRuby offers tight integration with the Java Virtual Machine, which will be ideal in many situations. In other situations, it will not be the best choice. For example, one of the advantages of RJB over JRuby is that the standard C-Ruby implementation can be used. This in turn offers, for example, full &lt;a href="http://www.rubyonrails.org/"&gt;Rails&lt;/a&gt; functionality and access to C extensions. A disadvantage of RJB is that, being written in C, it requires a working build toolchain for installation.&lt;/p&gt;

&lt;p&gt;I've seen &lt;a href="http://www.jaredrichardson.net/blog/2006/09/01/"&gt;one report&lt;/a&gt; of a Macintosh installation of RJB that failed. Without a Mac of my own, I can't confirm if this is indeed a problem. But this report also pointed me to a third approach to Ruby-Java integration, &lt;a href="http://www.cmt.phys.kyushu-u.ac.jp/~M.Sakurai/cgi-bin/fw/wiki.cgi?page=YAJB"&gt;Yet Another Java Bridge&lt;/a&gt; (YAJB). YAJB is different from both JRuby and RJB in that it extends the C implementation of Ruby with a Java bridge written in pure Java. In theory, it should run on any platform that both Ruby and Java run on.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.cmt.phys.kyushu-u.ac.jp/~M.Sakurai/java/ruby/yajb-0.8.1.tar.gz"&gt;YAJB-0.8.1&lt;/a&gt; installed on my system without a hitch. From the root directory of the distribution:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
# ruby setup.rb
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Using YAJB was straightforward. A Java &lt;tt&gt;Vector&lt;/tt&gt; instance could be instantiated and manipulated using familiar syntax:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;yajb/jbridge&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;include&lt;/span&gt; &lt;span class="constant"&gt;JavaBridge&lt;/span&gt;

&lt;span class="ident"&gt;v&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="ident"&gt;jnew&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;java.util.Vector&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;

&lt;span class="ident"&gt;v&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;add&lt;/span&gt;&lt;span class="punct"&gt;(&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;one&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;)&lt;/span&gt;
&lt;span class="ident"&gt;v&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;add&lt;/span&gt;&lt;span class="punct"&gt;(&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;two&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;)&lt;/span&gt;
&lt;span class="ident"&gt;v&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;size&lt;/span&gt; &lt;span class="comment"&gt;# =&amp;gt; 2&lt;/span&gt;
&lt;span class="ident"&gt;v&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;elementAt&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="number"&gt;1&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt; &lt;span class="comment"&gt;# =&amp;gt; &amp;quot;two&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Good integration tools can make the difference between actually using new technologies and simply observing them. Java developers interested in using Ruby now have at least three good options to choose from: JRuby; RJB; and YAJB.&lt;/p&gt;</description>
      <pubDate>Wed, 25 Oct 2006 14:53:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:65a72a41-d6a6-4728-82b4-c93b9fed8421</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2006/10/25/scripting-java-with-ruby-yet-another-java-bridge</link>
      <category>Tools</category>
      <category>ruby</category>
      <category>java</category>
      <category>integration</category>
      <category>rjb</category>
      <category>jruby</category>
      <category>yajb</category>
    </item>
  </channel>
</rss>
