<?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: A Molecular Language for Modern Chemistry: Reading FlexMol Documents with Octet</title>
    <link>http://depth-first.com/articles/2007/01/31/a-molecular-language-for-modern-chemistry-reading-flexmol-documents-with-octet</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>A Molecular Language for Modern Chemistry: Reading FlexMol Documents with Octet</title>
      <description>&lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/0596004206?ie=UTF8&amp;amp;tag=depthfirst-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0596004206"&gt;&lt;img border="0" src="http://depth-first.com/files/learning_xml.jpg" align="right"&gt;&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=depthfirst-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0596004206" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;An XML language is only as useful as the software tools that take advantage of it. &lt;a href="http://depth-first.com/articles/tag/flexmol"&gt;Previous articles&lt;/a&gt; have discussed how the XML language FlexMol can solve a variety of molecular representation problems ranging from the &lt;a href="http://depth-first.com/articles/2006/12/20/a-molecular-language-for-modern-chemistry-getting-started-with-flexmol"&gt;multiatom bonding of metallocenes&lt;/a&gt; to the &lt;a href="http://depth-first.com/articles/2006/12/20/a-molecular-language-for-modern-chemistry-getting-started-with-flexmol"&gt;axial chirality of biaryls&lt;/a&gt;. &lt;a href="http://depth-first.com/articles/2007/01/30/an-object-oriented-framework-for-molecular-representation-getting-started-with-octet"&gt;Octet&lt;/a&gt; is a framework written in Java that speaks FlexMol natively. In this article, I'll show how Octet can be used to read a sample FlexMol document.&lt;/p&gt;

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

&lt;p&gt;For this tutorial, you'll need &lt;a href="http://rubyforge.org/projects/rjb/"&gt;Ruby Java Bridge&lt;/a&gt; (RJB). Previous articles have discussed the installation and use of RJB on &lt;a href="http://depth-first.com/articles/2006/10/12/running-ruby-java-bridge-on-windows"&gt;Windows&lt;/a&gt; and &lt;a href="http://depth-first.com/articles/2006/08/26/scripting-java-libraries-with-ruby-java-bridge"&gt;Linux&lt;/a&gt;.&lt;/p&gt;

&lt;h4&gt;A Sample Molecule&lt;/h4&gt;

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

&lt;p&gt;A &lt;a href="http://depth-first.com/articles/2007/01/25/a-molecular-language-for-modern-chemistry-flexmol-tetrahedral-chirality-and-monolaterol"&gt;recent article&lt;/a&gt; disused a FlexMol representation of the chiral natural product monolaterol. Using a slightly modified numbering system for this molecule (shown above), we can construct a &lt;a href="http://depth-first.com/demo/20070131/s_monolaterol.xml"&gt;complete FlexMol representation&lt;/a&gt;. In this case, we simply start numbering at index zero, subtracting one from every index in the previous example to match the zero-based indices used in Octet.&lt;/p&gt;

&lt;h4&gt;A Demonstration Package&lt;/h4&gt;

&lt;p&gt;To illustrate the process of reading a FlexMol document, I've prepared a small package (&lt;strong&gt;demo-20070131.tar.gz&lt;/strong&gt;) that can be &lt;a href="https://sourceforge.net/project/showfiles.php?group_id=96108&amp;amp;package_id=220177&amp;amp;release_id=482855"&gt;downloaded from SourceForge&lt;/a&gt;. In it, you'll find an Octet jarfile (&lt;strong&gt;octet-0.8.2.jar&lt;/strong&gt;), a FlexMol representation of monolaterol (&lt;strong&gt;s_monolaterol.xml&lt;/strong&gt;), a Ruby library (&lt;strong&gt;reader.rb&lt;/strong&gt;), and some Ruby test code (&lt;strong&gt;test.rb&lt;/strong&gt;). Inflate this archive and make it your working directory.&lt;/p&gt;

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

&lt;p&gt;The following sequence of commands will run the test included with the demonstration package:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ export CLASSPATH=./octet-0.8.2.jar
$ ruby test.rb
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You should see several lines of output terminated with the line:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
The exact mass of monolaterol is 276.115029755.
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You can get more hands-on experience with loading and processing the monolaterol FlexMol document using interactive Ruby (irb). For example:&lt;/p&gt;

&lt;div class="console"&gt;
&lt;pre&gt;
$ irb
irb(main):001:0&gt; require 'reader'
=&gt; true
irb(main):002:0&gt; r=Reader.new
=&gt; #&lt;Reader:0x2b9ab173a1f0 @xml_reader=#&lt;#&lt;Class:0x2b9ab1741680&gt;:0x2b9ab1736690&gt;, @handler=#&lt;#&lt;Class:0x2b9ab1741680&gt;:0x2b9ab1736e10&gt;, @builder=#&lt;#&lt;Class:0x2b9ab1741680&gt;:0x2b9ab1736b90&gt;&gt;
irb(main):003:0&gt; mol=r.read_file 's_monolaterol.xml'
=&gt; #&lt;#&lt;Class:0x2b9ab1741680&gt;:0x2b9ab172cd48&gt;
irb(main):004:0&gt; mol.countAtoms
=&gt; 21
irb(main):005:0&gt; mol.countBondingSystems
=&gt; 24
&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Of course, this is just scratching the surface of what can be done once a FlexMol document has been loaded by Octet.&lt;/p&gt;

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

&lt;p&gt;Octet makes it possible to convert FlexMol documents into Java object representations that can be accessed through Ruby. With an object representation, the possibilities are limitless. Some simple examples have been provided here. Future articles will illustrate more advanced uses.&lt;/p&gt;</description>
      <pubDate>Wed, 31 Jan 2007 14:56:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:ab1f670a-3c7e-407d-af0e-c4343d7082d2</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2007/01/31/a-molecular-language-for-modern-chemistry-reading-flexmol-documents-with-octet</link>
      <category>Tools</category>
      <category>flexmol</category>
      <category>octet</category>
      <category>ruby</category>
      <category>java</category>
      <category>rjb</category>
      <category>monolaterol</category>
      <category>xml</category>
    </item>
  </channel>
</rss>
