Saturday, February 14, 2009

DSpace, chemical structures, CML and jmol

I have started to put some chemical structures into my DSpace instance. They are going in as CML files. CML is Chemical Markup Language. There is an open source tool called jmol which allows structures to be viewed as 3D rotating images, given a CML file. JMol includes a servlet so that web pages can display these images. I would like to see this used by DSpace. But in the meantime I have set things up so that CML files invoke an external jmol viewer. This is a bit like putting up PDFs and getting the external acrobat reader to display them. Here's how I did it:

  • Add a mimetype for XML to the list of registered types. Make the type known (as opposed to unknown or unsupported), and the mimetype chemical/x-cml.
  • Download the jmol package from sourceforge and ensure that the script (or jmol.bat on Windoze) has execute permission. On Windoze the environment variable JMOL_HOME must also be defined. On Unix just add the jmol directory to your PATH.
  • Test jmol by running the standalone viewer on a CML file. When that works you should be ready.
  • Add a CML item to a collection in your Dspace. That's it. Clicking on it will now run the viewer!

It would be great if the 3D image could be in the web page directly, like PDFs can with the browser add-on. But AFAIK there is no such add-on. There is the servlet but this would involve codes changes to DSpace.