<?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: CDK, the Ruby Way: RCDK-0.2.0</title>
    <link>http://depth-first.com/articles/2006/09/25/cdk-the-ruby-way-rcdk-0-2-0</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>CDK, the Ruby Way: RCDK-0.2.0</title>
      <description>&lt;p&gt;&lt;a href="http://rubyforge.org/projects/rcdk/"&gt;Ruby Chemistry Development Kit&lt;/a&gt; (RCDK) version 0.2.0 is &lt;a href="http://rubyforge.org/frs/?group_id=2199"&gt;now available&lt;/a&gt;. This version adds built-in support for &lt;a href="http://depth-first.com/articles/2006/08/28/drawing-2-d-structures-with-structure-cdk"&gt;Structure-CDK&lt;/a&gt;, a 2-D rendering framework. Simplifying the use of this library is a convenience layer enabling many common tasks to be accomplished with a single line of Ruby code.&lt;/p&gt;

&lt;p&gt;Installing RCDK-0.2.0 is simple. From the command line (as root):&lt;/p&gt;

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

&lt;p&gt;Be prepared for a bit of a wait as the large RCDK RubyGem downloads and is installed.&lt;/p&gt;

&lt;p&gt;If RCDK-0.1.0 is already installed on your system, version 0.2.0 can peacefully co-exist with it. Ruby will automatically load the most recent version of RCDK, and you can dynamically load the earlier version in your own code. If you'd like to uninstall RCDK-0.1.0 anyway, use the following (also as root):&lt;/p&gt;

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

&lt;p&gt;Follow the menu to uninstall RCDK-0.1.0 and you're done.&lt;/p&gt;

&lt;p&gt;If you haven't done so already, there is one bit of additional configuration. You'll need to update your &lt;tt&gt;LD_LIBRARY_PATH&lt;/tt&gt; to point to the location of your system's native Java libraries. On Linux with Sun's JDK, this can be done with the following:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386:$LD_LIBRARY_PATH
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This assumes the &lt;tt&gt;JAVA_HOME&lt;/tt&gt; was already set. If not, it will need to point to your systems Java installation directory.&lt;/p&gt;

&lt;p&gt;The whole process can be automated by including the above line at the end of your &lt;strong&gt;.bash_profile&lt;/strong&gt; file (or equivalent).&lt;/p&gt;

&lt;p&gt;As a simple demonstration, let's say you'd like to depict the 2-D structure encoded by a SMILES string as a 200x200 pixel PNG image. With RCDK-0.2.0, this can be done with the following Ruby code (which can be entered interactively via &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;util&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;

&lt;span class="ident"&gt;smiles&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Oc1ccccc1&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt; &lt;span class="comment"&gt;#phenol&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;smiles_to_png&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;smiles&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;phenol.png&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="number"&gt;200&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="number"&gt;200&lt;/span&gt;&lt;span class="punct"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This code creates &lt;strong&gt;phenol.png&lt;/strong&gt; in your current directory:&lt;/p&gt;

&lt;p&gt;&lt;center&gt;&lt;img src="http://depth-first.com/files/phenol.png"&gt;&lt;/img&gt;&lt;/center&gt;&lt;/p&gt;

&lt;p&gt;Of course, there's much more to RCDK than just SMILES depiction. Future articles will describe some of the many possibilities.&lt;/p&gt;</description>
      <pubDate>Mon, 25 Sep 2006 15:11:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:53da5e5a-a8d8-43b3-9d95-876d6e90ed10</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2006/09/25/cdk-the-ruby-way-rcdk-0-2-0</link>
      <category>Tools</category>
      <category>rcdk</category>
      <category>cdk</category>
      <category>ruby</category>
      <category>2d</category>
      <category>smiles</category>
    </item>
  </channel>
</rss>
