<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Slaw</id>
	<title>PyMOL Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Slaw"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php/Special:Contributions/Slaw"/>
	<updated>2026-05-14T18:17:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Spectrum&amp;diff=11869</id>
		<title>Spectrum</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Spectrum&amp;diff=11869"/>
		<updated>2014-04-28T19:17:39Z</updated>

		<summary type="html">&lt;p&gt;Slaw: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Spectrum_ex2.png|right|thumb|185px]]&lt;br /&gt;
= Overview =&lt;br /&gt;
[[Spectrum]] colors atoms with a spectrum of colors based on an atomic property.&lt;br /&gt;
    &lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
spectrum [expression [, palette [, selection [, minimum [, maximum [, byres ]]]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
''expression''&lt;br /&gt;
::count, b, q, or pc: respectively, atom count, temperature factor, occupancy, or partial charge {default: count}&lt;br /&gt;
    &lt;br /&gt;
''palette''&lt;br /&gt;
::string: palette name {default: rainbow}&lt;br /&gt;
 &lt;br /&gt;
''selection''&lt;br /&gt;
::string: atoms to color {default: (all)}&lt;br /&gt;
 &lt;br /&gt;
''minimum''&lt;br /&gt;
::float: {default: None (automatic)}&lt;br /&gt;
 &lt;br /&gt;
''maximum''&lt;br /&gt;
::float: {default: None (automatic)}&lt;br /&gt;
 &lt;br /&gt;
''byres''&lt;br /&gt;
::integer: controls whether coloring is applied per-residue {default: 0}&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
Minimum and maximum are determined automatically unless '''both''' arguments are provided and ''minimum &amp;lt; maximum''.&lt;br /&gt;
&lt;br /&gt;
Available palettes include:&lt;br /&gt;
*blue_green&lt;br /&gt;
*blue_magenta &lt;br /&gt;
*blue_red&lt;br /&gt;
*blue_white_green&lt;br /&gt;
*blue_white_magenta&lt;br /&gt;
*blue_white_red&lt;br /&gt;
*blue_white_yellow&lt;br /&gt;
*blue_yellow&lt;br /&gt;
*cbmr&lt;br /&gt;
*cyan_magenta&lt;br /&gt;
*cyan_red&lt;br /&gt;
*cyan_white_magenta&lt;br /&gt;
*cyan_white_red&lt;br /&gt;
*cyan_white_yellow &lt;br /&gt;
*cyan_yellow&lt;br /&gt;
*gcbmry&lt;br /&gt;
*green_blue&lt;br /&gt;
*green_magenta&lt;br /&gt;
*green_red&lt;br /&gt;
*green_white_blue &lt;br /&gt;
*green_white_magenta&lt;br /&gt;
*green_white_red&lt;br /&gt;
*green_white_yellow &lt;br /&gt;
*green_yellow&lt;br /&gt;
*green_yellow_red&lt;br /&gt;
*magenta_blue&lt;br /&gt;
*magenta_cyan&lt;br /&gt;
*magenta_green&lt;br /&gt;
*magenta_white_blue&lt;br /&gt;
*magenta_white_cyan &lt;br /&gt;
*magenta_white_green&lt;br /&gt;
*magenta_white_yellow&lt;br /&gt;
*magenta_yellow&lt;br /&gt;
*rainbow&lt;br /&gt;
*rainbow2&lt;br /&gt;
*rainbow2_rev&lt;br /&gt;
*rainbow_cycle&lt;br /&gt;
*rainbow_cycle_rev &lt;br /&gt;
*rainbow_rev red_blue&lt;br /&gt;
*red_cyan red_green&lt;br /&gt;
*red_white_blue&lt;br /&gt;
*red_white_cyan&lt;br /&gt;
*red_white_green&lt;br /&gt;
*red_white_yellow&lt;br /&gt;
*red_yellow&lt;br /&gt;
*red_yellow_green&lt;br /&gt;
*rmbc&lt;br /&gt;
*yellow_blue&lt;br /&gt;
*yellow_cyan&lt;br /&gt;
*yellow_cyan_white&lt;br /&gt;
*yellow_green&lt;br /&gt;
*yellow_magenta&lt;br /&gt;
*yellow_red&lt;br /&gt;
*yellow_white_blue&lt;br /&gt;
*yellow_white_green&lt;br /&gt;
*yellow_white_magenta&lt;br /&gt;
*yellow_white_red &lt;br /&gt;
*yrmbcg&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
== Simple ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
spectrum b, blue_red, minimum=10, maximum=50&lt;br /&gt;
&lt;br /&gt;
spectrum count, rainbow_rev, chain A, byres=1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Intermediate ==&lt;br /&gt;
The following script will create this image:&lt;br /&gt;
&lt;br /&gt;
[[Image:Spectrum_example.png|385px]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# color atoms based on their distance from a point&lt;br /&gt;
# returns the length of the distance between atom A and atom B&lt;br /&gt;
&lt;br /&gt;
diff_len = lambda x,y : math.sqrt((x[0]-y[0])*(x[0]-y[0]) + (x[1]-y[1])*(x[1]-y[1]) + (x[2]-y[2])*(x[2]-y[2]))&lt;br /&gt;
&lt;br /&gt;
# fetch 1hug from the PDB&lt;br /&gt;
&lt;br /&gt;
fetch 1hug, async=0&lt;br /&gt;
&lt;br /&gt;
# show it as surface&lt;br /&gt;
&lt;br /&gt;
as surface&lt;br /&gt;
&lt;br /&gt;
# create the pseudoatom at the origin&lt;br /&gt;
&lt;br /&gt;
pseudoatom pOrig, pos=(0,0,0), label=origin&lt;br /&gt;
&lt;br /&gt;
# these are special PyMOL variables that will hold # the coordinates of &lt;br /&gt;
# the atoms and the  pseudoatom&lt;br /&gt;
&lt;br /&gt;
stored.origCoord = []&lt;br /&gt;
stored.distCoord = []&lt;br /&gt;
&lt;br /&gt;
# copy the coordinates into those special variables &lt;br /&gt;
&lt;br /&gt;
iterate_state 1, pOrig, stored.origCoord.append((x,y,z))&lt;br /&gt;
iterate_state 1, 1hug, stored.distCoord.append((x,y,z))&lt;br /&gt;
&lt;br /&gt;
# extend origCoord to be the same length as the other&lt;br /&gt;
&lt;br /&gt;
stored.origCoord *= len(stored.distCoord)&lt;br /&gt;
&lt;br /&gt;
# calculate the distances&lt;br /&gt;
&lt;br /&gt;
newB = map(lambda x,y: diff_len(x,y), stored.distCoord, stored.origCoord)&lt;br /&gt;
&lt;br /&gt;
# put them into the b-factor of the protein&lt;br /&gt;
&lt;br /&gt;
alter 1hug, b=newB.pop(0)&lt;br /&gt;
&lt;br /&gt;
# color by rainbow_rev or any other&lt;br /&gt;
# palette listed in &amp;quot;help spectrum&amp;quot;&lt;br /&gt;
&lt;br /&gt;
spectrum b, rainbow_rev, 1hug&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[Advanced Coloring]]&lt;br /&gt;
* [[Palette Colorbars]]&lt;br /&gt;
* [[Advanced_Coloring#Coloring_with_.27chainbows.27_from_a_script|chainbow]]&lt;br /&gt;
* [[spectrumany]]&lt;br /&gt;
* [[Ramp_New]]&lt;br /&gt;
* [[spectrumbar]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User_talk:Slaw&amp;diff=10726</id>
		<title>User talk:Slaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User_talk:Slaw&amp;diff=10726"/>
		<updated>2013-10-26T15:40:21Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Contact==&lt;br /&gt;
&lt;br /&gt;
:Name: Sean Law&lt;br /&gt;
:Institution: University of Michigan&lt;br /&gt;
:Contact: seanlaw_(at)_umich_dot_edu&lt;br /&gt;
&lt;br /&gt;
==About Me==&lt;br /&gt;
&lt;br /&gt;
I am currently a post-doctoral research associate at the University of Michigan working for Dr. Charles L. Brooks III.&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=7816</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=7816"/>
		<updated>2013-03-19T13:55:53Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|filename  = jump.py&lt;br /&gt;
|author    = [[User:Slaw|Sean M. Law]]&lt;br /&gt;
|license   = -&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===Description===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Author Sean M. Law&lt;br /&gt;
    University of Michigan&lt;br /&gt;
    seanlaw_(at)_umich_dot_edu&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for i in range (x):&lt;br /&gt;
        for j in range (len(args)):&lt;br /&gt;
            cmd.frame(int(args[j]))&lt;br /&gt;
            cmd.refresh()&lt;br /&gt;
            time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:UI_Script]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6658</id>
		<title>Check Key</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6658"/>
		<updated>2013-03-19T13:54:58Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|filename  = check_key.py&lt;br /&gt;
|author    = [[User:Slaw|Sean M. Law]]&lt;br /&gt;
|license   = -&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===DESCRIPTION=== &lt;br /&gt;
&lt;br /&gt;
A simple script used to check if a given key is valid for for the [[Set Key]] command.  This is useful when the user would like to use a keyboard key as shortcut/hotkey in their script but need to check if the key is a valid one.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
check_key (keystroke)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the key specified is a valid one as defined in [[Set Key]] then it returns the value of the keystroke.  Otherwise, it returns None.&lt;br /&gt;
&lt;br /&gt;
For an example that calls this script, see [[Jump]].&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
allowed_keys=re.compile('(F1|F2|left|right|pgup|pgdn|home|insert|(CTRL-[A-Z])|ALT-[A-Z0-9])')&lt;br /&gt;
&lt;br /&gt;
def check_key (keystroke):&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Author Sean M. Law&lt;br /&gt;
    University of Michigan&lt;br /&gt;
    seanlaw_(at)_umich_dot_edu&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    keystroke=keystroke.strip('\&amp;quot;\'')&lt;br /&gt;
    out=allowed_keys.search(keystroke)&lt;br /&gt;
&lt;br /&gt;
    if (out != None):&lt;br /&gt;
        return keystroke         &lt;br /&gt;
    else:&lt;br /&gt;
        print &amp;quot;Error: Invalid key \&amp;quot;&amp;quot;+keystroke+&amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
        print &amp;quot;Valid Keys: F1, F2, left, right, pdup, pgdn, home, insert&amp;quot;&lt;br /&gt;
        print &amp;quot;            CTRL-A to CTRL-Z&amp;quot;&lt;br /&gt;
        print &amp;quot;            ALT-0 to ALT-9, ALT-A to ALT-Z&amp;quot;&lt;br /&gt;
        return&lt;br /&gt;
cmd.extend(&amp;quot;check_key&amp;quot;, check_key)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Button]] [[Set Key]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Spectrumbar&amp;diff=5532</id>
		<title>Spectrumbar</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Spectrumbar&amp;diff=5532"/>
		<updated>2013-03-19T13:53:19Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|filename  = spectrumbar.py&lt;br /&gt;
|author    = [[User:Slaw|Sean M. Law]]&lt;br /&gt;
|license   = -&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Description==&lt;br /&gt;
&lt;br /&gt;
Often times one may color their structure based upon some predefined color spectrum.  However, this alone is not helpful when dealing with publication images.  The purpose of this script is to allow the user to draw their own custom spectrum bar to accompany their structural images.&lt;br /&gt;
&lt;br /&gt;
Further work will be done to improve the functionality of this script.  Please feel free to contact the author for function requests.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
spectrumbar (RGB_Colors,radius=1.0,name=spectrumbar,head=(0.0,0.0,0.0),tail=(10.0,0.0,0.0),length=10.0, ends=square)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please see the script comments for further custom options.  Once the script completes, it will generate a new object called &amp;quot;spectrumbar&amp;quot; (which can be changed through the options) which is a cylinder colored according to the user-specified colors.&lt;br /&gt;
&lt;br /&gt;
Note: It is strongly recommended to turn off the specular reflections before ray tracing&lt;br /&gt;
&lt;br /&gt;
===EXAMPLES===&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:sb_red.png|thumb|300px|left|Fig.1 - spectrumbar red]]&lt;br /&gt;
||[[Image:sb_red.png|thumb|300px|left|Fig.2 - spectrumbar 1,0,0]]&lt;br /&gt;
||[[Image:sb_red_orange_yellow.png|thumb|300px|left|Fig.3 - spectrumbar red, orange, yellow]]&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:sb_default.png|thumb|300px|left|Fig.4 - spectrumbar red,orange,yellow,green,blue,purple]]&lt;br /&gt;
||[[Image:sb_default.png|thumb|300px|left|Fig.5 - spectrumbar 1,0,0, orange, yellow, 0,1,0, 0,0,1, purple]]&lt;br /&gt;
||[[Image:sb_radius.png|thumb|300px|left|Fig.6 - spectrum red,radius=2]]&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:sb_long_red_orange_long_yellow.png|thumb|300px|left|Fig 7 - spectrumbar red, red, red, orange, yellow, yellow]]&lt;br /&gt;
|[[Image:sb_rounded.png|thumb|300px|left|Fig 8 - spectrumbar red, radius=2, ends=rounded]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Script==&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol.cgo import *&lt;br /&gt;
from math import *&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from re import *&lt;br /&gt;
&lt;br /&gt;
def spectrumbar (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Author Sean M. Law&lt;br /&gt;
    University of Michigan&lt;br /&gt;
    seanlaw_(at)_umich_dot_edu&lt;br /&gt;
&lt;br /&gt;
    USAGE&lt;br /&gt;
&lt;br /&gt;
    While in PyMOL&lt;br /&gt;
&lt;br /&gt;
    run spectrumbar.py&lt;br /&gt;
&lt;br /&gt;
    spectrumbar (RGB_Colors,radius=1.0,name=spectrumbar,head=(0.0,0.0,0.0),tail=(10.0,0.0,0.0),length=10.0, ends=square)&lt;br /&gt;
&lt;br /&gt;
    Parameter     Preset         Type     Description&lt;br /&gt;
    RGB_Colors    [1.0,1.0,1.0]  N/A      RGB colors can be specified as a&lt;br /&gt;
                                          triplet RGB value or as PyMOL&lt;br /&gt;
                                          internal color name (i.e. red)&lt;br /&gt;
    radius        1.0            float    Radius of cylindrical spectrum bar&lt;br /&gt;
    name          spectrumbar    string   CGO object name for spectrum bar&lt;br /&gt;
    head          (0.0,0.0,0.0)  float    Starting coordinate for spectrum bar&lt;br /&gt;
    tail          (10.0,0.0,0.0) float    Ending coordinate for spectrum bar&lt;br /&gt;
    length        10.0           float    Length of spectrum bar&lt;br /&gt;
    ends          square         string   For rounded ends use ends=rounded&lt;br /&gt;
&lt;br /&gt;
    Examples:&lt;br /&gt;
&lt;br /&gt;
    spectrumbar red, green, blue&lt;br /&gt;
    spectrumbar 1.0,0.0,0.0, 0.0,1.0,0.0, 0.0,0.0,1.0&lt;br /&gt;
&lt;br /&gt;
    The above two examples produce the same spectrumbar!&lt;br /&gt;
&lt;br /&gt;
    spectrumbar radius=5.0&lt;br /&gt;
    spectrumbar length=20.0&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    rgb=[1.0, 1.0, 1.0]&lt;br /&gt;
    name=&amp;quot;spectrumbar&amp;quot;&lt;br /&gt;
    radius=1.0&lt;br /&gt;
    ends=&amp;quot;square&amp;quot;&lt;br /&gt;
    x1=0&lt;br /&gt;
    y1=0&lt;br /&gt;
    z1=0&lt;br /&gt;
    x2=10&lt;br /&gt;
    y2=0&lt;br /&gt;
    z2=0&lt;br /&gt;
    num=re.compile('[0-9]')&lt;br /&gt;
    abc=re.compile('[a-z]')&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;radius&amp;quot;):&lt;br /&gt;
            radius = float(kwargs[&amp;quot;radius&amp;quot;])&lt;br /&gt;
        elif (key == &amp;quot;name&amp;quot;):&lt;br /&gt;
            name=kwargs[&amp;quot;name&amp;quot;]&lt;br /&gt;
        elif (key == &amp;quot;head&amp;quot;):&lt;br /&gt;
            head=kwargs[&amp;quot;head&amp;quot;]&lt;br /&gt;
            head=head.strip('&amp;quot; []()')&lt;br /&gt;
            x1,y1,z1=map(float,head.split(','))&lt;br /&gt;
        elif (key == &amp;quot;tail&amp;quot;):&lt;br /&gt;
            tail=kwargs[&amp;quot;tail&amp;quot;]&lt;br /&gt;
            tail=tail.strip('&amp;quot; []()')&lt;br /&gt;
            x2,y2,z2=map(float,tail.split(','))&lt;br /&gt;
        elif (key == &amp;quot;length&amp;quot;):&lt;br /&gt;
            if (abc.search(kwargs[&amp;quot;length&amp;quot;])):&lt;br /&gt;
                print &amp;quot;Error: The length must be a value&amp;quot;&lt;br /&gt;
                return&lt;br /&gt;
            else:&lt;br /&gt;
                x2=float(kwargs[&amp;quot;length&amp;quot;]);&lt;br /&gt;
        elif (key == &amp;quot;ends&amp;quot;):&lt;br /&gt;
            ends=kwargs[&amp;quot;ends&amp;quot;]&lt;br /&gt;
        elif (key != &amp;quot;_self&amp;quot;):&lt;br /&gt;
            print &amp;quot;Ignoring unknown option \&amp;quot;&amp;quot;+key+&amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    if (len(args)&amp;gt;=1):&lt;br /&gt;
        rgb=[]&lt;br /&gt;
    while (len(args)&amp;gt;=1):&lt;br /&gt;
        if (num.search(args[0]) and abc.search(args[0])):&lt;br /&gt;
            if (str(cmd.get_color_tuple(args[0])) != &amp;quot;None&amp;quot;):&lt;br /&gt;
                rgb.extend(cmd.get_color_tuple(args.pop(0)))&lt;br /&gt;
            else:&lt;br /&gt;
                return&lt;br /&gt;
        elif (num.search(args[0])):&lt;br /&gt;
            rgb.extend([float(args.pop(0))])&lt;br /&gt;
        elif (abc.search(args[0])):&lt;br /&gt;
            if (str(cmd.get_color_tuple(args[0])) != &amp;quot;None&amp;quot;):&lt;br /&gt;
                rgb.extend(cmd.get_color_tuple(args.pop(0)))&lt;br /&gt;
            else:&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            print &amp;quot;Error: Unrecognized color format \&amp;quot;&amp;quot;+args[0]+&amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
            return&lt;br /&gt;
    &lt;br /&gt;
    if (len(rgb) % 3):&lt;br /&gt;
        print &amp;quot;Error: Missing RGB value&amp;quot;&lt;br /&gt;
        print &amp;quot;Please double check RGB values&amp;quot;&lt;br /&gt;
        return&lt;br /&gt;
&lt;br /&gt;
    dx=x2-x1&lt;br /&gt;
    dy=y2-y1&lt;br /&gt;
    dz=z2-z1&lt;br /&gt;
    if (len(rgb) == 3):&lt;br /&gt;
        rgb.extend([rgb[0]])&lt;br /&gt;
        rgb.extend([rgb[1]])&lt;br /&gt;
        rgb.extend([rgb[2]])&lt;br /&gt;
    t=1.0/(len(rgb)/3.0-1)&lt;br /&gt;
    c=len(rgb)/3-1&lt;br /&gt;
    s=0&lt;br /&gt;
    bar=[]&lt;br /&gt;
    &lt;br /&gt;
    while (s &amp;lt; c):&lt;br /&gt;
        if (len(rgb) &amp;gt;0):&lt;br /&gt;
            r=rgb.pop(0)&lt;br /&gt;
            g=rgb.pop(0)&lt;br /&gt;
            b=rgb.pop(0)&lt;br /&gt;
        if (s == 0 and ends == &amp;quot;rounded&amp;quot;):&lt;br /&gt;
            bar.extend([COLOR, float(r), float(g), float(b), SPHERE, x1+(s*t)*dx, y1+(s*t)*dy, z1+(s*t)*dz, radius])&lt;br /&gt;
        bar.extend([CYLINDER])&lt;br /&gt;
        bar.extend([x1+(s*t)*dx, y1+(s*t)*dy, z1+(s*t)*dz])&lt;br /&gt;
        bar.extend([x1+(s+1)*t*dx, y1+(s+1)*t*dy, z1+(s+1)*t*dz])&lt;br /&gt;
        bar.extend([radius, float(r), float(g), float(b)])&lt;br /&gt;
        if (len(rgb) &amp;gt;= 3):&lt;br /&gt;
            bar.extend([float(rgb[0]), float(rgb[1]), float(rgb[2])])&lt;br /&gt;
            r=rgb[0]&lt;br /&gt;
            g=rgb[1]&lt;br /&gt;
            b=rgb[2]&lt;br /&gt;
        else:&lt;br /&gt;
            bar.extend([float(r), float(g), float(b)])&lt;br /&gt;
        if (s == c-1 and ends == &amp;quot;rounded&amp;quot;):&lt;br /&gt;
            bar.extend([COLOR, float(r), float(g), float(b), SPHERE, x1+(s+1)*t*dx, y1+(s+1)*t*dy, z1+(s+1)*t*dz, radius])&lt;br /&gt;
        s=s+1&lt;br /&gt;
&lt;br /&gt;
    cmd.delete(name)&lt;br /&gt;
    cmd.load_cgo(bar,name)&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;spectrumbar&amp;quot;,spectrumbar)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:UI_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Pucker&amp;diff=9254</id>
		<title>Pucker</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Pucker&amp;diff=9254"/>
		<updated>2013-03-19T13:52:04Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|filename  = pucker.py&lt;br /&gt;
