<?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: Four Free 2-D Structure Editors for Web Applications</title>
    <link>http://depth-first.com/articles/2006/08/21/four-free-2-d-structure-editors-for-web-applications</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Walking the Web of Chemical Informatics</description>
    <item>
      <title>Four Free 2-D Structure Editors for Web Applications</title>
      <description>&lt;p&gt;The increasing trend toward hosting free chemical databases and other services on the web brings with it the need for a free, ergonomic, capable, and fast 2-D structure editor. For years, the options were rather limited. However, this situation has started to change. Four web-enabled editors are discussed here, with an emphasis on the steps needed to deploy them within a webpage and retrieve a text-based molecular representation. A sample webpage is provided for each editor that allows a user to draw a molecule and view the corresponding output in a browser.&lt;/p&gt;

&lt;h4&gt;Building a Web Application: The Key Players&lt;/h4&gt;

&lt;p&gt;Consider the case of John, who would like to know the TPSA of caffeine. John finds a new website, http://tpsacalculate.com, that calculates the TPSA of any molecule. This site presents John with a 2-D structure editor applet and a "Submit" button. John uses the applet to draw caffeine and then presses the  button. After one second, John sees a new page showing the structure of caffeine and its TPSA descriptor.&lt;/p&gt;

&lt;p&gt;By pressing the "Submit" button, John sets in motion a series of transactions between the editor applet, the webpage, and the server. First, the webpage extracts a molfile representation of caffeine from the editor using JavaScript. This molfile is then submitted to the server using an HTTP POST request. After processing the molfile, the server returns a page containing the TPSA that John requested.&lt;/p&gt;

&lt;p&gt;Several variations on this pattern are conceivable, each involving varying levels of involvement by the browser, the applet, and the server. Advanced use of JavaScript can lead to elimination of the applet entirely, an approach taken by the &lt;a href="http://pubchem.ncbi.nlm.nih.gov/search/"&gt;PubChem structure search&lt;/a&gt;. Even more interesting is the use of &lt;a href="http://www.ajaxian.com/"&gt;AJAX&lt;/a&gt;, which would eliminate both the applet and the page refresh step, setting the stage for highly-interactive chemical content using only a browser and JavaScript. Although no AJAX-powered 2-D structure editors currently exist, this situation can be expected to change in the future.&lt;/p&gt;

&lt;h4&gt;Obtaining Text Output From a 2-D Editor&lt;/h4&gt;

&lt;p&gt;Extracting text-based output requires the same boilerplate code for all four editors. This code consists of four main components: (1) an editor applet into which the user draws a structure; (2) a JavaScript function that collects the output from the applet; (3) an HTML text field into which the JavaScript function inserts the output; and (4) an HTML form containing a button that when pressed sets the process in motion.&lt;/p&gt;

&lt;p&gt;These commonalities make it possible factor out editor specific code and logic. The HTML below gives an example of what one basic template looks like.&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;html&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;head&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;title&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;Molfile Test&lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;title&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;head&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;body&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="comment"&gt;&amp;lt;!-- JavaScript --&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;script&lt;/span&gt; &lt;span class="attribute"&gt;language&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;JavaScript&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&lt;/span&gt;
      function writeOutput()
      {
       document.form.output.value = document.applet.OUTPUT_METHOD();
      }
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;script&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="comment"&gt;&amp;lt;!-- Applet --&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;applet&lt;/span&gt; &lt;span class="attribute"&gt;code&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;APPLET_CLASS&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;applet&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
                &lt;span class="attribute"&gt;archive&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;APPLET_JARFILE.jar&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
                &lt;span class="attribute"&gt;width&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt;&lt;span class="number"&gt;510&lt;/span&gt; &lt;span class="attribute"&gt;height&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt;&lt;span class="number"&gt;360&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;
    Please enable Java and JavaScript on your machine.
  &lt;span class="punct"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;applet&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;br&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&lt;/span&gt;

  &lt;span class="comment"&gt;&amp;lt;!-- Form --&amp;gt;&lt;/span&gt;
  &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;form&lt;/span&gt; &lt;span class="attribute"&gt;method&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;post&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;form&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;input&lt;/span&gt; &lt;span class="attribute"&gt;type&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;button&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&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;Get Output&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
                 &lt;span class="attribute"&gt;onclick&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;writeOutput()&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;input&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;br&lt;/span&gt; &lt;span class="punct"&gt;/&amp;gt;&amp;lt;&lt;/span&gt;&lt;span class="tag"&gt;br&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;textarea&lt;/span&gt; &lt;span class="attribute"&gt;name&lt;/span&gt;&lt;span class="punct"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;output&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt; &lt;span class="attribute"&gt;rows&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt;&lt;span class="number"&gt;20&lt;/span&gt; &lt;span class="attribute"&gt;cols&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt;&lt;span class="number"&gt;80&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="tag"&gt;textarea&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;form&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;body&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;html&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;The above HTML contains three editor-specific pieces of information: (1) APPLET_JARFILE; (2) APPLET_CLASS; and (3) OUTPUT_METHOD. APPLET_JARFILE is the name of the Java archive file (*.jar) containing the applet code. This name is created by the developer when s/he saves the archive to the webserver. APPLET_CLASS is the fully-qualified class name of the editor applet. OUTPUT_METHOD is the name of the applet method that returns output. These last two pieces of editor-specific information are listed in the summary that follows.&lt;/p&gt;

