<?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: Run Babel Anywhere Java Runs with JBabel</title>
    <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>Run Babel Anywhere Java Runs with JBabel</title>
      <description>&lt;p&gt;&lt;a href="http://openbabel.sf.net"&gt;&lt;img src="http://depth-first.com/files/Babel256.png" align="right"&gt;&lt;/img&gt;&lt;/a&gt;A &lt;a href="http://depth-first.com/articles/tag/nestedvm"&gt;recent series of D-F articles&lt;/a&gt; have discussed the use of &lt;a href="http://nestedvm.ibex.org/"&gt;NestedVM&lt;/a&gt; to compile cheminformatics programs written in C/C++ to pure java binaries that can be run on any system with a JVM. More specifically, an attempt to compile &lt;a href="http://openbabel.sf.net"&gt;OpenBabel's&lt;/a&gt; &lt;tt&gt;babel&lt;/tt&gt; program to bytecode was only &lt;a href="http://depth-first.com/articles/2007/11/26/compiling-open-babel-to-pure-java-bytecode-with-nestedvm-building-a-runnable-classfile-that-almost-works"&gt;partially successful&lt;/a&gt;. With the &lt;a href="http://sourceforge.net/mailarchive/forum.php?thread_name=819391.60947.qm%40web34201.mail.mud.yahoo.com&amp;amp;forum_name=openbabel-discuss"&gt;help of Geoff Hutchison&lt;/a&gt;, the problem was resolved. This article introduces JBabel, a platform-independent, pure Java implementation of OpenBabel's &lt;tt&gt;babel&lt;/tt&gt; program.&lt;/p&gt;

&lt;h4&gt;A Little About JBabel&lt;/h4&gt;

&lt;p&gt;JBabel was compiled from the &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=40728&amp;amp;package_id=32894&amp;amp;release_id=521581"&gt;Open Babel 2.1.1 source release&lt;/a&gt; and can be &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=144794&amp;amp;package_id=255103"&gt;downloaded from SourceForge&lt;/a&gt;. The same jarfile was successfully tested on Linux, Windows and Mac OS X. You can verify JBabel works on your platform with the following command:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ java -jar jbabel-20071209.jar -Hsmi
smi  SMILES format
A linear text format which can describe the connectivity
and chirality of a molecule
Write Options e.g. -xt
  n no molecule name
  t molecule name only
  r radicals lower case eg ethyl is Cc
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This version of JBabel was compiled with support for three formats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;SMILES (smi). Non-canonical SMILES.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;MDL (mol). Molfiles and SD Files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Canonical SMILES (can). Canonical SMILES implementation &lt;a href="http://depth-first.com/articles/2006/11/06/stone-soup"&gt;donated by eMolecules&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'll discuss exactly how support for these formats was added in a subsequent post. More formats will be added in the future. For now, let's just try JBabel out.&lt;/p&gt;

&lt;h4&gt;Testing JBabel&lt;/h4&gt;

&lt;p&gt;One way to use JBabel is interactively from the command line - just leave out an input or output file parameter. For example, if you wanted to get the eMolecules canonical SMILES for &lt;a href="http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=68617"&gt;sertraline&lt;/a&gt;, you might do something like this (be sure to use two returns to begin processing):&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ java -jar jbabel-20071209.jar -ismi -ocan
CN[C@H]1CC[C@H](C2=CC=CC=C12)C3=CC(=C(C=C3)Cl)Cl

CN[C@H]1CC[C@H](c2ccc(Cl)c(Cl)c2)c2ccccc12
1 molecule converted
34 audit log messages
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This canonical SMILES can be converted into a molfile with the following:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ java -jar jbabel-20071209.jar -ismi -omol
CN[C@H]1CC[C@H](c2ccc(Cl)c(Cl)c2)c2ccccc12


 OpenBabel12090723182D

 22 24  0  0  0  0  0  0  0  0999 V2000
    0.0000    0.0000    0.0000 C   0  0  0  0  0

...
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;To convert using input and output files, we could use a medium-sized dataset such as the &lt;a href="http://rubyforge.org/frs/download.php/27768/pubchem_benzodiazepine_20071110.sdf.gz"&gt;PubChem benzodiazepine dataset&lt;/a&gt; prepared for &lt;a href="http://rbtk.rubyforge.org/"&gt;Rubidium&lt;/a&gt;:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ java -jar jbabel-20071209.jar -imol pubchem_benzodiazepine_20071110.sdf -ocan pubchem_benzodiazepine_20071110.smi
==============================
*** Open Babel Warning  in ReadMolecule
  WARNING: Problems reading a MDL file
Cannot read title line

2117 molecules converted
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This test, which parses 2117 records, required four minutes forty-five seconds on my system. For comparison, the natively compiled binary did the same thing in about thirteen seconds. Clearly, the JBabel performance hit is substantial.&lt;/p&gt;

&lt;h4&gt;Uses&lt;/h4&gt;

