This is a read-only mirror of pymolwiki.org

Difference between revisions of "Slerpy"

From PyMOL Wiki
Jump to navigation Jump to search
Line 50: Line 50:
 
:You can adjust the rate of any transition using the ''ssetf'' command
 
:You can adjust the rate of any transition using the ''ssetf'' command
 
   
 
   
Step 7: Add any actions to your views using the saction command. Any number of pymol commands can be strung together separated by semicolons. If, for example, you want to change your protein from a cartoon to a surface and add a ligand when you get to view 5 you would do the following (assuming you've defined the pymol selections prot and lig):
+
Step 7A: Add any actions to your views using the saction command. Any number of pymol commands can be strung together separated by semicolons. If, for example, you want to change your protein from a cartoon to a surface and add a ligand when you get to view 5 you would do the following (assuming you've defined the pymol selections prot and lig):
 
   
 
   
 
  sgo 5
 
  sgo 5
 
  saction "hide cartoon, prot; show surface, prot; show sticks, lig"
 
  saction "hide cartoon, prot; show surface, prot; show sticks, lig"
  
Step 7 Alternative using scenes:
+
Step 7B (Alternative using scenes):
  
 
  sgo 5
 
  sgo 5
Line 131: Line 131:
  
 
  sinterpsetting stick_transparency, lig, 0.0, 1.0
 
  sinterpsetting stick_transparency, lig, 0.0, 1.0
+
 
 
'''slist''': List all views stored for interpolation. Also lists the number of frames in each transition.
 
'''slist''': List all views stored for interpolation. Also lists the number of frames in each transition.
 
   
 
   

Revision as of 04:21, 31 December 2006

Manual for Slerpy.py

An extension to pymol that creates a moderately easy to use environment for doing keyframe animation.


General Use

At the pymol command line type:

import slerpy

This will load the extended commands. All commands in slerpy begin with the letter s. Pymol's tab autocomplete feature will work on the additional commands.

Important concepts

The main function of slerpy is to record a series of pymol views. A movie can then be created by interpolating between these views. A pymol view consists mostly of the camera orientation (that is, the orientation of the viewers eye with respect to the molecule). It also includes information about the clipping planes.

It is important to realize that most slerpy commands act on the "current" view. You can navigate among views by using the sn, sp, and sgo commands. If you've changed the view around with the mouse or you just want to know the number of the current view you can get back to the current view with the sc command.

Pymol views do not contain information about how pymol objects and selections are displayed. If you just want to create a movie which moves around a single representation of a molecule then all you need to do is record the set of views that define the tour of the molecule.

If, on the other hand, you want to change the representation or change which items are displayed you will need to add actions to some of your views. An action is any set of pymol commands. Actions can be associated with any view in the series recorded by slerpy. The sscene command inserts a new view and simultaneously creates a pymol scene and the action to display it. The scene will include all of the objects and representations visible at the time the command was issued.

In order to control the rate of motion between the defined views in a slerpy movie, you can control the number of frames used in each interpolation. When a view is saved in slerpy it is associated by default with a transition of 50 frames to the next view. The number of frames in the transition can be altered with the ssetf command in slerpy.

The views and actions stored by slerpy can (and should) be saved to a key file with the swrite command. They can then be retrieved with the sread command. Note that swrite saves the current pymol state in a .pse file but sread does not read in the .pse file. If you're starting a new pymol session to continue work on an existing movie you should load the pse file before doing an sread.

Quick Start Tutorial

Step 1: You probably want to start off in a nice clean working directory that just has the coordinate files you want to work with.

Step 2: Read in your molecule(s) and create the various selections and representations that you want to include in the movie.

Step 3: At the pymol prompt, type:

import slerpy

Step 4: Get your molecule in exactly the orientation and representation that you want to use for the beginning of your movie.

Step 5: Type:

sinsert

Step 6: Using the mouse, move your molecule to the next orientation that you want to use. When you record the movie, the camera orientation will be interpolated between each consecutive pair of views. This can include changes in rotation, zooming, clipping etc.

Loop back to Step 5. Continue this until you've got all your orientations stored.
You can check how any set of transitions will look at any time by using the sshow command (see command ref for details).
You can adjust the rate of any transition using the ssetf command

Step 7A: Add any actions to your views using the saction command. Any number of pymol commands can be strung together separated by semicolons. If, for example, you want to change your protein from a cartoon to a surface and add a ligand when you get to view 5 you would do the following (assuming you've defined the pymol selections prot and lig):

sgo 5
saction "hide cartoon, prot; show surface, prot; show sticks, lig"

Step 7B (Alternative using scenes):

sgo 5
Now use the gui to create the representation you want and then:
sscene

Step 8: Save everything. Save your slerpy views and actions as well as a pse file of your current pymol session:

swrite mymovie

This will create mymovie.key, which has all of the views, frame counts, actions etc. and mymovie.pse, the associated pymol session file.

Step 9: Record the movie! Type:

srecord
You can then play the movie by typing the standard pymol command mplay or by clicking the play button in pymol.

Step 10: If you save the pymol session again, the pse file will contain the movie which can then be shown immediately after startup without running slerpy.py. Note that pymol will warn you when you load a pse file that contains a movie.

Step 11: If you want to, the movie can be exported using the mpng command (see the pymol documentation).

Tips and Tricks

Converting scenes to movies:

You can just step through the scenes and type sscene for each one. This will create a duplicate slerpy scene for each of the scenes you'd already saved but that's not such a disaster. Be sure to swrite when your done.

Note that there is some overhead associated with recalling scenes. To avoid pauses at view transitions, I prefer to actually issue the set of show and hide commands that will generate the scene rather than using the above method.

Starting off right:

It's a bit of a pain, but I like to associate with the first frame of the movie an action list that hides everything and then turns on all the objects that I want to have visible at the beginning. This ensures that when your movie loops back to the beginning it will look the same as it did the first time through. For example:

sgo 0
saction "hide everything; show lines, prot; show surface, activesite; show sticks, ligand"

Alternatively, start your slerpy work with an sscene.

Be sure to run your movie once it's been opened and before your presentation if you're presenting in pymol. This will ensure that any objects that don't appear until the middle of the movie are available in memory and won't need to be rebuilt while your audience waits.

Pausing on a view:

Just sgo to the view you want to stay on for a while and do an sinsert. This will insert a new view with the same orientation etc as the one you were just on. You can adjust the length of the pause by changing the number of frames for the transistion between these two identical views using the ssetf command.

Command Reference

Note that it is essential to understand that slerpy uses the concept of a current or active view. This is the element in the list to which most commands are applied. It is not necessarily the view that is currently visible on the screen. It is advisable to use the sc command frequently to make sure you really know which view your command is being applied to.

saction string: Assoiciates the pymol commands in string with the current view. string must be enclosed in quotes and must contain only valid pymol commands separated by semicolons.

sappend: Add the currently displayed view at the end of the list of views in slerpy

sappendaction string: Adds the action(s) in string to the list of actions associated with the current view

sc: Go to the slerpy active view

scrossfade startobject, endobject: During the transition from the current view to the next view startobject will fade out and endobject will fade in. The two objects must be shown as sticks. They must be objects, not merely selections, as of pymol 0.99.

sdelaction: Deletes the action associated with the current view. Be sure you're sure which view you're on before you use this. This will also delete any actions etc. associated with the view so be careful.

sdelete: Remove the slerpy active view from the list of views to be interpolated.

sdeletesetting: Remove the setting interpolation for the current view.

sdumpactions: List all actions by frame.

sgo n: Change the slerpy active view to view n.

sinsert: Add the currently displayed view after the slerpy active view.

sinterpsetting setting, selection, startval, endval : The pymol setting setting will be interpolated linearly from startval to endval during the transition from the current view to the next view. You can only interpolate one setting per transition. This is the hard way to, for example, fade out an object:

sinterpsetting stick_transparency, lig, 0.0, 1.0

slist: List all views stored for interpolation. Also lists the number of frames in each transition.

smorph startmodel,endmodel: The transition from the current frame to the next frame will consist of one frame per pymol state starting with state startmodel and ending with state endmodel. Subsequent frames (i.e. from subsequent views) will revert to state 1. The state numbers apply to currently visible objects so you will most likely want to have an object with your starting conformation, an object with your multi-state morphing model, and an object with your final conformation. You would then sgo to the frame where you want the morph to start and add an action to hide the starting conformation object and show the multi-model morphing object, do an smorph 1,30 or whatever the number of states in your morph is, append another frame and give it an action where the multi-state model is hidden and the final conformation is shown.

sn: Go to the next view

sp: Go to the previous view.

sread filename: Restore all the information written with swrite. Does not read in the pse file (to avoid inadvertantly writing over some new selections, scenes or whatever).

srecord: Records the movie

sreplace: Replace the slerpy current view with the currently displayed view.

sscene: Add a the currently displayed view after the slerpy active view and create a scene to go with it. The current pymol state, including which objects are displayed and how they are shown will therefor be captured.

ssetf: Set the number of frames to use in the transition from the slerpy active view to the next view

ssetupview n: This attempts to make sure that all objects are displayed (or not) as they would be when view n is arrived at in the movie. It goes through and executes all of the sactions from all preceeding views. For some reason this doesn't always work in complex cases.

sshow n,m: This command records and shows a segment of the movie showing the transitions starting with view n and ending with view m. If the arguments m and n are omitted the transition from the current view to the next view will be shown.

sdumpactions: Lists all of the currently assigned actions and their view numbers. Note that this list is a python dictionary and is therefore not in any particular order.

swrite filename: Writes all the information used by slerpy to a file filename.key. It also writes a pymol session file filename.pse containing all of your current objects, selections etc. The format of the .key file is supposed to be human readable and it can be convenient to edit this file rather than using saction over and over. After editing it by hand besure to do an sread.