&lt;h4&gt;Java Molecular Editor (JME)&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Homepage:&lt;/strong&gt; &lt;a href="http://www.molinspiration.com/jme/"&gt;Molinspiration&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;License:&lt;/strong&gt; Free for noncommercial development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code:&lt;/strong&gt; N/A&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Size:&lt;/strong&gt; 39 Kb&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;APPLET_CLASS:&lt;/strong&gt; JME&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT_METHOD:&lt;/strong&gt; molFile(); smiles(); nonisomericSmiles(); jmeFile();&lt;/p&gt;

&lt;p&gt;&lt;a href="http://depth-first.com/demo/20060820/jme/jme.html"&gt;View the Sample Page&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;JChemPaint&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Homepage:&lt;/strong&gt; &lt;a href="http://almost.cubic.uni-koeln.de/cdk/jcp"&gt;CDK&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;License:&lt;/strong&gt; &lt;a href="http://www.opensource.org/licenses/gpl-license.php"&gt;GPL&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code:&lt;/strong&gt; &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=20024&amp;amp;package_id=173599&amp;amp;release_id=400854"&gt;SourceForge&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Size:&lt;/strong&gt; up to 6.2 Mb&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;APPLET_CLASS:&lt;/strong&gt; org.openscience.cdk.applications.jchempaint.applet.JChemPaintEditorApplet  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT_METHOD:&lt;/strong&gt; getMolFile();&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Comment:&lt;/strong&gt; Although getSmiles() and getSmilesChiral() methods are available, neither produced the desired output during this test (version 2.1.5). The applet consists of 35 jar files, only some of which are necessary for minimal functionality.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://depth-first.com/demo/20060820/jchempaint/jchempaint.html"&gt;View the Sample Page&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;JMolDraw&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Homepage:&lt;/strong&gt; &lt;a href="http://sourceforge.net/projects/jmoldraw"&gt;SourceForge&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;License:&lt;/strong&gt; &lt;a href="http://www.opensource.org/licenses/gpl-license.php"&gt;GPL&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code:&lt;/strong&gt; &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=155468&amp;amp;package_id=173185&amp;amp;release_id=379497"&gt;SourceForge&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Size:&lt;/strong&gt; up to 1.4 Mb &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;APPLET_CLASS:&lt;/strong&gt; org.jmd.editor.main.JMolDraw&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT_METHOD:&lt;/strong&gt; getContentsAsMolfile(); getContentsAsJMEString()  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt; In contrast to the other three editors, there is no option to display this applet in the browser itself; it must be rendered as a separate window. In addition, this editor requires that several configuration and resource files be accessible on the server. Molfile output uses V3000 ctabs. Although V2000 ctabs are supported, the only way to activate this functionality is to modify the source code.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://depth-first.com/demo/20060820/jmoldraw/jmoldraw.html"&gt;View the Sample Page&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;MCDL&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Homepage:&lt;/strong&gt; &lt;a href="http://sourceforge.net/projects/mcdl"&gt;SourceForge&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;License:&lt;/strong&gt; Public Domain  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Source Code:&lt;/strong&gt; &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=148281&amp;amp;package_id=163529&amp;amp;release_id=405662"&gt;SourceForge&lt;/a&gt;  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Size:&lt;/strong&gt; 256 Kb&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;APPLET_CLASS:&lt;/strong&gt; mcdl.MCDLEditor  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;OUTPUT_METHOD:&lt;/strong&gt; getMDCL()  &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notes:&lt;/strong&gt; This editor only supports output in &lt;a href="http://depth-first.com/articles/2006/08/19/a-first-look-at-modular-chemical-descriptor-language-mcdl"&gt;Modular Chemical Descriptor Language&lt;/a&gt; format.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://depth-first.com/demo/20060820/mcdl/mcdl.html"&gt;View the Sample Page&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;This review has only scratched the surface of what is possible with these editors. For example, all accept input as well as providing output. As a result, they can be used to render 2-D molecular images, with more or less Java coding. Both MCDL and JME are especially attractive from the developer perspective because they are each distributed as a single jar file with a small footprint.&lt;/p&gt;

&lt;p&gt;Although numerous 2-D structure editors &lt;a href="http://dragon.klte.hu/~gundat/rajzprogramok/dprog.html"&gt;are available&lt;/a&gt;, those reviewed here meet the minimum requirements for the development of free chemical web applications: they work on nearly all computing platforms thanks to Java; and they are themselves free.&lt;/p&gt;</description>
      <pubDate>Mon, 21 Aug 2006 00:13:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:0bf7a108-3f4f-477a-b528-7dbb2352bda3</guid>
      <author>Rich Apodaca</author>
      <link>http://depth-first.com/articles/2006/08/21/four-free-2-d-structure-editors-for-web-applications</link>
      <category>Graphics</category>
      <category>web</category>
      <category>jchempaint</category>
      <category>mcdl</category>
      <category>jmoldraw</category>
      <category>jme</category>
      <category>editor</category>
      <category>2d</category>
      <category>webapp</category>
    </item>
  </channel>
</rss>