&lt;p&gt;Although it's very unlikely that JBabel will ever be useful in performance-critical situations, its portability makes it attractive for other uses. Examples include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;application development in heterogeneous computing environments;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;use on systems in which native compilation may be difficult, such as those with unusual configurations or operating systems;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;cases in which native binaries work poorly or not at all, such as in applets and Java applications;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;situations in which performance is a minor consideration, such as in end-user applications that process only a few molecules at a time, or during application prototyping&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;This article has described JBabel, the first portable binary version of OpenBabel's &lt;tt&gt;babel&lt;/tt&gt; molecular file format interconversion program. The next article in this series will describe in detail the steps that were used to compile it.&lt;/p&gt;</description>
      <pubDate>Mon, 10 Dec 2007 08:50:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:5d98a980-e3d6-4afd-8eb3-25769a28d13b</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel</link>
      <category>Tools</category>
      <category>jbabel</category>
      <category>babel</category>
      <category>openbabel</category>
      <category>nestedvm</category>
      <category>molfile</category>
      <category>canonicalsmiles</category>
      <category>smiles</category>
    </item>
    <item>
      <title>"Run Babel Anywhere Java Runs with JBabel" by Rich Apodaca</title>
      <description>&lt;p&gt;Bob, yes, the demo is a Java application. It could be turned into an applet by wrapping it in a class that extends java.applet.Applet.&lt;/p&gt;

&lt;p&gt;The only problem with that is that the code as it stands uses the filesystem. It would need to be edited to use Strings if you wanted to deploy as an unsigned applet.&lt;/p&gt;</description>
      <pubDate>Wed, 19 Mar 2008 08:59:57 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:69658970-4aa1-4696-840e-4514c8bcfe8f</guid>
      <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel#comment-445</link>
    </item>
    <item>
      <title>"Run Babel Anywhere Java Runs with JBabel" by Bob Hanson</title>
      <description>&lt;p&gt;Very interesting! What I see there is an application, not an applet, right? Does this compilation method allow for an applet with an associated JavaScript API?&lt;/p&gt;</description>
      <pubDate>Tue, 18 Mar 2008 23:37:19 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:d61886a8-d0c0-442a-86e3-194d1da78a8b</guid>
      <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel#comment-442</link>
    </item>
    <item>
      <title>"Run Babel Anywhere Java Runs with JBabel" by Rich Apodaca</title>
      <description>&lt;p&gt;Good point, Geoff. It looks like 1.7 MB or so is the lower limit for size. In some cases, having access to all formats will be useful. In others, less so. So number of formats vs. binary size is one of the trade-offs to consider.&lt;/p&gt;

&lt;p&gt;The Open Babel JNI will also remain useful because it offers a Java development library through which the Open Babel API can be invoked. JBabel, in contrast, is at this point a program that can be interfaced through the main method only.&lt;/p&gt;</description>
      <pubDate>Wed, 12 Dec 2007 20:19:18 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:6bdb3100-079e-4cc1-a086-1c0e8d2ad68e</guid>
      <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel#comment-308</link>
    </item>
    <item>
      <title>"Run Babel Anywhere Java Runs with JBabel" by Geoffrey Hutchison</title>
      <description>&lt;p&gt;Well, the reason JBabel can be 1.7MB is that it doesn't include very many file formats.&lt;/p&gt;

&lt;p&gt;The reason that the JNI interface is likely to still be useful is that it can dynamically load formats as needed.&lt;/p&gt;</description>
      <pubDate>Wed, 12 Dec 2007 19:23:27 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b8648e4b-a6c5-4266-a71d-67efd6d18b76</guid>
      <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel#comment-307</link>
    </item>
    <item>
      <title>"Run Babel Anywhere Java Runs with JBabel" by Rich Apodaca</title>
      <description>&lt;p&gt;Noel, sometimes size matters and sometimes it doesn't ;-).&lt;/p&gt;

&lt;p&gt;The more frequently and widely deployed an applet is, the &lt;a href="http://depth-first.com/articles/2007/04/18/a-2d-chemical-structure-editor-for-the-web-embracing-constraints-in-firefly" rel="nofollow"&gt;more important a small footprint becomes&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Still, in some situations having a page that initially loads slowly will be a great trade-off for a site that's faster to develop.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://sourceforge.net/project/showfiles.php?group_id=144794&amp;amp;package_id=255103" rel="nofollow"&gt;As you can see&lt;/a&gt;, JBabel in its current form is about 1.7 MB. This gives some room to maneuver.&lt;/p&gt;</description>
      <pubDate>Tue, 11 Dec 2007 09:36:18 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ab266e9f-bb46-4fc1-96d1-03f58e2cbaf6</guid>
      <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel#comment-304</link>
    </item>
    <item>
      <title>"Run Babel Anywhere Java Runs with JBabel" by baoilleach</title>
      <description>&lt;p&gt;Is Jar size important for applets? Is this an issue with JBabel?&lt;/p&gt;</description>
      <pubDate>Tue, 11 Dec 2007 03:19:07 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:2589de31-9290-4a31-bd42-e4121c343561</guid>
      <link>http://depth-first.com/articles/2007/12/10/run-babel-anywhere-java-runs-with-jbabel#comment-303</link>
    </item>
  </channel>
</rss>
