Monthly Archives: December 2009

Twirl Your Molecule Nicer and Faster

Well, Noel posted it already earlier on his blog: he has improved TwirlyMol quite a bit (the molecules look really awesome now), and I have worked on some improvements on how it is delivered by the Chemical Identifier Resolver.
If you have already embedded twirling molecules in your web page (as described here), Noel’s changes to TwirlyMol are visible immediately. Additionally, you can cache a once generated TwirlyMol on our web server. This reduces loading times quite a bit after the first request of the molecule. Here is, how it works :

1. create a div element, name it by the id attribute and set also the width and height attributes:

<div id="DIV_ID" height="height" width="width"></div>

2. load the TwirlyMol javascript with the following script:

<script src="http://cactus.nci.nih.gov/chemical/structure/IDENTIFIER/twirl_cached/DIV_ID"></script>

So, if you already use the “old” way in your web page for loading TiwrlyMol, you might change it to this for shorter loading times (however, we also will keep the previous method). The script created by the caching method will be available in our cache for 10 days since its last usage (after that it will be just re-cached after the next request).

Here it is how it works for NSC number 740 in the NCI database:

<div id="div_for_nsc740" height="400" width="600"></div>
<script src="http://cactus.nci.nih.gov/chemical/structure/NSC740/twirl_cached/div_for_nsc740"></script>

which creates the twirling molecule at the top of this post.