|
|
(49 intermediate revisions by 3 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 |
| | * CTRL-Enter will store but not reinterpolate |
|
| |
|
| == Your First Movie ==
| | New Scenes |
| Movies can be very simple, for example, animating an NMR ensemble:
| | * setups the scenes first |
| <source lang="python">
| | * then just goto the frame you want and hit enter and the current will be stored with it |
| # Your first movie.
| | * or you can right-click on the movie_panel and store with scene |
| fetch 1nmr
| |
| mplay
| |
|
| |
|
| # to stop the movie when you're ready
| | * purge kills the matrix info for the object |
| # 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.
| |
|
| |
|
| | 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 |
|
| |
|
| == Terminology == | | = Cool Movies = |
| Image 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) then 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).
| | * [[File:Traj_movie.mpg]] — MD Trajectory made awesome with PyMOL; 5 MB mpg file. |
| | * [[File:Long_movie_ray.mpg]] — long movie, shows dimerization, roams around the active site, 6 MB. |
| | * [[File:Motions_movie.mpg]] — a simple movie with motions. |
|
| |
|
| 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.
| | = tRNA hairball = |
| | |
| === 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'''
| |
| :: 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.
| |
| | |
| == 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.)
| |
| | |
| === [[frame]]===
| |
| 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).
| |
| | |
| Let's try a quick example with [[frame]],
| |
| <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,
| | for x in range(6): |
| <source lang="python">
| | n = "trna_%s" % x |
| # invalid command
| | cmd.rotate( "z", 60. * x, n) |
| state 40
| | cmd.show_as("cartoon", n) |
| </source>
| | cmd.origin("trna") |
| in PyMOL we [[set]] the [[States|state]]:
| | cmd.zoom() |
| <source lang="python">
| | python end |
| # how to set a state in PyMOL
| |
| set state, stateNo, objectName
| |
|
| |
|
| # for example
| |
| # set state to 40
| |
| set state, 40
| |
|
| |
|
| # also, get state
| | mset 1x360 |
| get state
| |
| </source>
| |
|
| |
|
| ==== States & Frames (optional reading) ====
| | frame 1 |
| As an example, look at the code from the "first movie":
| | orient vis |
| <source lang="python">
| | mview store |
| fetch 1nmr
| |
| mplay
| |
| # issue mstop, to stop the movie
| |
| </source>
| |
|
| |
|
| We can do a couple things now, let's try counting the number of states and frames PyMOL now knows about:
| | rots = [ [0., 1., 0.], [-1.4, 1., 0], [-1.4, -1., 0.], [0., 1., 0.], [-1.4, 1., 0.], [1.4, 1., 0.] ] |
| <source lang="python">
| | ang = [120,240,360] |
| # how many frames does PyMOL know about?
| |
| count_frames
| |
|
| |
|
| # what about states? | | python |
| count_states
| | #for f in [120,240,360]: |
| </source>
| | 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 |
|
| |
|
| 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 | | python |
| for x in range(1,cmd.count_frames()+1): | | #for f in [120,240,360]: |
| cmd.frame(x) | | for f in range(len(ang)): |
| print "Frame => %s; and State => %s" % ( str(x), str(cmd.get('state'))) | | cmd.frame(ang[f]) |
| | cmd.turn('y', 120) |
| | cmd.mview(action="store") |
| python end | | python end |
| </source>
| |
| which should show a 1-1 mapping of states to frames.
| |
|
| |
|
| === [[mset]] === | | mview interpolate, power=1 |
| [[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:
| | frame 1 |
| <source lang="python">
| | mplay |
| 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—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> | | </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]] ===
| |
|
| |
|
| = See Also = | | = See Also = |
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)