This is a read-only mirror of pymolwiki.org

Jump

From PyMOL Wiki
Revision as of 03:06, 28 March 2014 by Bell (talk | contribs) (8 revisions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Type Python Script
Download jump.py
Author(s) Sean M. Law
License -
This code has been put under version control in the project Pymol-script-repo

Description

In the case of movies or simulation trajectories, it is often useful to quickly jump between different frames but not necessarily in any order. This script allows the user to specify a list of frames and flipping through the set of frames is controlled by a user-defined keystroke (limited to those available through the Set Key command). This script is a nice tool for identifying different protein states from a simulation and can be used in conjunction with the Modevectors script in a very useful way by first characterizing the directionality of the movements (using Modevectors) and then visualizing the change directly using this script.

Note: This script also requires the Check Key script!


Usage

load the script using the run command

jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]

Example

jump 1, 10, 100

#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed
#Note that there is no limit to the number of frames that can be specified

jump 1, 10, 100, 1000, key='F1'
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively

jump 1, 10, 100, sleep=0.01
#This does the same thing as the first example except that the pause between frames is 10x faster
#One could consider the "sleep" option to be similar to the frame rate

jump 1, 10, 100, x=10
#This does the same thing as the first example except that each press of the hotkey will 
#cause the script to run through the specified frames 10 times before stopping.
#Note that you will not be able to control or exit the script during the 10 iterations!

PyMOL API

from pymol import cmd
import time

def jump (*args, **kwargs):
    
    """
    Author Sean M. Law
    University of Michigan
    seanlaw_(at)_umich_dot_edu
    """

    keystroke='pgdn'
    
    for key in kwargs:
        if (key == "key"):
            keystroke=kwargs["key"]
            keystroke=check_key(keystroke)
            if (keystroke == None):
                return
        else:
            continue

    cmd.set_key(keystroke, jumpit, args, kwargs)

    return

cmd.extend("jump", jump)

def jumpit (*args, **kwargs):

    x=1
    sleep=0.1

    for key in kwargs:
        if (key == "sleep"):
            sleep=kwargs["sleep"]
            sleep=float(sleep)
        elif (key == "x"):
            x=kwargs["x"]
            x=int(x)
        else:
            continue

    args=list(args)
    
    for i in range (x):
        for j in range (len(args)):
            cmd.frame(int(args[j]))
            cmd.refresh()
            time.sleep(sleep)

    return
cmd.extend("jumpit", jumpit)


See Also

Check Key