PyMOLWiki's Movie School
In a hurry? Need a movie now ?! See Movie Making for the Impatient. Otherwise, read on.
Here you will learn all the latest and greatest techniques for making PyMOL movies. These make you look like a master of PyMOL when you can show them off in a presentation or even in MPEG/AVI format.
- All scripts are commented
- All scrips can be directly copy/pasted into newer PyMOLs, which should then result is a movie being created (and possible automatically played, too).
- Please leave off-topic stuff or requests to this page's discussion page.
- As the rest of the wiki, this page is editable by all (registered) users. If you have a tip or movie you'd like to add, please feel free to do so.
While PyMOL's capability to produce static images is quite powerful, there are some stories that are better told through movies, than static images alone. This little page will provide the necessary ideas, links, code and examples for making movies in PyMOL.
Your First Movie
Movies can be very simple, for example, animating an NMR ensemble:
# Your first movie. fetch 1nmr mplay # to stop the movie when you're ready # type 'mstop'.
What PyMOL did here was to fetch the file from the PDB and load it into an object with 20 states. Somewhere between then and issuing mplay PyMOL created 20 frames for your object and assigned one state to each frame. This created the animated effect as we scroll through the frames.
Imagine a complex movie for a moment, a movie that has camera motions, objects moving independently or in concert with other objects, changing colors and representations. To handle camera motions PyMOL must know at all times where the camera is located and what it's pointed toward (as well as clipping planes). For objects to move around or be rotated without regard to the camera (the objects themselves rotate/translate, not just the camera), PyMOL has to store the coordinates and matrices for these objects, too. Changing colors and representations for each object must somehow also be stored. So, as you can see this is a multidimensional problem: at each time point in your movie, PyMOL must remember positions and representations, as well as make it easy for you to transition between them (interpolation).
Despite these complexities, PyMOL tries to enable movie making for even novice users. Let's start by defining a few PyMOL concepts—states, frames and scenes.
Basic Movie Terminology
- An object is any PyMOL-object loaded into PyMOL, like atoms, molecules, complexes, etc. When you load an PDB from disk/net it is loaded into PyMOL as an object.
- All pages regarding objects
- A selection is a specifically chosen set of atoms, molecules, complexes etc. in PyMOL. A selection is not an object, it's a subset of stuff from a (collection of) object(s). Selections can be named and when named have are distinguished from objects by having parentheses around their names. For example, foo would be an object and (foo) would be some selection. When you pick an atom (and get the default (sele) selection) or issue the ever-popular Selection command, you get a selection.
- All pages regarding selections
- A state is a particular conformation (set of coordinates) for a given object. For example an NMR ensemble could contain the same molecule, but in 20 different states. PyMOL can make movies from states. States do not store representations in PyMOL (eg. cartoons vs. sticks).
- See also All pages regarding states
- A scene as I understand stores the orientation/position of the camera, all object activity information, all atom-wise visibility, color, representations, and the global frame index.
- See Category:Scenes and Scene for more information. The Scene page has information on how to quickly add/remove and change scenes--suggested reading!
- A scene is the staged representations of objects and the orientation of the camera.
- See also All pages regarding scenes
- A frame can be thought of as a single frame in a movie reel. A frame stores state information and scene information.
- See also All pages regarding frames
- The movie panel is a frame indicator strip at the bottom of the screen. It shows a little icon for which frame you're currently on, and whether or not the camera has been set for that frame.
- See movie_panel for more information.
What is a Movie?
Now the we have the appropriate terminology to talk about movies in PyMOL, we can discuss what a movie really is. A movie in PyMOL is a series of frames stitched together in some way so as to create the desired animation. Once a movie is made in PyMOL, we have a few options for exporting it to other formats like png arrays or MPEG moves.
Movie Making for the Impatient
If you don't have time to or care to make more complex movies and want a movie now then read this section. It mostly involves the GUI for making movies, so get your mouse ready.
Simple Camera Motions
Simple 360 Scene Rotation
To make a movie that simply rotates around your scene 360 degrees, in the menu click on:
- Movie->Program->Camera->X-Roll->N Seconds
for an N-second movie rolling over the X-axis. Chose
- Movie->Program->Camera->Y-Roll->N Seconds
for the Y-axis roll.
Done! Press play.
Simple 30, 60, 90, 120, 180, Scene Rocking
This will show up to a 30, 60, 90, 120 or 180 rocking 'wedge' of the scene. If you don't want to rotate all the way around, use this.
- Movie->Program->Camera->X-Rock->X-Degrees over N-Seconds
Done! Press play.
Nutating is like a wiggle-rock; try it and see.
- Movie->Program->Camera->X-Rock->X-Degrees over N-Seconds
Done! Press play.
Zooming Around an Object
This is also known as camera movement. Let's make a simple program that just zooms in and out on a some atom.
- Click any atom and zoom on it
- Movie->Program->Scene Loop-> and if you want to nutate while at the scene choose Nutate otherwise choose Y-Rock.
Done! Press play.
- Hint: Make multiple scenes, making sure to store each one. Then use the Scene Loop to automatically program a movie for you!
First load the tutorial PDB:
- Type zoom i. 200 to zoom on the ligand
- Movie->Program->Scene Loop->Y-Rock->4 Seconds Each
Done! Press play.
Movie Making Commands
This tutorial assumes you have some basic knowledge about how to use PyMOL (eg. mousing, choosing and setting your representations, etc). If you're not yet at this level, please check out the Tutorial Category of pages (most notably the beginner tutorials).
I think it's help to think of the movie as a set of frames, like in a movie reel, so let's start there. (Each command below links to the command's PyMOL wiki page, so feel free to click through for more info.)
This command tells PyMOL to set the current frame to whichever you desire. To use it, just issue the command,
where X is some integer number indicating the frame you want to go to. If you issue a frame number greater than the number of frames, PyMOL sets the frame to the highest-numbered frame you have (similarly for negative numbers or numbers smaller than the minimum numbered frame).
Let's try a quick example with frame,
# create an empty 90 frame movie mset 1 x90 # turn on the movie panel (bottom of screen) set movie_panel, on # goto frame one frame 1 # try some intermediate frames; notice the blue indicator in the movie panel frame 10 frame 50 frame 90 # try going beyond the end and see what PyMOL does frame -1 frame 100 # play through the empty movie mplay # stop the movie mstop
Again, states are particular stored conformations of objects. Here we use PyMOL to set and get the states, and see how PyMOL mapped them to our earlier movie example.
This command has a similar idea of frame, but works a little differently. Instead of typing,
# invalid command state 40
# how to set a state in PyMOL set state, stateNo, objectName # for example # set state to 40 set state, 40 # also, get state get state
States & Frames (optional reading)
As an example, look at the code from the "first movie":
fetch 1nmr mplay # issue mstop, to stop the movie
We can do a couple things now, let's try counting the number of states and frames PyMOL now knows about:
# how many frames does PyMOL know about? count_frames # what about states? count_states
and now let's see how PyMOL mapped frames to states. Using the above commands and a little Python, let's see how PyMOL mapped the frames to states:
python for x in range(1,cmd.count_frames()+1): cmd.frame(x) print "Frame => %s; and State => %s" % ( str(x), str(cmd.get('state'))) python end
which should show a 1-1 mapping of states to frames.
mset is a very powerful command. This command tells PyMOL how to assign states to frames. So, now you see why it's necessary to clearly distinguish between and use the two. Let's learn how to use mset.
The syntax for mset can be a little tricky at first. I would write the syntax as:
mset stateSpec, frameSpec
which assigns the states in stateSpec to the frames in frameSpec., where stateSpec is any mset-valid state specification. PyMOl supports to patterns for stateSpec. You can do simply supply a number eg
or you can specify a range of states—like 1 through 55 as
# setting states 1 through 55 # caution: notice the space: 1 -55, not 1-55 (this is a PyMOL parser caveat) mset 1 -55
Simple enough. Now for frameSpec you can specify a single frame number like so or you can specify how many frames PyMOL should use to map to your specified states with the xNumber command. This will make sense with an example
# Recall: mset stateSpec frameSpec # so we are setting STATE 1 across a span of 90 frames mset 1 x90 # Recall: mset stateSpec frameSpec # so we are setting states 1..120 to the next 120 frames mset 1 -120 x120
NB: Actually the syntax is a little more complicated than this as PyMOL's mset command has the ability to remember in which frame the prior specification left the movie. So, you can sort of chain the specifications. Type help mset in PyMOL for more info or see mset.
The mview command can be intimidating, but all we need to know about it at present is that it can store the (1) camera position or (2) a given object position. The idea is to essentially make 'way points' in your movie and have PyMOL interpolate the in-between positions/coordinates, etc. For example, if I wanted to make a 100-frame movie of a zoom into an object, I could store and manually set 100 camera positions, or I could do the starting position and the final position and ask PyMOL to just interpolate that over 100 frames. The latter idea is obviously much simpler. So simple in fact, let's make a super-quick movie that does exactly what I just mentioned—100 frames of a slow zoom into some object. Start with a fresh PyMOL session (reinitialize) and then copy/paste the following:
1# let's initialize the movie to 100 frames, all of state 1 2# it's ONLY state 1, because we're only moving the camera around, not 3# changing structure coordinates of the leucine: 4mset 1 x100 5 6# show a leucine 7frag leu 8 9# position the residue 10orient 11 12# let's store the current camera position 13mview store 14 15# now set our way point to be frame 100 16frame 100 17 18# now let's zoom into some atom on the fragment 19zoom ID 10 20 21# now save this view at frame 100 22mview store 23 24# last thing is to tell PyMOL to interpolate the 100 frame zoom 25# so we don't have to do those 100 snapshots: 26mview reinterpolate 27 28# voila, you have a movie. To watch it go back to frame 1 and play it 29frame 1 30mplay 31 32# mstop when you're ready
'But, hold on!' you might say. Why is it so herky-jerky? We have smooth zooming but then a snap and back to frame one! Well, we never gave PyMOL any number of frames to interpolate the change from frame 100 back to frame 1 (since it wraps). If we wanted an a zoom in that was equally as fast as the zoom out we would simply replace line #16 with
# now set our way point to be frame 100 frame 100
but, if we wanted a slow, zoom in and a fast zoom out we could do
# now set our way point to be frame 100 frame 80
instead which would only give PyMOL 20 frames with which to zoom us out. Try it!
Very Basic Mview Syntax
This is a simple overview, see mview for complete details.
Using mview as you can see from above is pretty simple. The very basic syntax is:
# store the camera OR some object given by objName (if it's supplied) mview store[, object=objName] # reinterpolate (link together the positions) for the saved camera or object mview reinterpolate[, object=objName]
If you leave off the object=objName then you're storing the camera information only—and so none of your objects will be moving anywhere—just the camera. If you include an object name, then it stores that object's position information in the current frame. The mview store tells PyMOL to store the camera or objects coordinates, while the mview reinterpolate command tells PyMOL to link together the saved positions for the camera or the selected object in a smooth, cool way.
Movie Making & the PyMOL GUI
These screenshots are all current as of PyMOL 1.2b8.
Basic TK GUI
This image shows the movie menu in PyMOL.
- Append just adds X seconds to the end of your movie. This is the equivalent of madd 1 x(FPS*time). So, you can very easily add anywhere from 1/4s to 60 seconds to your video. You can use this multiple times.
- Frame Rate submenu that controls the frame rate of your movie in frames per second. It also controls whether or not the frame openGL screen frame rate is shown.
This menu shows the first 12 scenes stored by F-key that you can recall (if they were stored). Please take note of the Buttons menu. This make a small menu of scenes in the lower left hand corner of your openGL screen. Very handy for roving through, moving around and switching to scenes.
If you've chosen Mouse->3 Button All Modes from the Tk GUI you can now access the new mouse modes by clicking on the mouse info panel in the lower righ of the openGL window. Click until the modes cycle through Edit->View->Motions->Edit->...
In motions mode, if you click on all->M you get options for storing, clearing, smoothing, interpolating, etc the camera motions and positions.
Simple Movie Examples
We now the ability to make some pretty simple, but cool movies. So, let's try a few.
Let's try making a movie where we zoom into each ligand that's not water. In order to make this movie, I had to find a protein with suitable ligands, so you can do the same for your own protein. Just replace the hard-coded residue numbers.
Goal: Make a movie that zoom into the three ligands, stays on that ligand for 2 seconds, then moves to the next. I also want smooth zoom out at the end. Don't let the length of this movie script throw you off, you've seen all of the movie commands and the initial commands are just loading the and making it look good.
# setup PyMOL for the movie reinitialize set matrix_mode, 1 set movie_panel, 1 # load the PDB, make selections for the ligands and # make the protein look snazzy. #load /spc/pdb/2jep.pdb fetch 2jep, async=0 remove resn HOH orient select l1, c. A and i. 1397 select l2, c. A and i. 1396 select l3, c. B and i. 1396 as cartoon color grey show sticks, het color magnesium, het # At 30 FPS this is then a 16 second movie. # We look at the structure for 2 seconds, zoom in to each ligand # and look at it for another 2 seconds, then, zoom out and look again # at everything for another 2 seconds. # initialize the 480 frame movie mset 1 x480 # zoom all ('scene #1') frame 1 mview store # stay here for 2 seconds frame 60 mview store # zoom on ligand 1 ('scene #2') frame 120 zoom l1 mview store # stay here for 2 seconds frame 180 mview store # zoom on ligand 2 ('scene #3') frame 240 zoom l2 mview store # stay for 2 seconds frame 300 mview store # zoom to ligand 3 ('scene #4') frame 360 zoom l3 mview store # stay for 2 seconds frame 420 mview store # zoom out ('back to scene #1') frame 480 zoom mview store # interpolate the frames mview reinterpolate # play the awesome movie! mplay # stop when you want # mstop
Animating an Alignment
# setup PyMOL for the movie reinitialize set matrix_mode, 1 set movie_panel, 1 # load the PDBs fetch 1cll 1ggz, async=0 # orient the scene as cartoon orient # make 100-frame movie mset 1 x100 # goto frame 1 frame 1 # store the camera position and object # positions in frame 1 mview store mview store, object=1cll mview store, object=1ggz # goto frame 90 frame 90 # align the two proteins super 1cll, 1ggz # we rezoom to center the camera on the # two aligned proteins zoom # store the camera positions mview store # store the new object position(s) mview store, object=1cll mview store, object=1ggz # have PyMOL stitch together the scenes. mview reinterpolate mview reinterpolate, object=1cll mview reinterpolate, object=1ggz # rewind frame 1 # get some popcorn! :-) mplay
This movie will walk down the alpha carbons inspecting each one for 1/3 of a second. :-) What would be cool would be to calculate the difference vector from i. n+1 to i. n and then walk that path. Anyhow, here you go:
# usual setup reinitialize set matrix_mode, 1 set movie_panel, 1 # fetch 1CLL to work on; this will only work on 1cll # or any other protein with 144 AAs starting at resi 4. fetch 1cll, async=0 as lines, n. C+O+N+CA color marine zoom i. 4+5 # 10 frames per AA mset 1 x1440 mview store # this code maps the zooming of # one AA and it's neighbor to 10 frames python for x in range(0,144): cmd.zoom( "n. CA and i. " + str(x) + "+" + str(x+1)) cmd.frame((10*x)+1) cmd.mview("store") python end # goto the end and interpolate all the frames frame 288 mview store mview reinterpolate # I know, it's not smooth & cool like the other ones mplay
Putting It All Together
Now that we understand the basic PyMOL commands for movie making, we build a few ideas--which have already been hinted at--that lead to the final goal: allowing you to generate PyMOL movies to tell the stories you want to tell. We start simple and build up the complexity. Here's an outline of the ideas:
- camera motions—just moving the camera around your scene
- object motions—keeping the camera still, but moving the objects around the scene
- camera & object motions —moving both the camera and objects around
- representations—changing representations in a movie (eg. sticks to cartoons to surface; hiding/showing, etc.)
- motions & representations —adding all the motions and representations together
- extras—pseudoatom labels; scene messages, etc.
- final example movies—some examples combining the above knowledge
If you've read through most the above article on movie making, then these sections should be more of a review. There are some tricks in here that might be worth reading, however.
Many of the movie scripts below assume that you have readied PyMOL for movie generation. To do that use the following code:
reinitialize set matrix_mode, 1 set movie_panel, 1 set scene_buttons, 1 set cache_frames, 1 config_mouse three_button_motions, 1 # initialize a 100 frame movie mset 1 x100
One of our first movies above was a very simple zoom on an atom in an amino acid. The first 'scene' was the entire amino acid and the 2nd 'scene' was the zoomed in atom. We just connected the two scenes and asked PyMOL to make the transition between the two smooth. This is the idea of camera motions in PyMOL. (You may not know that when you click on a protein and rotate it or drag it in PyMOL you're actually moving the camera, not the protein.)
Assuming you had readied PyMOL to make your movie to get a camera motion you do the following:
- save the camera's first position information: Once you have the protein/object aligned and shown in the representation of your choice, set the camera position information
# goto the first frame frame 1 # store the CAMERA positions ONLY mview store
- save the cameras second position information: Now using the mouse (or scripted commands) move the camera to its new position--say zooming in on an important ligand or catalytic residue. Once that's done, tell PyMOL to store the new camera position in this frame:
# goto the first frame frame 88 # store the CAMERA positions ONLY mview store # now link the two stored camera positions together: mview reinterpolate # play your movie mplay
- mview reinterpolate, power=1" will turn off the smoothed starting and stopping of camera motions between the scenes. The smoothing gives a nicer feel to transitions. Try both, see which you prefer.
- check out mview's other options--like 'wrap'
- using the three_button_motions option, you can pretty much make the entire movie w/your mouse: All->M->Store is the same as, mview store, and All->M->Reinterpolate is the same as mview reinterpolate.
- mview reset unstores the camera position information for this frame.
Camera Motions Movie Example
This idea should be pretty sound at this point, but examples rock, so here's another. The pattern is:
- frame XYZ
- script the view
- mview store
# setup PyMOL for movies reinitialize set matrix_mode, 1 set movie_panel, 1 set scene_buttons, 1 set cache_frames, 1 config_mouse three_button_motions, 1 fetch 1te1, async=0 extract AA, c. A extract BB, c. B color marine, AA color grey, BB as surface, BB as cartoon, AA mset 1 x620 orient wizard message, "Can you see the blue protein inhibiting the gray protein?" frame 1 mview store frame 30 mview store ### cut below here and paste into script ### set_view (\ 0.307660401, 0.011366921, 0.951428533,\ 0.930296898, -0.213488042, -0.298277378,\ 0.199727684, 0.976880252, -0.076255992,\ 0.000000000, 0.000000000, -196.781448364,\ 27.129878998, 68.309677124, 51.827075958,\ 155.143981934, 238.418914795, -20.000000000 ) ### cut above here and paste into script ### # slowly show the inhibition frame 120 mview store # wait 3 seconds frame 180 mview store # define the inhib as the binding loop select inhib, AA and i. 148-155 select (none) # slowly zoom in frame 300 zoom inhib mview store # stop a second frame 330 mview store # look around the binding pocket frame 390 turn y, 150 mview store # wrap back more quickly... frame 420 turn y, -150 mview store # one more gratuitous view frame 500 ### cut below here and paste into script ### set_view (\ 0.943371952, 0.309539229, -0.119302809,\ -0.044248745, -0.239008784, -0.970008850,\ -0.328769624, 0.920357347, -0.211777285,\ 0.000000000, 0.000000000, -30.773454666,\ 35.418403625, 72.805625916, 52.437019348,\ 20.233829498, 41.313076019, -20.000000000 ) ### cut above here and paste into script ### mview store frame 560 mview store mview reinterpolate mplay
Now that we're experts at moving the PyMOL camera around, let's start moving objects around while keeping the camera steady. To do this you must have matrix_mode set to 1, otherwise PyMOL won't save your object's repositioning.
Let's use the same proteins as from the above inhibitor example. This time, let's try to get a simple movie that shows one of the proteins and then have the other one fly in to do the inhibiting.
# setup PyMOL for movies reinitialize set matrix_mode, 1 set movie_panel, 1 set scene_buttons, 1 set cache_frames, 1 config_mouse three_button_motions, 1 # download the complex and setup it up fetch 1te1, async=0 extract AA, c. A extract BB, c. B color marine, AA color grey, BB as surface, BB as cartoon, AA # intialize the movie mset 1 x410 # orient the scene set_view (\ 0.423117876, 0.061672822, 0.903973043,\ 0.789699256, -0.514252067, -0.334546506,\ 0.444237947, 0.855418444, -0.266292989,\ 0.000107866, -0.000027858, -196.784057617,\ 28.171787262, 70.919288635, 52.095287323,\ 155.143981934, 238.418914795, -20.000000000 ) # move the inhibitor off the screeen translate [0,0,100], object=AA # first movie scene frame 1 wizard message, "Let's watch the binder float it, while the camera doesn't move." mview store, object=AA mview store, object=BB # 2 second pause for the user to catch up frame 60 mview store, object=AA mview store, object=BB frame 300 # slide the inhibitor in from over the camera. :-) translate [0,0,-100], object=AA mview store, object=AA mview interpolate, object=AA # store & wait 2 seconds... frame 360 mview store, object=AA mview store, object=BB mview reinterpolate, object=AA mview reinterpolate, object=BB # 'explode' apart frame 380 translate [-70, 70, 70], object=AA translate [70, -70, -70], object=BB mview store, object=AA mview store, object=BB mview reinterpolate, object=AA mview reinterpolate, object=BB mplay
- Use the mouse to get the 'right orientation & zoom'. Then use get_view to get the view matrix. Finally, store that camera-position view matrix in your script. Works every time.
- For object motions, the command translate [-70,70,70], object=AA would be the same as using the mouse and moving the object AA -70 units on the X-axis, +70 units on the Y and 70 on the Z. If you don't use the object= you will not get the desired effect.
- For the above 'explosion' you can get quick motions by interpolating a large change over just a few frames.
Camera & Object Motions
Now let's combine the above two sections into one movie that has both object and camera motions. This should be cool...
# setup PyMOL for movies reinitialize set matrix_mode, 1 set movie_panel, 1 set scene_buttons, 1 set cache_frames, 1 config_mouse three_button_motions, 1 # download the complex and set it up fetch 1te1, async=0 extract AA, c. A extract BB, c. B color marine, AA color grey, BB as surface, BB as cartoon, AA mset 1 x120 # overview of the scene frame 1 mview store mview store, object=AA mview store, object=BB # zoom into the binding pocket- setting the view means # that this will be a camera motion from frames 1 to 120. frame 120 set_view (\ 0.993863702, 0.110482253, -0.005255031,\ 0.054543663, -0.530888498, -0.845684826,\ -0.096224494, 0.840209842, -0.533656776,\ 0.000000000, 0.000000000, -50.366786957,\ 34.781314850, 71.208221436, 52.535022736,\ 39.709556580, 61.024017334, -20.000000000 ) mview store mview store, object=AA mview store, object=BB # wiggle the inhibitor, like it's trying to escape python for x in range(20): cmd.madd("1 x3"); cmd.frame(1000); cmd.rotate("x", 2.0, object="AA") cmd.mview("store", object="AA") cmd.interpolate(object="AA",power=1) cmd.madd("1 x3"); cmd.frame(1000); cmd.rotate("x", -2.0, object="AA") cmd.mview("store", object="AA") cmd.interpolate(object="AA",power=1) python end mview store madd 1 x40 frame 470 mview store mview store, object=AA mview store, object=BB mview interpolate, object=AA mview interpolate, object=BB mview reinterpolate mplay
Scenes are the only way to change representations (eg sticks to cartoon). In PyMOL to show representation changes we need to have a list of scenes, that we then assign to a given frame. Once this is done we can reinterpolate through scenes to have beautifully smooth transitions.
PyMOL makes it very easy to setup your scenes--for that look--and save them in a stack (and, now, even move them around). We covered scenes already in the tutorial, so please check that if you need more help on scenes, or see Category:Scenes for more commands and hints.
In PyMOL, to attach a scene to a frame (or, technically a frame to a scene) we simply do the following:
mview store, scene=sceneName
Let's take a look at a simple movie that changes the representation of some object. This will show a tryptophan going from lines to sticks and back.
1set scene_buttons, 1 2set movie_panel, 1 3 4# make a 90 frame movie, all STATE 1. 5mset 1 x90 6 7# load a trypotphan fragment 8frag trp 9 10# Tell PyMOL to call this current view '001'. 11scene 001, store 12# goto frame 1 and store this scene & camera 13frame 1 14mview store, scene=001 15 16# setup the next 'view' 17as sticks 18scene 002, store 19 20# goto frame 60 and show sticks 21frame 45 22mview store, scene=002 23 24mview reinterpolate 25mplay
To show you how easy adding camera motions + representations is, simply insert after line 17 (as sticks) a new line 18 that only has
Here's what's happening in the movie, above. Lines 1—2 set PyMOL up to show you scene buttons and the movie panel. Line 5 makes a 90 frame movie that only spans the first state. Line 8 makes the TRP fragment from PyMOL's stored knowledge of residues. Line 11 asks PyMOL to store this current 'view' as a scene and call that scene 001. Now that a scene is made, we need to associate with a frame. So, we goto frame 1 in line 13. In line 14 we actually make the scene-to-frame assignment with the mview store command, specifying the mapping between scene 001 and frame 1. Lines 17 and 18 change the representation from lines to sticks and then orients the TRP residue (which causes the camera to move). In line 19, we save this new camera position and the sticks representation of TRP in the scene called 002. Next, in line 22, we go somewhere ahead in the movie, here 1/2 way to the end. Line 23 assigns scene 002 to frame 45. Lastly, because we changed the camera position, we need to reniterpolate it's movement, and that's done in line 25. As you know mplay just plays the movie.
- Hint: Clear frames with mview clear
- Hint: Clear scenes with scene sceneName, delete; you can delete all scenes with scene *, delete.
Now that we have that, let's learn more complex tricks with motion and representations!
Motions & Representations
Let's look at the inhibitor complex again, (pdb 1TE1). This time, we would like to make a more compex movie that shows moving objects (not the camera) and changing representations. I do not want wrapping b/c I slide the molecule off the sceen. To ensure that, I allow 0 transition frames, by setting the last frame in the movie by mview store.
# b/c there will be motions, we need matrix_mode reinitialize set matrix_mode, 1 set scene_buttons, 1 set movie_panel, 1 # setup the movie for 410 frames mset 1 x240 # load the complex & set it up fetch 1te1, async=0 as cartoon remove resn HOH extract AA, c. A extract BB, c. B # zoom in on the binding pocket ### cut below here and paste into script ### set_view (\ 0.478582859, -0.269358903, 0.835705996,\ 0.805654645, -0.243718535, -0.539927721,\ 0.349110991, 0.931690335, 0.100370787,\ 0.000000000, 0.000000000, -49.810981750,\ 35.418403625, 72.805625916, 52.437019348,\ 39.271358490, 60.350605011, -20.000000000 ) ### cut above here and paste into script ### # store object AA's position frame 1 scene 001, store, message="This doesn't quite give us a good feel for what's going on." mview store, object=AA mview store, scene=001 # change up the scene a bit frame 60 color grey, AA color marine, BB scene 002, store, message="Recoloring helps a little." mview store, scene=002 # show chain B as surface frame 120 as surface, BB mview store, object=AA scene 003, store, message="Surface helps alot." mview store, 120, scene=003 # show more frame 180 select inhib, AA and i. 148-155; show sticks, inhib color magenta, inhib select nn, BB within 7 of inhib; deselect; set transparency, 0.65, nn show sticks, nn set_bond stick_color, chartreuse, nn scene 004, store, message="Coloring, transparency, and other objects help more..." mview store, object=AA mview store, 180 # move AA away frame 240 translate [20, 10, 80], object=AA mview store, object=AA mview reinterpolate, object=AA mview store, 240 mview reinterpolate
- Hint: Use mview store, frameNo, scene=sceneName to save complex scenes. If you do:
frame X scene Y mview store X, scene=Y
then the PyMOL GUI may not have caught up to the correct place before saving the scene information.
- Hint: Things can get confusing with frames, states and whatnot. A good idea is to ALWAYS set your frame when setting a new scene. If you don't mview store might save a different frame number than you think you're on. Or, you can save the frame number too with, mview store, frameNo, scene=XXX, object=YYY.
- Hint: Use deselect in a script to hide the dots from making a new selection.
- Hint: Use set_bond to set bond properties, like colors, on sticks representations.
Exporting your Movie
Once you've setup your movie as in any of the previous examples, you have a couple options for making a movie.
Export from PyMOL: Newer PyMOLs support
- File->Save Movie As->MPEG
- File->Save Movie As->PNG Images
from the menu.
mpng: You can still use the good old mpng option to save all your frames to disk. You can then compile them into a MPEG (see below).
Old Style: One of the older scripting styles was to make minor changes and dump PNGs. This is essentially obviated with PyMOL's new movie-making functionality. The old style was to simply call cmd.png every time you made a scene change.
- Movie not ray traced? Make sure you set ray_trace_frames to 1.
See Software_Codecs for information on how to stitch together movies from PNGs and optimize them for great crisp-looking movies.