Previous Next

Chem 110L: Macromolecular Visualization Laboratory Exercise: PyMOL Movies

Any molecular visualization program allows the user to save individual views of a structure into a set of image files. These image files can then be converted into one movie file. The difference between programs lies in the ease of automation, and the level of control over the creation of image files. With PyMOL, thanks to the underlying Python-based language, you easily perform simple tasks. For example, it is easy to create a movie of a rotating or a rocking molecule. Furthermore, with some more effort you can create complex sequences of images that zoom in to specific regions, highlight interesting aspects, or convey the sense of dynamics in the system. Using external tools to manipulate the geometry of molecules (e.g. molecular dynamics) or interpolate between two experimental structures (e.g. morphing between the R and T state of hemoglobin) one can create animations that provide an approximate representation of conformational changes when a ligand binds to the protein.

Fortunately, there are several excellent tutorials online that demonstrate how to create movies with PyMOL. We will learn how to create a simple movie of a small rotating helical peptide. This is a low-cost movie: you need PyMOL (free), ImageMagick (free), a movie player (free), and an operating system (free if you choose wisely). To make thinks little more interesting, we will first custom-build the peptide.

Get your actor and dress it to your preferences

You get to direct a movie that rotates the peptide! To be a successful movie director, you need attractive actors ... and think about the message that you want to deliver to your audience. We worry about getting attractive actors first.

  1. Start a new Unix Shell, enter a PERM number and create a new direcory for your movie: mkdir PNG
  2. Reinitialize PyMOL. Under Build, select Residue, then pick Helix.
  3. Build a peptide (10-12 amino acids) of your choice by successively selecting amino acids from Build, Residue. You are trying to get a nice alpha helix, so avoid prolines.
  4. Notice that the N-terminus and the C-terminus are not complete. We'll fix the N-terminus first. Change to the Mouse Editing Mode and click on the Hydrogen connected to the N-terminal nitrogen atom. Then remove atoms from this selection (pk1). Now click on the N-terminal nitrogen atom. Then select Make (pk1) Positive from the Build menu. Now, select Fill Hydrogens on (pk1) to create a proper NH3 group at the N-terminus. Fixing the C-terminus is a little different. Click on the C-terminal carbon to select it as (pk1). Now type attach O,2,2 to add the oxygen atom with two valences. Click on the selected carbon to deselect it.
  5. From the right-hand toolbox, under Actions, select assign sec. struct., then show the peptide backbone as a cartoon with atoms shown as lines.
  6. Customize the apparence of the helix by typing set cartoon_transparency, 0.4 and set cartoon_oval_length, 0.9
  7. Type show sticks, name c or name o or name ca or name n or name h at the command line to emphasize the backbone atoms.
  8. Type dist (name o), (name h), 1.8 to show the hydrogen bonds in the backbone. Type hide labels.
  9. Type hide lines, elem h and (neighbor elem c) to hide nonpolar hydrogens.

Let the play begin!

OK, on with our Molecular Hollywood! To be a successful movie director, you also need to know how to "speak the speak". Few key words to remember are "states" and "frames". After you figure this out, all you have to do is to yell, "mrock" or "mroll", and shoot.

  1. Orient the molecule such that the helix is vertical.
  2. Predefine 180 movie frames, each showing the state 1 (we have only one structure, thus one state) by typing mset 1,180
  3. Use a predefined action, in this case rotating the molecule for one full turn (or walking the camera around the object for one full term) and snapping 180 evenly spaced frames, by typing util.mroll 1, 180, 1
  4. We will raytrace the frames to create a slicker image: set ray_trace_frames, 1
  5. No need to cache frames in memory while shooting a movie: set cache_frames, 0
  6. Under the File menu, select Save Movie. Save the sequence of PNG files with a unique file name, e.g. helix in this directory. Hit OK; the PyMOL is ray tracing every frame and writing it into a PNG file. Sit back and relax ... or browse the pretty pictures behind this link.
  7. Minimize PyMOL.

This little thing before we can claim our Oscars

Once finished, you can animate the sequence of images using the command animate *png in the directory where the files are. Converting a sequence of images into a movie can be achieved by many different means depending on the operating system and the available software. A free cross-platform converter and editor is provides by the ImageMagick suite of programs (thanks to J. Cristy, ImageMagick Studio LLC). In particular, the mogrify program can annotate a sequence of images, and the convert program will create an MPG movie with the help of the free mpeg2encode program.

  1. mogrify -draw " text 20, 30 'Hello, world' " -fill yellow -pointsize 18 helix005* helix010* helix015*
  2. convert -quiet -delay 1 *png helix_mov.mpg
  3. Play the movie file with a program VLC, installed on the Linux computers.

This was a pretty good start, your inner critic probably says now. But you can do a lot more. With only little more practice, you could create movies like this protein helix or this DNA double helix. Somewhat more complex examples can be seen at Cooperativity in Proteins page.

To work with more advanced movies, the following resources will be helpful: