<?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: Agile Chemical Informatics Development with CDK and Ruby: RCDK-0.3.0</title>
    <link>http://depth-first.com/articles/2006/10/30/agile-chemical-informatics-development-with-cdk-and-ruby-rcdk-0-3-0</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>Agile Chemical Informatics Development with CDK and Ruby: RCDK-0.3.0</title>
      <description>&lt;p&gt;&lt;img src="http://depth-first.com/files/cdk_logo.png" align="right"&gt;&lt;/img&gt;Ruby Chemistry Development Kit (RCDK) version 0.3.0 is now available from RubyForge. &lt;a href="http://depth-first.com/articles/2006/09/25/cdk-the-ruby-way-rcdk-0-2-0"&gt;RCDK&lt;/a&gt; enables the complete CDK API to be accessed from Ruby. This release adds support for &lt;a href="http://depth-first.com/articles/2006/10/17/from-iupac-nomenclature-to-2-d-structures-with-opsin"&gt;IUPAC nomenclature translation&lt;/a&gt;  and &lt;a href="http://depth-first.com/articles/2006/10/24/metaprogramming-with-ruby-mapping-java-packages-onto-ruby-modules"&gt;tighter Java integration&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Dependencies&lt;/h4&gt;

&lt;p&gt;RCDK requires Ruby, the Ruby developer libraries, a working build toolchain, and &lt;a href="http://rjb.rubyforge.org"&gt;Ruby Java Bridge&lt;/a&gt; (RJB). This latter dependency can be satisfied during the RCDK installation process if the RubyGems method is used (see 'Installation').&lt;/p&gt;

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

&lt;p&gt;RCDK can be conveniently installed using the &lt;a href="http://rubygems.org/"&gt;RubyGems&lt;/a&gt; packaging mechanism:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
# gem install rcdk
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Alternatively, the source package and RubyGem can be downloaded &lt;a href="http://rubyforge.org/frs/?group_id=2199"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;Tighter Java Integration&lt;/h4&gt;

&lt;p&gt;RCDK-0.3.0 introduces a previously-described &lt;a href="http://depth-first.com/articles/2006/10/24/metaprogramming-with-ruby-mapping-java-packages-onto-ruby-modules"&gt;Java package to Ruby module mapping mechanism&lt;/a&gt;. For example, if you'd like to create a Java &lt;tt&gt;ArrayList&lt;/tt&gt;, it can be done through the new &lt;tt&gt;jrequire&lt;/tt&gt; command:&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;require_gem&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rcdk&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;jrequire&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;java.util.ArrayList&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;list&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Java&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Util&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;ArrayList&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;list&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; 0&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;h4&gt;IUPAC Nomenclature Translation&lt;/h4&gt;

&lt;p&gt;RCDK's most important new chemical informatics feature is made possible by &lt;a href="http://wwmm.ch.cam.ac.uk/blogs/corbett/"&gt;Peter Corbett's&lt;/a&gt; excellent IUPAC nomenclature translation library &lt;a href="http://depth-first.com/articles/2006/10/17/from-iupac-nomenclature-to-2-d-structures-with-opsin"&gt;OPSIN&lt;/a&gt;. It can either be used directly with &lt;tt&gt;jrequire&lt;/tt&gt;, or indirectly through RCDK's convenience library &lt;tt&gt;RCDK::Util&lt;/tt&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;require_gem&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rcdk&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;rcdk/util&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;mol&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;RCDK&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Util&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Lang&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;read_iupac&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;quinoline&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
&lt;span class="ident"&gt;mol&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;getAtomCount&lt;/span&gt; &lt;span class="comment"&gt;# =&amp;gt; 10&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;There are two things to notice here. First, no &lt;tt&gt;jrequire&lt;/tt&gt; statement is needed when using the &lt;tt&gt;RCDK::Util&lt;/tt&gt; library. Second, there is a multisecond delay after &lt;tt&gt;read_iupac&lt;/tt&gt; is invoked. OPSIN itself introduces this delay during the &lt;tt&gt;NameToStructure&lt;/tt&gt; constructor call, and RCDK inherits this behavior. However, after the first invocation of &lt;tt&gt;read_iupac&lt;/tt&gt;, subsequent calls to this method are very fast.&lt;/p&gt;

&lt;p&gt;Let's decorate the quinoline nucleus with some substituents and render a 2-D image of the result. Execute the following code, either through the Ruby interpreter (&lt;tt&gt;ruby&lt;/tt&gt;) or through Interactive Ruby (&lt;tt&gt;irb&lt;/tt&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;require_gem&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;rcdk&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;rcdk/util&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="constant"&gt;RCDK&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Util&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Image&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;iupac_to_png&lt;/span&gt;&lt;span class="punct"&gt;('&lt;/span&gt;&lt;span class="string"&gt;3-chloro-4-(2-aminopropyl)-6-mercapto-8-(2-hydroxyphenyl)-quinoline-2-carboxylic acid&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;test.png&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="number"&gt;300&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;300&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Running this code produces the following image in your working directory:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/demo/20061030/test.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;h4&gt;Be Agile&lt;/h4&gt;

&lt;p&gt;RCDK marries the &lt;a href="http://www.martinfowler.com/articles/newMethodology.html"&gt;agility&lt;/a&gt; of the Ruby language with the functionality of three Open Source chemical informatics libraries: &lt;a href="http://cdk.sf.net"&gt;CDK&lt;/a&gt;; &lt;a href="http://depth-first.com/articles/2006/10/14/decoding-iupac-names-with-opsin"&gt;OPSIN&lt;/a&gt;; and &lt;a href="http://depth-first.com/articles/2006/08/28/drawing-2-d-structures-with-structure-cdk"&gt;Structure-CDK&lt;/a&gt;. Future articles will discuss some simple applications of this powerful combination.&lt;/p&gt;</description>
      <pubDate>Mon, 30 Oct 2006 14:03:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a5e77e1e-7c24-47e4-90e9-ed1e068b19c2</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2006/10/30/agile-chemical-informatics-development-with-cdk-and-ruby-rcdk-0-3-0</link>
      <category>Tools</category>
      <category>rcdk</category>
      <category>ruby</category>
      <category>cdk</category>
      <category>opsin</category>
      <category>agile</category>
      <category>java</category>
      <category>integration</category>
    </item>
  </channel>
</rss>
