Difference between revisions of "Scene"

From PyMOLWiki
Jump to navigation Jump to search
 
(13 intermediate revisions by 4 users not shown)
Line 1: Line 1:
===DESCRIPTION===
 
 
'''scene''' makes it possible to save and restore multiple scenes scene within a single session.  A scene consists of the view, all object activity information, all atom-wise visibility, color, representations, and the global frame index.
 
'''scene''' makes it possible to save and restore multiple scenes scene within a single session.  A scene consists of the view, all object activity information, all atom-wise visibility, color, representations, and the global frame index.
  
===USAGE (newer v1.1.b4)===
+
== Usage ==
<source lang="python">
 
scene [key [,action [, message, [ new_key=new-key-value ]]]]
 
</source>
 
  
Arguments:
+
scene [ key [, action [, message [, view [, color [, active [, rep
*key = string, new, auto, or *: use new for an automatically numbered new scene, use auto for the current scene (if one exists), and use * for all scenes (clear and recall actions only).
+
    [, frame [, animate [, new_key ]]]]]]]]]]
*action = store, recall, insert_after, insert_before, next, previous, update, rename, or clear: (default = recall).  If rename, then a new_key argument must be explicitly defined.
 
* message = string: a text message to display with the scene.
 
* new_key = string: the new name for the scene
 
  
===USAGE (older)===
+
=== Arguments ===
<source lang="python">
+
* '''key''' = string, new, auto, or *: use new for an automatically numbered new scene, use auto for the current scene (if one exists), and use * for all scenes (clear and recall actions only).
scene key [,action [,message [ ,view [,color [,active [,rep [,frame]]]]]]]
+
* '''action''' = store, recall, insert_after, insert_before, next, previous, update, rename, clear or append: (default = recall).  If rename, then a new_key argument must be explicitly defined.
scene *
+
* '''message''' = string: a text message to display with the scene.
</source>
+
* '''view''' = 1 or 0: controls whether the view is stored {default: 1}
 +
* '''color''' = 1 or 0: controls whether colors are stored {default: 1}
 +
* '''active''' = 1 or 0: controls whether activity (objects enabled/disabled) is stored {default: 1}
 +
* '''rep''' = 1 or 0: controls whether the representations are stored {default: 1}
 +
* '''frame''' = 1 or 0: controls whether the frame is stored {default: 1}
 +
* '''animate''' = float: animation duration in seconds {default: ''scene_animation_duration''}
 +
* '''new_key''' = string: the new name for the scene
  
Arguments:
+
== Using Scene ==
*key can be any string
+
The [[Scene]] command has quite a few actions/options that can be enabled by using the mouse and the keyboard through the usual [[Scene]] command or hot-keys.  Also, you can shift the scenes around using the new [[Scene_buttons]] and just dragging the scene names.
*action should be 'store' or 'recall' (default: 'recall')
 
*view: 1 or 0 controls whether the view is stored
 
*color: 1 or 0 controls whether colors are stored
 
*active: 1 or 0 controls whether activity is stored
 
*rep: 1 or 0 controls whether the representations are stored
 
*frame: 1 or 0 controls whether the frame is stored
 
  
===PYMOL API===
+
=== Storing scenes ===
 
<source lang="python">
 
<source lang="python">
cmd.scene(string key,string action,string-or-list message,int view,
+
# store this scene in the next spot, giving it the default name.
            int color, int active, int rep, int frame)
+
scene auto, store
 
</source>
 
</source>
 +
has the hot-key equivalent of '''CTRL-PageDown''' (FN+CTRL+DownArrow on the Mac).  Try turning on [[Scene_Buttons]] and then doing CTRL-PageDown; see the scene buttons popping up?
 +
 +
=== Scenes as Movies ===
 +
