Tuesday, March 15, 2011

How to implement Jmol in Beamer presentations

This week I had to day a presentation for the QM/MM course held by Professor Jan H. Jensen at the University of Copenhagen in which I would like to present the cytochrome P450cam enzyme as an interactive 3D Jmol model. This turned out to be a somewhat tedious project to do in Beamer, mostly due to the fact that I only read the first half of this tutorial section of the Jmol Wiki and hence not the second half which actually addresses many of the issues which I encountered. Note to self: Read all the introductions - the problem is most likely encountered before by someone else and hopefully solved already. Still, I would like to describe how I did it, as I actually ran into some minor TeX problems which I had to solve on my own.

I am running LaTeX thorugh Cygwin DLL 1.7.8-1 on my Windows Vista OS but the points on how to install the additional packages are general and thus apply to LaTeX being run on Mac OS as well as Linux. If you are running LaTeX via MiKTeX or any other program implementation of LaTeX, the packages should be installed without difficulty via the associated integrated package management.

Generate the Jmol input:

  • Note - you need at least version 12.0.RC26 to make .idtf files. Download the latest version here.

I retrieved the cytochrome P450cam (ferrous-dioxygen state) 1DZ8 input from the Protein Data Bank (PDB) here [1]. The .pdb file is downloaded by choosing the 'PDB File (Text)' from the 'Download Files' drop-down list in the upper right corner of the screen.
The .pdb file is opened in Jmol and should now be converted into a Universal 3D file (.u3d) but unfortunately Jmol does not support this as of yet (see the comment section in the previous post on embedding interactive 3D graphics in .pdf files from the MolecularModelingBasics blog here. What Jmol does support, though, is the generation of .idtf files. Once you have your molecular system open i Jmol, open the script console and type in:

write /home/Janus/Documents/test/test.idtf

This generates not only the .idtf file (test.idtf) but also a .tex file called test.idtf.tex which includes the appropriate TeX code.

Conversion of .idtf to .u3d format:

In order to convert to the .u3d format, I used the Universal 3D Sample Software in the newest version (U3D_A_061228_5). After unzipping, I typed in the following within CMD (again, this is Windows but is easily adapted for Mac or Linux OS):

C:\cygwin\home\Janus\presentation_qmmm>"\Users\Janus\Documents\U3D_A_061228_5\Bin\Win32\Release\IDTFConverter.exe" -input test.idtf -output test.u3d

This produces the appropriate test.u3d file and is the file called from the code in test.idtf.tex.

Implementation into Beamer:

I used the Beamer class of LaTeX to create the presentation and quickly realised from the errors in the initial attempts to compile that I needed (at least) two packages in addition to the minimal set of packages that I had already declared [beamerthemesplit, graphicx, amssymb, amsfonts, amsmath, hyperref]. From the test.idtf.tex file I could see that I needed the 'movie15' style which I located and downloaded from CTAN. Once downloaded, I placed it within my local texmf environment and updated:

$ pwd
$ mkdir movie15
$ mv ./movie15.sty movie15
$ texhash

From the next attempt to compile, I realised from the .log file that I also needed the 'ifdraft' package. I found the ifdraft.dtx file on CTAN here and compiled it again within my texmf environment

$ pwd
$ mkdir ifdraft
$ mv ./ifdraft.dtx ifdraft
$ tex ifdraft.dtx
$ texhash

Now I was able to compile. I noticed that the test.idft.tex file recommends the use of 'verbatim' but I removed this as I had no need for it. This might not always be the case, though.

Choice of PDF viewer:

I stumbled upon this obstacle when I had finally compiled and attempted to view the .pdf file. I have always been using TeXWorks as it integrates nicely with TeX but I realised that it did not support 3D illustrations and I hence had to download Adobe Acrobat Reader from here. The link points towards the download page for other versions than 9.x and the new X Reader, as none of these showed to be compatible with my 3D illustrations in line with TeXWorks (sigh!). Thus, if you do not have a license for Adobe Acrobat Pro Extended, you will have to use the Reader in a version no newer than 8.2*. I have used 8.2 and it works nicely.

* This might differ for other operating systems. Let me know.

The result:

I have uploaded the result (both the .pdb, .tex, and .pdf files archived as test.tar) on the QM/MM at KU site if you want to look at it or replicate from the .pdb file (here: 3L61 - find it at PDB here [2]).

[1] Schlichting et al. - Science, 2000, 287, 1615
[2] Lee et al. - Biochemistry, 2010, 49, 3412


Anonymous said...

Thanks Janus for this very helpful tutorial. Do you know how to embed a JMol animation (such as a molecular vibration) into Beamer? I have tried following your instructions, but all I got was a static picture embedded into the pdf file. I could rotate the picture, but the vibration was frozen!


Janus J. Eriksen said...

Hi Claudio.

I am afraid I do not have the necessary time to investigate this matter into detail at this moment in time (master's thesis in preparation) but I would expect one solution to be to record a movie or a sequence of stills within Jmol. Then proceed to embed that movie in your presentation by employing the


command in your preamble.
Note please, that I have not tested this solution but I now from experience that movies generated from Jmol works. You might loose the interactivity of the animation, though.

Kind Regards

Unknown said...

Hi Janus, thank you for your useful post, I use Fedora and works fine, adobe 8 works as a presentation viewer with this "plugin", unfurtanelly evince and okular does not work. Really, thank you a lot, I was looking for something like this for a while.