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 movie_auto_interpolate, off 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.mview("store") cmd.mview("interpolate", object="AA") cmd.mview("reinterpolate") cmd.madd("1 x3"); cmd.frame(1000); cmd.rotate("x", -2.0, object="AA") cmd.mview("store", object="AA") cmd.mview("store") cmd.mview("interpolate", object="AA") cmd.mview("reinterpolate") python end mview store madd 1 x60 frame 240 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.
1 set scene_buttons, 1 2 set movie_panel, 1 3 4 # make a 90 frame movie, all STATE 1. 5 mset 1 x90 6 7 # load a trypotphan fragment 8 frag trp 9 10 # Tell PyMOL to call this current view '001'. 11 scene 001, store 12 # goto frame 1 and store this scene & camera 13 frame 1 14 mview store, scene=001 15 16 # setup the next 'view' 17 as sticks 18 scene 002, store 19 20 # goto frame 60 and show sticks 21 frame 45 22 mview store, scene=002 23 24 mview reinterpolate 25 mplay
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.