If you desire to make a movie that only has camera changes or representation changes, then scenes are your friend.  Simply setup each view and then when ready you can do Scene->Store from the PyMOL menus (or ''scene auto, store'' on the command line or the third method Ctrl+PgDn (Fn+Ctrl+DownArrow on the Mac)).  Do this for each view you setup.  Once done, you can scroll through your scenes by pushing PgUp/PgDn.  PyMOL automatically interpolates when you use the PgUp/PgDn buttons, so you get the desired smooth transitions.  Mix this with [http://www.pymol.org/ax/ AxPyMOL] and you have movies in PowerPoint with very little work.
 +
 +
=== Auto-play through Scenes ===
 +
With this simple trick you can auto-play through scenes. This is similar to "Movie > Program > Scene Loop" but uses only a single frame.
 +
<syntaxhighlight lang="python">
 +
cmd.mset('1x1')
 +
cmd.set('scene_loop')
 +
cmd.set('movie_fps', 1.0 / 5.0)
 +
cmd.mdo(1, 'scene auto, next')
 +
cmd.mplay()
 +
</syntaxhighlight>
  
===EXAMPLES===
+
== Examples ==
 
Simple Examples.
 
Simple Examples.
 
<source lang="python">
 
<source lang="python">
  scene F1, store
+
scene F1, store
  scene F2, store, This view shows you the critical hydrogen bond.
+
scene F2, store, This view shows you the critical hydrogen bond.
 
   
 
   
  scene F1
+
scene F1
  scene F2
+
scene F2
 +
 
 +
scene *
 
</source>
 
</source>
  
Line 129: Line 138:
 
</source>
 
</source>
  
*Courtesy of Warren DeLano.
+
== PyMOL API ==
 
+
<source lang="python">
 +
cmd.scene(str key='auto', str action='recall', str-or-list message=None, bool view=1, bool color=1,
 +
    bool active=1, bool rep=1, bool frame=1, float animate=-1, str new_key=None)
 +
</source>
  
 
+
== Notes ==
 
 
===NOTES===
 
 
* To scroll through your frames, as in a presentation, just use the PG-UP and PG-DN keys.  Very handy.
 
* To scroll through your frames, as in a presentation, just use the PG-UP and PG-DN keys.  Very handy.
 
*Scenes F1 through F12 are automatically bound to function keys provided that "set_key" hasn't been used to redefine the behaviour of the respective key.
 
*Scenes F1 through F12 are automatically bound to function keys provided that "set_key" hasn't been used to redefine the behaviour of the respective key.
*If you have a script that modifies the representation of the molecules and stores them, quickly, then the stored frames may not be up to date.  I suggest calling "refresh" between the commands. For example,
+
*If you have a script that modifies the representation of the molecules and stores them, quickly, then the stored frames may not be up to date.  I suggest calling "refresh" between the commands.
<source lang="python">
 
fetch 2ilk 2psr
 
zero_residues 2ilk # see [[zero_residues]]
 
zero_residues 2psr # see [[zero_residues]]
 
optAlign 2ILK and i. 62-71+72-81+82-91, 2PSR and i. 21-30+31-40+41-50; refresh; scene F1, store;refresh;
 
optAlign 2ILK and i. 56-66+67-77+78-88, 2PSR and i. 41-51+52-62+63-73; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 129-140+141-152, 2PSR and i. 52-63+64-75; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 52-64+65-77+78-90, 2PSR and i. 20-32+33-45+46-58; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 36-49+50-63+64-77+78-91, 2PSR and i. 4-17+18-31+32-45+46-59; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 33-47+48-62+63-77+78-92, 2PSR and i. 1-15+16-30+31-45+46-60; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 33-48+49-64+65-80, 2PSR and i. 1-16+17-32+33-48; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 37-53+54-70+71-87, 2PSR and i. 5-21+22-38+39-55; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 36-53+54-71+72-89, 2PSR and i. 4-21+22-39+40-57; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 34-52+53-71+72-90, 2PSR and i. 2-20+21-39+40-58; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 32-51+52-71+72-91, 2PSR and i. 0-19+20-39+40-59; refresh; scene F1, insert_after;refresh;
 
optAlign 2ILK and i. 39-59+60-80, 2PSR and i. 8-28+29-49; refresh; scene F1, insert_after;refresh;
 
# ...and the script goes on.  If you didn't have the "refresh" statements in place, the
 
# stored frames could be incomplete.
 
</source>
 
  
===SEE ALSO===
+
== See Also ==
[[Cmd view]], [[Cmd set_view]], [[Cmd get_view]]
+
[[View]], [[Set_View]], [[Get_View]], [[Movie_from_scenes]]
  
===DEVELOPMENT TO DO===
+
==DEVELOPMENT TO DO==
 
Add support for save/restore of a certain global and object-and-state specific settings, such as: state, surface_color, ribbon_color, stick_color, transparency, sphere_transparency, etc.  This would probably best be done by defining a class of "scene" settings which are treated in this manner.  The current workaround is to create separate objects which are enabled/disabled differentially.
 
Add support for save/restore of a certain global and object-and-state specific settings, such as: state, surface_color, ribbon_color, stick_color, transparency, sphere_transparency, etc.  This would probably best be done by defining a class of "scene" settings which are treated in this manner.  The current workaround is to create separate objects which are enabled/disabled differentially.
  
[[Category:Commands|scene]]
+
[[Category:Scenes]]
 +
[[Category:States]]

Latest revision as of 17:25, 8 January 2016

scene makes it possible to save and restore multiple scenes scene within a single session. A scene consists of the view, all object activity information, all atom-wise visibility, color, representations, and the global frame index.

Usage

scene [ key [, action [, message [, view [, color [, active [, rep
    [, frame [, animate [, new_key ]]]]]]]]]]

Arguments

  • key = string, new, auto, or *: use new for an automatically numbered new scene, use auto for the current scene (if one exists), and use * for all scenes (clear and recall actions only).
  • action = store, recall, insert_after, insert_before, next, previous, update, rename, clear or append: (default = recall). If rename, then a new_key argument must be explicitly defined.
  • message = string: a text message to display with the scene.
  • view = 1 or 0: controls whether the view is stored {default: 1}
  • color = 1 or 0: controls whether colors are stored {default: 1}
  • active = 1 or 0: controls whether activity (objects enabled/disabled) is stored {default: 1}
  • rep = 1 or 0: controls whether the representations are stored {default: 1}
  • frame = 1 or 0: controls whether the frame is stored {default: 1}
  • animate = float: animation duration in seconds {default: scene_animation_duration}
  • new_key = string: the new name for the scene

Using Scene

The Scene command has quite a few actions/options that can be enabled by using the mouse and the keyboard through the usual Scene command or hot-keys. Also, you can shift the scenes around using the new Scene_buttons and just dragging the scene names.

Storing scenes

# store this scene in the next spot, giving it the default name.
scene auto, store

has the hot-key equivalent of CTRL-PageDown (FN+CTRL+DownArrow on the Mac). Try turning on Scene_Buttons and then doing CTRL-PageDown; see the scene buttons popping up?

Scenes as Movies

If you desire to make a movie that only has camera changes or representation changes, then scenes are your friend. Simply setup each view and then when ready you can do Scene->Store from the PyMOL menus (or scene auto, store on the command line or the third method Ctrl+PgDn (Fn+Ctrl+DownArrow on the Mac)). Do this for each view you setup. Once done, you can scroll through your scenes by pushing PgUp/PgDn. PyMOL automatically interpolates when you use the PgUp/PgDn buttons, so you get the desired smooth transitions. Mix this with AxPyMOL and you have movies in PowerPoint with very little work.

Auto-play through Scenes

With this simple trick you can auto-play through scenes. This is similar to "Movie > Program > Scene Loop" but uses only a single frame.

cmd.mset('1x1')
cmd.set('scene_loop')
cmd.set('movie_fps', 1.0 / 5.0)
cmd.mdo(1, 'scene auto, next')
cmd.mplay()

Examples

Simple Examples.

scene F1, store
scene F2, store, This view shows you the critical hydrogen bond.
 
scene F1
scene F2

scene *

This example shows how to use scenes in a movie!

# SUMMARY
#

# This script demonstrates one way of creating a movie from scenes.
# It assumes that we have three scenes, each running for 10 seconds
# (300 frames apiece) including 2-second transitions.

# 1) Load or create content for three scenes (this could just as easily
#    come from a session file).

load $TUT/1hpv.pdb
util.cbc
turn x,180
orient
as cartoon
scene 001, store

show sticks, organic
orient organic
scene 002, store

hide cartoon
show lines, byres organic expand 5
turn x,45
turn y,45
scene 003, store

# 2) Specify a 30-second movie -- state 1, 900 frames at 30 frames per second.

mset 1 x900

# 3) Program scene matrices as movie views at appopriate frames
#    and also add y-axis rocking between scenes.

scene 001, animate=0
mview store, 1
mview store, 240

turn y,-30
mview store, 70
turn y,60
mview store, 170

scene 002, animate=0
mview store, 300
mview store, 540

turn y,-30
mview store, 370
turn y,60
mview store, 470

scene 003, animate=0
mview store, 600
mview store, 840

turn y,-30
mview store, 670
turn y,60
mview store, 770

# 4) Now interpolate the movie camera.

mview interpolate
mview smooth
mview smooth

# 5) Activate scene content at the appropriate movie frames.
 
mdo 1: scene 001, view=0, quiet=1
mdo 240: scene 002, view=0, quiet=1
mdo 540: scene 003, view=0, quiet=1
mdo 840: scene 001, view=0, quiet=1

# 6) Force frame 1 content to load.

rewind

# 6) And play the movie.

mplay

PyMOL API

cmd.scene(str key='auto', str action='recall', str-or-list message=None, bool view=1, bool color=1,
    bool active=1, bool rep=1, bool frame=1, float animate=-1, str new_key=None)

Notes

  • To scroll through your frames, as in a presentation, just use the PG-UP and PG-DN keys. Very handy.
  • Scenes F1 through F12 are automatically bound to function keys provided that "set_key" hasn't been used to redefine the behaviour of the respective key.
  • If you have a script that modifies the representation of the molecules and stores them, quickly, then the stored frames may not be up to date. I suggest calling "refresh" between the commands.

See Also

View, Set_View, Get_View, Movie_from_scenes

DEVELOPMENT TO DO

Add support for save/restore of a certain global and object-and-state specific settings, such as: state, surface_color, ribbon_color, stick_color, transparency, sphere_transparency, etc. This would probably best be done by defining a class of "scene" settings which are treated in this manner. The current workaround is to create separate objects which are enabled/disabled differentially.