|author    = [[User:Slaw|Sean M. Law]]&lt;br /&gt;
|license   = -&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===DESCRIPTION=== &lt;br /&gt;
'''pucker.py''' is a PyMol script that returns the sugar pucker information (phase, amplitude, pucker) for a given selection.&lt;br /&gt;
&lt;br /&gt;
This script uses its own dihedral calculation scheme rather than the get_dihedral command.  Thus, it is lightning fast!&lt;br /&gt;
&lt;br /&gt;
If a selection does not contain any ribose sugars then an error message is returned.  &lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
pucker selection&lt;br /&gt;
#Calculates the sugar information for the given selection&lt;br /&gt;
&lt;br /&gt;
pucker selection, state=1&lt;br /&gt;
#Calculates the sugar information for the given selection in state 1&lt;br /&gt;
&lt;br /&gt;
pucker selection, state=0 &lt;br /&gt;
#Iterates over all states and calculates the sugar information for the given selection &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===EXAMPLES===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#fetch 1BNA.pdb&lt;br /&gt;
fetch 1bna&lt;br /&gt;
&lt;br /&gt;
#Select DNA only&lt;br /&gt;
#Otherwise, you will get an error for water not having sugars&lt;br /&gt;
select DNA, not solvent&lt;br /&gt;
&lt;br /&gt;
#Execute pucker command&lt;br /&gt;
pucker DNA&lt;br /&gt;
&lt;br /&gt;
#The output should look like this&lt;br /&gt;
 Phase     Amp    Pucker  Residue&lt;br /&gt;
161.22   55.32  C2'-endo  A 1&lt;br /&gt;
139.52   41.67   C1'-exo  A 2&lt;br /&gt;
 92.82   38.31  O4'-endo  A 3&lt;br /&gt;
166.35   48.47  C2'-endo  A 4&lt;br /&gt;
128.57   46.30   C1'-exo  A 5&lt;br /&gt;
126.92   49.75   C1'-exo  A 6&lt;br /&gt;
101.30   47.32  O4'-endo  A 7&lt;br /&gt;
115.62   49.23   C1'-exo  A 8&lt;br /&gt;
140.44   46.37   C1'-exo  A 9&lt;br /&gt;
145.79   53.36  C2'-endo  A 10&lt;br /&gt;
147.47   47.04  C2'-endo  A 11&lt;br /&gt;
113.80   51.69   C1'-exo  A 12&lt;br /&gt;
 &lt;br /&gt;
 Phase     Amp    Pucker  Residue&lt;br /&gt;
153.24   43.15  C2'-endo  B 13&lt;br /&gt;
128.49   45.01   C1'-exo  B 14&lt;br /&gt;
 67.74   43.84   C4'-exo  B 15&lt;br /&gt;
149.33   41.01  C2'-endo  B 16&lt;br /&gt;
169.27   42.30  C2'-endo  B 17&lt;br /&gt;
147.03   42.30  C2'-endo  B 18&lt;br /&gt;
116.29   47.52   C1'-exo  B 19&lt;br /&gt;
129.62   49.92   C1'-exo  B 20&lt;br /&gt;
113.61   42.93   C1'-exo  B 21&lt;br /&gt;
156.34   50.98  C2'-endo  B 22&lt;br /&gt;
116.89   44.21   C1'-exo  B 23&lt;br /&gt;
 34.70   45.55  C3'-endo  B 24&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===PYMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=python&amp;gt;&lt;br /&gt;
from pymol.cgo import *    # get constants&lt;br /&gt;
from math import *&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
&lt;br /&gt;
def pucker(selection,state=1):&lt;br /&gt;
&lt;br /&gt;
	# Author: Sean Law&lt;br /&gt;
	# Institute: University of Michigan&lt;br /&gt;
	# E-mail: seanlaw@umich.edu&lt;br /&gt;
&lt;br /&gt;
	#Comparison to output from 3DNA is identical&lt;br /&gt;
	#Note that the 3DNA output has the second chain&lt;br /&gt;
	#printed out in reverse order&lt;br /&gt;
	state=int(state)&lt;br /&gt;
	if state == 0:&lt;br /&gt;
		for state in range(1,cmd.count_states()+1):&lt;br /&gt;
			sel=cmd.get_model(selection,state)&lt;br /&gt;
			if state == 1:&lt;br /&gt;
				print &amp;quot; &amp;quot; #Blank line to separate chain output&lt;br /&gt;
				print &amp;quot;%5s  %6s  %6s  %8s  Residue&amp;quot; % (&amp;quot;State&amp;quot;,&amp;quot;Phase&amp;quot;,&amp;quot;Amp&amp;quot;, &amp;quot;Pucker&amp;quot;)&lt;br /&gt;
			get_pucker(sel,iterate=state)&lt;br /&gt;
	else:&lt;br /&gt;
		sel=cmd.get_model(selection,state)&lt;br /&gt;
		get_pucker(sel,iterate=0)&lt;br /&gt;
	return&lt;br /&gt;
&lt;br /&gt;
def get_pucker (sel,iterate=0):&lt;br /&gt;
	iterate=int(iterate)&lt;br /&gt;
	first=1&lt;br /&gt;
	old=&amp;quot; &amp;quot;&lt;br /&gt;
	oldchain=&amp;quot; &amp;quot;&lt;br /&gt;
	residue={}&lt;br /&gt;
	theta={}&lt;br /&gt;
	count=0&lt;br /&gt;
	for atom in sel.atom:&lt;br /&gt;
		new=atom.chain+&amp;quot; &amp;quot;+str(atom.resi)&lt;br /&gt;
		newchain=atom.chain+&amp;quot; &amp;quot;+atom.segi&lt;br /&gt;
		if oldchain != newchain and first:&lt;br /&gt;
			if iterate == 0:&lt;br /&gt;
				print &amp;quot; &amp;quot; #Blank line to separate chain output&lt;br /&gt;
				print &amp;quot;%6s  %6s  %8s  Residue&amp;quot; % (&amp;quot;Phase&amp;quot;, &amp;quot;Amp&amp;quot;, &amp;quot;Pucker&amp;quot;)&lt;br /&gt;
		if new != old and not first:&lt;br /&gt;
			#Check that all 5 atoms exist&lt;br /&gt;
			if len(residue) == 15:&lt;br /&gt;
				#Construct planes&lt;br /&gt;
				get_dihedrals(residue,theta)&lt;br /&gt;
				#Calculate pucker&lt;br /&gt;
				info = pseudo(residue,theta)&lt;br /&gt;
				print info+&amp;quot;  &amp;quot;+old&lt;br /&gt;
			else:&lt;br /&gt;
				print &amp;quot;There is no sugar in this residue&amp;quot;&lt;br /&gt;
			if oldchain != newchain:&lt;br /&gt;
				print &amp;quot; &amp;quot; #Blank line to separate chain output&lt;br /&gt;
				print &amp;quot;%6s  %6s  %8s  Residue&amp;quot; % (&amp;quot;Phase&amp;quot;, &amp;quot;Amp&amp;quot;, &amp;quot;Pucker&amp;quot;)&lt;br /&gt;
			#Clear values&lt;br /&gt;
			residue={}&lt;br /&gt;
			dihedrals={}&lt;br /&gt;
			theta={}&lt;br /&gt;
			#Store new value&lt;br /&gt;
			store_atom(atom,residue)&lt;br /&gt;
		else:&lt;br /&gt;
			store_atom(atom,residue)&lt;br /&gt;
		first=0&lt;br /&gt;
		old=new&lt;br /&gt;
		oldchain=newchain&lt;br /&gt;
	#Final Residue&lt;br /&gt;
	#Calculate dihedrals for final residue&lt;br /&gt;
	if len(residue) == 15:&lt;br /&gt;
		#Construct planes&lt;br /&gt;
		get_dihedrals(residue,theta)&lt;br /&gt;
		#Calculate pucker for final residue&lt;br /&gt;
		info = pseudo(residue,theta)&lt;br /&gt;
		if iterate == 0:&lt;br /&gt;
			print info+&amp;quot;  &amp;quot;+old&lt;br /&gt;
		else:&lt;br /&gt;
			print &amp;quot;%5d  %s&amp;quot; % (iterate,info+&amp;quot;  &amp;quot;+old)&lt;br /&gt;
	else:&lt;br /&gt;
		print &amp;quot;There is no sugar in this residue&amp;quot;&lt;br /&gt;
	return&lt;br /&gt;
&lt;br /&gt;
def sele_exists(sele):&lt;br /&gt;
	return sele in cmd.get_names(&amp;quot;selections&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
def pseudo(residue,theta):&lt;br /&gt;
	other=2*(sin(math.radians(36.0))+sin(math.radians(72.0)))&lt;br /&gt;
	&lt;br /&gt;
	#phase=atan2((theta4+theta1)-(theta3+theta0),2*theta2*(sin(math.radians(36.0))+sin(math.radians(72.0))))&lt;br /&gt;
	phase=atan2((theta['4']+theta['1'])-(theta['3']+theta['0']),theta['2']*other)&lt;br /&gt;
	amplitude=theta['2']/cos(phase)&lt;br /&gt;
	phase=math.degrees(phase)&lt;br /&gt;
	if phase &amp;lt; 0:&lt;br /&gt;
		phase+=360 # 0 &amp;lt;= Phase &amp;lt; 360&lt;br /&gt;
	#Determine pucker&lt;br /&gt;
	if phase &amp;lt; 36:&lt;br /&gt;
		pucker = &amp;quot;C3'-endo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 72:&lt;br /&gt;
		pucker = &amp;quot;C4'-exo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 108:&lt;br /&gt;
		pucker = &amp;quot;O4'-endo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 144:&lt;br /&gt;
		pucker = &amp;quot;C1'-exo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 180:&lt;br /&gt;
		pucker = &amp;quot;C2'-endo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 216:&lt;br /&gt;
		pucker = &amp;quot;C3'-exo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 252:&lt;br /&gt;
		pucker = &amp;quot;C4'-endo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 288:&lt;br /&gt;
		pucker = &amp;quot;O4'-exo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 324:&lt;br /&gt;
		pucker = &amp;quot;C1'-endo&amp;quot;&lt;br /&gt;
	elif phase &amp;lt; 360:&lt;br /&gt;
		pucker = &amp;quot;C2'-exo&amp;quot;&lt;br /&gt;
	else:&lt;br /&gt;
		pucker = &amp;quot;Phase is out of range&amp;quot;&lt;br /&gt;
	info = &amp;quot;%6.2f  %6.2f  %8s&amp;quot; % (phase, amplitude, pucker)&lt;br /&gt;
	return info&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
def store_atom(atom,residue):&lt;br /&gt;
	if atom.name == &amp;quot;O4'&amp;quot; or atom.name == &amp;quot;O4*&amp;quot;:&lt;br /&gt;
		residue['O4*X'] = atom.coord[0]&lt;br /&gt;
		residue['O4*Y'] = atom.coord[1]&lt;br /&gt;
		residue['O4*Z'] = atom.coord[2]&lt;br /&gt;
	elif atom.name == &amp;quot;C1'&amp;quot; or atom.name == &amp;quot;C1*&amp;quot;:&lt;br /&gt;
		residue['C1*X'] = atom.coord[0]&lt;br /&gt;
		residue['C1*Y'] = atom.coord[1]&lt;br /&gt;
		residue['C1*Z'] = atom.coord[2]&lt;br /&gt;
	elif atom.name == &amp;quot;C2'&amp;quot; or atom.name == &amp;quot;C2*&amp;quot;:&lt;br /&gt;
		residue['C2*X'] = atom.coord[0]&lt;br /&gt;
		residue['C2*Y'] = atom.coord[1]&lt;br /&gt;
		residue['C2*Z'] = atom.coord[2]&lt;br /&gt;
	elif atom.name == &amp;quot;C3'&amp;quot; or atom.name == &amp;quot;C3*&amp;quot;:&lt;br /&gt;
		residue['C3*X'] = atom.coord[0]&lt;br /&gt;
		residue['C3*Y'] = atom.coord[1]&lt;br /&gt;
		residue['C3*Z'] = atom.coord[2]&lt;br /&gt;
	elif atom.name == &amp;quot;C4'&amp;quot; or atom.name == &amp;quot;C4*&amp;quot;:&lt;br /&gt;
		residue['C4*X'] = atom.coord[0]&lt;br /&gt;
		residue['C4*Y'] = atom.coord[1]&lt;br /&gt;
		residue['C4*Z'] = atom.coord[2]&lt;br /&gt;
	return&lt;br /&gt;
&lt;br /&gt;
def get_dihedrals(residue,theta):&lt;br /&gt;
&lt;br /&gt;
	C = []&lt;br /&gt;
	ribose = residue.keys()&lt;br /&gt;
	ribose.sort()&lt;br /&gt;
	&lt;br /&gt;
	shift_up(ribose,6)&lt;br /&gt;
	for i in range (0,12):&lt;br /&gt;
		C.append(residue[ribose[i]])&lt;br /&gt;
	theta['0']=calcdihedral(C)&lt;br /&gt;
	&lt;br /&gt;
	C = []&lt;br /&gt;
	shift_down(ribose,3)&lt;br /&gt;
	for i in range (0,12):&lt;br /&gt;
		C.append(residue[ribose[i]])&lt;br /&gt;
	theta['1']=calcdihedral(C)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	C = []&lt;br /&gt;
	shift_down(ribose,3)&lt;br /&gt;
	for i in range (0,12):&lt;br /&gt;
		C.append(residue[ribose[i]])&lt;br /&gt;
	theta['2']=calcdihedral(C)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	C = []&lt;br /&gt;
	shift_down(ribose,3)&lt;br /&gt;
	for i in range (0,12):&lt;br /&gt;
		C.append(residue[ribose[i]])&lt;br /&gt;
	theta['3']=calcdihedral(C)&lt;br /&gt;
&lt;br /&gt;
	C = []&lt;br /&gt;
	shift_down(ribose,3)&lt;br /&gt;
	for i in range (0,12):&lt;br /&gt;
		C.append(residue[ribose[i]])&lt;br /&gt;
	theta['4']=calcdihedral(C)&lt;br /&gt;
	&lt;br /&gt;
	return&lt;br /&gt;
&lt;br /&gt;
def shift_up(list,value):&lt;br /&gt;
	for i in range (0,value):&lt;br /&gt;
		list.insert(0,list.pop())&lt;br /&gt;
	return&lt;br /&gt;
&lt;br /&gt;
def shift_down(list,value):&lt;br /&gt;
	for i in range (0,value):&lt;br /&gt;
		list.append(list.pop(0))&lt;br /&gt;
	return&lt;br /&gt;
&lt;br /&gt;
def calcdihedral(C):&lt;br /&gt;
	&lt;br /&gt;
	DX12=C[0]-C[3]&lt;br /&gt;
	DY12=C[1]-C[4]&lt;br /&gt;
	DZ12=C[2]-C[5]&lt;br /&gt;
	&lt;br /&gt;
	DX23=C[3]-C[6]&lt;br /&gt;
	DY23=C[4]-C[7]&lt;br /&gt;
	DZ23=C[5]-C[8]&lt;br /&gt;
	&lt;br /&gt;
	DX43=C[9]-C[6];&lt;br /&gt;
	DY43=C[10]-C[7];&lt;br /&gt;
	DZ43=C[11]-C[8];&lt;br /&gt;
&lt;br /&gt;
	#Cross product to get normal&lt;br /&gt;
	&lt;br /&gt;
	PX1=DY12*DZ23-DY23*DZ12;&lt;br /&gt;
	PY1=DZ12*DX23-DZ23*DX12;&lt;br /&gt;
	PZ1=DX12*DY23-DX23*DY12;&lt;br /&gt;
&lt;br /&gt;
	NP1=sqrt(PX1*PX1+PY1*PY1+PZ1*PZ1);&lt;br /&gt;
&lt;br /&gt;
	PX1=PX1/NP1&lt;br /&gt;
	PY1=PY1/NP1&lt;br /&gt;
	PZ1=PZ1/NP1&lt;br /&gt;
&lt;br /&gt;
	PX2=DY43*DZ23-DY23*DZ43;&lt;br /&gt;
	PY2=DZ43*DX23-DZ23*DX43;&lt;br /&gt;
	PZ2=DX43*DY23-DX23*DY43;&lt;br /&gt;
&lt;br /&gt;
	NP2=sqrt(PX2*PX2+PY2*PY2+PZ2*PZ2);&lt;br /&gt;
	&lt;br /&gt;
	PX2=PX2/NP2&lt;br /&gt;
	PY2=PY2/NP2&lt;br /&gt;
	PZ2=PZ2/NP2&lt;br /&gt;
&lt;br /&gt;
	DP12=PX1*PX2+PY1*PY2+PZ1*PZ2&lt;br /&gt;
&lt;br /&gt;
	TS=1.0-DP12*DP12&lt;br /&gt;
&lt;br /&gt;
	if TS &amp;lt; 0:&lt;br /&gt;
		TS=0&lt;br /&gt;
	else:&lt;br /&gt;
		TS=sqrt(TS)&lt;br /&gt;
	&lt;br /&gt;
	ANGLE=math.pi/2.0-atan2(DP12,TS)&lt;br /&gt;
&lt;br /&gt;
	PX3=PY1*PZ2-PY2*PZ1&lt;br /&gt;
	PY3=PZ1*PX2-PZ2*PX1&lt;br /&gt;
	PZ3=PX1*PY2-PX2*PY1&lt;br /&gt;
&lt;br /&gt;
	DP233=PX3*DX23+PY3*DY23+PZ3*DZ23&lt;br /&gt;
&lt;br /&gt;
	if DP233 &amp;gt; 0:&lt;br /&gt;
		ANGLE=-ANGLE&lt;br /&gt;
&lt;br /&gt;
	ANGLE=math.degrees(ANGLE)&lt;br /&gt;
&lt;br /&gt;
	if ANGLE &amp;gt; 180:&lt;br /&gt;
		ANGLE-=360&lt;br /&gt;
	if ANGLE &amp;lt; -180:&lt;br /&gt;
		ANGLE+=360&lt;br /&gt;
&lt;br /&gt;
	return ANGLE&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;pucker&amp;quot;,pucker)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Biochemical_Properties]]&lt;br /&gt;
