Forums | Mahara Community

Developers /
'Instant' 2D and 3D Chemistry Plugins

Geoff Rowland's profile picture
Posts: 108

17 May 2011, 1:21 PM

Here are another couple of blocktype plugins to allow 'instant' visualisation of 2D and 3D chemical structures in Mahara.

They both rely on the remarkable Chemical Identifier Resolver service developed by the Computer-Aided Drug Design (CADD) Group of the Chemical Biology Laboratory (CBL), National Cancer Institute (NCI), National Institute of Health (NIH) located at NCI-Frederick.

The first Chem 2D NIH (chemnih) plugin returns a Gif image of the 2D structure of any meaningful chemical search term. Valid search terms include a trivial chemical name, systematic (e.g. IUPAC) chemical name, SMILES, InChI or InChIKey. You can set the height and width of the block. You can also select whether the structure is shown in skeletal format (without explicit carbon atom labels or hydrogen atoms) or a fully displayed structure (with all atoms and atom labels).

So, just type in an appropriate term (e.g. ethanol, morphine, buckyball, Cl/C=C\Cl) and you get an (almost) instant image of the 2D structure.

The second Jmol NIH (jmolnih) plugin returns a Structure Data File (sdf) containing 3D cordinates that are rendered by the awesome Jmol Java applet.

To avoid security issues with remote file access by the unsigned Java applet, the file contents are read via PHP into a string variable which is then loaded by Jmol. Ugly, but it works!

As with the Chem 2D NIH plugin, you can set the height and width as it appears in a View.

For more advanced Jmol users, there are a couple of textarea controls that allow you to:
1. Specify an optional Jmol startup script to customise initial display of the applet

2. Enter optional Jmol.js JavaScript commands to add custom commands below the applet

Default script values are applied for general use

Note that development has focused on the functionality of this, and there may be security implications of running these scripts. Happy to receive advice and guidance from Mahara security gurus about this.


Both plugins can be downloaded from Github

On unpackging, the /chemnih and /jmolnih folders (and their contents) are simply copied into the /blocktype folder of your Mahara installation

For the /jmolnih plugin you also need to download and unpack the latest Jmol stable version (currently 12.0.43), rename the unpacked folder (e.g. /jmol-12.0.43) to /jmol and copy this (and its contents) into the /lib folder of your Mahara installation to give /lib/jmol. Not all the contents of the jmol folder are actually required. However, Jmol code is frequently updated so it is convenient to just replace the /jmol folder with the latest version.

Finally, visit your Site Administration > Plugin Administration page to enable the plugins.

Of course, for the /jmolnih plugin, you will need an up-to-date Java installation on the client computer

During configuration and initial display of the Jmol applet in a view, you may have to refresh the browser.

The plugins can be used alongside each other in a Mahara View to allow comparison of 2D and 3D chemical structures. I hope this plugin will help both science teachers and students to put together resources and presentations. For example, it should allow the easy construction of 'Molecule of the Month' type resources in Mahara.

In the near future, we intend to release some variants of the Jmol plugin to display local structure files (pdb, mol, cif, xyz, sdf cml etc) and directly display biological macromolecules from the RSCB Protein Data Base (PDB) service and mineral crystal structures from the Crystallography Open Database (COD)

I'll also put together some demo pages and add entries to the Mahara Wiki pages over the next few days/weeks.



Kristina Hoeppner's profile picture
Posts: 3671

19 May 2011, 12:46 AM

Hello Geoff,

Thank you for posting your plugins and also linking them on the wiki page for plugins.



anonymous profile picture
Deleted user
Posts: 2

02 July 2011, 4:05 PM

Hi Geoff,

I have installed yoy plugins following your instructions with care, but only Chem2D is working. First, it seem that the database table "artefact_file_mime_types" must be modified to add the requierd mimetypes.

Jmol NIH only present a line with the name of the compound as a link to a text page with structure data

The Jmol plugin in shows an EMPTY square. The applet is not being loaded. (positive test working  when using site)

I am working with mahara 1.3.6

¿Any idea of what's broken?

Geoff Rowland's profile picture
Posts: 108

03 July 2011, 9:56 AM

Hi Enrique

Jmol NIH and Chem2D should not need additional mime-types as these feed the remote file contents into Mahara without storage.

The Jmol plugin does need the database table 'artefact_file_mime_types' to be updated. This should happen if you follow the instructions on the wiki

However, you may also have to increase (e.g. + 1) the $config->version value in /artefact/file/version.php, then visit the admin page to force the database update (I will add this instruction to the wiki)

OK I have now just got the same symptoms as you (empty square) with the latest Jmol version 12.0.46. On reverting to Jmol 12.0.43, things work as expected. So, try using an older version of Jmol from:

I'll investigate further as to what has changed between Jmol versions.

Also, be aware that the NIH NCI/CADD Chemical Identifier Service ( is still in development and occasionally goes off-line. It's actually offline at the time of this post

The fall-over behaviour of the plugin could probably be improved for this. I'm also hoping that the Chemical Identifier Resolver service will eventually be mirrored. Alternatively, it may be possiible to build in redundancy in through additional connections to similar services such as PubChem and Chemspider

Hope that helps


Geoff Rowland's profile picture
Posts: 108

03 July 2011, 11:23 AM


From a quick test Jmol-12.0.43 (and earlier) works fine with the Mahara plugins

Later versions (12.0.44, 12.0.45 and 12.0.46) do not work

So, for the time being, use Jmol-12.0.43

I'll investigate further...

Geoff Rowland's profile picture
Posts: 108

04 July 2011, 2:49 AM

Robert Hanson, the lead Jmol developer, has identified the bug in Jmol.js. The next Jmol version (12.0.47) should have a fix.

Enrique, Thanks for the 'heads up'.


6 results