Creating Animated Molecule Movies in Chimera
PDB Files and Molecular Modeling Software
Chimera output, using POV-ray raytracing
ventually, almost every chemist will need to include an image of some
kind of molecule in a PowerPoint presentation. The best way to convey
the true shape of a molecule is with a rotating three-dimensional model.
Since PowerPoint is the common standard for presentations these days,
that means you have to make a movie.
The first step in making a movie of a molecule is to obtain a PDB file. PDB files can be downloaded from a number of places, including www.rcsb.org/pdb, or they can be created using a molecule editor (see below). Even though PDB is a text format, you can't just create a PDB file by hand; it must be optimized with Ammp, Mopac (a closed-source, commercial program), or some other software algorithm to find the correct energy-minimized structure. Don't bother with molecule formats other than PDB; some of them don't uniquely describe a molecule and will happily convert your carefully crafted molecule to a chemical abomination from hell.
Next, you need some molecular modeling software or a molecule viewer. The three best ones to my knowledge are Chimera (Linux, Windows, OS X, Irix, HP Tru64 Unix, and FreeBSD), Viewmol (Linux, FreeBSD, SunOS, AIX, Irix), and Vmd (Linux, OS X, and Windows). Chimera is the best for making movies because it has scripting, which is essential for smooth movement. Best of all, Chimera is free. It was developed under an NIH grant--which means, if you're an American taxpayer, you paid for it already.
For general molecule rendering, these other software packages may work. I have only minimally tested them.
- Swiss PDB viewer (deepview) (Windows/Mac only)
- moilin (Windows only)
- yasara (Linux, Windows, OSX)
- ymol (Linux, Windows, FreeBSD, IRIX, OSF/1, ULTRIX, AIX, Solaris, HP-UX) (I could not get it to compile in Linux).
- pymol (Linux, Windows, Mac) - would not compile in Linux Suse 10.0 but
compiled in older versions. To compile and run pymol, issue the
following commands:
su
python setup.py install
python setup2.py install
exit
./pymol
- VegaZZ (Windows only) - An excellent, easy to use viewer. Even though it only handles one molecule at a time, you can use VegaZZ to interactively create a molecule and optimize its 3D structure, then save the result as a PDB file. It is free, but unfortunately the program is spyware: it contacts the vendor over the Internet every time you start it up.
- ICM Browser Pro (commercial)
- Amira (commercial)
- JME - a crude web-based 2D structure editor. Doesn't create PDBs.
- Webmo - is difficult to install. This software is a bunch of cgi scripts, and it's necessary to change your webserver configuration to install it.
Displaying a molecule in high resolution in Chimera
Next, get the molecules to their starting position. It's essential to make the resolution as high as possible, because when it's converted to an MPEG or MP2 to accommodate the limitations of Windows, much of the resolution will be lost. These are the settings I use to make high-resolution molecules in Chimera:
- File → Open for each molecule
- Favorites → Model Panel. This can be used to link or unlink two or more molecules.
- Make the molecules as big as practicable and rotate to their starting
position.
left mouse = rotate
center mouse = translate
right mouse = scale
- Presets → Interactive → All atoms. Activates the ability to set the color of carbon atoms.
- Actions → Color by Element. Sets each element to a different color.
- Favorites → Model Panel. This is the control panel that determines whether to rotate one or both of your molecules, and also sets their properties. Click on the small colored box next to 'ID' to change the backbone color of the desired molecule.
- Actions → Atoms → Bonds → Ball and Stick.
- Tools → Viewing Controls → Lighting - make molecule less bright
- Increase key to fill ratio to 8
- Depth Cueing on, Start Ratio 0.98
- Subdivision Quality 20
- Rotation Center of Rotation Method = Center of Models
- Model panel → Attributes → Ball Scale = 0.3. This makes the spheres bigger.
- Actions → Color → Click 'Background' → Click Dim Gray. If you click a color first, your molecule is messed up, and you have to re-start from the 'presets' step.
- Session → Save → Mymolecule.py. Save the session in case the result is no good.
- To save an image for publication, use File → Save Image → Retrace with POV-Ray = True. This will create a PNG file. Never use JPEGs for any type of scientific or technical image.
Creating a movie in Chimera
Animated rendering of a simple phosphate molecule. Click on image to
view or download movie (MPEG format).
Once the molecule is displayed at the highest possible resolution, create a command script to rotate the molecule while creating a movie file. This is essential for getting smooth movement. The alternative, rotating the molecule by hand and saving each frame, is too time-consuming to be practical.
This should be done on a fast computer, because it can take several hours to create a ten-second movie.
- Edit a text file named movie.cmd. You must use MPEG if movie will
be used in PowerPoint. Even though some newer versions of PowerPoint
might be able to handle mp4 files, you cannot always predict what
computer your presentation will be run on. For example, Office 2000
can only handle MPEG and MP2. The other three options (AVI, MP4, and
MOV (Quicktime)), which provide much higher quality, don't work.
Even this low standard requires Windows XP for the movie to be
displayed. In Windows 2000, it's very difficult to play any kind of
movie in PowerPoint.
Another problem: a presentation created on one version of PowerPoint may hang on another version if it contains a movie. Also, although PowerPoint doesn't warn you about this, the original mpeg file has to be in the same location that it was when you inserted it, or the animation won't run. - Here is a minimal movie.cmd file:
# Anything after a '#' is a comment
movie record framerate 10 raytrace true
wait
turn y 3 120
wait
movie stop
movie encode mformat mpeg bitrate 4000 output mymovie3.mpeg
A complete list of commands is at: http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/framecommand.html
- Open the text file 'movie.cmd' as a command file. The movie is created and saved automatically in the specified filename.
- Don't touch your keyboard or mouse until Chimera is done, or an error message will pop up and Chimera will stop.
Notes
- The 'turn y 3 120' command rotates the active molecule(s) around the y-axis in 3 degree increments for 120 different frames to create a complete 360° rotation.
- If you use more than about 200 steps, Chimera will get stuck. Instead of the pov-ray progress bar, only a blank window is displayed, and the molecule stops rotating. This means that Chimera has gotten lost and no movie will be created. What seems to be happening is that Chimera is just creating the last frame over and over. Clicking "Abort" will produce an error message and force Chimera to begin creating the movie. At this point, the only evidence that Chimera is still running is that the size of your movie file continues to increase. If Chimera crashes, the earlier frames are still good, and it's still possible to create a movie from them (see below).
- The size of your movie file will continue to increase for several minutes even if you close the Chimera window. It's neccesary to wait until the movie stops increasing in size before inserting it into PowerPoint.
- After creating a movie, it is necessary to re-start Chimera, because it becomes extremely slow and may crash or hang. It can also crash the X Window system at this stage. If you need to use your window manager to crash Chimera in order to escape, don't forget to delete all the temporary files that Chimera creates in /tmp.
- After running several simulations, the X Window system also becomes slow for other applications. It is advisable to re-start X after using Chimera. The reason for this is unknown.
Creating a movie in Linux
It's also possible to create a movie from individual image frames. This can be done with ffmpeg. See http://electron.mit.edu/~gsteele/ffmpeg/ for more details. However, ffmpeg is very user-unfriendly and its documentation, quite frankly, sucks. Basically, you must use a "%0nd.jpg" (where n is the number of digits in your filename) to specify the input files, and your files must be numbered sequentially. Using "*.jpg" will not work. Even though the "%nd" looks like a shell wildcard, it's not; ffmpeg is not using the shell. The specifier "%05d" is C for a five-digit integer padded on the left with zeroes.
For example, if chimera hangs or crashes, you can still create a movie
from the files left behind in /tmp, using the following commands:
cd /tmp
for f in *png ; do convert -quality 100 $f `basename $f png`jpg; done
ffmpeg -b 4000 -i chimovie_cxva-%5d.jpg test.mpeg
Although it doesn't seem to be documented anywhere, ffmpeg uses the
extension of the output file specified to determine what to create.
The "-b 4000" sets the bitrate; setting a large value is essential to
get acceptable quality. A value of 4000 is a good compromise between
file size and quality. Another useful command line option is '-r',
which sets the frame rate. However, this only works in later formats
such as mp4, not mpeg.
Here's another example:
- Convert all images to jpegs with 100% quality:
for f in *png ; do convert -quality 100 $f `basename $f png`jpg; done
- Use ffmpeg to convert to mp4. The filenames must contain a fixed
number of sequentially ordered digits (e.g., abc001.jpg for frame 1,
abc002.jpg for frame 2, etc). The first example creates an mp4 with 10
frames per second and 1800 kbps. The second creates an mpeg at the default
rate (25 fps, 200 kbps).
ffmpeg -r 10 -b 1800 -i %03d.jpg test.mp4 ffmpeg -i %03d.jpg test.mpeg - Use a media viewer or download Quicktime from Apple to view the image.