[[Category:Biochemical_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Matrix_mode&amp;diff=8088</id>
		<title>Matrix mode</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Matrix_mode&amp;diff=8088"/>
		<updated>2012-10-03T04:44:20Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Stores object position information. &lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#Allow object positions to be saved upon repositioning&lt;br /&gt;
set matrix_mode, 1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
[[MovieSchool_5 | Movie School 5]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User:Seanlaw&amp;diff=3180</id>
		<title>User:Seanlaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User:Seanlaw&amp;diff=3180"/>
		<updated>2012-06-15T19:27:56Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User:Seanlaw&amp;diff=3179</id>
		<title>User:Seanlaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User:Seanlaw&amp;diff=3179"/>
		<updated>2012-06-15T19:26:50Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Redirected page to User:Slaw&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[User:Slaw]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4910</id>
		<title>User:Slaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4910"/>
		<updated>2012-06-15T19:24:08Z</updated>

		<summary type="html">&lt;p&gt;Slaw: /* Contributions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==About Me==&lt;br /&gt;
&lt;br /&gt;
*Name: Sean M. Law&lt;br /&gt;
*Location: University of Michigan&lt;br /&gt;
*Position: Post-doctoral Fellow&lt;br /&gt;
&lt;br /&gt;
==Contributions==&lt;br /&gt;
&lt;br /&gt;
[[pucker]] - A script to calculate sugar pucker&lt;br /&gt;
&lt;br /&gt;
[[modevectors]] - Draws modevectors in an arrow representation&lt;br /&gt;
&lt;br /&gt;
[[spectrumbar]] - Draws a spectrumbar with user specified colors&lt;br /&gt;
&lt;br /&gt;
[[jump]] - Set a key to allow jumping between frames&lt;br /&gt;
&lt;br /&gt;
[[check key]] - Checks if a key binding is allowed&lt;br /&gt;
&lt;br /&gt;
[[save2traj]] - Output frames of an object to a CHARMM formatted DCD trajectory file&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4909</id>
		<title>User:Slaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4909"/>
		<updated>2012-06-15T19:20:42Z</updated>

		<summary type="html">&lt;p&gt;Slaw: /* About Me */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==About Me==&lt;br /&gt;
&lt;br /&gt;
*Name: Sean M. Law&lt;br /&gt;
*Location: University of Michigan&lt;br /&gt;
*Position: Post-doctoral Fellow&lt;br /&gt;
&lt;br /&gt;
==Contributions==&lt;br /&gt;
&lt;br /&gt;
[[pucker]] - A script to calculate sugar pucker&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Modevectors&amp;diff=8102</id>
		<title>Modevectors</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Modevectors&amp;diff=8102"/>
		<updated>2012-04-30T19:36:22Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|filename  = modevectors.py&lt;br /&gt;
|author    = [[User:Slaw|Sean M. Law]]&lt;br /&gt;
|license   = -&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===DESCRIPTION=== &lt;br /&gt;
[[Image:Modevectors.png|right|thumb|250px|Example showing modevectors in action.  (See Examples below).]]&lt;br /&gt;
&lt;br /&gt;
'''modevectors.py''' is a PyMol script that was originally written to visualize results obtained from Normal Mode Analysis (NMA) by drawing arrows or vectors from a starting structure to a final structure.  However, this script can be used to visualize the direction of motion between two specified states (e.g. targeted MD, comparing open and closed structures, etc).  The strength of this script is that the arrows are highly customizable with numerous options to choose from (see script below).  It is important to note that the two states MUST be identical except for the X, Y, and Z coordinates.  That is, you cannot draw vectors between homologous structures.  The default settings sets the background to white and displays the arrows along with the first object frame (in cartoon representation).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: Ray tracing these CGO arrows appears to be a memory intensive process so please save a session before ray tracing and use &amp;quot;pymol -qc&amp;quot; where necessary.  If anybody can come up with a method to improve this please e-mail me (see address in script).&lt;br /&gt;
&lt;br /&gt;
Update: A new way of drawing the arrows has been implemented for PyMOL v.1.1 and has been updated in this code (which automatically detects the version that you are using).  The new method uses the built in cone primitive rather than concentric circles decreasing in size.  Thus, the new method is much less memory intensive and is a significant improvement over the old method.  Additionally, you may want to turn off [[ray shadow]] depending on the [[scene]] that you are viewing as shadows can be confusing to others when seen in publications.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
modevectors first_obj_frame, last_obj_frame [,first_state=1 [,last_state=1 [,outname=modevectors \&lt;br /&gt;
  [,head=1.0 [,tail=0.3 \[,head_length=1.5 [,headrgb=(1.0,1.0,1.0) [,tailrgb=(1.0,1.0,1.0) [,cutoff=4.0 &lt;br /&gt;
  [,skip=0 [,cut=0.5 [,atom=CA [,stat=show [,factor=1.0 [,notail=0]]]]]]]]]]]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please see the script comments for further custom options.  Once the script completes, it will generate a new object called &amp;quot;modevectors&amp;quot; (which can be changed through the options).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===EXAMPLES===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
modevectors 1E3M, 1W7A&lt;br /&gt;
modevectors 1E3M, 1W7A, outname=&amp;quot;arrows&amp;quot;&lt;br /&gt;
modevectors 1E3M, 1W7A, atom=&amp;quot;P&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Copy/paste the following code to see an example of modevectors.  This uses a multistate protein and the arrows are connected between the first and last states.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import modevectors&lt;br /&gt;
# fetch the PDBs from pdb.org&lt;br /&gt;
fetch 1c3y, finish=1, multiplex=0, async=0&lt;br /&gt;
# separate the first and last states of the NMR ensemble to individual objects&lt;br /&gt;
split_states 1c3y, 1, 1&lt;br /&gt;
split_states 1c3y, 23, 23&lt;br /&gt;
hide&lt;br /&gt;
# run the modevectors code&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023&lt;br /&gt;
# just setup a nice representation&lt;br /&gt;
as cartoon, 1c3y_0001 or 1c3y_0023&lt;br /&gt;
show cgo, modevectors&lt;br /&gt;
color marine, 1c3y_0001&lt;br /&gt;
color purpleblue, 1c3y_0023&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following set of examples will illustrate the power of each optional argument.  Each example should be compared to the default figure in the table below.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[Image:mv_default.png|thumb|300px|left|Fig.1 - Default Settings]]&lt;br /&gt;
||[[Image:mv_fig2.png|thumb|300px|left|Fig.2 - Arrow direction drawn from CA to CA]]&lt;br /&gt;
||[[Image:mv_fig3.png|thumb|300px|left|Fig.3 - Arrow head radius]]&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:mv_fig4.png|thumb|300px|left|Fig.4 - Arrow tail radius]]&lt;br /&gt;
||[[Image:mv_fig5.png|thumb|300px|left|Fig.5 - Arrow head length]]&lt;br /&gt;
||[[Image:mv_fig6.png|thumb|300px|left|Fig.6 - Arrow head RGB]]&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:mv_fig7.png|thumb|300px|left|Fig.7 - Arrow tail RGB]]&lt;br /&gt;
||[[Image:mv_fig8.png|thumb|300px|left|Fig.8 - Arrow length cutoff]]&lt;br /&gt;
||[[Image:mv_fig9.png|thumb|300px|left|Fig.9 - Skip every other arrow]]&lt;br /&gt;
|-&lt;br /&gt;
|[[Image:mv_fig10.png|thumb|300px|left|Fig.10 - Subtract value from vector length]]&lt;br /&gt;
||[[Image:mv_fig11.png|thumb|300px|left|Fig.11 - Draw arrows from CB atoms]]&lt;br /&gt;
||[[Image:mv_fig12.png|thumb|300px|left|Fig.12 - Shorten by 50%]]&lt;br /&gt;
|-&lt;br /&gt;
|||[[Image:mv_fig13.png|thumb|300px|left|Fig.13 - Multiple options being used (see final example below)]]&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
reinitialize&lt;br /&gt;
import modevectors&lt;br /&gt;
&lt;br /&gt;
fetch 1c3y, async=0&lt;br /&gt;
&lt;br /&gt;
split_states 1c3y, 1, 1&lt;br /&gt;
split_states 1c3y, 23, 23&lt;br /&gt;
hide&lt;br /&gt;
 &lt;br /&gt;
#This is the default setting (Fig.1)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023&lt;br /&gt;
 &lt;br /&gt;
#This is shows that the direction of the arrows is drawn from the 1c3y_0001 towards 1c3y_0023 (Fig.2)&lt;br /&gt;
show cartoon, 1c3y_0023&lt;br /&gt;
color red, 1c3y_0023&lt;br /&gt;
 &lt;br /&gt;
#This controls the base radius of the cone/arrow head in angstroms (Fig.3)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, head=2.5&lt;br /&gt;
 &lt;br /&gt;
#This controls the radius of the cylinders/arrow tails in angstroms (Fig.4)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, tail=0.75&lt;br /&gt;
 &lt;br /&gt;
#This controls the length of the cone/arrow head in angstroms (Fig.5)&lt;br /&gt;
#Note that this option does NOT increase the vector length but simply changes the tail length&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, head_length=3.0&lt;br /&gt;
 &lt;br /&gt;
#This controls the colour of the cone/arrow head using RGB values (Fig.6)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, headrgb=(1.0,0.0,0.0)&lt;br /&gt;
 &lt;br /&gt;
#This controls the colour of the cylinder/arrow tails using RGB values (Fig.7)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, tailrgb=(1.0,0.0,0.0)&lt;br /&gt;
 &lt;br /&gt;
#This controls the which vectors to show based on a specific cutoff value in angstroms.  Vector lengths that are less &lt;br /&gt;
#than the cutoff value will not be displayed (Fig.8)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, cutoff=30.0&lt;br /&gt;
 &lt;br /&gt;
#This controls how many vectors to skip (integer value) and is useful when there are too many vectors showing.  &lt;br /&gt;
#Skip=1 will show every other arrow (Fig.9)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, skip=1&lt;br /&gt;
 &lt;br /&gt;
#This controls how much to cut from each vector (in angstroms).  Note that arrows will point in the opposite directions &lt;br /&gt;
#when too much is cutoff (resulting in a negative vector length) (Fig.10) and should be used with caution!&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, cut=15.0&lt;br /&gt;
 &lt;br /&gt;
#This controls which atom to draw a vector from (Fig.11).  Note that this is case-sensitive and is really only useful &lt;br /&gt;
#when atom=CA or when atom=P (for DNA backbones)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, atom=CB&lt;br /&gt;
 &lt;br /&gt;
#This controls how much to multiple the length of each vector by (percentage increase/decrease) (Fig.12)&lt;br /&gt;
#This example halves the length of each vector (50%)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, factor=0.5&lt;br /&gt;
 &lt;br /&gt;
#This hides the statistics which count atoms skipped, atoms counted (number of arrows showing), and number of atoms &lt;br /&gt;
#that did not meet the cutoff and are not shown&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, stat=hide&lt;br /&gt;
 &lt;br /&gt;
#This example shows multiple options being used (Fig.13)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, head=2.0, tail=1.0, head_length=2.0, headrgb=(1.0,0.0,0.0), tailrgb=(0.0,0.0,1.0),&lt;br /&gt;
cutoff=0.0,skip=0,cut=0,atom=CA,factor=0.8&lt;br /&gt;
 &lt;br /&gt;
#Finally, this example hides all arrow tails and only uses arrow heads via the notail option(No Figure)&lt;br /&gt;
modevectors 1c3y_0001, 1c3y_0023, head=2.0, cutoff=0.0,skip=0,cut=0,atom=CA,factor=0.8, notail=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;br /&gt;
[[Category:Pymol-script-repo]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4908</id>
		<title>User:Slaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4908"/>
		<updated>2012-04-30T19:35:54Z</updated>

		<summary type="html">&lt;p&gt;Slaw: /* About Me */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==About Me==&lt;br /&gt;
&lt;br /&gt;
*Name: Sean M. Law&lt;br /&gt;
*Location: University of Michigan&lt;br /&gt;
*Position: Post-doctoral Fellow&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4907</id>
		<title>User:Slaw</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User:Slaw&amp;diff=4907"/>
		<updated>2012-04-30T19:35:34Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Created page with &amp;quot;==About Me==  Name: Sean M. Law Location: University of Michigan Position: Post-doctoral Fellow&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==About Me==&lt;br /&gt;
&lt;br /&gt;
Name: Sean M. Law&lt;br /&gt;
Location: University of Michigan&lt;br /&gt;
Position: Post-doctoral Fellow&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Mdo&amp;diff=8090</id>
		<title>Mdo</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Mdo&amp;diff=8090"/>
		<updated>2012-02-08T20:41:01Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''mdo''' sets up a command to be executed upon entry into the specified frame of the movie.  These commands are usually created by a PyMOL utility program (such as util.mrock).  Command can actually contain several commands separated by semicolons ';'&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
 mdo frame : command&lt;br /&gt;
&lt;br /&gt;
===PYMOL API===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt; &lt;br /&gt;
cmd.mdo( int frame, string command )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===EXAMPLE===&lt;br /&gt;
 // Creates a single frame movie involving a rotation about X and Y&lt;br /&gt;
 load test.pdb&lt;br /&gt;
 mset 1&lt;br /&gt;
 mdo 1: turn x,5; turn y,5;&lt;br /&gt;
 mplay&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
//Show waters within 4 Angstroms around the first residue from a 15 frame simulation trajectory&lt;br /&gt;
load structure.pdb&lt;br /&gt;
load_traj structure.dcd, structure, start=1, stop=15&lt;br /&gt;
mset 1 -15&lt;br /&gt;
for a in range(1,16): cmd.mdo(a,&amp;quot;hide sphere; select waters, (structure &amp;amp; i. 1 around 4) &amp;amp; resn HOH, state=&amp;quot;+str(a)+&amp;quot;; show sphere, waters&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===NOTES===&lt;br /&gt;
The '''mset''' command must first be used to define the movie before &amp;quot;mdo&amp;quot; statements will have any effect.  Redefinition of the movie clears any existing mdo statements.&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Mset]], [[Mplay]], [[Mstop]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Commands|Mdo]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Delete&amp;diff=7704</id>
		<title>Delete</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Delete&amp;diff=7704"/>
		<updated>2011-08-08T16:26:58Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''delete''' removes objects or selections matching an expression ''name'', which can include wildcards.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
delete name  &lt;br /&gt;
delete all   # deletes all objects&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
name = name of object or selection &lt;br /&gt;
&lt;br /&gt;
===PYMOL API===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cmd.delete(string name = object-or-selection-name )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that special care needs to be taken to ensure that the object or selection name does not contain any quotes when passed as an argument.&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Remove|Remove]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Commands|Delete]]&lt;br /&gt;
[[Category:Input Output Module|Delete]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Ray_Trace_Gain&amp;diff=9981</id>
		<title>Ray Trace Gain</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Ray_Trace_Gain&amp;diff=9981"/>
		<updated>2010-09-28T14:33:11Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
A setting that alters the outline thickness when using ray_trace_mode=1 (full color with black outline).&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
set ray_trace_gain, 0.0&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Ray_Trace_Gain&amp;diff=9980</id>
		<title>Ray Trace Gain</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Ray_Trace_Gain&amp;diff=9980"/>
		<updated>2010-09-28T14:32:03Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Created page with '===Description===  A setting that alters the outline thickness when using Ray Trace Mode=1 (full color with black outline).  ===Usage===  set ray_trace_gain, 0.0  ==See Also=…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
A setting that alters the outline thickness when using [[Ray Trace Mode]]=1 (full color with black outline).&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
set ray_trace_gain, 0.0&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
&lt;br /&gt;
*[[Ray Trace Mode]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Ray&amp;diff=9973</id>
		<title>Ray</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Ray&amp;diff=9973"/>
		<updated>2010-09-28T14:29:53Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''ray''' creates a ray-traced image of the current frame. &lt;br /&gt;
[[Image:Gslike.png|right|350px|thumb|Varying settings to play with rendering options]]&lt;br /&gt;
&lt;br /&gt;
=Details= &lt;br /&gt;
This command is used to make high-resolution photos fit for publication and formal movies.  Please note, the '''ray''' command can take some time (up to several minutes, depending on image complexity and size).&lt;br /&gt;
&lt;br /&gt;
For those who are making movies with PyMOL, '''Ray''' is one of the most commonly used last steps before stitching the frames together to compile the movie.  '''Ray''' has many powerful features such as setting the size of the image -- and it still works even if the [[Viewport]] or screen is smaller than the requested output file dimensions.&lt;br /&gt;
&lt;br /&gt;
[[Image:No_ray_trace.png|Image, not ray traced.|thumb|200px]] [[Image:ray_traced.png|Image, ray traced.|thumb|200px]]&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
 ray [width,height [,renderer [,angle [,shift ]]]&lt;br /&gt;
'''angle''' and '''shift''' can be used to generate matched stereo pairs&lt;br /&gt;
&lt;br /&gt;
'''width''' and '''height''' can be set to any non-negative integer. If both are set to zero than the current window size is used and is equivalent to just using '''ray''' with no arguments. If one is set to zero (or missing) while the other is a positive integer, then the argument set to zero (or missing) will be scaled to preserve the current aspect ratio.&lt;br /&gt;
&lt;br /&gt;
==PyMol API==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;cmd.ray(int width,int height,int renderer=-1,float shift=0)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Settings==&lt;br /&gt;
===Modes===&lt;br /&gt;
Setting the '''[[Ray_trace_mode]]''' variable in PyMOL changes the way PyMOL's internal renderer represents proteins in the final output.  New modes were recently added to give the user more options of molecular representation.  New modes are: normal rendering, but with a black outline (nice for presentations); black and white only; quantized color with black outline (also, very nice for presentations; more of a ''cartoony'' appearance).  &lt;br /&gt;
&lt;br /&gt;
'''Note:''' Mode 3, the quantized color one, sort of '''burns''' the background if you're using this setting.  This will make a pure white background somewhat &amp;quot;offwhite&amp;quot;; thus, a poster would look poor because you could see the border for the image.  If you'll be using this mode, try the [[ray_opaque_background]] setting.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# normal color&lt;br /&gt;
set ray_trace_mode, 0&lt;br /&gt;
&lt;br /&gt;
# normal color + black outline&lt;br /&gt;
set ray_trace_mode,  1&lt;br /&gt;
&lt;br /&gt;
# black outline only&lt;br /&gt;
set ray_trace_mode,  2&lt;br /&gt;
&lt;br /&gt;
# quantized color + black outline&lt;br /&gt;
set ray_trace_mode,  3&lt;br /&gt;
&lt;br /&gt;
set ray_trace_mode, 1 # (or 2 or 3; best with &amp;quot;bg_color white;set antialias,2&amp;quot;)&lt;br /&gt;
# These two new modes -- 2 and 3 -- are cool cartoon looking modes.&lt;br /&gt;
&lt;br /&gt;
# change the color of the outline to a named color, or a hex-code&lt;br /&gt;
set ray_trace_color, magenta&lt;br /&gt;
set ray_trace_color, 0x0033ff&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here are the example images for the new modes&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Ray_mode_1_ex.png|set ray_trace_mode,1&lt;br /&gt;
Image:Ray_mode_2_ex.png|set ray_trace_mode,2&lt;br /&gt;
Image:Ray_mode_3_ex.png|set ray_trace_mode,3&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Perspective===&lt;br /&gt;
====Perspective Example Images====&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:No_persp.png|Example with Perspective Turned Off&lt;br /&gt;
Image:Persp1.png|Example with Perspective Turned On&lt;br /&gt;
Image:Persp2.png|Example with Perspective Turned On and Field of View Set High (70).&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Notes=====&lt;br /&gt;
PyMol 0.97 and prior used '''orthoscopic''' rendering -- that is, no perspective.  Upon the arrival of 0.98 and later, we get perspective based rendering at a cost of a 4x decrease in render speed.  If you want perspective&lt;br /&gt;
 set orthoscopic, off&lt;br /&gt;
Otherwise&lt;br /&gt;
 set orthoscopic, on&lt;br /&gt;
To magnify the effect of perspective on the scene,&lt;br /&gt;
 set field_of_view, X&lt;br /&gt;
where 50&amp;lt;X&amp;lt;70.  Default is 20.  50-70 gives a very strong perspective effect.  Nb. the field of view is in Y, not X as one would expect.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Renderer===&lt;br /&gt;
'''renderer = -1''' is default (use value in ray_default_renderer)&lt;br /&gt;
&lt;br /&gt;
'''renderer =  0''' uses PyMOL's internal renderer&lt;br /&gt;
&lt;br /&gt;
'''renderer =  1''' uses PovRay's renderer.  This is Unix-only and you must have &amp;quot;x-povray&amp;quot; in your path.  It utilizes two temporary files: &amp;quot;tmp_pymol.pov&amp;quot; and &amp;quot;tmp_pymol.png&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Performance==&lt;br /&gt;
*The ray performance depends on distance between camera and molecule.&lt;br /&gt;
If the distance is big rendering takes much time. If the distance is too small distant parts of molecule dissolve.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Close_ray.png|Too close to molecule&lt;br /&gt;
Image:Middle_ray.png|Normal distance&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
* Tip: If you have a rather complicated scene that is zoomed into only a part of the molecule, you can speed up the ray tracing by hiding everything else outside of a certain range of the zoomed-on point.  For example, if I have a large molecule and I'm looking only at the 30-atom ligand bound to it, then I can do something like the following:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# setup your complex scene&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
# zoom on the hetero atom (ligand and not water) within 5 Angstroms&lt;br /&gt;
select hh, het and not resn HOH&lt;br /&gt;
zoom hh, 5&lt;br /&gt;
&lt;br /&gt;
# turn on depth cueing&lt;br /&gt;
set depth_cue, 1&lt;br /&gt;
&lt;br /&gt;
# now, select stuff to hide; we select everything that is &lt;br /&gt;
# farther than 8 Ang from our main selection&lt;br /&gt;
select th, (all) and not ( (all) within 8 of hh) )&lt;br /&gt;
&lt;br /&gt;
hide everything, th&lt;br /&gt;
&lt;br /&gt;
# any additional commands you want&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
ray&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
As an example of the efficacy of this method, I ray traced a rather complex scene with all the atoms visible here's the output of ray:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;ray&lt;br /&gt;
 Ray: render time: 24.50 sec. = 146.9 frames/hour (941.88 sec. accum.).&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and here is the result when I soft-clipped everything else using the above method:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;ray&lt;br /&gt;
 Ray: render time: 47.93 sec. = 75.1 frames/hour (989.80 sec. accum.).&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The two images in the following gallery show the results of the rendering.&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:Ray_method_off.png|normal ray tracing.  This took twice as long to make as the image to the right.  Same size, and DPI.&lt;br /&gt;
Image:Ray_method_on.png|manually hiding things you won't see anyway.  This took 1/2 the time to render as compared to the same sized &amp;amp; DPId image at left.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Memory===&lt;br /&gt;
If memory is an issue for you in PyMOL, try executing your rendering from a script rather than a PyMOL session file.  An unfortunate unavoidable consequence of the fact that we use Python's portable, platform-independent &amp;quot;pickle&amp;quot; machinery for PyMOL session files.  Packing or unpacking a Session or Scene file thus requires that there be two simultanous copies of the information to reside in RAM simultaneously:  one native and a second in Python itself.&lt;br /&gt;
&lt;br /&gt;
So when memory is a limiting factor, scripts are recommended over sessions.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
===Simple===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# ray trace the current scene using the default size of the viewport&lt;br /&gt;
ray&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Specify Image Size===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# ray trace the current scene, but scaled to 1024x768 pixels&lt;br /&gt;
ray 1024,768&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Specify Renderer===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# ray trace with an external renderer.&lt;br /&gt;
ray renderer=0&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===High Quality B&amp;amp;W Rendering===&lt;br /&gt;
[[Image:1l9l.png|thumb|center|Black and White (ray_trace_mode,2); click to see full image]]&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Black and White Script&lt;br /&gt;
load /tmp/3fib.pdb;&lt;br /&gt;
show cartoon;&lt;br /&gt;
set ray_trace_mode, 2;  # black and white cartoon&lt;br /&gt;
bg_color white;&lt;br /&gt;
set antialias, 2;&lt;br /&gt;
ray 600,600&lt;br /&gt;
png /tmp/1l9l.png&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===High Quality Color===&lt;br /&gt;
[[Image:1l9l_2.png|thumb|center|Color mode (ray_trace_mode,3); click to see full image]]&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Color Script&lt;br /&gt;
load /tmp/thy_model/1l9l.pdb;&lt;br /&gt;
hide lines;&lt;br /&gt;
show cartoon;&lt;br /&gt;
set ray_trace_mode, 3; # color&lt;br /&gt;
bg_color white;&lt;br /&gt;
set antialias, 2;&lt;br /&gt;
remove resn HOH&lt;br /&gt;
remove resn HET&lt;br /&gt;
ray 600,600&lt;br /&gt;
png /tmp/1l9l.png&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Ray Tracing Stereo Images===&lt;br /&gt;
:''See [[Stereo_Ray]]''&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
# &amp;quot;help faster&amp;quot; for optimization tips with the builtin renderer. &amp;quot;help povray&amp;quot; for how to use PovRay instead of PyMOL's built-in    ray-tracing engine.  For high-quality photos, please also see the [[Antialias]] command.  [[Ray shadows]] for controlling shadows.&lt;br /&gt;
# See also [[Ray Tracing]].&lt;br /&gt;
# [http://www.gimp.org/tutorials/Color2BW Desaturation Tutorial] -- A good resource for making nice B&amp;amp;W images from color images (desaturation).&lt;br /&gt;
#[[Ray Trace Gain]]&lt;br /&gt;
&lt;br /&gt;
==User comments==&lt;br /&gt;
;How do I ray trace a publication-ready (~300dpi) image using PyMol?&lt;br /&gt;
:This answer is in the [[:Category:Advanced_Issues|Advanced Issues]] (Image Manipulation Section).&lt;br /&gt;
&lt;br /&gt;
[[Category:Commands|Ray]]&lt;br /&gt;
[[Category:Publication_Quality|Ray]]&lt;br /&gt;
[[Category:Performance|Ray]]&lt;br /&gt;
[[Category:Movies|Ray]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Rms&amp;diff=8636</id>
		<title>Rms</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Rms&amp;diff=8636"/>
		<updated>2010-08-27T01:44:31Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Rms]] computes a RMS fit between two atom selections, but does not tranform the models after performing the fit.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
rms (selection), (target-selection)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
===EXAMPLES===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fit ( mutant and name ca ), ( wildtype and name ca )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===USER COMMENTS===&lt;br /&gt;
&lt;br /&gt;
To determine the RMS without any fitting, see [[Rms_Cur]]&lt;br /&gt;
&lt;br /&gt;
See [[Intra_Rms]] for selection caveats for this group of commands.&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Fit]], [[Rms_Cur]], [[Intra_Fit]], [[Intra_Rms]], [[Intra_Rms_Cur]], [[Pair_Fit]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Commands|Rms]]&lt;br /&gt;
[[Category:Structure_Alignment|Rms]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Centroid&amp;diff=13640</id>
		<title>Centroid</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Centroid&amp;diff=13640"/>
		<updated>2010-06-30T18:38:45Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview == &lt;br /&gt;
[[COM]] is a small script that returns the value of the center of mass of your selection.  It also can translate the object of that selection to the origin.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
COM (selection=PyMOLSelection), [center=boolean]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# get the COM of the polymer&lt;br /&gt;
COM polymer&lt;br /&gt;
&lt;br /&gt;
# move some 'ligand' to the origin&lt;br /&gt;
COM ligand, center=True&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# Copyright (c) 2008, Jason Vertrees&lt;br /&gt;
# All rights reserved.&lt;br /&gt;
#&lt;br /&gt;
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following&lt;br /&gt;
# conditions are met:&lt;br /&gt;
#&lt;br /&gt;
#     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer.&lt;br /&gt;
#     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
#     * Neither the name of the &amp;lt;ORGANIZATION&amp;gt; nor the names of its contributors may be used to endorse or promote products derived&lt;br /&gt;
#     * from this software without specific prior written permission.&lt;br /&gt;
#&lt;br /&gt;
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT&lt;br /&gt;
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL&lt;br /&gt;
# THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES&lt;br /&gt;
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE&lt;br /&gt;
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2008-09-26&lt;br /&gt;
# REV   : 1&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def COM(selection, center=False):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        centerOfMass: get the center of mass of selection or move selection to the origin.&lt;br /&gt;
        param: selection -- a valid PyMOL selection&lt;br /&gt;
        param: center    -- (boolean) if (False) return the center of mass, else if (True) center the selection&lt;br /&gt;
        returns: center of mass: [ xCOM, yCOM, zCOM ]&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        model = cmd.get_model(selection)&lt;br /&gt;
        nAtom = len(model.atom)&lt;br /&gt;
&lt;br /&gt;
        COM = numpy.array([0.,0.,0.])&lt;br /&gt;
        stored.curLoc = []&lt;br /&gt;
&lt;br /&gt;
        for a in model.atom:&lt;br /&gt;
                COM += numpy.array(a.coord)&lt;br /&gt;
                if ( center ):&lt;br /&gt;
                        stored.curLoc.append( a.coord )&lt;br /&gt;
        COM /= float(nAtom)&lt;br /&gt;
&lt;br /&gt;
        if ( center ):&lt;br /&gt;
                stored.curLoc = (numpy.array(stored.curLoc) - COM).tolist()&lt;br /&gt;
                cmd.alter_state(1, selection, &amp;quot;(x,y,z)=stored.curLoc.pop(0)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        return COM.tolist()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;COM&amp;quot;, COM)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Center_Of_Mass]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|CenterOfMass]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Com&amp;diff=3477</id>
		<title>Com</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Com&amp;diff=3477"/>
		<updated>2010-06-30T18:38:45Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview == &lt;br /&gt;
[[COM]] is a small script that returns the value of the center of mass of your selection.  It also can translate the object of that selection to the origin.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
COM (selection=PyMOLSelection), [center=boolean]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# get the COM of the polymer&lt;br /&gt;
COM polymer&lt;br /&gt;
&lt;br /&gt;
# move some 'ligand' to the origin&lt;br /&gt;
COM ligand, center=True&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# Copyright (c) 2008, Jason Vertrees&lt;br /&gt;
# All rights reserved.&lt;br /&gt;
#&lt;br /&gt;
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following&lt;br /&gt;
# conditions are met:&lt;br /&gt;
#&lt;br /&gt;
#     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer.&lt;br /&gt;
#     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
#     * Neither the name of the &amp;lt;ORGANIZATION&amp;gt; nor the names of its contributors may be used to endorse or promote products derived&lt;br /&gt;
#     * from this software without specific prior written permission.&lt;br /&gt;
#&lt;br /&gt;
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT&lt;br /&gt;
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL&lt;br /&gt;
# THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES&lt;br /&gt;
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE&lt;br /&gt;
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2008-09-26&lt;br /&gt;
# REV   : 1&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def COM(selection, center=False):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        centerOfMass: get the center of mass of selection or move selection to the origin.&lt;br /&gt;
        param: selection -- a valid PyMOL selection&lt;br /&gt;
        param: center    -- (boolean) if (False) return the center of mass, else if (True) center the selection&lt;br /&gt;
        returns: center of mass: [ xCOM, yCOM, zCOM ]&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        model = cmd.get_model(selection)&lt;br /&gt;
        nAtom = len(model.atom)&lt;br /&gt;
&lt;br /&gt;
        COM = numpy.array([0.,0.,0.])&lt;br /&gt;
        stored.curLoc = []&lt;br /&gt;
&lt;br /&gt;
        for a in model.atom:&lt;br /&gt;
                COM += numpy.array(a.coord)&lt;br /&gt;
                if ( center ):&lt;br /&gt;
                        stored.curLoc.append( a.coord )&lt;br /&gt;
        COM /= float(nAtom)&lt;br /&gt;
&lt;br /&gt;
        if ( center ):&lt;br /&gt;
                stored.curLoc = (numpy.array(stored.curLoc) - COM).tolist()&lt;br /&gt;
                cmd.alter_state(1, selection, &amp;quot;(x,y,z)=stored.curLoc.pop(0)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        return COM.tolist()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;COM&amp;quot;, COM)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Center_Of_Mass]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|CenterOfMass]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Centroid&amp;diff=13639</id>
		<title>Centroid</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Centroid&amp;diff=13639"/>
		<updated>2010-06-30T18:38:33Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview == &lt;br /&gt;
[[COM]] is a small script that returns the value of the center of mass of your selection.  It also can translate the object of that selection to the origin.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
COM (selection=PyMOLSelection), [center=boolean]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# get the COM of the polymer&lt;br /&gt;
COM polymer&lt;br /&gt;
&lt;br /&gt;
# move some 'ligand' to the origin&lt;br /&gt;
COM ligand, center=True&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# Copyright (c) 2008, Jason Vertrees&lt;br /&gt;
# All rights reserved.&lt;br /&gt;
#&lt;br /&gt;
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following&lt;br /&gt;
# conditions are met:&lt;br /&gt;
#&lt;br /&gt;
#     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer.&lt;br /&gt;
#     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
#     * Neither the name of the &amp;lt;ORGANIZATION&amp;gt; nor the names of its contributors may be used to endorse or promote products derived&lt;br /&gt;
#     * from this software without specific prior written permission.&lt;br /&gt;
#&lt;br /&gt;
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT&lt;br /&gt;
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL&lt;br /&gt;
# THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES&lt;br /&gt;
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE&lt;br /&gt;
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2008-09-26&lt;br /&gt;
# REV   : 1&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def COM(selection, center=False):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        centerOfMass: get the center of mass of selection or move selection to the origin.&lt;br /&gt;
        param: selection -- a valid PyMOL selection&lt;br /&gt;
        param: center    -- (boolean) if (False) return the center of mass, else if (True) center the selection&lt;br /&gt;
        returns: center of mass: [ xCOM, yCOM, zCOM ]&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        model = cmd.get_model(selection)&lt;br /&gt;
        nAtom = len(model.atom)&lt;br /&gt;
&lt;br /&gt;
        COM = numpy.array([0.,0.,0.])&lt;br /&gt;
        stored.curLoc = []&lt;br /&gt;
&lt;br /&gt;
        for a in model.atom:&lt;br /&gt;
                COM += numpy.array(a.coord)&lt;br /&gt;
                if ( center ):&lt;br /&gt;
                        stored.curLoc.append( a.coord )&lt;br /&gt;
        COM /= float(nAtom)&lt;br /&gt;
&lt;br /&gt;
        if ( center ):&lt;br /&gt;
                stored.curLoc = (numpy.array(stored.curLoc) - COM).tolist()&lt;br /&gt;
                cmd.alter_state(1, selection, &amp;quot;(x,y,z)=stored.curLoc.pop(0)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        return COM.tolist()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;COM&amp;quot;, COM)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Center_of_Mass]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|CenterOfMass]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Com&amp;diff=3476</id>
		<title>Com</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Com&amp;diff=3476"/>
		<updated>2010-06-30T18:38:33Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview == &lt;br /&gt;
[[COM]] is a small script that returns the value of the center of mass of your selection.  It also can translate the object of that selection to the origin.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
COM (selection=PyMOLSelection), [center=boolean]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# get the COM of the polymer&lt;br /&gt;
COM polymer&lt;br /&gt;
&lt;br /&gt;
# move some 'ligand' to the origin&lt;br /&gt;
COM ligand, center=True&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# Copyright (c) 2008, Jason Vertrees&lt;br /&gt;
# All rights reserved.&lt;br /&gt;
#&lt;br /&gt;
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following&lt;br /&gt;
# conditions are met:&lt;br /&gt;
#&lt;br /&gt;
#     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer.&lt;br /&gt;
#     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
#     * Neither the name of the &amp;lt;ORGANIZATION&amp;gt; nor the names of its contributors may be used to endorse or promote products derived&lt;br /&gt;
#     * from this software without specific prior written permission.&lt;br /&gt;
#&lt;br /&gt;
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT&lt;br /&gt;
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL&lt;br /&gt;
# THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES&lt;br /&gt;
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE&lt;br /&gt;
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2008-09-26&lt;br /&gt;
# REV   : 1&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def COM(selection, center=False):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        centerOfMass: get the center of mass of selection or move selection to the origin.&lt;br /&gt;
        param: selection -- a valid PyMOL selection&lt;br /&gt;
        param: center    -- (boolean) if (False) return the center of mass, else if (True) center the selection&lt;br /&gt;
        returns: center of mass: [ xCOM, yCOM, zCOM ]&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        model = cmd.get_model(selection)&lt;br /&gt;
        nAtom = len(model.atom)&lt;br /&gt;
&lt;br /&gt;
        COM = numpy.array([0.,0.,0.])&lt;br /&gt;
        stored.curLoc = []&lt;br /&gt;
&lt;br /&gt;
        for a in model.atom:&lt;br /&gt;
                COM += numpy.array(a.coord)&lt;br /&gt;
                if ( center ):&lt;br /&gt;
                        stored.curLoc.append( a.coord )&lt;br /&gt;
        COM /= float(nAtom)&lt;br /&gt;
&lt;br /&gt;
        if ( center ):&lt;br /&gt;
                stored.curLoc = (numpy.array(stored.curLoc) - COM).tolist()&lt;br /&gt;
                cmd.alter_state(1, selection, &amp;quot;(x,y,z)=stored.curLoc.pop(0)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        return COM.tolist()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;COM&amp;quot;, COM)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Center_of_Mass]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|CenterOfMass]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Centroid&amp;diff=13638</id>
		<title>Centroid</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Centroid&amp;diff=13638"/>
		<updated>2010-06-30T18:38:18Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview == &lt;br /&gt;
[[COM]] is a small script that returns the value of the center of mass of your selection.  It also can translate the object of that selection to the origin.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
COM (selection=PyMOLSelection), [center=boolean]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# get the COM of the polymer&lt;br /&gt;
COM polymer&lt;br /&gt;
&lt;br /&gt;
# move some 'ligand' to the origin&lt;br /&gt;
COM ligand, center=True&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# Copyright (c) 2008, Jason Vertrees&lt;br /&gt;
# All rights reserved.&lt;br /&gt;
#&lt;br /&gt;
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following&lt;br /&gt;
# conditions are met:&lt;br /&gt;
#&lt;br /&gt;
#     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer.&lt;br /&gt;
#     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
#     * Neither the name of the &amp;lt;ORGANIZATION&amp;gt; nor the names of its contributors may be used to endorse or promote products derived&lt;br /&gt;
#     * from this software without specific prior written permission.&lt;br /&gt;
#&lt;br /&gt;
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT&lt;br /&gt;
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL&lt;br /&gt;
# THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES&lt;br /&gt;
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE&lt;br /&gt;
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2008-09-26&lt;br /&gt;
# REV   : 1&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def COM(selection, center=False):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        centerOfMass: get the center of mass of selection or move selection to the origin.&lt;br /&gt;
        param: selection -- a valid PyMOL selection&lt;br /&gt;
        param: center    -- (boolean) if (False) return the center of mass, else if (True) center the selection&lt;br /&gt;
        returns: center of mass: [ xCOM, yCOM, zCOM ]&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        model = cmd.get_model(selection)&lt;br /&gt;
        nAtom = len(model.atom)&lt;br /&gt;
&lt;br /&gt;
        COM = numpy.array([0.,0.,0.])&lt;br /&gt;
        stored.curLoc = []&lt;br /&gt;
&lt;br /&gt;
        for a in model.atom:&lt;br /&gt;
                COM += numpy.array(a.coord)&lt;br /&gt;
                if ( center ):&lt;br /&gt;
                        stored.curLoc.append( a.coord )&lt;br /&gt;
        COM /= float(nAtom)&lt;br /&gt;
&lt;br /&gt;
        if ( center ):&lt;br /&gt;
                stored.curLoc = (numpy.array(stored.curLoc) - COM).tolist()&lt;br /&gt;
                cmd.alter_state(1, selection, &amp;quot;(x,y,z)=stored.curLoc.pop(0)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        return COM.tolist()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;COM&amp;quot;, COM)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Center of Mass]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|CenterOfMass]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Com&amp;diff=3475</id>
		<title>Com</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Com&amp;diff=3475"/>
		<updated>2010-06-30T18:38:18Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview == &lt;br /&gt;
[[COM]] is a small script that returns the value of the center of mass of your selection.  It also can translate the object of that selection to the origin.&lt;br /&gt;
&lt;br /&gt;
== Syntax ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
COM (selection=PyMOLSelection), [center=boolean]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# get the COM of the polymer&lt;br /&gt;
COM polymer&lt;br /&gt;
&lt;br /&gt;
# move some 'ligand' to the origin&lt;br /&gt;
COM ligand, center=True&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# Copyright (c) 2008, Jason Vertrees&lt;br /&gt;
# All rights reserved.&lt;br /&gt;
#&lt;br /&gt;
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following&lt;br /&gt;
# conditions are met:&lt;br /&gt;
#&lt;br /&gt;
#     * Redistributions of source code must retain the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer.&lt;br /&gt;
#     * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following&lt;br /&gt;
#     * disclaimer in the documentation and/or other materials provided with the distribution.&lt;br /&gt;
#     * Neither the name of the &amp;lt;ORGANIZATION&amp;gt; nor the names of its contributors may be used to endorse or promote products derived&lt;br /&gt;
#     * from this software without specific prior written permission.&lt;br /&gt;
#&lt;br /&gt;
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &amp;quot;AS IS&amp;quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT&lt;br /&gt;
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL&lt;br /&gt;
# THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES&lt;br /&gt;
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS&lt;br /&gt;
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE&lt;br /&gt;
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2008-09-26&lt;br /&gt;
# REV   : 1&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def COM(selection, center=False):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        centerOfMass: get the center of mass of selection or move selection to the origin.&lt;br /&gt;
        param: selection -- a valid PyMOL selection&lt;br /&gt;
        param: center    -- (boolean) if (False) return the center of mass, else if (True) center the selection&lt;br /&gt;
        returns: center of mass: [ xCOM, yCOM, zCOM ]&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        model = cmd.get_model(selection)&lt;br /&gt;
        nAtom = len(model.atom)&lt;br /&gt;
&lt;br /&gt;
        COM = numpy.array([0.,0.,0.])&lt;br /&gt;
        stored.curLoc = []&lt;br /&gt;
&lt;br /&gt;
        for a in model.atom:&lt;br /&gt;
                COM += numpy.array(a.coord)&lt;br /&gt;
                if ( center ):&lt;br /&gt;
                        stored.curLoc.append( a.coord )&lt;br /&gt;
        COM /= float(nAtom)&lt;br /&gt;
&lt;br /&gt;
        if ( center ):&lt;br /&gt;
                stored.curLoc = (numpy.array(stored.curLoc) - COM).tolist()&lt;br /&gt;
                cmd.alter_state(1, selection, &amp;quot;(x,y,z)=stored.curLoc.pop(0)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
        return COM.tolist()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;COM&amp;quot;, COM)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Center of Mass]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|CenterOfMass]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Talk:Axpymol&amp;diff=167</id>
		<title>Talk:Axpymol</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Talk:Axpymol&amp;diff=167"/>
		<updated>2010-06-10T21:14:47Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Does this mean that AxPyMOL is no longer supported or that it is built into the regular distribution?&lt;br /&gt;
&lt;br /&gt;
Never mind, I found the answer on the PyMOL homepage.  Thanks!&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Talk:Axpymol&amp;diff=166</id>
		<title>Talk:Axpymol</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Talk:Axpymol&amp;diff=166"/>
		<updated>2010-06-10T21:13:21Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Created page with 'Does this mean that AxPyMOL is no longer supported or that it is built into the regular distribution?'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Does this mean that AxPyMOL is no longer supported or that it is built into the regular distribution?&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Main_Page&amp;diff=4780</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Main_Page&amp;diff=4780"/>
		<updated>2010-05-28T16:03:07Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; style=&amp;quot;padding-bottom: 4em;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size:210%; font-weight: bold; color:#032d45; text-align:center; padding: 5px; margin-bottom: 4px;&amp;quot; | Welcome to the PyMOL Wiki!&lt;br /&gt;
|- style=&amp;quot;text-align:center; font-weight:bold; color: #6d6003; font-size: 140%; font-style: italic; font-family: serif;&amp;quot;&lt;br /&gt;
| The community-run support site for the [http://pymol.org PyMOL] molecular viewer.&lt;br /&gt;
|}&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; width=&amp;quot;45%&amp;quot; style=&amp;quot;background: #EDEBD5; margin-bottom: 4em; border-bottom: 1px solid #AFB29E; border-left: 1px solid #AFB29E; border-right: 1px solid #AFB29E;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.4em; font-weight: bold; color: #032d45; text-align:center; background: #5F7F96; padding-top:0.5em; padding-bottom: 0.25em; border-top: 2px solid #AFB29E; border-bottom: 1px solid #fff;&amp;quot; |Quick Links&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;font-size: 1.1em; color #61021F; padding: 0.5em 1em 0.5em 3em;&amp;quot;|'''[[:Category:Tutorials|Tutorials]]''' || '''[[TOPTOC|Table of Contents]]''' || '''[[:Category:Commands|Commands]]'''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-size: 1.1em; color #61021F; padding: 0.5em 1em 0.5em 3em;&amp;quot;|'''[[:Category:Script_Library|Script Library]]''' || '''[[:Category:Plugins|Plugins]]''' || '''[[:Category:FAQ|FAQ]]'''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-size: 1.1em; color #61021F; padding: 0.5em 1em 0.5em 3em;&amp;quot;|'''[[Gallery]]''' | '''[[Covers]]'''&lt;br /&gt;
||'''[[CheatSheet|PyMOL Cheat Sheet]]''' (''[[Media:PymolRef.pdf|PDF]]'')&lt;br /&gt;
||'''[[GoogleSearch]]'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;100%&amp;quot;&lt;br /&gt;
| style=&amp;quot;vertical-align: top; width: 40%&amp;quot; |&lt;br /&gt;
{| class=&amp;quot;jtable&amp;quot; style=&amp;quot;float: left; width: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.4em; font-weight: bold; text-align:left; border-bottom: 2px solid #6678b1;&amp;quot; | News &amp;amp;amp; Updates&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| [[Center Of Mass]] has been re-written to calculate either the center-of-geometry or (mass-weighted) center-of-mass for a given selection and represents that selection as a pseudoatom (rather than a CGO sphere).  &lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| [[Jump]] is a tool for jumping from one frame to another when you have a movie, MD simulation, or multiple models loaded into PyMOL.&lt;br /&gt;
|-&lt;br /&gt;
! New Scripts&lt;br /&gt;
| [[ResDe]] is a suite of programs designed to assist crystallographers in defining user defined hydrogen bond distance restraints, which can be helpful when refining low-resolution structures.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[BiologicalUnit]], for a workaround to the buggy [[Symexp]] command or if you just want to learn more about symmetry expansion in PyMOL.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[Supercell]], the new script for making XxYxZ supercells.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[Split_Object_Along_Axis]], for a script that allows one to select a bond, and then generate 2 selections: one for the selection of all atoms that are on one side of this bond, and the other selection for the atoms on the other side of the bond.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[Consistent_View/_Map_Inspect]], which is a toolkit for rapidly inspecting multiple maps and models.&lt;br /&gt;
|-&lt;br /&gt;
! Server updates&lt;br /&gt;
| The underlying servers upon which the PyMOLWiki runs were upgraded over the weekend.  We are now fully functional.  A '''deep''' thanks to [http://www.bitgnome.net BitGnome] for donating time and hardware for the PyMOL project.&lt;br /&gt;
|-&lt;br /&gt;
! fetch_host setting&lt;br /&gt;
| [[Fetch_Host]] has been added to allow users to download PDBs from their PDB server (pdb, pdb euro, or pdb japan) of choice.&lt;br /&gt;
|-&lt;br /&gt;
! Fetch&lt;br /&gt;
| [[Fetch]] has been updated to also load electron density maps.&lt;br /&gt;
|-&lt;br /&gt;
! Schrodinger Buys PyMOL&lt;br /&gt;
| Schrodinger has purchased PyMOL.  Development, support and open-source fun to continue!  Read about the [http://www.schrodinger.com/news/47/ sale].&lt;br /&gt;
|-&lt;br /&gt;
! User Movie&lt;br /&gt;
| One of our users has posted another [http://www.youtube.com/watch?v=eQWw6x3fLF0 interesting movie], images from which were created with PyMOL.  &lt;br /&gt;
|-&lt;br /&gt;
! New setting&lt;br /&gt;
| [[surface_cavity_mode]] to change how PyMOL displays cavities.&lt;br /&gt;
|-&lt;br /&gt;
! Search fixed.&lt;br /&gt;
| Thanks to a eagle-eyed user, our search has been fixed.  Please let us know if you have any search-related problems.&lt;br /&gt;
|-&lt;br /&gt;
! New Command&lt;br /&gt;
| [[Cache]]&amp;amp;mdash;stores information on structures, so we don't have to recompute them.&lt;br /&gt;
|-&lt;br /&gt;
! Warren &lt;br /&gt;
| News about Warren DeLano's passing may be read on [[Warren|Warren's memorial page]].&lt;br /&gt;
|-&lt;br /&gt;
! Setting&lt;br /&gt;
| [[Fetch_Path]]&amp;amp;mdash;Sets the default path for the [[fetch]] command.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| [[SelInside]]&amp;amp;mdash;Creates a custom selection of all atoms spatially inside some user-defined box.&lt;br /&gt;
|}&lt;br /&gt;
|style=&amp;quot;vertical-align: top; width: 40%&amp;quot;|&lt;br /&gt;
{| class=&amp;quot;jtable&amp;quot; style=&amp;quot;float: right; width: 90%&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.4em; font-weight: bold; text-align:left; border-bottom: 2px solid #6678b1;&amp;quot; |Did you know...&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;div class=&amp;quot;didyouknow&amp;quot; &amp;gt;&lt;br /&gt;
&amp;lt;DPL&amp;gt;&lt;br /&gt;
namespace=&lt;br /&gt;
category=Commands|Plugins|Script_Library|Settings&lt;br /&gt;
includepage=*&lt;br /&gt;
includemaxlength=450&lt;br /&gt;
escapelinks=false&lt;br /&gt;
resultsheader=__NOTOC__ __NOEDITSECTION__&lt;br /&gt;
randomcount=1&lt;br /&gt;
mode=userformat&lt;br /&gt;
addpagecounter=true&lt;br /&gt;
listseparators=,&amp;lt;h3&amp;gt;[[%PAGE%]]&amp;lt;/h3&amp;gt;,,\n&lt;br /&gt;
&amp;lt;/DPL&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
|&lt;br /&gt;
|style=&amp;quot;vertical-align: top; width: 18%&amp;quot;|&lt;br /&gt;
&amp;lt;DPL&amp;gt;&lt;br /&gt;
imagecontainer=Covers&lt;br /&gt;
randomcount=1&lt;br /&gt;
escapelinks=false&lt;br /&gt;
openreferences=true&lt;br /&gt;
listseparators=[[,%PAGE%,|thumb|185px|A Random PyMOL-generated Cover.  See [[Covers]].]],\n&lt;br /&gt;
ordermethod=none&lt;br /&gt;
&amp;lt;/DPL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Main_Page&amp;diff=4779</id>
		<title>Main Page</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Main_Page&amp;diff=4779"/>
		<updated>2010-05-28T16:02:39Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; style=&amp;quot;padding-bottom: 4em;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size:210%; font-weight: bold; color:#032d45; text-align:center; padding: 5px; margin-bottom: 4px;&amp;quot; | Welcome to the PyMOL Wiki!&lt;br /&gt;
|- style=&amp;quot;text-align:center; font-weight:bold; color: #6d6003; font-size: 140%; font-style: italic; font-family: serif;&amp;quot;&lt;br /&gt;
| The community-run support site for the [http://pymol.org PyMOL] molecular viewer.&lt;br /&gt;
|}&lt;br /&gt;
{| align=&amp;quot;center&amp;quot; width=&amp;quot;45%&amp;quot; style=&amp;quot;background: #EDEBD5; margin-bottom: 4em; border-bottom: 1px solid #AFB29E; border-left: 1px solid #AFB29E; border-right: 1px solid #AFB29E;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.4em; font-weight: bold; color: #032d45; text-align:center; background: #5F7F96; padding-top:0.5em; padding-bottom: 0.25em; border-top: 2px solid #AFB29E; border-bottom: 1px solid #fff;&amp;quot; |Quick Links&lt;br /&gt;
|- &lt;br /&gt;
| style=&amp;quot;font-size: 1.1em; color #61021F; padding: 0.5em 1em 0.5em 3em;&amp;quot;|'''[[:Category:Tutorials|Tutorials]]''' || '''[[TOPTOC|Table of Contents]]''' || '''[[:Category:Commands|Commands]]'''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-size: 1.1em; color #61021F; padding: 0.5em 1em 0.5em 3em;&amp;quot;|'''[[:Category:Script_Library|Script Library]]''' || '''[[:Category:Plugins|Plugins]]''' || '''[[:Category:FAQ|FAQ]]'''&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;font-size: 1.1em; color #61021F; padding: 0.5em 1em 0.5em 3em;&amp;quot;|'''[[Gallery]]''' | '''[[Covers]]'''&lt;br /&gt;
||'''[[CheatSheet|PyMOL Cheat Sheet]]''' (''[[Media:PymolRef.pdf|PDF]]'')&lt;br /&gt;
||'''[[GoogleSearch]]'''&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;100%&amp;quot;&lt;br /&gt;
| style=&amp;quot;vertical-align: top; width: 40%&amp;quot; |&lt;br /&gt;
{| class=&amp;quot;jtable&amp;quot; style=&amp;quot;float: left; width: 90%;&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.4em; font-weight: bold; text-align:left; border-bottom: 2px solid #6678b1;&amp;quot; | News &amp;amp;amp; Updates&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| [[Center Of Mass]] has been re-written to calculate either the center-of-geometry or (mass-weighted) center-of-mass for a given selection and represents that selection as a pseudoatom (rather than a CGO sphere).  This script provides three improvements to the previous script: 1) The real center-of-mass can be calculated based on a table of atomic masses, 2) pseudoatoms are used to represent the center-of-mass which, unlike CGO spheres, can be used to measure distances, angles, etc, 3) The COM/COG calculator is written as an independent function which can be called as &amp;quot;get_com&amp;quot;.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| [[Jump]] is a tool for jumping from one frame to another when you have a movie, MD simulation, or multiple models loaded into PyMOL.&lt;br /&gt;
|-&lt;br /&gt;
! New Scripts&lt;br /&gt;
| [[ResDe]] is a suite of programs designed to assist crystallographers in defining user defined hydrogen bond distance restraints, which can be helpful when refining low-resolution structures.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[BiologicalUnit]], for a workaround to the buggy [[Symexp]] command or if you just want to learn more about symmetry expansion in PyMOL.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[Supercell]], the new script for making XxYxZ supercells.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[Split_Object_Along_Axis]], for a script that allows one to select a bond, and then generate 2 selections: one for the selection of all atoms that are on one side of this bond, and the other selection for the atoms on the other side of the bond.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| See [[Consistent_View/_Map_Inspect]], which is a toolkit for rapidly inspecting multiple maps and models.&lt;br /&gt;
|-&lt;br /&gt;
! Server updates&lt;br /&gt;
| The underlying servers upon which the PyMOLWiki runs were upgraded over the weekend.  We are now fully functional.  A '''deep''' thanks to [http://www.bitgnome.net BitGnome] for donating time and hardware for the PyMOL project.&lt;br /&gt;
|-&lt;br /&gt;
! fetch_host setting&lt;br /&gt;
| [[Fetch_Host]] has been added to allow users to download PDBs from their PDB server (pdb, pdb euro, or pdb japan) of choice.&lt;br /&gt;
|-&lt;br /&gt;
! Fetch&lt;br /&gt;
| [[Fetch]] has been updated to also load electron density maps.&lt;br /&gt;
|-&lt;br /&gt;
! Schrodinger Buys PyMOL&lt;br /&gt;
| Schrodinger has purchased PyMOL.  Development, support and open-source fun to continue!  Read about the [http://www.schrodinger.com/news/47/ sale].&lt;br /&gt;
|-&lt;br /&gt;
! User Movie&lt;br /&gt;
| One of our users has posted another [http://www.youtube.com/watch?v=eQWw6x3fLF0 interesting movie], images from which were created with PyMOL.  &lt;br /&gt;
|-&lt;br /&gt;
! New setting&lt;br /&gt;
| [[surface_cavity_mode]] to change how PyMOL displays cavities.&lt;br /&gt;
|-&lt;br /&gt;
! Search fixed.&lt;br /&gt;
| Thanks to a eagle-eyed user, our search has been fixed.  Please let us know if you have any search-related problems.&lt;br /&gt;
|-&lt;br /&gt;
! New Command&lt;br /&gt;
| [[Cache]]&amp;amp;mdash;stores information on structures, so we don't have to recompute them.&lt;br /&gt;
|-&lt;br /&gt;
! Warren &lt;br /&gt;
| News about Warren DeLano's passing may be read on [[Warren|Warren's memorial page]].&lt;br /&gt;
|-&lt;br /&gt;
! Setting&lt;br /&gt;
| [[Fetch_Path]]&amp;amp;mdash;Sets the default path for the [[fetch]] command.&lt;br /&gt;
|-&lt;br /&gt;
! New Script&lt;br /&gt;
| [[SelInside]]&amp;amp;mdash;Creates a custom selection of all atoms spatially inside some user-defined box.&lt;br /&gt;
|}&lt;br /&gt;
|style=&amp;quot;vertical-align: top; width: 40%&amp;quot;|&lt;br /&gt;
{| class=&amp;quot;jtable&amp;quot; style=&amp;quot;float: right; width: 90%&amp;quot;&lt;br /&gt;
|+ style=&amp;quot;font-size: 1.4em; font-weight: bold; text-align:left; border-bottom: 2px solid #6678b1;&amp;quot; |Did you know...&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;div class=&amp;quot;didyouknow&amp;quot; &amp;gt;&lt;br /&gt;
&amp;lt;DPL&amp;gt;&lt;br /&gt;
namespace=&lt;br /&gt;
category=Commands|Plugins|Script_Library|Settings&lt;br /&gt;
includepage=*&lt;br /&gt;
includemaxlength=450&lt;br /&gt;
escapelinks=false&lt;br /&gt;
resultsheader=__NOTOC__ __NOEDITSECTION__&lt;br /&gt;
randomcount=1&lt;br /&gt;
mode=userformat&lt;br /&gt;
addpagecounter=true&lt;br /&gt;
listseparators=,&amp;lt;h3&amp;gt;[[%PAGE%]]&amp;lt;/h3&amp;gt;,,\n&lt;br /&gt;
&amp;lt;/DPL&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
|&lt;br /&gt;
|style=&amp;quot;vertical-align: top; width: 18%&amp;quot;|&lt;br /&gt;
&amp;lt;DPL&amp;gt;&lt;br /&gt;
imagecontainer=Covers&lt;br /&gt;
randomcount=1&lt;br /&gt;
escapelinks=false&lt;br /&gt;
openreferences=true&lt;br /&gt;
listseparators=[[,%PAGE%,|thumb|185px|A Random PyMOL-generated Cover.  See [[Covers]].]],\n&lt;br /&gt;
ordermethod=none&lt;br /&gt;
&amp;lt;/DPL&amp;gt;&lt;br /&gt;
&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5048</id>
		<title>Center of mass</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5048"/>
		<updated>2010-05-27T13:39:39Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
This script calculates the true center-of-mass (COM) or the center-of-geometry (COG) for a given selection and returns the x, y, z values in the form of a [[Pseudoatom]] (rather than a CGO sphere).  The benefit of using a [[Pseudoatom]] is that it can be selected and used in calculations.  In addition, this script also iteratively goes through all states of a selection if more than one state exists and appends the corresponding COM/COG values as states into the [[Pseudoatom]].  The script itself is quite simple yet robust enough to be applied in different settings.  As well, the calculation of the COM/COG is handled independently from the formation of the [[Pseudoatom]] and can be called as an independent function where applicable.&lt;br /&gt;
&lt;br /&gt;
Note: In order to use the [[Pseudoatom]] in your measurements (i.e. distance), you need to invoke the distance calculation directly via the command line using the [[Distance]] function and not via the Wizard!&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
com selection [,state=None [,mass=None [,name=None]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fetch 1c3y, finish=1, multiplex=0&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1&lt;br /&gt;
#Create a pseudoatom representing the 1c3y COG and store it as &amp;quot;1c3y_COM&amp;quot;&lt;br /&gt;
#The &amp;quot;1c3y_COM&amp;quot; object will contain 1 state only&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COG&lt;br /&gt;
#Create a pseudoatom representing the 1c3y COG and store it as &amp;quot;COG&amp;quot;&lt;br /&gt;
#The &amp;quot;COG&amp;quot; object will contain 1 state only&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COM, mass=1&lt;br /&gt;
#Create a pseudoatom representing the 1c3y COM and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
#The &amp;quot;COM&amp;quot; object will contain 1 state only&lt;br /&gt;
&lt;br /&gt;
com 1c3y, name=COM, mass=1&lt;br /&gt;
#Create a single pseudoatom containing the COM for each state found in 1c3y and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
#The &amp;quot;COM&amp;quot; object will contain MULTIPLE states!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
&lt;br /&gt;
def com (selection,state=None,mass=None,name=None):&lt;br /&gt;
   &lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   if (name == None):&lt;br /&gt;
      name=selection+&amp;quot;_COM&amp;quot;&lt;br /&gt;
   cmd.delete(name)&lt;br /&gt;
   &lt;br /&gt;
   if (state != None):&lt;br /&gt;
      x, y, z=get_com(selection,mass=mass)&lt;br /&gt;
      print &amp;quot;%f %f %f&amp;quot; % (x, y, z)&lt;br /&gt;
      cmd.pseudoatom(name,pos=[x, y, z])&lt;br /&gt;
      cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   else:&lt;br /&gt;
      for i in range(cmd.count_states()):&lt;br /&gt;
         x, y, z=get_com(selection,mass=mass,state=i+1)&lt;br /&gt;
         print &amp;quot;State %d:%f %f %f&amp;quot; % (i+1, x, y, z)&lt;br /&gt;
         cmd.pseudoatom(name,pos=[x, y, z],state=i+1)&lt;br /&gt;
         cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   &lt;br /&gt;
   return&lt;br /&gt;
 &lt;br /&gt;
cmd.extend(&amp;quot;com&amp;quot;,com)&lt;br /&gt;
&lt;br /&gt;
def get_com (selection,state=1,mass=None):&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   atmass={'H':1.00800000000000, 'C':12.0110000000000, \&lt;br /&gt;
              'N':14.0070000000000, 'O':15.9994000000000, \&lt;br /&gt;
              'P':30.9740000000000, 'S':32.0600000000000, \&lt;br /&gt;
              'F':18.9980000000000&lt;br /&gt;
           }&lt;br /&gt;
   &lt;br /&gt;
   totmass=0.0&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      print &amp;quot;Calculating mass-weighted COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   state=int(state)&lt;br /&gt;
   model = cmd.get_model(selection,state)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
      if (mass != None):&lt;br /&gt;
         if (a.name[0] in atmass):&lt;br /&gt;
            x+= a.coord[0]*atmass[a.name[0]]&lt;br /&gt;
            y+= a.coord[1]*atmass[a.name[0]]&lt;br /&gt;
            z+= a.coord[2]*atmass[a.name[0]]&lt;br /&gt;
            totmass+=atmass[a.name[0]]&lt;br /&gt;
         else:&lt;br /&gt;
            print &amp;quot;Please add atomic mass for &amp;quot;+a.name+&amp;quot; to atmass&amp;quot;&lt;br /&gt;
            return&lt;br /&gt;
      else:&lt;br /&gt;
         x+= a.coord[0]&lt;br /&gt;
         y+= a.coord[1]&lt;br /&gt;
         z+= a.coord[2]&lt;br /&gt;
&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      return x/totmass, y/totmass, z/totmass&lt;br /&gt;
   else:&lt;br /&gt;
      return x/len(model.atom), y/len(model.atom), z/len(model.atom)&lt;br /&gt;
cmd.extend(&amp;quot;get_com&amp;quot;, get_com)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Previous Implementation===&lt;br /&gt;
&lt;br /&gt;
Here is a script that calculates the center of geometry from a selection. &lt;br /&gt;
It gets hold of the coordinates with cmd.get_model.&lt;br /&gt;
Make sure the atoms in the selection are of equal weight. &lt;br /&gt;
&lt;br /&gt;
For a sample application, see: [http://yggdrasil.biotec.tu-dresden.de/abac/b.47.1.2___b.16.1.1___g.4.1.1.html &amp;quot;Convergent Evolution Examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
## Author: Andreas Henschel 2006&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol.cgo import *&lt;br /&gt;
&lt;br /&gt;
def centerOfMass(selection):&lt;br /&gt;
   ## assumes equal weights (best called with &amp;quot;and name ca&amp;quot; suffix)&lt;br /&gt;
   model = cmd.get_model(selection)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
       x+= a.coord[0]&lt;br /&gt;
       y+= a.coord[1]&lt;br /&gt;
       z+= a.coord[2]&lt;br /&gt;
   return (x/len(model.atom), y/len(model.atom), z/len(model.atom))&lt;br /&gt;
&lt;br /&gt;
cmd.load(&amp;quot;/group/bioinf/Data/PDBLinks/1c7c.pdb&amp;quot;)&lt;br /&gt;
cmd.select(&amp;quot;domain&amp;quot;, &amp;quot;/1c7c//A/143-283/ and name ca&amp;quot;) ## selecting a domain&lt;br /&gt;
&lt;br /&gt;
domainCenter=centerOfMass(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Center of mass: (%.1f,%.1f,%.1f)&amp;quot;% domainCenter&lt;br /&gt;
cmd.as(&amp;quot;cartoon&amp;quot;, &amp;quot;all&amp;quot;)&lt;br /&gt;
cmd.show(&amp;quot;spheres&amp;quot;, &amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Creating a sphere CGO&lt;br /&gt;
com = [COLOR, 1.0, 1.0, 1.0, SPHERE]+list(domainCenter) + [3.0] ## white sphere with 3A radius&lt;br /&gt;
cmd.load_cgo(com, &amp;quot;CoM&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
cmd.zoom(&amp;quot;1c7c&amp;quot;, 1.0)&lt;br /&gt;
cmd.center(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ pymol -qc centerOfMass4.py&lt;br /&gt;
#Center of mass: (-1.0,24.5,48.2)&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|Center of Mass]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5047</id>
		<title>Center of mass</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5047"/>
		<updated>2010-05-27T02:32:42Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
This script calculates the true center-of-mass (COM) or the center-of-geometry (COG) for a given selection and returns the x, y, z values in the form of a [[Pseudoatom]] (rather than a CGO sphere).  The benefit of using a [[Pseudoatom]] is that it can be selected and used in calculations.  In addition, this script also iteratively goes through all states of a selection if more than one state exists and appends the corresponding COM/COG values as states into the [[Pseudoatom]].  The script itself is quite simple yet robust enough to be applied in different settings.  As well, the calculation of the COM/COG is handled independently from the formation of the [[Pseudoatom]] and can be called as an independent function where applicable.&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
com selection [,state=None [,mass=None [,name=None]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fetch 1c3y, finish=1, multiplex=0&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1&lt;br /&gt;
#Create a pseudoatom representing the 1c3y COG and store it as &amp;quot;1c3y_COM&amp;quot;&lt;br /&gt;
#The &amp;quot;1c3y_COM&amp;quot; object will contain 1 state only&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COG&lt;br /&gt;
#Create a pseudoatom representing the 1c3y COG and store it as &amp;quot;COG&amp;quot;&lt;br /&gt;
#The &amp;quot;COG&amp;quot; object will contain 1 state only&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COM, mass=1&lt;br /&gt;
#Create a pseudoatom representing the 1c3y COM and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
#The &amp;quot;COM&amp;quot; object will contain 1 state only&lt;br /&gt;
&lt;br /&gt;
com 1c3y, name=COM, mass=1&lt;br /&gt;
#Create a single pseudoatom containing the COM for each state found in 1c3y and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
#The &amp;quot;COM&amp;quot; object will contain MULTIPLE states!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
&lt;br /&gt;
def com (selection,state=None,mass=None,name=None):&lt;br /&gt;
   &lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   if (name == None):&lt;br /&gt;
      name=selection+&amp;quot;_COM&amp;quot;&lt;br /&gt;
   cmd.delete(name)&lt;br /&gt;
   &lt;br /&gt;
   if (state != None):&lt;br /&gt;
      x, y, z=get_com(selection,mass=mass)&lt;br /&gt;
      print &amp;quot;%f %f %f&amp;quot; % (x, y, z)&lt;br /&gt;
      cmd.pseudoatom(name,pos=[x, y, z])&lt;br /&gt;
      cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   else:&lt;br /&gt;
      for i in range(cmd.count_states()):&lt;br /&gt;
         x, y, z=get_com(selection,mass=mass,state=i+1)&lt;br /&gt;
         print &amp;quot;State %d:%f %f %f&amp;quot; % (i+1, x, y, z)&lt;br /&gt;
         cmd.pseudoatom(name,pos=[x, y, z],state=i+1)&lt;br /&gt;
         cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   &lt;br /&gt;
   return&lt;br /&gt;
 &lt;br /&gt;
cmd.extend(&amp;quot;com&amp;quot;,com)&lt;br /&gt;
&lt;br /&gt;
def get_com (selection,state=1,mass=None):&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   atmass={'H':1.00800000000000, 'C':12.0110000000000, \&lt;br /&gt;
              'N':14.0070000000000, 'O':15.9994000000000, \&lt;br /&gt;
              'P':30.9740000000000, 'S':32.0600000000000, \&lt;br /&gt;
              'F':18.9980000000000&lt;br /&gt;
           }&lt;br /&gt;
   &lt;br /&gt;
   totmass=0.0&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      print &amp;quot;Calculating mass-weighted COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   state=int(state)&lt;br /&gt;
   model = cmd.get_model(selection,state)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
      if (mass != None):&lt;br /&gt;
         if (a.name[0] in atmass):&lt;br /&gt;
            x+= a.coord[0]*atmass[a.name[0]]&lt;br /&gt;
            y+= a.coord[1]*atmass[a.name[0]]&lt;br /&gt;
            z+= a.coord[2]*atmass[a.name[0]]&lt;br /&gt;
            totmass+=atmass[a.name[0]]&lt;br /&gt;
         else:&lt;br /&gt;
            print &amp;quot;Please add atomic mass for &amp;quot;+a.name+&amp;quot; to atmass&amp;quot;&lt;br /&gt;
            return&lt;br /&gt;
      else:&lt;br /&gt;
         x+= a.coord[0]&lt;br /&gt;
         y+= a.coord[1]&lt;br /&gt;
         z+= a.coord[2]&lt;br /&gt;
&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      return x/totmass, y/totmass, z/totmass&lt;br /&gt;
   else:&lt;br /&gt;
      return x/len(model.atom), y/len(model.atom), z/len(model.atom)&lt;br /&gt;
cmd.extend(&amp;quot;get_com&amp;quot;, get_com)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Previous Implementation===&lt;br /&gt;
&lt;br /&gt;
Here is a script that calculates the center of geometry from a selection. &lt;br /&gt;
It gets hold of the coordinates with cmd.get_model.&lt;br /&gt;
Make sure the atoms in the selection are of equal weight. &lt;br /&gt;
&lt;br /&gt;
For a sample application, see: [http://yggdrasil.biotec.tu-dresden.de/abac/b.47.1.2___b.16.1.1___g.4.1.1.html &amp;quot;Convergent Evolution Examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
## Author: Andreas Henschel 2006&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol.cgo import *&lt;br /&gt;
&lt;br /&gt;
def centerOfMass(selection):&lt;br /&gt;
   ## assumes equal weights (best called with &amp;quot;and name ca&amp;quot; suffix)&lt;br /&gt;
   model = cmd.get_model(selection)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
       x+= a.coord[0]&lt;br /&gt;
       y+= a.coord[1]&lt;br /&gt;
       z+= a.coord[2]&lt;br /&gt;
   return (x/len(model.atom), y/len(model.atom), z/len(model.atom))&lt;br /&gt;
&lt;br /&gt;
cmd.load(&amp;quot;/group/bioinf/Data/PDBLinks/1c7c.pdb&amp;quot;)&lt;br /&gt;
cmd.select(&amp;quot;domain&amp;quot;, &amp;quot;/1c7c//A/143-283/ and name ca&amp;quot;) ## selecting a domain&lt;br /&gt;
&lt;br /&gt;
domainCenter=centerOfMass(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Center of mass: (%.1f,%.1f,%.1f)&amp;quot;% domainCenter&lt;br /&gt;
cmd.as(&amp;quot;cartoon&amp;quot;, &amp;quot;all&amp;quot;)&lt;br /&gt;
cmd.show(&amp;quot;spheres&amp;quot;, &amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Creating a sphere CGO&lt;br /&gt;
com = [COLOR, 1.0, 1.0, 1.0, SPHERE]+list(domainCenter) + [3.0] ## white sphere with 3A radius&lt;br /&gt;
cmd.load_cgo(com, &amp;quot;CoM&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
cmd.zoom(&amp;quot;1c7c&amp;quot;, 1.0)&lt;br /&gt;
cmd.center(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ pymol -qc centerOfMass4.py&lt;br /&gt;
#Center of mass: (-1.0,24.5,48.2)&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|Center of Mass]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5046</id>
		<title>Center of mass</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5046"/>
		<updated>2010-05-27T02:29:41Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
This script calculates the true center-of-mass (COM) or the center-of-geometry (COG) for a given selection and returns the x, y, z values in the form of a [[Pseudoatom]] (rather than a CGO sphere).  The benefit of using a [[Pseudoatom]] is that it can be selected and used in calculations.  In addition, this script also iteratively goes through all states of a selection if more than one state exists and appends the corresponding COM/COG values as states into the [[Pseudoatom]].  The script itself is quite simple yet robust enough to be applied in different settings.  As well, the calculation of the COM/COG is handled independently from the formation of the [[Pseudoatom]] and can be called as an independent function where applicable.&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
com selection [,state=None [,mass=None [,name=None]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fetch 1c3y, finish=1, multiplex=0&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1&lt;br /&gt;
#create a pseudoatom representing the 1c3y COG and store it as &amp;quot;1c3y_COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COG&lt;br /&gt;
#create a pseudoatom representing the 1c3y COG and store it as &amp;quot;COG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COM, mass=1&lt;br /&gt;
#create a pseudoatom representing the 1c3y COM and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
com 1c3y, name=COM, mass=1&lt;br /&gt;
#create a single pseudoatom containing the COM for each state found in 1c3y and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
&lt;br /&gt;
def com (selection,state=None,mass=None,name=None):&lt;br /&gt;
   &lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   if (name == None):&lt;br /&gt;
      name=selection+&amp;quot;_COM&amp;quot;&lt;br /&gt;
   cmd.delete(name)&lt;br /&gt;
   &lt;br /&gt;
   if (state != None):&lt;br /&gt;
      x, y, z=get_com(selection,mass=mass)&lt;br /&gt;
      print &amp;quot;%f %f %f&amp;quot; % (x, y, z)&lt;br /&gt;
      cmd.pseudoatom(name,pos=[x, y, z])&lt;br /&gt;
      cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   else:&lt;br /&gt;
      for i in range(cmd.count_states()):&lt;br /&gt;
         x, y, z=get_com(selection,mass=mass,state=i+1)&lt;br /&gt;
         print &amp;quot;State %d:%f %f %f&amp;quot; % (i+1, x, y, z)&lt;br /&gt;
         cmd.pseudoatom(name,pos=[x, y, z],state=i+1)&lt;br /&gt;
         cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   &lt;br /&gt;
   return&lt;br /&gt;
 &lt;br /&gt;
cmd.extend(&amp;quot;com&amp;quot;,com)&lt;br /&gt;
&lt;br /&gt;
def get_com (selection,state=1,mass=None):&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   atmass={'H':1.00800000000000, 'C':12.0110000000000, \&lt;br /&gt;
              'N':14.0070000000000, 'O':15.9994000000000, \&lt;br /&gt;
              'P':30.9740000000000, 'S':32.0600000000000, \&lt;br /&gt;
              'F':18.9980000000000&lt;br /&gt;
           }&lt;br /&gt;
   &lt;br /&gt;
   totmass=0.0&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      print &amp;quot;Calculating mass-weighted COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   state=int(state)&lt;br /&gt;
   model = cmd.get_model(selection,state)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
      if (mass != None):&lt;br /&gt;
         if (a.name[0] in atmass):&lt;br /&gt;
            x+= a.coord[0]*atmass[a.name[0]]&lt;br /&gt;
            y+= a.coord[1]*atmass[a.name[0]]&lt;br /&gt;
            z+= a.coord[2]*atmass[a.name[0]]&lt;br /&gt;
            totmass+=atmass[a.name[0]]&lt;br /&gt;
         else:&lt;br /&gt;
            print &amp;quot;Please add atomic mass for &amp;quot;+a.name+&amp;quot; to atmass&amp;quot;&lt;br /&gt;
            return&lt;br /&gt;
      else:&lt;br /&gt;
         x+= a.coord[0]&lt;br /&gt;
         y+= a.coord[1]&lt;br /&gt;
         z+= a.coord[2]&lt;br /&gt;
&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      return x/totmass, y/totmass, z/totmass&lt;br /&gt;
   else:&lt;br /&gt;
      return x/len(model.atom), y/len(model.atom), z/len(model.atom)&lt;br /&gt;
cmd.extend(&amp;quot;get_com&amp;quot;, get_com)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Previous Implementation===&lt;br /&gt;
&lt;br /&gt;
Here is a script that calculates the center of geometry from a selection. &lt;br /&gt;
It gets hold of the coordinates with cmd.get_model.&lt;br /&gt;
Make sure the atoms in the selection are of equal weight. &lt;br /&gt;
&lt;br /&gt;
For a sample application, see: [http://yggdrasil.biotec.tu-dresden.de/abac/b.47.1.2___b.16.1.1___g.4.1.1.html &amp;quot;Convergent Evolution Examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
## Author: Andreas Henschel 2006&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol.cgo import *&lt;br /&gt;
&lt;br /&gt;
def centerOfMass(selection):&lt;br /&gt;
   ## assumes equal weights (best called with &amp;quot;and name ca&amp;quot; suffix)&lt;br /&gt;
   model = cmd.get_model(selection)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
       x+= a.coord[0]&lt;br /&gt;
       y+= a.coord[1]&lt;br /&gt;
       z+= a.coord[2]&lt;br /&gt;
   return (x/len(model.atom), y/len(model.atom), z/len(model.atom))&lt;br /&gt;
&lt;br /&gt;
cmd.load(&amp;quot;/group/bioinf/Data/PDBLinks/1c7c.pdb&amp;quot;)&lt;br /&gt;
cmd.select(&amp;quot;domain&amp;quot;, &amp;quot;/1c7c//A/143-283/ and name ca&amp;quot;) ## selecting a domain&lt;br /&gt;
&lt;br /&gt;
domainCenter=centerOfMass(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Center of mass: (%.1f,%.1f,%.1f)&amp;quot;% domainCenter&lt;br /&gt;
cmd.as(&amp;quot;cartoon&amp;quot;, &amp;quot;all&amp;quot;)&lt;br /&gt;
cmd.show(&amp;quot;spheres&amp;quot;, &amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Creating a sphere CGO&lt;br /&gt;
com = [COLOR, 1.0, 1.0, 1.0, SPHERE]+list(domainCenter) + [3.0] ## white sphere with 3A radius&lt;br /&gt;
cmd.load_cgo(com, &amp;quot;CoM&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
cmd.zoom(&amp;quot;1c7c&amp;quot;, 1.0)&lt;br /&gt;
cmd.center(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ pymol -qc centerOfMass4.py&lt;br /&gt;
#Center of mass: (-1.0,24.5,48.2)&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|Center of Mass]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5045</id>
		<title>Center of mass</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Center_of_mass&amp;diff=5045"/>
		<updated>2010-05-27T02:29:13Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
This script calculates the true center-of-mass (COM) or the center-of-geometry (COG) for a given selection and returns the x, y, z values in the form of a [[Pseudoatom]] (rather than a CGO sphere).  The benefit of using a [[Pseudoatom]] is that it can be selected and used in calculations.  In addition, this script also iteratively goes through all states of a selection if more than one state exists and appends the corresponding COM/COG values as states into the [[Pseudoatom]].  The script itself is quite simple yet robust enough to be applied in different settings.  As well, the calculation of the COM/COG is handled independently from the formation of the [[Pseudoatom]] and can be called as an independent function where applicable.&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
com selection [,state=None [,mass=None [,name=None]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;gt;&lt;br /&gt;
fetch 1c3y, finish=1, multiplex=0&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1&lt;br /&gt;
#create a pseudoatom representing the 1c3y COG and store it as &amp;quot;1c3y_COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COG&lt;br /&gt;
#create a pseudoatom representing the 1c3y COG and store it as &amp;quot;COG&amp;quot;&lt;br /&gt;
&lt;br /&gt;
com 1c3y, state=1, name=COM, mass=1&lt;br /&gt;
#create a pseudoatom representing the 1c3y COM and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
com 1c3y, name=COM, mass=1&lt;br /&gt;
#create a single pseudoatom containing the COM for each state found in 1c3y and store it as &amp;quot;COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
&lt;br /&gt;
def com (selection,state=None,mass=None,name=None):&lt;br /&gt;
   &lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   if (name == None):&lt;br /&gt;
      name=selection+&amp;quot;_COM&amp;quot;&lt;br /&gt;
   cmd.delete(name)&lt;br /&gt;
   &lt;br /&gt;
   if (state != None):&lt;br /&gt;
      x, y, z=get_com(selection,mass=mass)&lt;br /&gt;
      print &amp;quot;%f %f %f&amp;quot; % (x, y, z)&lt;br /&gt;
      cmd.pseudoatom(name,pos=[x, y, z])&lt;br /&gt;
      cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   else:&lt;br /&gt;
      for i in range(cmd.count_states()):&lt;br /&gt;
         x, y, z=get_com(selection,mass=mass,state=i+1)&lt;br /&gt;
         print &amp;quot;State %d:%f %f %f&amp;quot; % (i+1, x, y, z)&lt;br /&gt;
         cmd.pseudoatom(name,pos=[x, y, z],state=i+1)&lt;br /&gt;
         cmd.show(&amp;quot;spheres&amp;quot;,name)&lt;br /&gt;
   &lt;br /&gt;
   return&lt;br /&gt;
 &lt;br /&gt;
cmd.extend(&amp;quot;com&amp;quot;,com)&lt;br /&gt;
&lt;br /&gt;
def get_com (selection,state=1,mass=None):&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
   Author: Sean Law&lt;br /&gt;
   Michigan State University&lt;br /&gt;
   slaw (at) msu . edu&lt;br /&gt;
   &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   atmass={'H':1.00800000000000, 'C':12.0110000000000, \&lt;br /&gt;
              'N':14.0070000000000, 'O':15.9994000000000, \&lt;br /&gt;
              'P':30.9740000000000, 'S':32.0600000000000, \&lt;br /&gt;
              'F':18.9980000000000&lt;br /&gt;
           }&lt;br /&gt;
   &lt;br /&gt;
   totmass=0.0&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      print &amp;quot;Calculating mass-weighted COM&amp;quot;&lt;br /&gt;
&lt;br /&gt;
   state=int(state)&lt;br /&gt;
   model = cmd.get_model(selection,state)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
      if (mass != None):&lt;br /&gt;
         if (a.name[0] in atmass):&lt;br /&gt;
            x+= a.coord[0]*atmass[a.name[0]]&lt;br /&gt;
            y+= a.coord[1]*atmass[a.name[0]]&lt;br /&gt;
            z+= a.coord[2]*atmass[a.name[0]]&lt;br /&gt;
            totmass+=atmass[a.name[0]]&lt;br /&gt;
         else:&lt;br /&gt;
            print &amp;quot;Please add atomic mass for &amp;quot;+a.name+&amp;quot; to atmass&amp;quot;&lt;br /&gt;
            return&lt;br /&gt;
      else:&lt;br /&gt;
         x+= a.coord[0]&lt;br /&gt;
         y+= a.coord[1]&lt;br /&gt;
         z+= a.coord[2]&lt;br /&gt;
&lt;br /&gt;
   if (mass!=None):&lt;br /&gt;
      return x/totmass, y/totmass, z/totmass&lt;br /&gt;
   else:&lt;br /&gt;
      return x/len(model.atom), y/len(model.atom), z/len(model.atom)&lt;br /&gt;
cmd.extend(&amp;quot;get_com&amp;quot;, get_com)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Previous Implementation===&lt;br /&gt;
&lt;br /&gt;
Here is a script that calculates the center of geometry from a selection. &lt;br /&gt;
It gets hold of the coordinates with cmd.get_model.&lt;br /&gt;
Make sure the atoms in the selection are of equal weight. &lt;br /&gt;
&lt;br /&gt;
For a sample application, see: [http://yggdrasil.biotec.tu-dresden.de/abac/b.47.1.2___b.16.1.1___g.4.1.1.html &amp;quot;Convergent Evolution Examples&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
## Author: Andreas Henschel 2006&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol.cgo import *&lt;br /&gt;
&lt;br /&gt;
def centerOfMass(selection):&lt;br /&gt;
   ## assumes equal weights (best called with &amp;quot;and name ca&amp;quot; suffix)&lt;br /&gt;
   model = cmd.get_model(selection)&lt;br /&gt;
   x,y,z=0,0,0&lt;br /&gt;
   for a in model.atom:&lt;br /&gt;
       x+= a.coord[0]&lt;br /&gt;
       y+= a.coord[1]&lt;br /&gt;
       z+= a.coord[2]&lt;br /&gt;
   return (x/len(model.atom), y/len(model.atom), z/len(model.atom))&lt;br /&gt;
&lt;br /&gt;
cmd.load(&amp;quot;/group/bioinf/Data/PDBLinks/1c7c.pdb&amp;quot;)&lt;br /&gt;
cmd.select(&amp;quot;domain&amp;quot;, &amp;quot;/1c7c//A/143-283/ and name ca&amp;quot;) ## selecting a domain&lt;br /&gt;
&lt;br /&gt;
domainCenter=centerOfMass(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;Center of mass: (%.1f,%.1f,%.1f)&amp;quot;% domainCenter&lt;br /&gt;
cmd.as(&amp;quot;cartoon&amp;quot;, &amp;quot;all&amp;quot;)&lt;br /&gt;
cmd.show(&amp;quot;spheres&amp;quot;, &amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
## Creating a sphere CGO&lt;br /&gt;
com = [COLOR, 1.0, 1.0, 1.0, SPHERE]+list(domainCenter) + [3.0] ## white sphere with 3A radius&lt;br /&gt;
cmd.load_cgo(com, &amp;quot;CoM&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
cmd.zoom(&amp;quot;1c7c&amp;quot;, 1.0)&lt;br /&gt;
cmd.center(&amp;quot;domain&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ pymol -qc centerOfMass4.py&lt;br /&gt;
#Center of mass: (-1.0,24.5,48.2)&lt;br /&gt;
#ah@bioinfws19:~/Projects/PyMOL$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|Center of Mass]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Get_state&amp;diff=7423</id>
		<title>Get state</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Get_state&amp;diff=7423"/>
		<updated>2010-05-25T21:39:51Z</updated>

		<summary type="html">&lt;p&gt;Slaw: moved Get state to Get State&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Get State]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Get_State&amp;diff=7401</id>
		<title>Get State</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Get_State&amp;diff=7401"/>
		<updated>2010-05-25T21:39:51Z</updated>

		<summary type="html">&lt;p&gt;Slaw: moved Get state to Get State&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;get_state&amp;quot; returns the current state index (1-based)&lt;br /&gt;
&lt;br /&gt;
===PYMOL API===&lt;br /&gt;
&lt;br /&gt;
   cmd.get_state()&lt;br /&gt;
&lt;br /&gt;
===NOTES===&lt;br /&gt;
&lt;br /&gt;
   States refer to different geometric configurations which an object&lt;br /&gt;
   can above.  By default, states and movie frames have a one-to-one&lt;br /&gt;
   relationship.  States can be visited in an arbitrary order to&lt;br /&gt;
   create frames.  The &amp;quot;mset&amp;quot; command allows you to build a&lt;br /&gt;
   relationship between states and frames.&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
&lt;br /&gt;
[[Get Frame]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Get_Frame&amp;diff=7396</id>
		<title>Get Frame</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Get_Frame&amp;diff=7396"/>
		<updated>2010-05-25T21:39:33Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Created page with '===DESCRIPTION===     &amp;quot;get_frame&amp;quot; returns the current frame index (1-based)  ===PYMOL API===     Frames refers to sequences of images in a movie.  Sequential frames    may contai…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===DESCRIPTION===&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;get_frame&amp;quot; returns the current frame index (1-based)&lt;br /&gt;
&lt;br /&gt;
===PYMOL API===&lt;br /&gt;
&lt;br /&gt;
   Frames refers to sequences of images in a movie.  Sequential frames&lt;br /&gt;
   may contain identical molecular states, they may have one-to-one&lt;br /&gt;
   correspondance to molecular states (default), or they may have an&lt;br /&gt;
   arbitrary relationship, specific using the &amp;quot;mset&amp;quot; command.&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
&lt;br /&gt;
[[Get State]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Get_State&amp;diff=7400</id>
		<title>Get State</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Get_State&amp;diff=7400"/>
		<updated>2010-05-25T21:38:43Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Created page with '===Description===     &amp;quot;get_state&amp;quot; returns the current state index (1-based)  ===PYMOL API===     cmd.get_state()  ===NOTES===     States refer to different geometric configuratio…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;get_state&amp;quot; returns the current state index (1-based)&lt;br /&gt;
&lt;br /&gt;
===PYMOL API===&lt;br /&gt;
&lt;br /&gt;
   cmd.get_state()&lt;br /&gt;
&lt;br /&gt;
===NOTES===&lt;br /&gt;
&lt;br /&gt;
   States refer to different geometric configurations which an object&lt;br /&gt;
   can above.  By default, states and movie frames have a one-to-one&lt;br /&gt;
   relationship.  States can be visited in an arbitrary order to&lt;br /&gt;
   create frames.  The &amp;quot;mset&amp;quot; command allows you to build a&lt;br /&gt;
   relationship between states and frames.&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
&lt;br /&gt;
[[Get Frame]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8399</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8399"/>
		<updated>2010-05-25T15:36:40Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Author Sean Law&lt;br /&gt;
    Michigan State University&lt;br /&gt;
    slaw_(at)_msu_dot_edu&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for i in range (x):&lt;br /&gt;
        for j in range (len(args)):&lt;br /&gt;
            cmd.frame(int(args[j]))&lt;br /&gt;
            cmd.refresh()&lt;br /&gt;
            time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:UI_Script]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8398</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8398"/>
		<updated>2010-05-25T04:18:35Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Author Sean Law&lt;br /&gt;
    Michigan State University&lt;br /&gt;
    slaw_(at)_msu_dot_edu&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for i in range (x):&lt;br /&gt;
        for j in range (len(args)):&lt;br /&gt;
            cmd.frame(int(args[j]))&lt;br /&gt;
            cmd.refresh()&lt;br /&gt;
            time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:UI_Script]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6657</id>
		<title>Check Key</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6657"/>
		<updated>2010-05-25T04:16:31Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===DESCRIPTION=== &lt;br /&gt;
&lt;br /&gt;
A simple script used to check if a given key is valid for for the [[Set Key]] command.  This is useful when the user would like to use a keyboard key as shortcut/hotkey in their script but need to check if the key is a valid one.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
check_key (keystroke)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the key specified is a valid one as defined in [[Set Key]] then it returns the value of the keystroke.  Otherwise, it returns None.&lt;br /&gt;
&lt;br /&gt;
For an example that calls this script, see [[Jump]].&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
allowed_keys=re.compile('(F1|F2|left|right|pgup|pgdn|home|insert|(CTRL-[A-Z])|ALT-[A-Z0-9])')&lt;br /&gt;
&lt;br /&gt;
def check_key (keystroke):&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Author Sean Law&lt;br /&gt;
    Michigan State University&lt;br /&gt;
    slaw_(at)_msu_dot_edu&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    keystroke=keystroke.strip('\&amp;quot;\'')&lt;br /&gt;
    out=allowed_keys.search(keystroke)&lt;br /&gt;
&lt;br /&gt;
    if (out != None):&lt;br /&gt;
        return keystroke         &lt;br /&gt;
    else:&lt;br /&gt;
        print &amp;quot;Error: Invalid key \&amp;quot;&amp;quot;+keystroke+&amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
        print &amp;quot;Valid Keys: F1, F2, left, right, pdup, pgdn, home, insert&amp;quot;&lt;br /&gt;
        print &amp;quot;            CTRL-A to CTRL-Z&amp;quot;&lt;br /&gt;
        print &amp;quot;            ALT-0 to ALT-9, ALT-A to ALT-Z&amp;quot;&lt;br /&gt;
        return&lt;br /&gt;
cmd.extend(&amp;quot;check_key&amp;quot;, check_key)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Button]] [[Set Key]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8397</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8397"/>
		<updated>2010-05-25T04:16:06Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    Author Sean Law&lt;br /&gt;
    Michigan State University&lt;br /&gt;
    slaw_(at)_msu_dot_edu&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for j in range (len(args)):&lt;br /&gt;
        cmd.frame(int(args[j]))&lt;br /&gt;
        cmd.refresh()&lt;br /&gt;
        time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:UI_Script]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8396</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8396"/>
		<updated>2010-05-25T04:15:30Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    #Author Sean Law&lt;br /&gt;
    #Michigan State University&lt;br /&gt;
    #slaw_(at)_msu_dot_edu&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for j in range (len(args)):&lt;br /&gt;
        cmd.frame(int(args[j]))&lt;br /&gt;
        cmd.refresh()&lt;br /&gt;
        time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:UI_Script]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8395</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8395"/>
		<updated>2010-05-25T04:14:21Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    #Author Sean Law&lt;br /&gt;
    #Michigan State University&lt;br /&gt;
    #slaw_(at)_msu_dot_edu&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for j in range (len(args)):&lt;br /&gt;
        cmd.frame(int(args[j]))&lt;br /&gt;
        cmd.refresh()&lt;br /&gt;
        time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category::UI_Script]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8394</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8394"/>
		<updated>2010-05-25T04:14:06Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    #Author Sean Law&lt;br /&gt;
    #Michigan State University&lt;br /&gt;
    #slaw_(at)_msu_dot_edu&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for j in range (len(args)):&lt;br /&gt;
        cmd.frame(int(args[j]))&lt;br /&gt;
        cmd.refresh()&lt;br /&gt;
        time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category::UI_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8393</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8393"/>
		<updated>2010-05-25T04:13:45Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1 [,x=1 [,key='pgdn']]]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, x=10&lt;br /&gt;
#This does the same thing as the first example except that each press of the hotkey will &lt;br /&gt;
#cause the script to run through the specified frames 10 times before stopping.&lt;br /&gt;
#Note that you will not be able to control or exit the script during the 10 iterations!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    #Author Sean Law&lt;br /&gt;
    #Michigan State University&lt;br /&gt;
    #slaw_(at)_msu_dot_edu&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for j in range (len(args)):&lt;br /&gt;
        cmd.frame(int(args[j]))&lt;br /&gt;
        cmd.refresh()&lt;br /&gt;
        time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[UI_Scripts]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Jump&amp;diff=8392</id>
		<title>Jump</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Jump&amp;diff=8392"/>
		<updated>2010-05-25T04:06:56Z</updated>

		<summary type="html">&lt;p&gt;Slaw: Created page with '===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 al…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Description===&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
Note: This script also requires the [[Check Key]] script!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Usage===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump [frame1 [,...frameN [,sleep=0.1,[key='pgdn']]]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
jump 1, 10, 100&lt;br /&gt;
&lt;br /&gt;
#This causes the movie to jump from frame 1 to frame 10 and finally to frame 100 each time the 'pgdn' key is pressed&lt;br /&gt;
#Note that there is no limit to the number of frames that can be specified&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, 1000, key='F1'&lt;br /&gt;
#This sets the hotkey to F1.  When pressed, it will jump through the frames 1, 10, 100, 1000 respectively&lt;br /&gt;
&lt;br /&gt;
jump 1, 10, 100, sleep=0.01&lt;br /&gt;
#This does the same thing as the first example except that the pause between frames is 10x faster&lt;br /&gt;
#One could consider the &amp;quot;sleep&amp;quot; option to be similar to the frame rate&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
def jump (*args, **kwargs):&lt;br /&gt;
    &lt;br /&gt;
    #Author Sean Law&lt;br /&gt;
    #Michigan State University&lt;br /&gt;
    #slaw_(at)_msu_dot_edu&lt;br /&gt;
&lt;br /&gt;
    keystroke='pgdn'&lt;br /&gt;
    &lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;key&amp;quot;):&lt;br /&gt;
            keystroke=kwargs[&amp;quot;key&amp;quot;]&lt;br /&gt;
            keystroke=check_key(keystroke)&lt;br /&gt;
            if (keystroke == None):&lt;br /&gt;
                return&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    cmd.set_key(keystroke, jumpit, args, kwargs)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;jump&amp;quot;, jump)&lt;br /&gt;
&lt;br /&gt;
def jumpit (*args, **kwargs):&lt;br /&gt;
&lt;br /&gt;
    x=1&lt;br /&gt;
    sleep=0.1&lt;br /&gt;
&lt;br /&gt;
    for key in kwargs:&lt;br /&gt;
        if (key == &amp;quot;sleep&amp;quot;):&lt;br /&gt;
            sleep=kwargs[&amp;quot;sleep&amp;quot;]&lt;br /&gt;
            sleep=float(sleep)&lt;br /&gt;
        elif (key == &amp;quot;x&amp;quot;):&lt;br /&gt;
            x=kwargs[&amp;quot;x&amp;quot;]&lt;br /&gt;
            x=int(x)&lt;br /&gt;
        else:&lt;br /&gt;
            continue&lt;br /&gt;
&lt;br /&gt;
    args=list(args)&lt;br /&gt;
    &lt;br /&gt;
    for j in range (len(args)):&lt;br /&gt;
        cmd.frame(int(args[j]))&lt;br /&gt;
        cmd.refresh()&lt;br /&gt;
        time.sleep(sleep)&lt;br /&gt;
&lt;br /&gt;
    return&lt;br /&gt;
cmd.extend(&amp;quot;jumpit&amp;quot;, jumpit)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===See Also===&lt;br /&gt;
&lt;br /&gt;
[[Check Key]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6656</id>
		<title>Check Key</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6656"/>
		<updated>2010-05-25T04:06:52Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===DESCRIPTION=== &lt;br /&gt;
&lt;br /&gt;
A simple script used to check if a given key is valid for for the [[Set Key]] command.  This is useful when the user would like to use a keyboard key as shortcut/hotkey in their script but need to check if the key is a valid one.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
check_key (keystroke)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the key specified is a valid one as defined in [[Set Key]] then it returns the value of the keystroke.  Otherwise, it returns None.&lt;br /&gt;
&lt;br /&gt;
For an example that calls this script, see [[Jump]].&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
allowed_keys=re.compile('(F1|F2|left|right|pgup|pgdn|home|insert|(CTRL-[A-Z])|ALT-[A-Z0-9])')&lt;br /&gt;
&lt;br /&gt;
def check_key (keystroke):&lt;br /&gt;
&lt;br /&gt;
    #Author Sean Law&lt;br /&gt;
    #Michigan State University&lt;br /&gt;
    #slaw_(at)_msu_dot_edu&lt;br /&gt;
&lt;br /&gt;
    keystroke=keystroke.strip('\&amp;quot;\'')&lt;br /&gt;
    out=allowed_keys.search(keystroke)&lt;br /&gt;
&lt;br /&gt;
    if (out != None):&lt;br /&gt;
        return keystroke         &lt;br /&gt;
    else:&lt;br /&gt;
        print &amp;quot;Error: Invalid key \&amp;quot;&amp;quot;+keystroke+&amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
        print &amp;quot;Valid Keys: F1, F2, left, right, pdup, pgdn, home, insert&amp;quot;&lt;br /&gt;
        print &amp;quot;            CTRL-A to CTRL-Z&amp;quot;&lt;br /&gt;
        print &amp;quot;            ALT-0 to ALT-9, ALT-A to ALT-Z&amp;quot;&lt;br /&gt;
        return&lt;br /&gt;
cmd.extend(&amp;quot;check_key&amp;quot;, check_key)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Button]] [[Set Key]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6655</id>
		<title>Check Key</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6655"/>
		<updated>2010-05-25T04:05:42Z</updated>

		<summary type="html">&lt;p&gt;Slaw: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===DESCRIPTION=== &lt;br /&gt;
&lt;br /&gt;
A simple script used to check if a given key is valid for for the [[Set Key]] command.  This is useful when the user would like to use a keyboard key as shortcut/hotkey in their script but need to check if the key is a valid one.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
check_key (keystroke)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the key specified is a valid one as defined in [[Set Key]] then it returns the value of the keystroke.  Otherwise, it returns None.&lt;br /&gt;
&lt;br /&gt;
For an example that calls this script, see [[Jump]].&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
allowed_keys=re.compile('(F1|F2|left|right|pgup|pgdn|home|insert|(CTRL-[A-Z])|ALT-[A-Z0-9])')&lt;br /&gt;
&lt;br /&gt;
def check_key (keystroke):&lt;br /&gt;
&lt;br /&gt;
    #Author Sean Law&lt;br /&gt;
    #Michigan State University&lt;br /&gt;
    #slaw_(at)_msu_dot_edu&lt;br /&gt;
&lt;br /&gt;
    keystroke=keystroke.strip('\&amp;quot;\'')&lt;br /&gt;
    out=allowed_keys.search(keystroke)&lt;br /&gt;
&lt;br /&gt;
    if (out != None):&lt;br /&gt;
        return keystroke         &lt;br /&gt;
    else:&lt;br /&gt;
        print &amp;quot;Error: Invalid key \&amp;quot;&amp;quot;+keystroke+&amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
        print &amp;quot;Valid Keys: F1, F2, left, right, pdup, pgdn, home, insert&amp;quot;&lt;br /&gt;
        print &amp;quot;            CTRL-A to CTRL-Z&amp;quot;&lt;br /&gt;
        print &amp;quot;            ALT-0 to ALT-9, ALT-A to ALT-Z&amp;quot;&lt;br /&gt;
        return&lt;br /&gt;
cmd.extend(&amp;quot;check_key&amp;quot;, check_key)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Button]] [[Set Key]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6654</id>
		<title>Check Key</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Check_Key&amp;diff=6654"/>
		<updated>2010-05-25T03:51:19Z</updated>

		<summary type="html">&lt;p&gt;Slaw: moved Check key to Check Key:&amp;amp;#32;Case sensitive title&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===DESCRIPTION=== &lt;br /&gt;
&lt;br /&gt;
A simple script used to check if a given key is valid for for the [[Set Key]] command.  This is useful when the user would like to use a keyboard key as shortcut/hotkey in their script but need to check if the key is a valid one.&lt;br /&gt;
&lt;br /&gt;
===USAGE===&lt;br /&gt;
&lt;br /&gt;
load the script using the [[run]] command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
check_key (keystroke)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the key specified is a valid one as defined in [[Set Key]] then it returns the value of the keystroke.  Otherwise, it returns None.&lt;br /&gt;
&lt;br /&gt;
For an example that calls this script, see [[Jump]].&lt;br /&gt;
&lt;br /&gt;
===PyMOL API===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
allowed_keys=re.compile('(F1|F2|left|right|pgup|pgdn|home|insert|(CTRL-[A-Z])|ALT-[A-Z0-9])')&lt;br /&gt;
&lt;br /&gt;
def check_key (keystroke):&lt;br /&gt;
    keystroke=keystroke.strip('\&amp;quot;\'')&lt;br /&gt;
    out=allowed_keys.search(keystroke)&lt;br /&gt;
&lt;br /&gt;
    if (out != None):&lt;br /&gt;
        return keystroke         &lt;br /&gt;
    else:&lt;br /&gt;
        print &amp;quot;Error: Invalid key \&amp;quot;&amp;quot;+keystroke+&amp;quot;\&amp;quot;&amp;quot;&lt;br /&gt;
        print &amp;quot;Valid Keys: F1, F2, left, right, pdup, pgdn, home, insert&amp;quot;&lt;br /&gt;
        print &amp;quot;            CTRL-A to CTRL-Z&amp;quot;&lt;br /&gt;
        print &amp;quot;            ALT-0 to ALT-9, ALT-A to ALT-Z&amp;quot;&lt;br /&gt;
        return&lt;br /&gt;
cmd.extend(&amp;quot;check_key&amp;quot;, check_key)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===SEE ALSO===&lt;br /&gt;
[[Button]] [[Set Key]]&lt;/div&gt;</summary>
		<author><name>Slaw</name></author>
	</entry>
</feed>