User Tools

Site Tools


PyMOL Molecular Viewer Interface and Animation Watch the video tutorial on SnareMedia's Vimeo channel!

Summary Introduction to the PyMOL interface and animation

Software PyMOL, Adobe After Effects CS5.5

Instructor Bonnie Scott

PyMOL is a stand-alone software program for viewing and animating molecular structures. PyMOL can be downloaded for free at

PyMOL Interface

1. Open PyMOL. Two windows appear. The smaller top window (called the External GUI) contains the main menu, shortcut buttons, and the command line. The larger bottom window (called the PyMOL Viewer) contains the 3D viewport, object manager, and several other useful tools.

2. Fetch a molecule. PyMOL displays the atomic coordinates of a molecular structure from a PDB file. Go to the Protein Data Bank ( and download the PDB file for 2ptc (trypsin and trypsin inhibitor complex). In PyMOL, go to File > Open and select the saved PDB file or go to Plugin > PDB Loader Service and enter the PDB code 2ptc. You can also Fetch one or more PDB files at a time using the command line. Type fetch 2ptc into the command line to display the 2ptc molecular structure.

3. Explore the PyMOL Viewer. The viewer has a 3D viewport, object manager, mouse navigation guide, a selection tool (S), animation controls, and a second command line. The structures from the PDB file 2ptc are now seen in the viewport. The default molecular representation is a simplified atomic model called Lines. In the object manager, there is an object called all that represents all objects in the viewport as well as an object for each chain within the PDB file. The object manager allows you to adjust settings like view, representation, color, selections, and labels using the command buttons Action (A), Show (S), Hide (H), Label (L), and Color (C). Importantly, changing a representation in the viewport using the Show (S) button does not replace the last model, it just adds it on top. To stop objects from piling up, use the Hide (H) button to remove unwanted models. Explore the main menu in the top window to see redundant and extended options for manipulating objects in the viewport and object manager.

4. Make selections. Use the object manager to create selections of entire objects (eg. to change a molecule's representation), use the Sequence tool (S) to create a selection of part of an object (eg. to change the color of a particular residue), or select structures directly within the 3D viewport. The Sequence (S) button in the lower right corner should not be confused with the Show (S) button in the object manager! Once the Sequence (S) tool is activated, a detailed list of chains/residues/atoms appears at the top of the viewport. Select parts by clicking or dragging across a range and an active selection object now appears in the object manager. A good workflow is to always make changes to an object as a renamed selection. This allows you to go back to the object's original state at any time. To change the active selection to a permanent renamed selection, go to rename from the Actions (A) menu and give it a new name. If you don't rename your selection, it will be replaced by the next active selection. If your model disappears, select Reset from the Shortcut Buttons or reselect the model type from the Show (S) menu. You can also reset PyMOL to its initial state (but losing all data) by selecting File > Reinitalize.

5. Save and customize your project. In your viewport, you should see the 2 chain complex for 2ptc, trypsin and trypsin inhibitor. Importantly, there is no Undo command, so if you delete any atoms during your session, you need to restart! First, save your PyMOL session (.pse file) by going to File > Save Session. Go to Display and deselect Depth Cue. Remove all water molecules from the scene by going to all > Action (A) > remove waters. Open the sequence viewer by activating the Sequence button in the lower right corner or from the main menu Display > Sequence. Under Display > Sequence Mode, change the setting from Residue Codes (default) to Chains. Select the E chain and in the object manager, select Action (A) for (sele) > rename selection. Use backspace to delete the sele_ entry, type chainE, and press enter. In the object manager, select Hide (H) for (chainE) > Lines, then select Show (S) > cartoon (in PyMOL, ribbon refers to a backbone model). Select Color (C) for (chainE) > blues > slate. Repeat these steps for chain I, except use the color oranges > yelloworange. To highlight the trypsin active site, go to Display > Sequence Mode >Residue Codes for chain E and select Serine (S) 214, Histidine (H) 57, and Aspartate (D) 102, as well as Aspartate (D) 189 involved in ligand stabilization. Rename the selection chainE_SHDD and go to Action (A) for (chainE_SHDD) > preset > ball and stick. If it looks like a gap was made in the cartoon model, select 2ptc > Show (S) > cartoon to refresh the model view with no gaps. To highlight the critical lysine residue on the trypsin inhibitor, go to the sequence viewer for chain I and select Lysine (K) 15. Again, go to Display > Sequence Mode > Atoms and select the CA atom. Rename the selection chainI_K and go to Action (A) for (chainI_K) > preset > ball and stick. To change the background to white, go to Display > Background > White.

6. Share your work. To share your work, you need to save your project. You will most likely Save Image As a PNG (lossless bitmap image) or VRML-2 (geometry for a 3D application like Cinema 4D). We will cover saving a movie later. First, make sure to adjust your viewport! What you see is what you get and your work will be saved exactly as you see it in the viewport. Adjust the size of the viewer and zoom in/out to make the molecule the right size. Remember, images for print are larger (300 dpi resolution) than for the web (72 dpi resolution). Also, PyMOL does not save a maximum quality image by default. To change this, go to Display > Quality > Maximum Quality. Curves are now more rounded and shading is smoother.

TIP! Use the Ray Shortcut Button (renders image using the POV-RAY render engine) before saving an image to create a higher quality version with nicely rendered shadows. However, this will take some time, depending on the image. Ray tracing will disappear if the view is changed in any way!

7. Exercise your power by using the command line! PyMOL is built using the Python scripting language. The command line is a powerful tool that let's you run Python text commands to communicate with PyMOL. It can make your life a lot easier because there are many advanced options that simply don't appear in the point-and-click graphical interface. It can also be a lot faster by automating tasks and making complex changes. However, coding can be daunting for a lot of people. To learn some simple commands, explore the Practical Pymol fo Beginners webpage on the PyMOL Wiki at

Make a Movie Using PyMOL and After Effects

To create simple animations, you can use either the graphical interface or the command line.

Graphical interface method

Scene rotation (360 degrees): Movie > Program > Camera Loop > X-Roll > N Seconds. Go to Save Movie As > PNG Images. Scene rocking (partial scene rotation by 30, 60, 90, 120, or 180 degrees): Movie > Program > Camera Loop > X-Rock > X-Degrees over N-Seconds. Go to Save Movie As > PNG Images. Scene nutate (wiggle-rock scene rotation): Movie > Program > Camera Loop > Nutate > X-Degrees over N-Seconds. Go to Save Movie As > PNG Images. Camera zoom (eg. on specific tryptophan residue): Build > Residue > Tryptophan… then Scene > Store > F1… (click any atom and zoom in) then Scene > Store > F2… then Movie > Program > Scene Loop > Nutate or Y-Rock. Go to Save Movie As > PNG Images.

In general, to make multiple scenes: 1) Scene > Store >… to save your scene, 2) Movie > Program > … to create the type of animation, and 3) Scene Loop to link the scene animations together into a movie.

Command line method

Type the following into the command line and hit enter after each). Go to the PyMOL Wiki for details on scripting other types of animations.

Scene rotation (360 degrees): mset 1, 180 defines the movie util.mroll 1, 180, 1 executes the command to create full rotation over 180 frames set ray_trace_frames, 1 turns ON ray tracing set cache_frames, 0 turns OFF cache frames (saves frames in memory)

For Mac users, simply go to File > Save Movie As > Quicktime (not available for PC). Choose Compression type > Video, Motion > Frames per second > 30, Key frame every > 24 frames, and move the Quality slider to the desired setting.

For PC users, go to Save Movie As > PNG Images (MPEG is not recommended - see PyMOL Wiki for details). Use a program like Adobe After Effects to create a movie from the PNG image sequence. From the After Effects File menu, select Import Multiple Files. In the following window, check PNG sequence then Open. Drag your image sequence file into the composition area and After Effects creates a movie! To save the movie, go to Composition > Make Movie. Choose your video settings (typically Quicktime or MPEG4) and output location. Select the Render button and voila, you have a movie! The video can be further compressed using a H.264 Codec in a program like Adobe Media Encoder.

students/pymol_molecular_viewer_interface_and_animation.txt · Last modified: 2012/05/08 14:06 by bonnies