User:Inchoate: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
 
(23 intermediate revisions by 2 users not shown)
Line 1: Line 1:
My name is Jason Vertrees and I'm a postdoc in computational biology.  Currently, I study proteins through mathematical models & machine learning.  My previous work was in theoretical biophysics.
My name is Jason Vertrees and I'm an independent consultant working with DeLano Scientific to promote PyMOL.  My previous work was in theoretical biophysics and machine learning to predict properties of proteins.


Also, I am the owner and of the PyMOLWiki website.
Also, I am the owner of the PyMOLWiki website.  I started it to help the PyMOL community store and organize information regarding PyMOL.


If you are interested in Biophysical, Structural or Compuational Biology, check out [http://www.bscb.utmb.edu/ BSCB@UTMB] -- my old school.
If you are interested in Biophysical, Structural or Compuational Biology, check out [http://www.bscb.utmb.edu/ BSCB@UTMB] -- my old school.


 
-- '''Jason Vertrees, PhD <br/>
'''Jason Vertrees, PhD
''Jason dot Vertrees (_at-) gmail dot com''
 
''jv(_at-)cs_dot_dartmouth(dot2)edu''
 
[http://www.cs.dartmouth.edu/~jv/ My Page]


= My ~/.pymolrc =
= My ~/.pymolrc =
Line 35: Line 31:
set ray_opaque_background,0
set ray_opaque_background,0
set defer_builds_mode, 3
set defer_builds_mode, 3
set async_builds, 1
</source>
</source>


== To Do ==
== To Do ==
* texture_fonts, 1 -- for speed
* pseudo-atoms; you can label them.  RightClick->New->PAtom->and then label it; move the atom (and the label goes w/it).  You can also move the label by itself
* movie_panel
* mset - clears the movie
* Movie->UpdateMovie
* Movie->UpdateMovie
* Scene->Buttons (shows buttons for each scene)
* Scene->Optmize (before saving scenes; use before optimizing)
* Scene->Optmize (before saving scenes; use before optimizing)
* Scene->Cache (cache's surface data)
* Scene->Cache (cache's surface data)
* A good way to make movies seems to be:
** madd
** prepare a scene; turn on scene buttons
** Fn+CTRL+down-arrow # adds the scene;
** madd 1 x90
** mview store, -1
* repeat
* when done do mview reinterpolate
* play the movie
* matrix_mode
* dot_solvent
* dot_solvent


Line 110: Line 92:




= Movie Making =
New motions
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.
* Enter alone will store+reinterpolate
 
* Shift-Enter will just store & clears the reinterpolation
== Your First Movie ==
* CTRL-Enter will store but not reinterpolate
Movies can be very simple, for example, animating an NMR ensemble:
<source lang="python">
# Your first movie.
fetch 1nmr
mplay
 
# to stop the movie when you're ready
# type 'mstop'.
</source>
 
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.
 
 
== Terminology ==
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&mdash;states, frames and scenes.
 
=== Basic Movie Terminology ===
'''object'''
::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.
:: [[:Category:Objects|All pages regarding objects]]
 
'''selection'''
:: 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 [[Select]]ion command, you get a selection.
:: [[:Category:Selections|All pages regarding selections]]
 
'''states'''
:: 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 [[:Category:States|All pages regarding states]]
 
'''scenes'''
'''interpolation'''
:: A scene is the staged representations of objects and the orientation of the camera.
:: See also [[:Category:Scenes|All pages regarding scenes]]
 
'''frames'''
:: A frame can be thought of as a single frame in a movie reel.  A frame stores state information and scene information.
:: See also [[:Category:Frames|All pages regarding frames]]


'''Movie Panel'''
New Scenes
:: 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.
* setups the scenes first
:: See [[movie_panel]] for more information.
* then just goto the frame you want and hit enter and the current will be stored with it
* or you can right-click on the movie_panel and store with scene


== What is a Movie? ==
* purge kills the matrix info for the object
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 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 [[:Category:Tutorials|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.)
New movie stuff
* CTRL-LEFTCLK + DRAG RIGHT = add frame/states
* CTRL-LEFTCLK + DRAG LEFT = erase frame/states
* Rt clk on object
** Shift+Middle = drag
** shift+Left = rotate


=== [[frame]]===
= Cool Movies =
This command tells PyMOL to set the current frame to whichever you desire. To use it, just issue the command, <source lang="python">frame X</source> 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).
* [[File:Traj_movie.mpg]] &mdash; MD Trajectory made awesome with PyMOL; 5 MB mpg file.
* [[File:Long_movie_ray.mpg]] &mdash; long movie, shows dimerization, roams around the active site, 6 MB.
* [[File:Motions_movie.mpg]] &mdash; a simple movie with motions.


Let's try a quick example with [[frame]],
= tRNA hairball =
<source lang="python">
<source lang="python">
# create an empty 90 frame movie
reinit
mset 1 x90
unset movie_auto_interpolate
# turn on the movie panel (bottom of screen)
# position molecule & view
set movie_panel, on
fetch 1yfg, trna, async=0
# goto frame one
orient
frame 1       
rotate z, 60, trna
# 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
</source>


python
for x in range(6):
  n = "trna_%s" % x
  cmd.create( n, "trna", 1, 1)


=== [[States|set state]] ===
cmd.disable("trna")
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.
cmd.translate( [0, -60, 0], "trna" )
 
cmd.origin("trna")
This command has a similar idea of [[frame]], but works a little differently.  Instead of typing,
<source lang="python">
# invalid command
state 40
</source>
in PyMOL we [[set]] the [[States|state]]:
<source lang="python">
# 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
</source>


==== States &amp; Frames (optional reading) ====
for x in range(6):
As an example, look at the code from the "first movie":
  n = "trna_%s" % x
<source lang="python">
  cmd.rotate( "z", 60. * x, n)
fetch 1nmr
  cmd.show_as("cartoon", n)
mplay
   cmd.origin("trna")
# issue mstop, to stop the movie
   cmd.zoom()
</source>
 
We can do a couple things now, let's try counting the number of states and frames PyMOL now knows about:
<source lang="python">
# how many frames does PyMOL know about?
count_frames
 
# what about states?
count_states
</source>
 
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:
<source lang="python">
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
python end
</source>
which should show a 1-1 mapping of states to frames.
=== [[mset]] ===
[[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:
<source lang="python">
mset stateSpec frameSpec
</source>
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
<source lang="python">
mset 1
</source>
or you can specify a range of states&mdash;like 1 through 55 as
<source lang="python">
# setting states 1 through 55
# caution: notice the space: 1 -55, not 1-55 (this is a PyMOL parser caveat)
mset 1 -55
</source>
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
<source lang="python">
# 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
</source>
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]].
=== [[mview]] ===
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&mdash;100 frames of a slow zoom into some object.  Start with a fresh PyMOL session ([[reinitialize]]) and then copy/paste the following:
<source lang="python" line=1>
# let's initialize the movie to 100 frames, all of state 1
# it's ONLY state 1, because we're only moving the camera around, not
# changing structure coordinates of the leucine:
mset 1 x100
# show a leucine
frag leu
# position the residue
orient
# let's store the current camera position
mview store
# now set our way point to be frame 100
frame 100
# now let's zoom into some atom on the fragment
zoom ID 10
# now save this view at frame 100
mview store
# last thing is to tell PyMOL to interpolate the 100 frame zoom
# so we don't have to do those 100 snapshots:
mview reinterpolate
# voila, you have a movie.  To watch it go back to frame 1 and play it
frame 1
mplay
# mstop when you're ready
</source>
'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
<source lang="python">
# now set our way point to be frame 100
frame 100
</source>
but, if we wanted a slow, zoom in and a ''fast'' zoom out we could do
<source lang="python">
# now set our way point to be frame 100
frame 80
</source>
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:
<source lang="python">
# 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]
</source>
If you leave off the '''object=objName''' then you're storing the '''camera information only'''&mdash;and so none of your objects will be moving anywhere&mdash;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.
== Simple Movie Examples ==
We now the ability to make some pretty simple, but cool movies.  So, let's try a few.
=== Multiple Zooming ===
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.
<source lang="python">
# 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, asyn=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 1x360
mset 1 x480


# zoom all ('scene #1')
frame 1
frame 1
mview store
orient vis
# 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
mview store


# zoom on ligand 2  ('scene #3')
rots = [ [0., 1., 0.], [-1.4, 1., 0], [-1.4, -1., 0.], [0., 1., 0.], [-1.4, 1., 0.], [1.4, 1., 0.] ]
frame 240
ang = [120,240,360]
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
</source>
=== Animating an Alignment ===
<source lang="python">
# 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
</source>
=== BB Inspector ===
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:
<source lang="python">
# 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
python
for x in range(0,144):
#for f in [120,240,360]:
  cmd.zoom( "n. CA and i. " + str(x) + "+" + str(x+1))
for f in range(len(ang)):
   cmd.frame((10*x)+1)
   cmd.frame(ang[f])
  cmd.mview("store")
  for t in range(6):
    cmd.rotate(rots[t], 120, object="trna_%s" % t)
python end
python end
mview interpolate, object=trna_*, power=1


# 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
</source>
== 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'''&mdash;just moving the camera around your scene
* '''object motions'''&mdash;keeping the camera still, but moving the objects around the scene
* '''camera &amp; object motions '''&mdash;moving both the camera and objects around
* '''representations'''&mdash;changing representations in a movie (eg. sticks to cartoons to surface; hiding/showing, etc.)
* '''motions &amp; representations '''&mdash;adding all the motions and representations together
* '''extras'''&mdash;pseudoatom labels; scene messages, etc.
* '''final example movies'''&mdash;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:
<source lang="python">
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
</source>
===Camera Motions===
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
<source lang="python">
# goto the first frame
frame 1
# store the CAMERA positions ONLY
mview store
</source>
* '''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:
<source lang="python">
# 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
</source>
Hints:
* '''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
<source lang="python">
# 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
</source>
===Object Motions===
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.
<source lang="python">
# 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
</source>
Hints:
* Use the mouse to get the 'right orientation &amp; 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 &amp; Object Motions===
Now let's combine the above two sections into one movie that has both object and camera motions.  This should be cool...
''' FIXME '''
<source lang="python">
# 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
python
for x in range(20):
#for f in [120,240,360]:
  cmd.madd("1 x3"); cmd.frame(1000);
for f in range(len(ang)):
  cmd.rotate("x", 2.0, object="AA")
   cmd.frame(ang[f])
   cmd.mview("store", object="AA")
   cmd.turn('y', 120)
  cmd.interpolate(object="AA",power=1)
   cmd.mview(action="store")
 
  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
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, power=1
mview interpolate, object=BB
mview reinterpolate


frame 1
mplay
mplay
</source>
</source>
===Representations===
===Motions &amp; Representations ===
=== Extras ===
== Exporting your Movie ==
This wiki already has lots of information on how to convert your PyMOL movie to another format.  Check out [[Making_Movies|those]] [[Software_Codecs|pages]].
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.
Hints:
* Movie not ray traced?  Make sure you set ray_trace_frames to 1.
=== Codecs ===
See [[Software_Codecs]] for information on how to stitch together movies from PNGs and optimize them for great crisp-looking movies.


= See Also =
= See Also =

Latest revision as of 00:14, 25 February 2010

My name is Jason Vertrees and I'm an independent consultant working with DeLano Scientific to promote PyMOL. My previous work was in theoretical biophysics and machine learning to predict properties of proteins.

Also, I am the owner of the PyMOLWiki website. I started it to help the PyMOL community store and organize information regarding PyMOL.

If you are interested in Biophysical, Structural or Compuational Biology, check out BSCB@UTMB -- my old school.

-- Jason Vertrees, PhD
Jason dot Vertrees (_at-) gmail dot com

My ~/.pymolrc

run ~/playground/pymol_scripts/oload.py
run ~/playground/cealign/qkabsch.py
run ~/playground/cealign/cealign.py
run ~/playground/pymol_scripts/find_bind.py
run ~/playground/pymol_scripts/zero.py
run ~/playground/pymol_scripts/removeAlt.py
run ~/playground/pymol_scripts/toGroup.py

one_letter ={'VAL':'V', 'ILE':'I', 'LEU':'L', 'GLU':'E', 'GLN':'Q', \
'ASP':'D', 'ASN':'N', 'HIS':'H', 'TRP':'W', 'PHE':'F', 'TYR':'Y',    \
'ARG':'R', 'LYS':'K', 'SER':'S', 'THR':'T', 'MET':'M', 'ALA':'A',    \
'GLY':'G', 'PRO':'P', 'CYS':'C'}

set ribbon_width, 8
set antialias,2
set cartoon_fancy_helices,1
set ray_trace_mode,1
set depth_cue,0
set ray_trace_fog,0
set ray_opaque_background,0
set defer_builds_mode, 3
set async_builds, 1

To Do

  • Movie->UpdateMovie
  • Scene->Optmize (before saving scenes; use before optimizing)
  • Scene->Cache (cache's surface data)
  • dot_solvent

Movie Notes

#
# Simple movie of independent motions
#

# This create an ala and a tyr.  It moves the ala indepdendent
# of the tyr. 
#
# Q: Why are the orientations off?  What is the equivalent
#    command to moving something with mouse_motions?

# reinit
reinitialize

set matrix_mode, 1
# turns on handy scene buttons
set scene_buttons, 1
# turns on the movie panel at the bottom of the sceen
set movie_panel, 1
# turns on a special mouse button panel
config_mouse three_button_motions

# start with an empty movie, scene 1 with 90 frames
mset 1 x90

# create an ala and tyr
frag ala
frag tyr
as spheres

# create our scene
translate [10, 0, 0], object=ala, camera=0
orient

# store the first frame
frame 1
mview store, object=ala

# goto the next frame
frame 45
translate [-20, 0, 0], object=ala, camera=0
orient

# store this frame
mview store, object=ala

#reinterpolate the scene
mview reinterpolate, object=ala


New motions

  • Enter alone will store+reinterpolate
  • Shift-Enter will just store & clears the reinterpolation
  • CTRL-Enter will store but not reinterpolate

New Scenes

  • setups the scenes first
  • then just goto the frame you want and hit enter and the current will be stored with it
  • or you can right-click on the movie_panel and store with scene
  • purge kills the matrix info for the object


New movie stuff

  • CTRL-LEFTCLK + DRAG RIGHT = add frame/states
  • CTRL-LEFTCLK + DRAG LEFT = erase frame/states
  • Rt clk on object
    • Shift+Middle = drag
    • shift+Left = rotate

Cool Movies

tRNA hairball

reinit
unset movie_auto_interpolate
# position molecule & view
fetch 1yfg, trna, async=0
orient
rotate z, 60, trna

python
for x in range(6):
  n = "trna_%s" % x
  cmd.create( n, "trna", 1, 1)

cmd.disable("trna")
cmd.translate( [0, -60, 0], "trna" )
cmd.origin("trna")

for x in range(6):
  n = "trna_%s" % x
  cmd.rotate( "z", 60. * x, n)
  cmd.show_as("cartoon", n)
  cmd.origin("trna")
  cmd.zoom()
python end


mset 1x360

frame 1
orient vis
mview store

rots = [ [0., 1., 0.], [-1.4, 1., 0], [-1.4, -1., 0.], [0., 1., 0.], [-1.4, 1., 0.], [1.4, 1., 0.] ]
ang = [120,240,360]

python
#for f in [120,240,360]:
for f in range(len(ang)): 
  cmd.frame(ang[f])
  for t in range(6):
    cmd.rotate(rots[t], 120, object="trna_%s" % t)
python end
mview interpolate, object=trna_*, power=1

python
#for f in [120,240,360]:
for f in range(len(ang)): 
  cmd.frame(ang[f])
  cmd.turn('y', 120)
  cmd.mview(action="store")
python end

mview interpolate, power=1

frame 1
mplay

See Also

oload, Cealign, find_bind, zero, removeAlt, toGroup, ribbon_width, antialias, cartoon_fancy_helices, depth_cue, ray_trace_fog, ray_opaque_background, defer_builds_mode, ray_trace_mode.

Tree 19:08, 26 May 2009 (UTC)