Crystallography‎ > ‎Molecular graphics‎ > ‎Pymol‎ > ‎


Autoplay through scenes

To play through a number of scenes, use the following commands:

cmd.set('movie_fps', 1.0 / 5.0)
cmd.mdo(1, 'scene auto, next')

This is similar to "Movie > Program > Scene Loop" but using a single frame.

Combine rotations/rocking/rolling with zooms and smooth transition between different scenes

  1. Create your scenes for the desired views;
  2. Click on the first scene (usually called F1);
  3. Add the desired animation using the menus "Movie > Program > Camera Loop";
  4. Move to the end of the animation just inserted (either use the movie slider at the bottom and place it all the way to the end, or use the command "cmd.ending()");
  5. Repeat the sequence in 2-4 for the other scenes F2, F3, etc.
  6. Check and add transitions between scenes: if pymol did not already automatically incorporated the transitions, one way to do it is by moving the movie slider at the bottom of the window to the last frames or each scene/animation (using the right button of the mouse) , and then drag the slider so as to expand the range of the transition. Alternatively, a more accurate way to do it is by using the command "cmd.mmove(XXX,YYY,1,object='none')" with XXX and YYY being the last and first frames numbers between which you want your transition. 
Here is the list of commands required (scripted using the log function, and that will have to be inserted in the Pymol> prompt one by one):


Below is a movie generated with the exact procedure above, adding "cmd.mmove(160,122,1,object='none')" only at the end, which adds the transition between F1 and F2, while other transitions between other scenes got automatically incorporated (but can be edited, of course):

Movies in Pymol (from v 1.4)  that will play in Microsoft powerpoint (last updated Oct 2011)

  1. Create png single frames from the Save As in MacPymol (or PyMOLX11Hybrid)
  2. Command+Shift+Open these frames in QuickTime 7 (PRO, ~$30 for this)
  3. Export from Quicktime 7 (PRO only) using Movie to Windows Media (this works only if Flip4Mac Studio is installed; if Flip4Mac free player only available, then the output wmv file will be partial) using Default Settings.
  4. Now, this WMV file can be inserted as movie in a ppt presentation; will it work on any Windows-based PC/any ppt version? Good question.

External links

Movie School

Animating symmetry

Fetch a protein (1yme)

fetch 1yme, one, async=0

symmetry expand

symexp foo, one, one, 4

rename for easier use; call it "two"

set_name foo01-100-1,two

remove others

dele foo*

setup the camera view


set up a simple movie and save camera position

mset 1x60
mview store

save mobile objects original position

mview store, object=one

align the two objects

align one, two, object=aln

grab the transformation matrix

mm = cmd.get_object_matrix("one")

undo the transformation

matrix_reset one
frame 60

this caused the problems

set matrix_mode, 2

move object one

cmd.transform_object("one", mm)

store its new position which PyMOL automaticaly reinterpolates

mview store, object=one

Simple rotation around y

 To generate images separated by 1 degrees around y, save this file as 360.pml. Save this file in the folder where pymol is running, then in the command line type:


This generate images (360 frames in png format) separated by 1 degrees rotation around y. Once you have the images, either usingQuickTime , Adobe Something or whatever, open them as sequence and save a gif or mov file. Alternatively, copy the following in a script file to your directory, calling it and run it
# the line above may need changing depending on your computing environment
# this line generates a counting variable i
@ i = 1002
# 100 images will be converted
while ($i < 1100)
echo $i
@ b = 3000 - $i
# convert each image from PNG to GIF (you need ~ImageMagick for this )
convert -type palette f$i.png f$i.gif
# generate the images "backwards" so we can create a continuous loop.
ln -sf f$i.gif f$b.gif
@ i++
convert -type palette f1001.png f1001.gif
convert -type palette f$i.png f$i.gif
# this is the key command - it makes a single GIF file out of all separate
# GIF files
convert -loop 0 -delay 3 -type palette f*.gif all.gif
You should now have an animated gif called all.gif in your directory.

Using util.mroll funtion

After you set the desired view, type:

mset 1 x120 

to set up 120 frames (ideal for smooth 360 rotation).

then type: 


to load the views into the 120 frames. 

Then click on play (bottom right) to view the movie.

Setup the desired view and highlight desired features, then set pymol to render frames (under the movies menu). 
At the end, select save movie from the file menu and that's it. 

It saves a .mov file (and it also gives plenty of optimization options) in your desired location. 
Alternatively, it's also possible to save .png frames that can be later assembled for example with "open sequence" in QuickTime.

Movie from script

Example of script I use to create animations/movies. In this case, the script is a text file called pymol-scene.pml that

1. creates representation,
2. uses the scenes and movie commands of pymol to
3. generate a movie that is possible to run in pymol and then
4. save the movie as sequence of images that need to be built by QuickTime or ImageReady.
It runs by simply typing @pymol-scene.pml from the pymol command line. Here is the script:

load ./model.pdb
bg_color white
hide everything
show cartoon, chain B
set sticks_radius,0.15
show sticks, chain E
set cartoon_fancy_helices,1
set cartoon_dumbbell_width,0.2
set cartoon_rect_width,0.15
set cartoon_highlight_color,99
set cartoon_transparency, 0.4
color green, resi 43-285
color marine, resi 286-515
color cyan, resi 516-541
color yellow, resi 542-768
color red, resi 769-1016
scene 001, store
orient chain E # this orient the view on the chain I want to focus on
clip near, 25.0
scene 002, store
hide cartoon
create v1, (resi 1 and name O17) # here I create dashed lines for inter-atomic distances
create v2, (resi 1 and name ZN)
create v3, (resi 1 and name O15)
create v4, (resi 108 and name ~NE2)
create v5, (resi 112 and name ~NE2)
create v6, (resi 189 and name ~OE1)
create v7, (resi 1 and name O15)
create v8, (resi 1 and name O15)
create v9, (resi 1 and name O15)
create v10, (resi 1 and name O15)
distance (v1), (v2) # and here I tell pymol to show those distances
distance (v3), (v2)
distance (v4), (v2)
distance (v5), (v2)
distance (v6), (v2)
distance (v3), (v2)
hide labels
set label_color,black
color black, dist**
set dash_gap,0.1
set sphere_scale,0.3
set stick_radius,0.15
show spheres, chain C
color magenta, chain C
set line_width,3
set valence,1
show lines, byres chain E expand 5
set label_position,[-1.5,1.1,0.5]
set label_size, 15
zoom chain E
clip near, 1.2
clip far, -5
turn x,45
turn y,45
scene 003, store
mset 1 x900
scene 001, animate=0
mview store, 1
mview store, 240
turn y,-30
mview store, 70
turn y,110
mview store, 170
scene 002, animate=0
mview store, 300
mview store, 540
turn y,-70
mview store, 370
turn y,60
mview store, 470
scene 003, animate=0
mview store, 600
mview store, 840
turn y,-60
mview store, 670
turn y,80
mview store, 770
mview interpolate
mview smooth
mview smooth
mdo 1: scene 001, view=0, quiet=1
mdo 240: scene 002, view=0, quiet=1
mdo 540: scene 003, view=0, quiet=1
mdo 840: scene 001, view=0, quiet=1