Casual Saturdays: Wwwwwipeout

Posted by Rich Apodaca Sat, 29 Sep 2007 15:11:00 GMT

It's a fine line between crazy enough and just crazy. The dilemma is that you never know which category you're in before you start.

Designing the Obvious

Posted by Rich Apodaca Fri, 28 Sep 2007 12:29:00 GMT

Designing good user interfaces is difficult work. One of the hardest things about it is what you're forced to give up: abandoning your hard-won mental map and adopting that of the user; stripping half the product's features - and then stripping half of what's left; and fending off featuritis with a big club as the product matures. Everyone knows these things are important, but for some reason we repeat the same mistakes over and over.

So it was with great enthusiasm that I found Robert Hoekman, Jr.'s new book Designing the Obvious. Good technical books collect illustrative examples and present them clearly. But great technical books provide a system for understanding the examples. Designing the Obvious is one of them.

As an example, have you ever considered a confirmation dialog to be a symptom of a fundamentally flawed application design? The next time you find yourself needing one of these doodads, consider this passage:

The only implementation-model piece of design I've seen while using Backpack is the JavaScript alert message that pops open when I attempt to delete something from a Backpack page. It asks, simply, "Are You Sure?"

While the message is a pretty standard confirmation message - which we're all used to seeing - it's a sign of the underlying system. It's a big ol' banner that says "I don't have an undo feature and the only way I can deal with you deleting an object from your page is to interrupt your workflow with this message to make sure you know what you're doing."

Hoekman's solution is simple - give your users an undo feature and ditch the confirmation dialog. This makes perfect sense, but how many times has the opposite been done instead?

Sometimes the obvious is far from obvious.

InChI for Newbies

Posted by Rich Apodaca Thu, 27 Sep 2007 12:39:00 GMT

The IUPAC International Chemical Indentifier (InChI) provides an open system for converting molecular representations into strings of text. Because text processing is one of the things computers do very well, InChI serves as an important link between chemistry and computer science.

Unfortunately, the InChI documentation is rather scattered. To help remedy this problem, I have selected some links to Depth-First articles discussing InChI. These articles span a wide range of perspectives. They have been divided into categories for easier navigation, although many contain information that any user of InChI could find useful.

InChI in Context

Hacking InChI

InChI and the Web

InChIMatic

Please feel free to link to your favorite InChI resource in the comments section.

Image Generator Credit: txt2pic.com

PubChem for Newbies 2

Posted by Rich Apodaca Wed, 26 Sep 2007 12:42:00 GMT

PubChem is arguably the most important free repository of information about small molecules on the planet. Although its size is staggering (over 10 million unique compounds), what makes PubChem important is its completely open approach to chemical information. Never before in the history of chemistry has so much information been made available, free to anyone who cares to use it.

Despite PubChem's pioneering approach, many factors make the service difficult to learn and navigate. Most notably, its practical yet bewildering integration into NIH's other far-flung database activities serve as highly effective camouflage for the treasures that lie beneath.

With this in mind, I thought it would be useful to collect all Depth-First articles on PubChem into one place. They have been broken down into categories, although many articles contain elements useful to anyone interested in PubChem.

For Chemists

For Hackers

For Everyone

If you've got a favorite PubChem resource you'd like to share, please feel free to leave a comment.

Image Service Credit: txt2pic.com

Hacking PubChem: Visually Inspect Results for CAS Number and Keyword Searches 1

Posted by Rich Apodaca Tue, 25 Sep 2007 14:55:00 GMT

A recent article described how PubChem could be used to quickly search for CAS numbers. Although useful, the approach is limited in that only an array of PubChem CIDs was returned. What would be really useful would be a simple way to create a report with entries hyperlinked into the PubChem site itself to aid in visual inspection. In this tutorial, we'll see how an HTML template and a few extra lines of code can do just that.

The Template

Ruby supports a number of HTML templating mechanisms. In this example, we'll use an ERB template resurrected from the Molbank graphical table of contents tutorial:

<html>
  <head>
    <title>
      <%= "PubChem Search for #{term}" %>
    </title>
  </head>
  <body>
    <h1>
      <%= "Search: #{term}" %>
    </h1>
    <table>
      <tr>
      <% col = 0 %>
      <% cids.each do |cid| %>
        <td>
          <% image = "http://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=#{cid}" %>
          <% summary = "http://pubchem.ncbi.nlm.nih.gov/summary/summary.cgi?cid=#{cid}" %>
          <a href="<%= summary %>">
            <img src="<%= image %>" border="2"></img>
          </a>
          <center>
            <span style="font-size: 8px">
              <a href="<%= summary %>"><%= "CID-#{cid}" %></a>
            </span>
          </center>
        </td>
        <% col += 1 %>
        <% if col > 5 %>
          <% col = 0 %>
          </tr>
          <tr>
        <% end %>
      <%end %>
      </tr>
    </table>
  </body>
</html>

The above template uses a search term and an array of CIDs to build a table of results. Each cell in the table contains a color 2D image and the CID, both hyperlinked into PubChem itself.

Saving this library to a file called template.rhtml is all we need to do.

The Library

The library is a modification of the one shown in the previous article in this series:

require 'rubygems'
require 'mechanize'
require 'erb'

module PubChemTerms
  def report term
    cids = get_cids term
    erb = ERB.new(IO.read("template.rhtml"))

    File.open "output.html", 'w+' do |file|
      file << erb.result(binding)
    end
  end

  def get_cids term
    agent = WWW::Mechanize.new
    page = agent.get "http://www.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=pccompound&retmax=100&term=#{term}"

    (page.parser/"id").collect {|id| id.innerHTML}
  end
end

The method report accepts a search term and uses our template to render a report.

Testing

By saving the above library in a file called pubchem.rb, we can search by keyword via interactive ruby (irb):

$ irb
irb(main):001:0> require 'pubchem'
=> true
irb(main):002:0> include PubChemTerms
=> Object
irb(main):003:0> report 'esomeprazole'
=> #

This produces a file called output.html that can be viewed with any browser:

As in the original version of the library, we can also query by CAS number:

$ irb
irb(main):001:0> require 'pubchem'
=> true
irb(main):002:0> include PubChemTerms
=> Object
irb(main):003:0> report '119141-88-7'
=> #

Conclusions

The simple approach outlined here could be extended in many ways. For example, we could easily retrieve molfiles based on keyword or CAS number search. We could pipe queries together or work with query lists. We could blend in ChemSpider data. We could even build a simple Web application (with Rails) that returned customized reports. Mixing in Ruby CDK or Ruby Open Babel offers still more possibilities.

Increasingly, the most important question in cheminformatics is not "What can we build?", but rather "What should we build?" Success in this new world requires a much deeper understanding of how cheminformatics software is being used by real chemists and where it's not.

Older posts: 1 2 3 ... 5