Thursday, 22 January 2009

Turn, turn, turn - TwistyMol ready for action

A new version of TwistyMol is available. It's now ready for use by others (that means YOU). Here's a simple example and here's another with a few more molecules.

What's changed since last time? Well I've added in an SDF file parser, made it possible to have multiple TwistyMols on the same page, sorted out the rotation (at least for the moment) and gone a bit overboard on the shadows. Performance on IE is still a big problem, and displaying more than a handful of molecules at the same time is out of the question (too slow). I still don't know if this is an intrinsic problem with VML or just the whole Canvas to Excanvas to VML conversion.

If you want to use it yourself, download the Javascript files referenced in the HEAD section of the demo page, and look at the code on the demo page itself. The only tricky part is getting the SDF file into Javascript - you'll either have to place it on a webserver and use an Ajax call or do as I did and convert it to a Javascript string variable (hint: read() it in with Python and convert \n to \\n).

Feel free to modify and distribute the code. You could add a comment below with a link if you use it anywhere.

7 comments:

Geoff Hutchison said...

This gives me an evil thought. On Mac, you can create HTML previews of documents. This includes JavaScript.

I may hack this into a molecule previewer. Sound OK to you?

Chris said...

Hi,

Would it be OK if I have a look at adding this to iBabel?

Chris

Noel O'Boyle said...

That would be cool and groovy respectively.

Rajarshi said...

Very nice! Any plans for zoom? that would make it a nice alternative to JMol, which does take some time to load

Noel O'Boyle said...

Zoom? All that stuff's working already. Try the middle or right mouse buttons.

Rajarshi said...

Aah; coolest!

Felix said...

and of course the shadows are cool :)