<?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=Zhentg</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=Zhentg"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php/Special:Contributions/Zhentg"/>
	<updated>2026-05-30T22:03:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Contact_map_visualizer&amp;diff=14929</id>
		<title>Contact map visualizer</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Contact_map_visualizer&amp;diff=14929"/>
		<updated>2021-11-17T09:34:20Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Generate Contact Map */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = plugin&lt;br /&gt;
|filename = plugins/contact_map_visualizer.py&lt;br /&gt;
|author    = [[User:Venky|Venkatramanan Krishnamani]] &lt;br /&gt;
|license   = -&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
'''Enhanced version of this plugin is now available at [[CMPyMOL]]'''&lt;br /&gt;
&lt;br /&gt;
The '''contact map visualizer''' plugin can link contact map images to the residues in PyMOL in a interactive way. Contact maps are pixel graphics where each protein residue corresponds to one line and one row of pixels. Thus for a 100 residue protein, such a image has 100x100 pixels. A common tool to generate such images is '''g_mdmat''' from the [http://www.gromacs.org gromacs] package.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
 contact_map_visualizer [ image_file [, selection ]]&lt;br /&gt;
&lt;br /&gt;
== Required Dependencies ==&lt;br /&gt;
&lt;br /&gt;
* [http://pygame.org/ pygame]&lt;br /&gt;
* [http://wiki.python.org/moin/TkInter Tkinter] (optional and usually included with PyMOL)&lt;br /&gt;
* [http://www.pythonware.com/products/pil/ PIL] (optional, for automatically converting XPM images)&lt;br /&gt;
&lt;br /&gt;
Example for installing all dependencies on a Ubuntu like system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt-get install python-tk python-imaging python-pygame&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
* Navigate to plugins &amp;gt; install&lt;br /&gt;
* Locate the downloaded '''contact_map_visualizer.py''' file in the dialogbox and select 'OK'&lt;br /&gt;
* Quit and Restart 'pymol'&lt;br /&gt;
&lt;br /&gt;
Alternative way: Just [[run]] the script, it will provide a command but no menu plugin entry.&lt;br /&gt;
&lt;br /&gt;
== Generate Contact Map ==&lt;br /&gt;
&lt;br /&gt;
[[File:Contact-Map-of-a-Trajectory.png|thumb|200px|right|Mean contact map of a protein trajectory generated from g_mdmat tool in the Gromacs analysis package.]]&lt;br /&gt;
&lt;br /&gt;
Use the command [http://manual.gromacs.org/online/g_mdmat.html g_mdmat] from [http://www.gromacs.org Gromacs] analysis package. A typical contact map looks like the figure on the right.  &lt;br /&gt;
&lt;br /&gt;
To generate contact map of a single PDB. For example contact map for a PDB from RCSB, use the following command&lt;br /&gt;
 g_mdmat -f &amp;lt;protein.pdb&amp;gt; -s &amp;lt;protein.pdb&amp;gt; -mean contact-map.xpm&lt;br /&gt;
To generate a mean contact map form a protein trajectory&lt;br /&gt;
 g_mdmat -f &amp;lt;trajectory.pdb&amp;gt; -s &amp;lt;starting-frame.pdb&amp;gt; -mean contact-map.xpm&lt;br /&gt;
&lt;br /&gt;
For Gromacs 2021&lt;br /&gt;
To generate contact map of a single PDB. For example contact map for a PDB from RCSB, use the following command&lt;br /&gt;
 gmx g_mdmat -f &amp;lt;protein.pdb&amp;gt; -s &amp;lt;protein.pdb&amp;gt; -mean contact-map.xpm&lt;br /&gt;
To generate a mean contact map form a protein trajectory&lt;br /&gt;
 gmx g_mdmat -f &amp;lt;trajectory.pdb&amp;gt; -s &amp;lt;starting-frame.pdb&amp;gt; -mean contact-map.xpm&lt;br /&gt;
To convert XPM to PNG format&lt;br /&gt;
 convert contact-map.xpm contact-map.png&lt;br /&gt;
&lt;br /&gt;
== Screenshot ==&lt;br /&gt;
&lt;br /&gt;
[[File:Screenshot.png|thumb|800px|center]]&lt;br /&gt;
&lt;br /&gt;
== Copyright ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
# Copyright Notice&lt;br /&gt;
# ================&lt;br /&gt;
# &lt;br /&gt;
# The PyMOL Plugin source code in this file is copyrighted, but you are&lt;br /&gt;
# free to use and copy it as long as you don't change or remove any of&lt;br /&gt;
# the copyright notices.&lt;br /&gt;
# &lt;br /&gt;
# -----------------------------------------------------------------------------------&lt;br /&gt;
# This PyMOL Plugin Contact Maps Visualizer is&lt;br /&gt;
# Copyright (C) 2012 by Venkatramanan Krishnamani &amp;lt;venks@andrew.cmu.edu&amp;gt;&lt;br /&gt;
# &lt;br /&gt;
#                        All Rights Reserved&lt;br /&gt;
# &lt;br /&gt;
# Permission to use, copy, modify, distribute, and distribute modified&lt;br /&gt;
# versions of this software and its documentation for any purpose and&lt;br /&gt;
# without fee is hereby granted, provided that the above copyright&lt;br /&gt;
# notice appear in all copies and that both the copyright notice and&lt;br /&gt;
# this permission notice appear in supporting documentation, and that&lt;br /&gt;
# the name(s) of the author(s) not be used in advertising or publicity&lt;br /&gt;
# pertaining to distribution of the software without specific, written&lt;br /&gt;
# prior permission.&lt;br /&gt;
# &lt;br /&gt;
# THE AUTHOR(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,&lt;br /&gt;
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.  IN&lt;br /&gt;
# NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR&lt;br /&gt;
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF&lt;br /&gt;
# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR&lt;br /&gt;
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR&lt;br /&gt;
# PERFORMANCE OF THIS SOFTWARE.&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Plugins]]&lt;br /&gt;
[[Category:Pymol-script-repo]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14406</id>
		<title>ColorByDistance</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14406"/>
		<updated>2018-11-12T10:08:15Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Color the surface of a binding site by the distance to a specific atom.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files &lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**colorByDistance anchor, bindingSite&lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
def colorByDistance(anchor='anchor', site='site'):&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Spectrum#Intermediate&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color atoms of a binding site based on their distance from a point&lt;br /&gt;
	#May also refer to https://pymolwiki.org/index.php/Ramp_New#Ramp_.2B_Distance_Measure&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 site from the PDB&lt;br /&gt;
&lt;br /&gt;
	#fetch site, 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;
	cmd.pseudoatom(&amp;quot;pOrig&amp;quot;, anchor, label=&amp;quot;origin&amp;quot;)&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;
	cmd.iterate_state(1, &amp;quot;pOrig&amp;quot;, 'stored.origCoord.append((x,y,z))')&lt;br /&gt;
	cmd.iterate_state(1, site, '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;
	stored.newB = map(lambda x,y: diff_len(x,y), stored.distCoord, stored.origCoord)&lt;br /&gt;
	#print(stored.newB)&lt;br /&gt;
	# put them into the b-factor of the protein&lt;br /&gt;
&lt;br /&gt;
	cmd.alter( site, &amp;quot;b=stored.newB.pop(0)&amp;quot;)&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;
	cmd.spectrum(expression=&amp;quot;b&amp;quot;, palette=&amp;quot;rainbow&amp;quot;, selection=site)&lt;br /&gt;
	cmd.set(&amp;quot;surface_color&amp;quot;,&amp;quot;-1&amp;quot;,site) #color the surface of the binding site by corresponding atom colors&lt;br /&gt;
cmd.extend('colorByDistance', colorByDistance)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByGroup&amp;diff=14410</id>
		<title>ColorByGroup</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByGroup&amp;diff=14410"/>
		<updated>2018-11-12T09:54:36Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Color the objects by their groups.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files, create groups&lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**colorByGroup&lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
def colorByGroup(palette=&amp;quot;rainbow&amp;quot;):&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Get_Names#ARGUMENTS&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color the objects by their groups.&lt;br /&gt;
	# returns the length of the distance between atom A and atom B&lt;br /&gt;
	groups=cmd.get_names(&amp;quot;group_objects&amp;quot;)&lt;br /&gt;
	numClusters=len(groups)&lt;br /&gt;
	import math&lt;br /&gt;
	for x in range(numClusters):&lt;br /&gt;
		cmd.alter(groups[x],&amp;quot;b=&amp;quot;+str(x))&lt;br /&gt;
	cmd.spectrum( &amp;quot;b&amp;quot;, palette, &amp;quot; &amp;quot;.join(groups))&lt;br /&gt;
	#https://pymolwiki.org/index.php/Spectrum&lt;br /&gt;
cmd.extend('colorByGroup', colorByGroup)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByGroup&amp;diff=14409</id>
		<title>ColorByGroup</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByGroup&amp;diff=14409"/>
		<updated>2018-11-12T06:47:06Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Color the objects by their groups.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files, create groups&lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**colorByGroup&lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
def colorByGroup():&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Get_Names#ARGUMENTS&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color the objects by their groups.&lt;br /&gt;
	# returns the length of the distance between atom A and atom B&lt;br /&gt;
	groups=cmd.get_names(&amp;quot;group_objects&amp;quot;)&lt;br /&gt;
	numClusters=len(groups)&lt;br /&gt;
	import math&lt;br /&gt;
	for x in range(numClusters):&lt;br /&gt;
		colorCode=x*int(math.floor(255/numClusters))&lt;br /&gt;
		util.cba(colorCode,groups[x])&lt;br /&gt;
		print(colorCode,groups[x])&lt;br /&gt;
cmd.extend('colorByGroup', colorByGroup)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByGroup&amp;diff=14408</id>
		<title>ColorByGroup</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByGroup&amp;diff=14408"/>
		<updated>2018-11-12T06:42:01Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: Created page with &amp;quot;{{Infobox script-repo |type      = script |author    = Zhenting Gao }} == Introduction == Color the objects by their groups.  == Usage == *Open PyMOL  *Load PD...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Color the objects by their groups.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files, create groups&lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**colorByGroup&lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
def colorByGroup():&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Get_Names#ARGUMENTS&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color atoms of a binding site 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;
	groups=cmd.get_names(&amp;quot;group_objects&amp;quot;)&lt;br /&gt;
	numClusters=len(groups)&lt;br /&gt;
	import math&lt;br /&gt;
	for x in range(numClusters):&lt;br /&gt;
		colorCode=x*int(math.floor(255/numClusters))&lt;br /&gt;
		util.cba(colorCode,groups[x])&lt;br /&gt;
		print(colorCode,groups[x])&lt;br /&gt;
cmd.extend('colorByGroup', colorByGroup)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14405</id>
		<title>ColorByDistance</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14405"/>
		<updated>2018-11-12T06:35:31Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Color the surface of a binding site by the distance to a specific atom.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files &lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**colorByDistance anchor, bindingSite&lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
def colorByDistance(anchor='anchor', site='site'):&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Spectrum#Intermediate&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color atoms of a binding site 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 site from the PDB&lt;br /&gt;
&lt;br /&gt;
	#fetch site, 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;
	cmd.iterate_state(1, anchor, 'stored.origCoord.append((x,y,z))')&lt;br /&gt;
	cmd.iterate_state(1, site, '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;
	stored.newB = map(lambda x,y: diff_len(x,y), stored.distCoord, stored.origCoord)&lt;br /&gt;
	print(stored.newB)&lt;br /&gt;
	# put them into the b-factor of the protein&lt;br /&gt;
&lt;br /&gt;
	cmd.alter( &amp;quot;site&amp;quot;, &amp;quot;b=stored.newB.pop(0)&amp;quot;)&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;
	cmd.spectrum(expression=&amp;quot;b&amp;quot;, palette=&amp;quot;rainbow&amp;quot;, selection=site)&lt;br /&gt;
	cmd.set(&amp;quot;surface_color&amp;quot;,&amp;quot;-1&amp;quot;,site) #color the surface of the binding site by corresponding atom colors&lt;br /&gt;
cmd.extend('colorByDistance', colorByDistance)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14404</id>
		<title>ColorByDistance</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14404"/>
		<updated>2018-11-12T06:33:08Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
def colorByDistance(anchor='anchor', site='site'):&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Spectrum#Intermediate&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color atoms of a binding site 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 site from the PDB&lt;br /&gt;
&lt;br /&gt;
	#fetch site, 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;
	cmd.iterate_state(1, anchor, 'stored.origCoord.append((x,y,z))')&lt;br /&gt;
	cmd.iterate_state(1, site, '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;
	stored.newB = map(lambda x,y: diff_len(x,y), stored.distCoord, stored.origCoord)&lt;br /&gt;
	print(stored.newB)&lt;br /&gt;
	# put them into the b-factor of the protein&lt;br /&gt;
&lt;br /&gt;
	cmd.alter( &amp;quot;site&amp;quot;, &amp;quot;b=stored.newB.pop(0)&amp;quot;)&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;
	cmd.spectrum(expression=&amp;quot;b&amp;quot;, palette=&amp;quot;rainbow&amp;quot;, selection=site)&lt;br /&gt;
	cmd.set(&amp;quot;surface_color&amp;quot;,&amp;quot;-1&amp;quot;,site) #color the surface of the binding site by corresponding atom colors&lt;br /&gt;
cmd.extend('colorByDistance', colorByDistance)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=14468</id>
		<title>RmsdByResidue</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=14468"/>
		<updated>2018-11-12T06:32:22Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
RMSD between two structures of the same protein. The concept is similar as RMSF between two structures.&lt;br /&gt;
*programming &lt;br /&gt;
**Platform &lt;br /&gt;
***PyMOL &lt;br /&gt;
****rms_cur &lt;br /&gt;
**Feature &lt;br /&gt;
***Output &lt;br /&gt;
****RMSD of all atoms of each residues pairs &lt;br /&gt;
****Least RMSD of all atoms of each residues pairs &lt;br /&gt;
*****symmetry of Phe, Tyr, His, Asp, Glu, Gln, Asn, Arg, Leu and Val needs to be considered &lt;br /&gt;
******switch the atom name and then calculate the RMSD again &lt;br /&gt;
******Selected least RMSD of a residue pair for report &lt;br /&gt;
*******RMSD of backbone atoms of each residues pairs &lt;br /&gt;
*******RMSD of C alpha atoms of each residues pairs &lt;br /&gt;
*****With defined residues pairs &lt;br /&gt;
******Residue pair can be limited to within binding site &lt;br /&gt;
**Workflow &lt;br /&gt;
***Read reference and target pdb files &lt;br /&gt;
****two structures should be superposed before using this function &lt;br /&gt;
*Note &lt;br /&gt;
**Python &lt;br /&gt;
**PyMOL &lt;br /&gt;
***Clean attributes &lt;br /&gt;
****otherwise rms_cur will fail &lt;br /&gt;
***How to get residue name? &lt;br /&gt;
****residue name, residue index and etc. can only be read from an atom&lt;br /&gt;
*Reference&lt;br /&gt;
**https://sourceforge.net/p/pymol/mailman/message/32710889/&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files &lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**rmsdByRes pdb1, resSelection, pdb2 &lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#load library&lt;br /&gt;
from pymol import cmd, stored&lt;br /&gt;
import sys&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
#function to judge if a file exists&lt;br /&gt;
def is_non_zero_file(fpath):&lt;br /&gt;
    return os.path.isfile(fpath) and os.path.getsize(fpath) &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
#function to switch atom names within a residue&lt;br /&gt;
def switchName(residueSelection, atomName1, atomName2):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the name of two atoms&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName1, 'name=&amp;quot;gzt&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName2, 'name=&amp;quot;'+atomName1+'&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name gzt&amp;quot;, 'name=&amp;quot;'+atomName2+'&amp;quot;')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#function to change atom names of some residues with symetric sidechain&lt;br /&gt;
def flipAtomName(targetResidueSelection):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the atom names of specific residues&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create flipped residue&lt;br /&gt;
  cmd.create(&amp;quot;flippedRes&amp;quot;,targetResidueSelection+&amp;quot; and not alt B&amp;quot;)&lt;br /&gt;
  targetResidueCa=cmd.get_model(&amp;quot;flippedRes and name CA&amp;quot;)&lt;br /&gt;
  for g in targetResidueCa.atom:&lt;br /&gt;
#   print g.resn&lt;br /&gt;
    if g.resn=='ARG':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;NH1&amp;quot;, &amp;quot;NH2&amp;quot;)&lt;br /&gt;
    elif g.resn=='HIS':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;ND1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASP':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;OD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='PHE':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;OE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='LEU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;ND2&amp;quot;)&lt;br /&gt;
    elif g.resn=='TYR':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='VAL':&lt;br /&gt;
      switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CG1&amp;quot;, &amp;quot;CG2&amp;quot;)&lt;br /&gt;
  cmd.sort()&lt;br /&gt;
# cmd.label(&amp;quot;flippedRes&amp;quot;,&amp;quot;name&amp;quot;)&lt;br /&gt;
  return &amp;quot;flippedRes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#main function&lt;br /&gt;
def rmsdByRes(referenceProteinChain,sel, targetProteinChain):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Update&lt;br /&gt;
    Zhenting Gao on 7/28/2016&lt;br /&gt;
&lt;br /&gt;
  USAGE&lt;br /&gt;
&lt;br /&gt;
    rmsf referenceProteinChain, targetProteinChain, selection [,byres=0], [reference_state=1]&lt;br /&gt;
&lt;br /&gt;
    Calculate the RMSD for each residue pairs from two chains of the same protein from two crystal structures.&lt;br /&gt;
&lt;br /&gt;
  Workflow&lt;br /&gt;
    Read reference and target pdb files&lt;br /&gt;
    Align two structures&lt;br /&gt;
        sel target, proA and chain A&lt;br /&gt;
            #define target protein chain&lt;br /&gt;
        sel refrence, proB and chain A&lt;br /&gt;
            #define reference protein chain&lt;br /&gt;
        align target, reference&lt;br /&gt;
            #automatical alignment&lt;br /&gt;
    Clean attributes&lt;br /&gt;
        otherwise rms_cur will fail&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create temporary objects, exclude alternative conformation B&lt;br /&gt;
  cmd.create(&amp;quot;ref_gzt&amp;quot;, referenceProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
  cmd.create(&amp;quot;target_gzt&amp;quot;, targetProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
#  cmd.align(&amp;quot;target_gzt&amp;quot;,&amp;quot;ref_gzt&amp;quot;,object=&amp;quot;align&amp;quot;)&lt;br /&gt;
# parameters&lt;br /&gt;
  outputText=&amp;quot;&amp;quot;&lt;br /&gt;
  res2Check=['HIS','ASP','ARG','PHE','GLN','GLU','LEU','ASN','TYR','VAL']&lt;br /&gt;
       &lt;br /&gt;
# select alpha carbon of selected residues in reference structure&lt;br /&gt;
  calpha=cmd.get_model(sel+&amp;quot; and name CA and not alt B&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
  for g in calpha.atom:&lt;br /&gt;
#  print g.resi+g.resn&lt;br /&gt;
   if cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi)==cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi):&lt;br /&gt;
    rmsdRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    rmsdResCa=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;)&lt;br /&gt;
    rmsdResBackbone=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;)&lt;br /&gt;
#  calculate minimum rmsd&lt;br /&gt;
    rmsdResMin=rmsdRes&lt;br /&gt;
    if g.resn in res2Check:&lt;br /&gt;
      flippedRes=flipAtomName(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
      rmsdFlippedRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,flippedRes)&lt;br /&gt;
      if rmsdFlippedRes&amp;lt;rmsdRes:&lt;br /&gt;
       rmsdResMin=rmsdFlippedRes&lt;br /&gt;
&lt;br /&gt;
#    print cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi),cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    outputText+=&amp;quot;%s,%s,%s,%.3f,%.3f,%.3f,%.3f\n&amp;quot; % (targetProteinChain,g.resn,g.resi,rmsdRes,rmsdResCa,rmsdResBackbone,rmsdResMin)&lt;br /&gt;
  &lt;br /&gt;
  print outputText&lt;br /&gt;
# Destroy temporary objects&lt;br /&gt;
  cmd.delete(&amp;quot;ref_gzt target_gzt align res_gzt &amp;quot;+flippedRes)&lt;br /&gt;
  &lt;br /&gt;
# Save data into csv&lt;br /&gt;
  outputFile='rmsdByRes_'+sel+'.csv'&lt;br /&gt;
  f=open(outputFile,'a')&lt;br /&gt;
  if not is_non_zero_file(outputFile):&lt;br /&gt;
   f.write(&amp;quot;targe,residueName,residueId,allAtomRMSD,rmsdResCa,rmsdResBackbone,allAtomRMSDMin\n&amp;quot;)&lt;br /&gt;
  f.write(outputText)&lt;br /&gt;
  f.close()&lt;br /&gt;
  print &amp;quot;Results saved in &amp;quot;+outputFile&lt;br /&gt;
  &lt;br /&gt;
cmd.extend(&amp;quot;rmsdByRes&amp;quot;,rmsdByRes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Library]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;br /&gt;
[[Category:Pymol-script-repo]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14403</id>
		<title>ColorByDistance</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14403"/>
		<updated>2018-11-12T06:23:43Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Code===&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
def colorByDistance(anchor='anchor', site='site'):&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Spectrum#Intermediate&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color atoms of a binding site 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 site from the PDB&lt;br /&gt;
&lt;br /&gt;
	#fetch site, 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;
	cmd.iterate_state(1, anchor, 'stored.origCoord.append((x,y,z))')&lt;br /&gt;
	cmd.iterate_state(1, site, '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;
	stored.newB = map(lambda x,y: diff_len(x,y), stored.distCoord, stored.origCoord)&lt;br /&gt;
	print(stored.newB)&lt;br /&gt;
	# put them into the b-factor of the protein&lt;br /&gt;
&lt;br /&gt;
	cmd.alter( &amp;quot;site&amp;quot;, &amp;quot;b=stored.newB.pop(0)&amp;quot;)&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;
	cmd.spectrum(expression=&amp;quot;b&amp;quot;, palette=&amp;quot;rainbow&amp;quot;, selection=site)&lt;br /&gt;
	cmd.set(&amp;quot;surface_color&amp;quot;,&amp;quot;-1&amp;quot;,site) #color the surface of the binding site by corresponding atom colors&lt;br /&gt;
cmd.extend('colorByDistance', colorByDistance)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14402</id>
		<title>ColorByDistance</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=ColorByDistance&amp;diff=14402"/>
		<updated>2018-11-12T06:23:07Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: Created page with &amp;quot;===Code=== def colorByDistance(anchor='anchor', site='site'): 	#Based on: https://pymolwiki.org/index.php/Spectrum#Intermediate 	#Author: Zhenting Gao (zhentgpicasa@gmail.com)...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Code===&lt;br /&gt;
def colorByDistance(anchor='anchor', site='site'):&lt;br /&gt;
	#Based on: https://pymolwiki.org/index.php/Spectrum#Intermediate&lt;br /&gt;
	#Author: Zhenting Gao (zhentgpicasa@gmail.com)&lt;br /&gt;
	#Update: 11/12/2018&lt;br /&gt;
	#Aim: Color atoms of a binding site 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 site from the PDB&lt;br /&gt;
&lt;br /&gt;
	#fetch site, 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;
	cmd.iterate_state(1, anchor, 'stored.origCoord.append((x,y,z))')&lt;br /&gt;
	cmd.iterate_state(1, site, '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;
	stored.newB = map(lambda x,y: diff_len(x,y), stored.distCoord, stored.origCoord)&lt;br /&gt;
	print(stored.newB)&lt;br /&gt;
	# put them into the b-factor of the protein&lt;br /&gt;
&lt;br /&gt;
	cmd.alter( &amp;quot;site&amp;quot;, &amp;quot;b=stored.newB.pop(0)&amp;quot;)&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;
	cmd.spectrum(expression=&amp;quot;b&amp;quot;, palette=&amp;quot;rainbow&amp;quot;, selection=site)&lt;br /&gt;
	cmd.set(&amp;quot;surface_color&amp;quot;,&amp;quot;-1&amp;quot;,site) #color the surface of the binding site by corresponding atom colors&lt;br /&gt;
cmd.extend('colorByDistance', colorByDistance)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13759</id>
		<title>RmsdByResidue</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13759"/>
		<updated>2016-12-09T08:56:47Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
RMSD between two structures of the same protein &lt;br /&gt;
*programming &lt;br /&gt;
**Platform &lt;br /&gt;
***PyMOL &lt;br /&gt;
****rms_cur &lt;br /&gt;
**Feature &lt;br /&gt;
***Output &lt;br /&gt;
****RMSD of all atoms of each residues pairs &lt;br /&gt;
****Least RMSD of all atoms of each residues pairs &lt;br /&gt;
*****symmetry of Phe, Tyr, His, Asp, Glu, Gln, Asn, Arg, Leu and Val needs to be considered &lt;br /&gt;
******switch the atom name and then calculate the RMSD again &lt;br /&gt;
******Selected least RMSD of a residue pair for report &lt;br /&gt;
*******RMSD of backbone atoms of each residues pairs &lt;br /&gt;
*******RMSD of C alpha atoms of each residues pairs &lt;br /&gt;
*****With defined residues pairs &lt;br /&gt;
******Residue pair can be limited to within binding site &lt;br /&gt;
**Workflow &lt;br /&gt;
***Read reference and target pdb files &lt;br /&gt;
****two structures should be superposed before using this function &lt;br /&gt;
*Note &lt;br /&gt;
**Python &lt;br /&gt;
**PyMOL &lt;br /&gt;
***Clean attributes &lt;br /&gt;
****otherwise rms_cur will fail &lt;br /&gt;
***How to get residue name? &lt;br /&gt;
****residue name, residue index and etc. can only be read from an atom&lt;br /&gt;
*Reference&lt;br /&gt;
**https://sourceforge.net/p/pymol/mailman/message/32710889/&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files &lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**rmsdByRes pdb1, resSelection, pdb2 &lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#load library&lt;br /&gt;
from pymol import cmd, stored&lt;br /&gt;
import sys&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
#function to judge if a file exists&lt;br /&gt;
def is_non_zero_file(fpath):&lt;br /&gt;
    return os.path.isfile(fpath) and os.path.getsize(fpath) &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
#function to switch atom names within a residue&lt;br /&gt;
def switchName(residueSelection, atomName1, atomName2):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the name of two atoms&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName1, 'name=&amp;quot;gzt&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName2, 'name=&amp;quot;'+atomName1+'&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name gzt&amp;quot;, 'name=&amp;quot;'+atomName2+'&amp;quot;')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#function to change atom names of some residues with symetric sidechain&lt;br /&gt;
def flipAtomName(targetResidueSelection):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the atom names of specific residues&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create flipped residue&lt;br /&gt;
  cmd.create(&amp;quot;flippedRes&amp;quot;,targetResidueSelection+&amp;quot; and not alt B&amp;quot;)&lt;br /&gt;
  targetResidueCa=cmd.get_model(&amp;quot;flippedRes and name CA&amp;quot;)&lt;br /&gt;
  for g in targetResidueCa.atom:&lt;br /&gt;
#   print g.resn&lt;br /&gt;
    if g.resn=='ARG':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;NH1&amp;quot;, &amp;quot;NH2&amp;quot;)&lt;br /&gt;
    elif g.resn=='HIS':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;ND1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASP':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;OD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='PHE':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;OE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='LEU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;ND2&amp;quot;)&lt;br /&gt;
    elif g.resn=='TYR':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='VAL':&lt;br /&gt;
      switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CG1&amp;quot;, &amp;quot;CG2&amp;quot;)&lt;br /&gt;
  cmd.sort()&lt;br /&gt;
# cmd.label(&amp;quot;flippedRes&amp;quot;,&amp;quot;name&amp;quot;)&lt;br /&gt;
  return &amp;quot;flippedRes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#main function&lt;br /&gt;
def rmsdByRes(referenceProteinChain,sel, targetProteinChain):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Update&lt;br /&gt;
    Zhenting Gao on 7/28/2016&lt;br /&gt;
&lt;br /&gt;
  USAGE&lt;br /&gt;
&lt;br /&gt;
    rmsf referenceProteinChain, targetProteinChain, selection [,byres=0], [reference_state=1]&lt;br /&gt;
&lt;br /&gt;
    Calculate the RMSD for each residue pairs from two chains of the same protein from two crystal structures.&lt;br /&gt;
&lt;br /&gt;
  Workflow&lt;br /&gt;
    Read reference and target pdb files&lt;br /&gt;
    Align two structures&lt;br /&gt;
        sel target, proA and chain A&lt;br /&gt;
            #define target protein chain&lt;br /&gt;
        sel refrence, proB and chain A&lt;br /&gt;
            #define reference protein chain&lt;br /&gt;
        align target, reference&lt;br /&gt;
            #automatical alignment&lt;br /&gt;
    Clean attributes&lt;br /&gt;
        otherwise rms_cur will fail&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create temporary objects, exclude alternative conformation B&lt;br /&gt;
  cmd.create(&amp;quot;ref_gzt&amp;quot;, referenceProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
  cmd.create(&amp;quot;target_gzt&amp;quot;, targetProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
#  cmd.align(&amp;quot;target_gzt&amp;quot;,&amp;quot;ref_gzt&amp;quot;,object=&amp;quot;align&amp;quot;)&lt;br /&gt;
# parameters&lt;br /&gt;
  outputText=&amp;quot;&amp;quot;&lt;br /&gt;
  res2Check=['HIS','ASP','ARG','PHE','GLN','GLU','LEU','ASN','TYR','VAL']&lt;br /&gt;
       &lt;br /&gt;
# select alpha carbon of selected residues in reference structure&lt;br /&gt;
  calpha=cmd.get_model(sel+&amp;quot; and name CA and not alt B&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
  for g in calpha.atom:&lt;br /&gt;
#  print g.resi+g.resn&lt;br /&gt;
   if cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi)==cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi):&lt;br /&gt;
    rmsdRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    rmsdResCa=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;)&lt;br /&gt;
    rmsdResBackbone=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;)&lt;br /&gt;
#  calculate minimum rmsd&lt;br /&gt;
    rmsdResMin=rmsdRes&lt;br /&gt;
    if g.resn in res2Check:&lt;br /&gt;
      flippedRes=flipAtomName(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
      rmsdFlippedRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,flippedRes)&lt;br /&gt;
      if rmsdFlippedRes&amp;lt;rmsdRes:&lt;br /&gt;
       rmsdResMin=rmsdFlippedRes&lt;br /&gt;
&lt;br /&gt;
#    print cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi),cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    outputText+=&amp;quot;%s,%s,%s,%.3f,%.3f,%.3f,%.3f\n&amp;quot; % (targetProteinChain,g.resn,g.resi,rmsdRes,rmsdResCa,rmsdResBackbone,rmsdResMin)&lt;br /&gt;
  &lt;br /&gt;
  print outputText&lt;br /&gt;
# Destroy temporary objects&lt;br /&gt;
  cmd.delete(&amp;quot;ref_gzt target_gzt align res_gzt &amp;quot;+flippedRes)&lt;br /&gt;
  &lt;br /&gt;
# Save data into csv&lt;br /&gt;
  outputFile='rmsdByRes_'+sel+'.csv'&lt;br /&gt;
  f=open(outputFile,'a')&lt;br /&gt;
  if not is_non_zero_file(outputFile):&lt;br /&gt;
   f.write(&amp;quot;targe,residueName,residueId,allAtomRMSD,rmsdResCa,rmsdResBackbone,allAtomRMSDMin\n&amp;quot;)&lt;br /&gt;
  f.write(outputText)&lt;br /&gt;
  f.close()&lt;br /&gt;
  print &amp;quot;Results saved in &amp;quot;+outputFile&lt;br /&gt;
  &lt;br /&gt;
cmd.extend(&amp;quot;rmsdByRes&amp;quot;,rmsdByRes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Library]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;br /&gt;
[[Category:Pymol-script-repo]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13758</id>
		<title>RmsdByResidue</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13758"/>
		<updated>2016-12-08T06:47:11Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
RMSD between two structures of the same protein &lt;br /&gt;
*programming &lt;br /&gt;
**Platform &lt;br /&gt;
****PyMOL &lt;br /&gt;
*****rms_cur &lt;br /&gt;
**Feature &lt;br /&gt;
***Output &lt;br /&gt;
					® RMSD of all atoms of each residues pairs &lt;br /&gt;
					® Least RMSD of all atoms of each residues pairs &lt;br /&gt;
						◊ symmetry of Phe, Tyr, His, Asp, Glu, Gln, Asn, Arg, Leu and Val needs to be considered &lt;br /&gt;
							} switch the atom name and then calculate the RMSD again &lt;br /&gt;
						◊ Selected least RMSD of a residue pair for report &lt;br /&gt;
					® RMSD of backbone atoms of each residues pairs &lt;br /&gt;
					® RMSD of C alpha atoms of each residues pairs &lt;br /&gt;
				□ With defined residues pairs &lt;br /&gt;
					® Residue pair can be limited to within binding site &lt;br /&gt;
			§ Workflow &lt;br /&gt;
				□ Read reference and target pdb files &lt;br /&gt;
					® #two structures should be superposed before using this function &lt;br /&gt;
			§ Note &lt;br /&gt;
				□ Python &lt;br /&gt;
				□ PyMOL &lt;br /&gt;
					® Clean attributes &lt;br /&gt;
						◊ otherwise rms_cur will fail &lt;br /&gt;
					® How to get residue name? &lt;br /&gt;
						◊ residue name, residue index and etc. can only be read from an atom &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files &lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**rmsdByRes pdb1, resSelection, pdb2 &lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
Text&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
Text&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#load library&lt;br /&gt;
from pymol import cmd, stored&lt;br /&gt;
import sys&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
#function to judge if a file exists&lt;br /&gt;
def is_non_zero_file(fpath):&lt;br /&gt;
    return os.path.isfile(fpath) and os.path.getsize(fpath) &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
#function to switch atom names within a residue&lt;br /&gt;
def switchName(residueSelection, atomName1, atomName2):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the name of two atoms&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName1, 'name=&amp;quot;gzt&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName2, 'name=&amp;quot;'+atomName1+'&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name gzt&amp;quot;, 'name=&amp;quot;'+atomName2+'&amp;quot;')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#function to change atom names of some residues with symetric sidechain&lt;br /&gt;
def flipAtomName(targetResidueSelection):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the atom names of specific residues&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create flipped residue&lt;br /&gt;
  cmd.create(&amp;quot;flippedRes&amp;quot;,targetResidueSelection+&amp;quot; and not alt B&amp;quot;)&lt;br /&gt;
  targetResidueCa=cmd.get_model(&amp;quot;flippedRes and name CA&amp;quot;)&lt;br /&gt;
  for g in targetResidueCa.atom:&lt;br /&gt;
#   print g.resn&lt;br /&gt;
    if g.resn=='ARG':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;NH1&amp;quot;, &amp;quot;NH2&amp;quot;)&lt;br /&gt;
    elif g.resn=='HIS':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;ND1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASP':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;OD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='PHE':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;OE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='LEU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;ND2&amp;quot;)&lt;br /&gt;
    elif g.resn=='TYR':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='VAL':&lt;br /&gt;
      switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CG1&amp;quot;, &amp;quot;CG2&amp;quot;)&lt;br /&gt;
  cmd.sort()&lt;br /&gt;
# cmd.label(&amp;quot;flippedRes&amp;quot;,&amp;quot;name&amp;quot;)&lt;br /&gt;
  return &amp;quot;flippedRes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#main function&lt;br /&gt;
def rmsdByRes(referenceProteinChain,sel, targetProteinChain):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Update&lt;br /&gt;
    Zhenting Gao on 7/28/2016&lt;br /&gt;
&lt;br /&gt;
  USAGE&lt;br /&gt;
&lt;br /&gt;
    rmsf referenceProteinChain, targetProteinChain, selection [,byres=0], [reference_state=1]&lt;br /&gt;
&lt;br /&gt;
    Calculate the RMSD for each residue pairs from two chains of the same protein from two crystal structures.&lt;br /&gt;
&lt;br /&gt;
  Workflow&lt;br /&gt;
    Read reference and target pdb files&lt;br /&gt;
    Align two structures&lt;br /&gt;
        sel target, proA and chain A&lt;br /&gt;
            #define target protein chain&lt;br /&gt;
        sel refrence, proB and chain A&lt;br /&gt;
            #define reference protein chain&lt;br /&gt;
        align target, reference&lt;br /&gt;
            #automatical alignment&lt;br /&gt;
    Clean attributes&lt;br /&gt;
        otherwise rms_cur will fail&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create temporary objects, exclude alternative conformation B&lt;br /&gt;
  cmd.create(&amp;quot;ref_gzt&amp;quot;, referenceProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
  cmd.create(&amp;quot;target_gzt&amp;quot;, targetProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
#  cmd.align(&amp;quot;target_gzt&amp;quot;,&amp;quot;ref_gzt&amp;quot;,object=&amp;quot;align&amp;quot;)&lt;br /&gt;
# parameters&lt;br /&gt;
  outputText=&amp;quot;&amp;quot;&lt;br /&gt;
  res2Check=['HIS','ASP','ARG','PHE','GLN','GLU','LEU','ASN','TYR','VAL']&lt;br /&gt;
       &lt;br /&gt;
# select alpha carbon of selected residues in reference structure&lt;br /&gt;
  calpha=cmd.get_model(sel+&amp;quot; and name CA and not alt B&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
  for g in calpha.atom:&lt;br /&gt;
#  print g.resi+g.resn&lt;br /&gt;
   if cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi)==cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi):&lt;br /&gt;
    rmsdRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    rmsdResCa=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;)&lt;br /&gt;
    rmsdResBackbone=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;)&lt;br /&gt;
#  calculate minimum rmsd&lt;br /&gt;
    rmsdResMin=rmsdRes&lt;br /&gt;
    if g.resn in res2Check:&lt;br /&gt;
      flippedRes=flipAtomName(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
      rmsdFlippedRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,flippedRes)&lt;br /&gt;
      if rmsdFlippedRes&amp;lt;rmsdRes:&lt;br /&gt;
       rmsdResMin=rmsdFlippedRes&lt;br /&gt;
&lt;br /&gt;
#    print cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi),cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    outputText+=&amp;quot;%s,%s,%s,%.3f,%.3f,%.3f,%.3f\n&amp;quot; % (targetProteinChain,g.resn,g.resi,rmsdRes,rmsdResCa,rmsdResBackbone,rmsdResMin)&lt;br /&gt;
  &lt;br /&gt;
  print outputText&lt;br /&gt;
# Destroy temporary objects&lt;br /&gt;
  cmd.delete(&amp;quot;ref_gzt target_gzt align res_gzt &amp;quot;+flippedRes)&lt;br /&gt;
  &lt;br /&gt;
# Save data into csv&lt;br /&gt;
  outputFile='rmsdByRes_'+sel+'.csv'&lt;br /&gt;
  f=open(outputFile,'a')&lt;br /&gt;
  if not is_non_zero_file(outputFile):&lt;br /&gt;
   f.write(&amp;quot;targe,residueName,residueId,allAtomRMSD,rmsdResCa,rmsdResBackbone,allAtomRMSDMin\n&amp;quot;)&lt;br /&gt;
  f.write(outputText)&lt;br /&gt;
  f.close()&lt;br /&gt;
  print &amp;quot;Results saved in &amp;quot;+outputFile&lt;br /&gt;
  &lt;br /&gt;
cmd.extend(&amp;quot;rmsdByRes&amp;quot;,rmsdByRes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Library]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;br /&gt;
[[Category:Pymol-script-repo]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13757</id>
		<title>RmsdByResidue</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13757"/>
		<updated>2016-12-08T06:46:20Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|author    = [[User:zhentg|Zhenting Gao]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
RMSD between two structures of the same protein &lt;br /&gt;
*programming &lt;br /&gt;
**Platform &lt;br /&gt;
****PyMOL &lt;br /&gt;
*****rms_cur &lt;br /&gt;
**Feature &lt;br /&gt;
***Output &lt;br /&gt;
					® RMSD of all atoms of each residues pairs &lt;br /&gt;
					® Least RMSD of all atoms of each residues pairs &lt;br /&gt;
						◊ symmetry of Phe, Tyr, His, Asp, Glu, Gln, Asn, Arg, Leu and Val needs to be considered &lt;br /&gt;
							} switch the atom name and then calculate the RMSD again &lt;br /&gt;
						◊ Selected least RMSD of a residue pair for report &lt;br /&gt;
					® RMSD of backbone atoms of each residues pairs &lt;br /&gt;
					® RMSD of C alpha atoms of each residues pairs &lt;br /&gt;
				□ With defined residues pairs &lt;br /&gt;
					® Residue pair can be limited to within binding site &lt;br /&gt;
			§ Workflow &lt;br /&gt;
				□ Read reference and target pdb files &lt;br /&gt;
					® #two structures should be superposed before using this function &lt;br /&gt;
			§ Note &lt;br /&gt;
				□ Python &lt;br /&gt;
				□ PyMOL &lt;br /&gt;
					® Clean attributes &lt;br /&gt;
						◊ otherwise rms_cur will fail &lt;br /&gt;
					® How to get residue name? &lt;br /&gt;
						◊ residue name, residue index and etc. can only be read from an atom &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
*Open PyMOL &lt;br /&gt;
*Load PDB files &lt;br /&gt;
*run this Python script inside PyMOL &lt;br /&gt;
*call the function &lt;br /&gt;
**rmsdByRes pdb1, resSelection, pdb2 &lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
* '''sel1''' = first selection&lt;br /&gt;
* '''sel2''' = second selection&lt;br /&gt;
* '''max_dist''' = max distance in Angstroms&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
* '''output''' = accepts Screen/Print/None (default N)&lt;br /&gt;
* '''sidechain''' = limits (Y) results to sidechain atoms (default N)&lt;br /&gt;
* '''show''' = shows (Y) individual distances in pymol menu (default=N)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
'''example #1'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;pairwise_dist 1efa and chain D, 1efa and chain B, 3, output=S, show=Y&lt;br /&gt;
 &lt;br /&gt;
1efa/D/DC/13/OP1 to 1efa/B/TYR/47/OH: 2.765&lt;br /&gt;
1efa/D/DC/13/OP2 to 1efa/B/LEU/6/N: 2.983&lt;br /&gt;
1efa/D/DC/13/OP2 to 1efa/B/LEU/6/CB: 2.928&lt;br /&gt;
1efa/D/DT/14/O4' to 1efa/B/ALA/57/CB: 2.827&lt;br /&gt;
1efa/D/DT/14/OP1 to 1efa/B/ASN/25/OD1: 2.858&lt;br /&gt;
1efa/D/DT/14/OP1 to 1efa/B/GLN/54/NE2: 2.996&lt;br /&gt;
1efa/D/DT/14/OP2 to 1efa/B/SER/21/OG: 2.517&lt;br /&gt;
1efa/D/DC/15/N4 to 1efa/B/GLN/18/NE2: 2.723&lt;br /&gt;
1efa/D/DA/16/N6 to 1efa/B/GLN/18/NE2: 2.931&lt;br /&gt;
 &lt;br /&gt;
Number of distances calculated: 9&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#load library&lt;br /&gt;
from pymol import cmd, stored&lt;br /&gt;
import sys&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
#function to judge if a file exists&lt;br /&gt;
def is_non_zero_file(fpath):&lt;br /&gt;
    return os.path.isfile(fpath) and os.path.getsize(fpath) &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
#function to switch atom names within a residue&lt;br /&gt;
def switchName(residueSelection, atomName1, atomName2):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the name of two atoms&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName1, 'name=&amp;quot;gzt&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName2, 'name=&amp;quot;'+atomName1+'&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name gzt&amp;quot;, 'name=&amp;quot;'+atomName2+'&amp;quot;')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#function to change atom names of some residues with symetric sidechain&lt;br /&gt;
def flipAtomName(targetResidueSelection):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the atom names of specific residues&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create flipped residue&lt;br /&gt;
  cmd.create(&amp;quot;flippedRes&amp;quot;,targetResidueSelection+&amp;quot; and not alt B&amp;quot;)&lt;br /&gt;
  targetResidueCa=cmd.get_model(&amp;quot;flippedRes and name CA&amp;quot;)&lt;br /&gt;
  for g in targetResidueCa.atom:&lt;br /&gt;
#   print g.resn&lt;br /&gt;
    if g.resn=='ARG':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;NH1&amp;quot;, &amp;quot;NH2&amp;quot;)&lt;br /&gt;
    elif g.resn=='HIS':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;ND1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASP':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;OD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='PHE':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;OE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='LEU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;ND2&amp;quot;)&lt;br /&gt;
    elif g.resn=='TYR':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='VAL':&lt;br /&gt;
      switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CG1&amp;quot;, &amp;quot;CG2&amp;quot;)&lt;br /&gt;
  cmd.sort()&lt;br /&gt;
# cmd.label(&amp;quot;flippedRes&amp;quot;,&amp;quot;name&amp;quot;)&lt;br /&gt;
  return &amp;quot;flippedRes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#main function&lt;br /&gt;
def rmsdByRes(referenceProteinChain,sel, targetProteinChain):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Update&lt;br /&gt;
    Zhenting Gao on 7/28/2016&lt;br /&gt;
&lt;br /&gt;
  USAGE&lt;br /&gt;
&lt;br /&gt;
    rmsf referenceProteinChain, targetProteinChain, selection [,byres=0], [reference_state=1]&lt;br /&gt;
&lt;br /&gt;
    Calculate the RMSD for each residue pairs from two chains of the same protein from two crystal structures.&lt;br /&gt;
&lt;br /&gt;
  Workflow&lt;br /&gt;
    Read reference and target pdb files&lt;br /&gt;
    Align two structures&lt;br /&gt;
        sel target, proA and chain A&lt;br /&gt;
            #define target protein chain&lt;br /&gt;
        sel refrence, proB and chain A&lt;br /&gt;
            #define reference protein chain&lt;br /&gt;
        align target, reference&lt;br /&gt;
            #automatical alignment&lt;br /&gt;
    Clean attributes&lt;br /&gt;
        otherwise rms_cur will fail&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create temporary objects, exclude alternative conformation B&lt;br /&gt;
  cmd.create(&amp;quot;ref_gzt&amp;quot;, referenceProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
  cmd.create(&amp;quot;target_gzt&amp;quot;, targetProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
#  cmd.align(&amp;quot;target_gzt&amp;quot;,&amp;quot;ref_gzt&amp;quot;,object=&amp;quot;align&amp;quot;)&lt;br /&gt;
# parameters&lt;br /&gt;
  outputText=&amp;quot;&amp;quot;&lt;br /&gt;
  res2Check=['HIS','ASP','ARG','PHE','GLN','GLU','LEU','ASN','TYR','VAL']&lt;br /&gt;
       &lt;br /&gt;
# select alpha carbon of selected residues in reference structure&lt;br /&gt;
  calpha=cmd.get_model(sel+&amp;quot; and name CA and not alt B&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
  for g in calpha.atom:&lt;br /&gt;
#  print g.resi+g.resn&lt;br /&gt;
   if cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi)==cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi):&lt;br /&gt;
    rmsdRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    rmsdResCa=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;)&lt;br /&gt;
    rmsdResBackbone=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;)&lt;br /&gt;
#  calculate minimum rmsd&lt;br /&gt;
    rmsdResMin=rmsdRes&lt;br /&gt;
    if g.resn in res2Check:&lt;br /&gt;
      flippedRes=flipAtomName(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
      rmsdFlippedRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,flippedRes)&lt;br /&gt;
      if rmsdFlippedRes&amp;lt;rmsdRes:&lt;br /&gt;
       rmsdResMin=rmsdFlippedRes&lt;br /&gt;
&lt;br /&gt;
#    print cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi),cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    outputText+=&amp;quot;%s,%s,%s,%.3f,%.3f,%.3f,%.3f\n&amp;quot; % (targetProteinChain,g.resn,g.resi,rmsdRes,rmsdResCa,rmsdResBackbone,rmsdResMin)&lt;br /&gt;
  &lt;br /&gt;
  print outputText&lt;br /&gt;
# Destroy temporary objects&lt;br /&gt;
  cmd.delete(&amp;quot;ref_gzt target_gzt align res_gzt &amp;quot;+flippedRes)&lt;br /&gt;
  &lt;br /&gt;
# Save data into csv&lt;br /&gt;
  outputFile='rmsdByRes_'+sel+'.csv'&lt;br /&gt;
  f=open(outputFile,'a')&lt;br /&gt;
  if not is_non_zero_file(outputFile):&lt;br /&gt;
   f.write(&amp;quot;targe,residueName,residueId,allAtomRMSD,rmsdResCa,rmsdResBackbone,allAtomRMSDMin\n&amp;quot;)&lt;br /&gt;
  f.write(outputText)&lt;br /&gt;
  f.close()&lt;br /&gt;
  print &amp;quot;Results saved in &amp;quot;+outputFile&lt;br /&gt;
  &lt;br /&gt;
cmd.extend(&amp;quot;rmsdByRes&amp;quot;,rmsdByRes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Library]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;br /&gt;
[[Category:Pymol-script-repo]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=User:Zhentg&amp;diff=13761</id>
		<title>User:Zhentg</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=User:Zhentg&amp;diff=13761"/>
		<updated>2016-12-08T06:36:52Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: Created page with &amp;quot;Zhenting Gao [http://www.linkedin.com/in/zhentg &amp;gt;&amp;gt;LinkedIn]&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Zhenting Gao&lt;br /&gt;
[http://www.linkedin.com/in/zhentg &amp;gt;&amp;gt;LinkedIn]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13599</id>
		<title>RmsdByResidue</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13599"/>
		<updated>2016-08-10T08:08:35Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#load library&lt;br /&gt;
from pymol import cmd, stored&lt;br /&gt;
import sys&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
#function to judge if a file exists&lt;br /&gt;
def is_non_zero_file(fpath):&lt;br /&gt;
    return os.path.isfile(fpath) and os.path.getsize(fpath) &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
#function to switch atom names within a residue&lt;br /&gt;
def switchName(residueSelection, atomName1, atomName2):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the name of two atoms&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName1, 'name=&amp;quot;gzt&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName2, 'name=&amp;quot;'+atomName1+'&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name gzt&amp;quot;, 'name=&amp;quot;'+atomName2+'&amp;quot;')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#function to change atom names of some residues with symetric sidechain&lt;br /&gt;
def flipAtomName(targetResidueSelection):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the atom names of specific residues&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create flipped residue&lt;br /&gt;
  cmd.create(&amp;quot;flippedRes&amp;quot;,targetResidueSelection+&amp;quot; and not alt B&amp;quot;)&lt;br /&gt;
  targetResidueCa=cmd.get_model(&amp;quot;flippedRes and name CA&amp;quot;)&lt;br /&gt;
  for g in targetResidueCa.atom:&lt;br /&gt;
#   print g.resn&lt;br /&gt;
    if g.resn=='ARG':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;NH1&amp;quot;, &amp;quot;NH2&amp;quot;)&lt;br /&gt;
    elif g.resn=='HIS':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;ND1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASP':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;OD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='PHE':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;OE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='LEU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;ND2&amp;quot;)&lt;br /&gt;
    elif g.resn=='TYR':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='VAL':&lt;br /&gt;
      switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CG1&amp;quot;, &amp;quot;CG2&amp;quot;)&lt;br /&gt;
  cmd.sort()&lt;br /&gt;
# cmd.label(&amp;quot;flippedRes&amp;quot;,&amp;quot;name&amp;quot;)&lt;br /&gt;
  return &amp;quot;flippedRes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#main function&lt;br /&gt;
def rmsdByRes(referenceProteinChain,sel, targetProteinChain):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Update&lt;br /&gt;
    Zhenting Gao on 7/28/2016&lt;br /&gt;
&lt;br /&gt;
  USAGE&lt;br /&gt;
&lt;br /&gt;
    rmsf referenceProteinChain, targetProteinChain, selection [,byres=0], [reference_state=1]&lt;br /&gt;
&lt;br /&gt;
    Calculate the RMSD for each residue pairs from two chains of the same protein from two crystal structures.&lt;br /&gt;
&lt;br /&gt;
  Workflow&lt;br /&gt;
    Read reference and target pdb files&lt;br /&gt;
    Align two structures&lt;br /&gt;
        sel target, proA and chain A&lt;br /&gt;
            #define target protein chain&lt;br /&gt;
        sel refrence, proB and chain A&lt;br /&gt;
            #define reference protein chain&lt;br /&gt;
        align target, reference&lt;br /&gt;
            #automatical alignment&lt;br /&gt;
    Clean attributes&lt;br /&gt;
        otherwise rms_cur will fail&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create temporary objects, exclude alternative conformation B&lt;br /&gt;
  cmd.create(&amp;quot;ref_gzt&amp;quot;, referenceProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
  cmd.create(&amp;quot;target_gzt&amp;quot;, targetProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
#  cmd.align(&amp;quot;target_gzt&amp;quot;,&amp;quot;ref_gzt&amp;quot;,object=&amp;quot;align&amp;quot;)&lt;br /&gt;
# parameters&lt;br /&gt;
  outputText=&amp;quot;&amp;quot;&lt;br /&gt;
  res2Check=['HIS','ASP','ARG','PHE','GLN','GLU','LEU','ASN','TYR','VAL']&lt;br /&gt;
       &lt;br /&gt;
# select alpha carbon of selected residues in reference structure&lt;br /&gt;
  calpha=cmd.get_model(sel+&amp;quot; and name CA and not alt B&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
  for g in calpha.atom:&lt;br /&gt;
#  print g.resi+g.resn&lt;br /&gt;
   if cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi)==cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi):&lt;br /&gt;
    rmsdRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    rmsdResCa=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;)&lt;br /&gt;
    rmsdResBackbone=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;)&lt;br /&gt;
#  calculate minimum rmsd&lt;br /&gt;
    rmsdResMin=rmsdRes&lt;br /&gt;
    if g.resn in res2Check:&lt;br /&gt;
      flippedRes=flipAtomName(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
      rmsdFlippedRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,flippedRes)&lt;br /&gt;
      if rmsdFlippedRes&amp;lt;rmsdRes:&lt;br /&gt;
       rmsdResMin=rmsdFlippedRes&lt;br /&gt;
&lt;br /&gt;
#    print cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi),cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    outputText+=&amp;quot;%s,%s,%s,%.3f,%.3f,%.3f,%.3f\n&amp;quot; % (targetProteinChain,g.resn,g.resi,rmsdRes,rmsdResCa,rmsdResBackbone,rmsdResMin)&lt;br /&gt;
  &lt;br /&gt;
  print outputText&lt;br /&gt;
# Destroy temporary objects&lt;br /&gt;
  cmd.delete(&amp;quot;ref_gzt target_gzt align res_gzt &amp;quot;+flippedRes)&lt;br /&gt;
  &lt;br /&gt;
# Save data into csv&lt;br /&gt;
  outputFile='rmsdByRes_'+sel+'.csv'&lt;br /&gt;
  f=open(outputFile,'a')&lt;br /&gt;
  if not is_non_zero_file(outputFile):&lt;br /&gt;
   f.write(&amp;quot;targe,residueName,residueId,allAtomRMSD,rmsdResCa,rmsdResBackbone,allAtomRMSDMin\n&amp;quot;)&lt;br /&gt;
  f.write(outputText)&lt;br /&gt;
  f.close()&lt;br /&gt;
  print &amp;quot;Results saved in &amp;quot;+outputFile&lt;br /&gt;
  &lt;br /&gt;
cmd.extend(&amp;quot;rmsdByRes&amp;quot;,rmsdByRes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Library]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;br /&gt;
[[Category:Pymol-script-repo]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13598</id>
		<title>RmsdByResidue</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=RmsdByResidue&amp;diff=13598"/>
		<updated>2016-08-10T08:06:41Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: Created page with &amp;quot;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt; #load library from pymol import cmd, stored import sys import os  #function to judge if a file exists def is_non_zero_file(fpath):     return os.path.is...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#load library&lt;br /&gt;
from pymol import cmd, stored&lt;br /&gt;
import sys&lt;br /&gt;
import os&lt;br /&gt;
&lt;br /&gt;
#function to judge if a file exists&lt;br /&gt;
def is_non_zero_file(fpath):&lt;br /&gt;
    return os.path.isfile(fpath) and os.path.getsize(fpath) &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
#function to switch atom names within a residue&lt;br /&gt;
def switchName(residueSelection, atomName1, atomName2):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the name of two atoms&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName1, 'name=&amp;quot;gzt&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name &amp;quot;+atomName2, 'name=&amp;quot;'+atomName1+'&amp;quot;')&lt;br /&gt;
  cmd.alter(residueSelection+&amp;quot; and name gzt&amp;quot;, 'name=&amp;quot;'+atomName2+'&amp;quot;')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#function to change atom names of some residues with symetric sidechain&lt;br /&gt;
def flipAtomName(targetResidueSelection):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  switch the atom names of specific residues&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create flipped residue&lt;br /&gt;
  cmd.create(&amp;quot;flippedRes&amp;quot;,targetResidueSelection+&amp;quot; and not alt B&amp;quot;)&lt;br /&gt;
  targetResidueCa=cmd.get_model(&amp;quot;flippedRes and name CA&amp;quot;)&lt;br /&gt;
  for g in targetResidueCa.atom:&lt;br /&gt;
#   print g.resn&lt;br /&gt;
    if g.resn=='ARG':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;NH1&amp;quot;, &amp;quot;NH2&amp;quot;)&lt;br /&gt;
    elif g.resn=='HIS':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;ND1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASP':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;OD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='PHE':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;NE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='GLU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OE1&amp;quot;, &amp;quot;OE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='LEU':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
    elif g.resn=='ASN':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;OD1&amp;quot;, &amp;quot;ND2&amp;quot;)&lt;br /&gt;
    elif g.resn=='TYR':&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CD1&amp;quot;, &amp;quot;CD2&amp;quot;)&lt;br /&gt;
     switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CE1&amp;quot;, &amp;quot;CE2&amp;quot;)&lt;br /&gt;
    elif g.resn=='VAL':&lt;br /&gt;
      switchName(&amp;quot;flippedRes&amp;quot;, &amp;quot;CG1&amp;quot;, &amp;quot;CG2&amp;quot;)&lt;br /&gt;
  cmd.sort()&lt;br /&gt;
# cmd.label(&amp;quot;flippedRes&amp;quot;,&amp;quot;name&amp;quot;)&lt;br /&gt;
  return &amp;quot;flippedRes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
#main function&lt;br /&gt;
def rmsdByRes(referenceProteinChain,sel, targetProteinChain):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Update&lt;br /&gt;
    Zhenting Gao on 7/28/2016&lt;br /&gt;
&lt;br /&gt;
  USAGE&lt;br /&gt;
&lt;br /&gt;
    rmsf referenceProteinChain, targetProteinChain, selection [,byres=0], [reference_state=1]&lt;br /&gt;
&lt;br /&gt;
    Calculate the RMSD for each residue pairs from two chains of the same protein from two crystal structures.&lt;br /&gt;
&lt;br /&gt;
  Workflow&lt;br /&gt;
    Read reference and target pdb files&lt;br /&gt;
    Align two structures&lt;br /&gt;
        sel target, proA and chain A&lt;br /&gt;
            #define target protein chain&lt;br /&gt;
        sel refrence, proB and chain A&lt;br /&gt;
            #define reference protein chain&lt;br /&gt;
        align target, reference&lt;br /&gt;
            #automatical alignment&lt;br /&gt;
    Clean attributes&lt;br /&gt;
        otherwise rms_cur will fail&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
# Create temporary objects, exclude alternative conformation B&lt;br /&gt;
  cmd.create(&amp;quot;ref_gzt&amp;quot;, referenceProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;ref_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
  cmd.create(&amp;quot;target_gzt&amp;quot;, targetProteinChain+&amp;quot; and polymer and not alt B&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;chain='A'&amp;quot;)&lt;br /&gt;
  cmd.alter(&amp;quot;target_gzt&amp;quot;, &amp;quot;segi=''&amp;quot;)&lt;br /&gt;
#  cmd.align(&amp;quot;target_gzt&amp;quot;,&amp;quot;ref_gzt&amp;quot;,object=&amp;quot;align&amp;quot;)&lt;br /&gt;
# parameters&lt;br /&gt;
  outputText=&amp;quot;&amp;quot;&lt;br /&gt;
  res2Check=['HIS','ASP','ARG','PHE','GLN','GLU','LEU','ASN','TYR','VAL']&lt;br /&gt;
       &lt;br /&gt;
# select alpha carbon of selected residues in reference structure&lt;br /&gt;
  calpha=cmd.get_model(sel+&amp;quot; and name CA and not alt B&amp;quot;)&lt;br /&gt;
  &lt;br /&gt;
  for g in calpha.atom:&lt;br /&gt;
#  print g.resi+g.resn&lt;br /&gt;
   if cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi)==cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi):&lt;br /&gt;
    rmsdRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    rmsdResCa=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca&amp;quot;)&lt;br /&gt;
    rmsdResBackbone=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;,&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi+&amp;quot; and name ca+n+c+o&amp;quot;)&lt;br /&gt;
#  calculate minimum rmsd&lt;br /&gt;
    rmsdResMin=rmsdRes&lt;br /&gt;
    if g.resn in res2Check:&lt;br /&gt;
      flippedRes=flipAtomName(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
      rmsdFlippedRes=cmd.rms_cur(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi,flippedRes)&lt;br /&gt;
      if rmsdFlippedRes&amp;lt;rmsdRes:&lt;br /&gt;
       rmsdResMin=rmsdFlippedRes&lt;br /&gt;
&lt;br /&gt;
#    print cmd.count_atoms(&amp;quot;ref_gzt and polymer and resi &amp;quot;+g.resi),cmd.count_atoms(&amp;quot;target_gzt and polymer and resi &amp;quot;+g.resi)&lt;br /&gt;
    outputText+=&amp;quot;%s,%s,%s,%.3f,%.3f,%.3f,%.3f\n&amp;quot; % (targetProteinChain,g.resn,g.resi,rmsdRes,rmsdResCa,rmsdResBackbone,rmsdResMin)&lt;br /&gt;
  &lt;br /&gt;
  print outputText&lt;br /&gt;
# Destroy temporary objects&lt;br /&gt;
  cmd.delete(&amp;quot;ref_gzt target_gzt align res_gzt &amp;quot;+flippedRes)&lt;br /&gt;
  &lt;br /&gt;
# Save data into csv&lt;br /&gt;
  outputFile='rmsdByRes_'+sel+'.csv'&lt;br /&gt;
  f=open(outputFile,'a')&lt;br /&gt;
  if not is_non_zero_file(outputFile):&lt;br /&gt;
   f.write(&amp;quot;targe,residueName,residueId,allAtomRMSD,rmsdResCa,rmsdResBackbone,allAtomRMSDMin\n&amp;quot;)&lt;br /&gt;
  f.write(outputText)&lt;br /&gt;
  f.close()&lt;br /&gt;
  print &amp;quot;Results saved in &amp;quot;+outputFile&lt;br /&gt;
  &lt;br /&gt;
cmd.extend(&amp;quot;rmsdByRes&amp;quot;,rmsdByRes)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script Library]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=BiologicalUnit&amp;diff=863</id>
		<title>BiologicalUnit</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=BiologicalUnit&amp;diff=863"/>
		<updated>2011-09-26T05:06:30Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This script can be used to re-create biological units for proteins.  (This was created as a workaround of PyMOL's semi-functioning [[Symexp]] command.)  It's also a fun script to play with for learning about symmetry.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery widths=250px heights=250px&amp;gt;&lt;br /&gt;
Image:before.png|single unit, before running this program&lt;br /&gt;
Image:after.png|after the expansion of the 60 units&lt;br /&gt;
Image:1rmv fiber.png|Example creating the biological unit for PDB 1RMV created from fiber diffraction.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
load /path/to/some/pdbFile.pdb&lt;br /&gt;
symMat = readSymmetry(&amp;quot;/path/to/some/pdbFile.pdb&amp;quot;,&amp;quot;pdbFile&amp;quot;)&lt;br /&gt;
biologicalUnit(&amp;quot;mates&amp;quot;, &amp;quot;pdbFile&amp;quot;, symMat)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
# Jason Vertrees &amp;lt;Jason-dot-Vertrees-at-schrodinger_dot_com&amp;gt;, 2010.&lt;br /&gt;
#&lt;br /&gt;
import pymol&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
&lt;br /&gt;
def readSymmetry(inFile, verbose=None):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  This function will read &amp;quot;inFile&amp;quot; and glean the&lt;br /&gt;
  symmetry operations, if any, from it.&lt;br /&gt;
  &lt;br /&gt;
  PARAMS&lt;br /&gt;
    inFile&lt;br /&gt;
      (string) path to PDB file&lt;br /&gt;
      &lt;br /&gt;
    verbose&lt;br /&gt;
      (boolean) if verbose is not None, print more&lt;br /&gt;
      &lt;br /&gt;
  RETURNS&lt;br /&gt;
    matrix&lt;br /&gt;
      Array of lists.  One 16-element list per symmetry operation.  Feed this matrix&lt;br /&gt;
      into manualSymExp in order to make the other symmetry mates in the biological unit&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  # a remark-350 lines has:&lt;br /&gt;
  # REMARK 350 BIOMTn TAGn X Y Z Tx&lt;br /&gt;
  REM, TAG, BIOMT, OPNO, X, Y, Z, TX = range(8)&lt;br /&gt;
  &lt;br /&gt;
  thePDB = open(inFile, 'rb').readlines()&lt;br /&gt;
  &lt;br /&gt;
  matrices = []&lt;br /&gt;
  curTrans = -1&lt;br /&gt;
  &lt;br /&gt;
  # The transformation is,&lt;br /&gt;
  # output = U*input + Tx&lt;br /&gt;
  &lt;br /&gt;
  for l in thePDB:&lt;br /&gt;
    tokens = l.split()&lt;br /&gt;
    if len(tokens)!=8:&lt;br /&gt;
      continue&lt;br /&gt;
    if tokens[REM]==&amp;quot;REMARK&amp;quot; and tokens[TAG]==&amp;quot;350&amp;quot; and tokens[BIOMT].startswith(&amp;quot;BIOMT&amp;quot;):&lt;br /&gt;
      if tokens[OPNO]!=curTrans:&lt;br /&gt;
        # new transformation matrix&lt;br /&gt;
        matrices.append([])&lt;br /&gt;
      &lt;br /&gt;
      matrices[-1].append( map( lambda s: float(s), tokens[X:]))&lt;br /&gt;
      curTrans = tokens[OPNO]&lt;br /&gt;
&lt;br /&gt;
  if verbose!=None:&lt;br /&gt;
    print &amp;quot;Found %s symmetry operators in %s.&amp;quot; % (len(matrices), inFile)&lt;br /&gt;
  return matrices&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
def biologicalUnit(prefix, objSel, matrices ):&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  Manually expands the object in &amp;quot;objSel&amp;quot; by the symmetry operations provided in &amp;quot;matrices&amp;quot; and&lt;br /&gt;
  prefixes the new objects with &amp;quot;prefix&amp;quot;.&lt;br /&gt;
  &lt;br /&gt;
  PARAMS&lt;br /&gt;
    prefix&lt;br /&gt;
      (string) prefix name for new objects&lt;br /&gt;
    &lt;br /&gt;
    objSel&lt;br /&gt;
      (string) name of object to expand&lt;br /&gt;
      &lt;br /&gt;
    matrices&lt;br /&gt;
      (list of 16-element lists) array of matrices from readSymmetry&lt;br /&gt;
      &lt;br /&gt;
    RETUNRS&lt;br /&gt;
      None&lt;br /&gt;
  &lt;br /&gt;
    SIDE EFFECTS&lt;br /&gt;
      Creates N new obects each rotated and translated according to the symmetry operators, where N&lt;br /&gt;
      equals len(matrices).&lt;br /&gt;
  &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
  for m in matrices:&lt;br /&gt;
    n = cmd.get_unused_name(prefix)&lt;br /&gt;
    cmd.create(n, objSel)&lt;br /&gt;
    s1 = &amp;quot;%s + (x*%s + y*%s + z*%s)&amp;quot; % (m[0][3], m[0][0], m[0][1], m[0][2])&lt;br /&gt;
    s2 = &amp;quot;%s + (x*%s + y*%s + z*%s)&amp;quot; % (m[1][3], m[1][0], m[1][1], m[1][2])&lt;br /&gt;
    s3 = &amp;quot;%s + (x*%s + y*%s + z*%s)&amp;quot; % (m[2][3], m[2][0], m[2][1], m[2][2])&lt;br /&gt;
    cmd.alter_state(1, n, &amp;quot;(x,y,z) = (%s, %s, %s)&amp;quot; % (s1, s2, s3) )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Notes =&lt;br /&gt;
This is slow compared to [[Symexp]]; use the above for learning, playing and when [[Symexp]] doesn't work as advertised.&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
*[[BiologicalUnit/Quat]] (alternative implementation)&lt;br /&gt;
*[[Symexp]]&lt;br /&gt;
*[[SuperSym]]&lt;br /&gt;
*[http://pdbbeta.rcsb.org/pdb/static.do?p=education_discussion/Looking-at-Structures/bioassembly_tutorial.html PDB Tutorial Biol. Units]&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Fiber_diffraction Wikipedia article]&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Talk:BiologicalUnit&amp;diff=292</id>
		<title>Talk:BiologicalUnit</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Talk:BiologicalUnit&amp;diff=292"/>
		<updated>2010-05-20T06:07:47Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[User:Zhentg|Dr. Zhenting Gao]] 06:07, 20 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
The script does not work for me. Can anyone help me out?&lt;br /&gt;
&lt;br /&gt;
My procedure is&lt;br /&gt;
#Open PyMOL&lt;br /&gt;
#run E:/readSymmetry.py&lt;br /&gt;
#symMat = readSymmetry(&amp;quot;E:/pdb1k4c.pdb&amp;quot;,&amp;quot;pdbFile&amp;quot;)&lt;br /&gt;
#biologicalUnit(&amp;quot;mates&amp;quot;, &amp;quot;pdbFile&amp;quot;, symMat)&lt;br /&gt;
#Then the following error occurs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;d:\cadd\pymol/modules\pymol\parser.py&amp;quot;, line 455, in parse&lt;br /&gt;
    exec(layer.com2+&amp;quot;\n&amp;quot;,self.pymol_names,self.pymol_names)&lt;br /&gt;
  File &amp;quot;&amp;lt;string&amp;gt;&amp;quot;, line 1, in ?&lt;br /&gt;
  File &amp;quot;E:/readSymmetry.py&amp;quot;, line 77, in biologicalUnit&lt;br /&gt;
    n = cmd.get_unused_name(prefix)&lt;br /&gt;
AttributeError: 'module' object has no attribute 'get_unused_name'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Talk:BiologicalUnit&amp;diff=291</id>
		<title>Talk:BiologicalUnit</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Talk:BiologicalUnit&amp;diff=291"/>
		<updated>2010-05-20T06:07:19Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: Created page with '~~~~  The script does not work for me.  My procedure is #Open PyMOL #run E:/readSymmetry.py #symMat = readSymmetry(&amp;quot;E:/pdb1k4c.pdb&amp;quot;,&amp;quot;pdbFile&amp;quot;) #biologicalUnit(&amp;quot;mates&amp;quot;, &amp;quot;pdbFile&amp;quot;,…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[User:Zhentg|Dr. Zhenting Gao]] 06:07, 20 May 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
The script does not work for me.&lt;br /&gt;
&lt;br /&gt;
My procedure is&lt;br /&gt;
#Open PyMOL&lt;br /&gt;
#run E:/readSymmetry.py&lt;br /&gt;
#symMat = readSymmetry(&amp;quot;E:/pdb1k4c.pdb&amp;quot;,&amp;quot;pdbFile&amp;quot;)&lt;br /&gt;
#biologicalUnit(&amp;quot;mates&amp;quot;, &amp;quot;pdbFile&amp;quot;, symMat)&lt;br /&gt;
#Then the following error occurs&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;d:\cadd\pymol/modules\pymol\parser.py&amp;quot;, line 455, in parse&lt;br /&gt;
    exec(layer.com2+&amp;quot;\n&amp;quot;,self.pymol_names,self.pymol_names)&lt;br /&gt;
  File &amp;quot;&amp;lt;string&amp;gt;&amp;quot;, line 1, in ?&lt;br /&gt;
  File &amp;quot;E:/readSymmetry.py&amp;quot;, line 77, in biologicalUnit&lt;br /&gt;
    n = cmd.get_unused_name(prefix)&lt;br /&gt;
AttributeError: 'module' object has no attribute 'get_unused_name'&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Cealign_plugin&amp;diff=13275</id>
		<title>Cealign plugin</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cealign_plugin&amp;diff=13275"/>
		<updated>2009-06-08T07:43:28Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
'''Go directly to [[Cealign#Version_0.8-RBS|DOWNLOAD]]'''&lt;br /&gt;
&lt;br /&gt;
This page is the home page of the open-source CEAlign PyMOL plugin.  The CE algorithm is a fast and accurate protein structure alignment algorithm, pioneered by Drs. Shindyalov and Bourne (See &lt;br /&gt;
References).  There are a few changes from the original CE publication (See Notes).  &lt;br /&gt;
&lt;br /&gt;
The source code is implemented in C with the rotations finally done by Numpy in Python.  Because the computationally complex portion of the code is written in C, it's quick.  That is, on my machines --- relatively fast 64-bit machines --- I can align two 400+ amino acid structures in about 0.300 s with the C++ implementation.&lt;br /&gt;
&lt;br /&gt;
This plugs into PyMol very easily.  See [[Cealign#The_Code|the code]] and [[Cealign#Examples|examples]] for installation and usage.&lt;br /&gt;
&lt;br /&gt;
== Comparison to PyMol ==&lt;br /&gt;
'''Why should you use this?'''&lt;br /&gt;
&lt;br /&gt;
PyMOL's structure alignment algorithm is fast and robust.  However, its first step is to perform a sequence alignment of the two selections.  Thus, proteins in the '''twilight zone''' or those having a low sequence identity, may not align well.  Because CE is a structure-based alignment, this is not a problem.  Consider the following example.  The image at LEFT was the result of CE-aligning two proteins (1C0M chain B to 1BCO).  The result is '''152''' aligned (alpha carbons) residues (not atoms) at '''4.96 Angstroms'''.  The image on the RIGHT shows the results from PyMol's align command: an alignment of '''221 atoms''' (not residues) at an RMSD of '''15.7 Angstroms'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:cealign_ex1.png|Cealign's results (152 aligned; 4.96 Ang.)&lt;br /&gt;
Image:pymol_align.png|PyMol's results (763 atoms; 18.4 Ang. )&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit vs. optAlign ===&lt;br /&gt;
====Take Home messages====&lt;br /&gt;
* [[fit]] and [[optAlign]] perform nearly equally as well&lt;br /&gt;
* if you need an algorithm with an appropriate reference, use [[optAlign]] (references at bottom of page).&lt;br /&gt;
* [[fit]] is faster -- if you're aligning many structures, use it over [[optAlign]]&lt;br /&gt;
&lt;br /&gt;
====Discussion====&lt;br /&gt;
[[optAlign]] is a function within the [[Cealign]] package that performs the optimal superposition of two objects of equal length.  [[optAlign]] follows the Kabsch algorithm which is a closed form, and provably optimal solution to the problem.  [[fit]] on the other hand uses the Jacobi rotations to iteratively arrive at the solution of optimal superposition.  The difference in error between [[optAilgn]] and [[fit]] seems to be a non-issue (see below) as they both arrive at equivalent solutions for the rotation matrix.  The two algorithms are undertake different approaches to orthogonally diagonalizing the correlation matrix.&lt;br /&gt;
&lt;br /&gt;
PyMOL's [[fit]] is fast and works well.  If you have to use something with a known reference then check out the &amp;quot;optAlign&amp;quot; function from the qkabsch.py file that comes with this [[Calign]] package.  If not, you can just use [[fit]] and avoid installing new software.  :-)&lt;br /&gt;
&lt;br /&gt;
optAlign is slower than fit.  I just tested both on a sample NMR ensemble; and, while not an extensive validation of &amp;quot;fit&amp;quot; it shows that (1) fit is faster; and (2) fit gets the same exact RMSD as &amp;quot;optAlign&amp;quot; (when optAlign is told to use all atoms, not just CA).  To make optAlign use all atoms and not just the alpha-carbon backbones, comment out (that is, put a &amp;quot;#&amp;quot; at the start of lines 183 and 184 in qkabsch.py, where it says &amp;quot;CUT HERE&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fetch 1nmr&lt;br /&gt;
split_states 1nmr&lt;br /&gt;
delete 1nmr&lt;br /&gt;
&lt;br /&gt;
# compare fit and optAlign RMSDs&lt;br /&gt;
for x in cmd.get_names(): print cmd.fit(&amp;quot;1nmr_0001&amp;quot;, x)&lt;br /&gt;
for x in cmd.get_names(): optAlign(x, &amp;quot;1nmr_0001&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source  lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# results from fit&lt;br /&gt;
0.0&lt;br /&gt;
4.50344991684&lt;br /&gt;
5.33588504791&lt;br /&gt;
5.78613853455&lt;br /&gt;
7.25597000122&lt;br /&gt;
6.67145586014&lt;br /&gt;
3.25131297112&lt;br /&gt;
3.36766290665&lt;br /&gt;
6.74802017212&lt;br /&gt;
5.1579709053&lt;br /&gt;
5.96959495544&lt;br /&gt;
6.68093347549&lt;br /&gt;
4.13217163086&lt;br /&gt;
5.51539039612&lt;br /&gt;
6.24266338348&lt;br /&gt;
6.03838825226&lt;br /&gt;
5.01363992691&lt;br /&gt;
5.33336305618&lt;br /&gt;
6.87617444992&lt;br /&gt;
7.797062397&lt;br /&gt;
&lt;br /&gt;
#results from optAlign&lt;br /&gt;
RMSD=0.000000&lt;br /&gt;
RMSD=4.503450&lt;br /&gt;
RMSD=5.335886&lt;br /&gt;
RMSD=5.786138&lt;br /&gt;
RMSD=7.255970&lt;br /&gt;
RMSD=6.671456&lt;br /&gt;
RMSD=3.251313&lt;br /&gt;
RMSD=3.367663&lt;br /&gt;
RMSD=6.748021&lt;br /&gt;
RMSD=5.157971&lt;br /&gt;
RMSD=5.969595&lt;br /&gt;
RMSD=6.680934&lt;br /&gt;
RMSD=4.132172&lt;br /&gt;
RMSD=5.515390&lt;br /&gt;
RMSD=6.242664&lt;br /&gt;
RMSD=6.038388&lt;br /&gt;
RMSD=5.013640&lt;br /&gt;
RMSD=5.333363&lt;br /&gt;
RMSD=6.876174&lt;br /&gt;
RMSD=7.797062&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
=== Usage ===&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&lt;br /&gt;
CEAlign has the semantic, and syntactic formalism of&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign MASTER, TARGET&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where a post-condition of the algorithm is that the coordinates of the '''MASTER''' protein are unchanged.  This allows for easier multi-protein alignments.  For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1AUE, 1BZ4&lt;br /&gt;
cealign 1AUE, 1B68&lt;br /&gt;
cealign 1AUE, 1A7V&lt;br /&gt;
cealign 1AUE, 1CPR&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will superimpose all the TARGETS onto the MASTER.&lt;br /&gt;
&lt;br /&gt;
=====Examples=====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1cll and i. 42-55, 1ggz and c. A&lt;br /&gt;
cealign 1kao, 1ctq&lt;br /&gt;
cealign 1fao, 1eaz&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Multiple Structure Alignments=====&lt;br /&gt;
Use the '''alignto''' command, now provided with cealign.  Just type,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
alignto PROT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to align all your proteins in PyMOL to the one called, '''PROT'''.&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
See '''Changes''' for updates.  But, overall, the results here are great.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:v7_1fao_1eaz.png|EASY: 1FAO vs. 1EAZ; 96 residues, 1.28 Ang&lt;br /&gt;
Image:v7_1cbs_1hmt.png|EASY: 1CBS vs. 1HMT; 128 residues, 2.01 Ang&lt;br /&gt;
Image:v7_1a15_1b50.png|MODERATE: 1A15 vs 1B50; 56 residues, 2.54 Ang.&lt;br /&gt;
Image:v7_1oan_1s6n.png|EASY: 1OAN vs. 1S6N (state 1); 96 residues aligned to 3.83 Ang. RMSD.&lt;br /&gt;
Image:v7_1rlw_1byn.png|HARD: 1RLW to 1BYN; 104 residues; 2.21 Ang.&lt;br /&gt;
Image:v7_1ten_3hhr.png|HARD: 1TEN vs. 3HHR; 80 residues, 2.91 Ang.&lt;br /&gt;
Image:v7_2sim_1nsb.png|HARD: 2SIM vs. 1NSB; 272 residues, 4.93 Ang.&lt;br /&gt;
Image:v7_1cew_1mol.png|HARD: 1CEW vs. 1MOL; 80 residues, 4.03 Ang.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
===Mac OS X (10.5)===&lt;br /&gt;
[[Image:Cealign mac os x.png|300px|thumb|center|CEAlign running on Mac OS X (10.5)]]&lt;br /&gt;
* Install PyMOL under fink.&lt;br /&gt;
* Install Numpy for fink:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
/sw/bin/fink install scipy-core-py25&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* Download and install cealign (download instructions below)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo /sw/bin/python setup.py install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* In PyMOL, run the two scripts needed for cealing: &amp;quot;cealign.py&amp;quot; and &amp;quot;qkabsch.py&amp;quot;. These are located in the cealign directory you previously downloaded.&lt;br /&gt;
* Voila!&lt;br /&gt;
* Note that the above python version must match the same version that is used by PyMOL. If you are using the pre-compiled version of MacPyMOL, the above instructions won't work.&lt;br /&gt;
&lt;br /&gt;
===Windows systems===&lt;br /&gt;
This is a quick and dirty method to get it working on Win32 right now, more details coming soon.&lt;br /&gt;
====Requirements====&lt;br /&gt;
* Latest PyMol, installed on your system&lt;br /&gt;
* Numpy for python 2.4 -- quick download of just what's needed: http://users.umassmed.edu/Shivender.Shandilya/pymol/numpy.zip[Note: the numpy.zip here are corrupt, users may download the latest 'Numpy for python 2.4' directly from SourceForge.net &amp;lt;[[User:Zhentg|Dr. Zhenting Gao]] 07:43, 8 June 2009 (UTC)&amp;gt;]&lt;br /&gt;
* Pre-compiled ccealign.pyd python module: http://users.umassmed.edu/Shivender.Shandilya/pymol/ccealign.zip&lt;br /&gt;
* Modified pymolrc: http://users.umassmed.edu/Shivender.Shandilya/pymol/pymolrc&lt;br /&gt;
* cealign.py and qkabsch.py from the Cealign-0.8-RBS package: download below&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# Unzip the numpy.zip file, which will give you a folder named '''numpy'''&lt;br /&gt;
# Move this entire folder to: C:\Program Files\DeLano Scientific\PyMOL\modules\  (or the corresponding location on your system)&lt;br /&gt;
# Unzip ccealign.zip, which will give you a file called  '''ccealign.pyd'''&lt;br /&gt;
# Move this pyd file to: C:\Program Files\DeLano Scientific\PyMOL\py24\DLLs\  (or the corresponding location on your system)&lt;br /&gt;
# Copy the downloaded '''pymolrc''' file to: C:\Program Files\DeLano Scientific\PyMOL\   (or the corresponding location on your system)&lt;br /&gt;
# Extract and copy the files cealign.py and qkabsch.py from the Cealign-0.8-RBS package to: C:\Program Files\DeLano Scientific\PyMOL\py24\Lib\   (or the corresponding location on your system)&lt;br /&gt;
# Run PyMol and load some molecules&lt;br /&gt;
# Run this command in Pymol: '''cealign molecule1, molecule2'''&lt;br /&gt;
# Enjoy!&lt;br /&gt;
&lt;br /&gt;
===Gentoo Linux===&lt;br /&gt;
Add the science overlay via&lt;br /&gt;
 layman -a sci&lt;br /&gt;
and emerge the cealign plugin&lt;br /&gt;
 emerge pymol-plugins-cealign&lt;br /&gt;
&lt;br /&gt;
===*nix systems===&lt;br /&gt;
====Requirements====&lt;br /&gt;
* C compiler&lt;br /&gt;
* Python 2.4+ with distutils&lt;br /&gt;
* Numpy&lt;br /&gt;
** for User-compiled PyMOL: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install&amp;lt;/source&amp;gt;&lt;br /&gt;
** for the precompiled version of PyMOL &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR_TO/pymol/ext/&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# uncompress the distribution file '''cealign-VERSION.tgz'''&lt;br /&gt;
# cd cealign-VERSION&lt;br /&gt;
# sudo python setup.py install  # if you installed by PyMOL by hand&lt;br /&gt;
## python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR/TO/pymol/ext/  # if you are using the precompiled binary download&lt;br /&gt;
# insert &amp;quot;run DIR_TO_CEALIGN/cealign.py&amp;quot; and &amp;quot;run DIR_TO_CEALIGN/qkabsch.py&amp;quot; into your '''.pymolrc''' file, or just run the two Python scripts by hand.&lt;br /&gt;
# load some molecules&lt;br /&gt;
# run, '''cealign molecule1, molecule2'''&lt;br /&gt;
# enjoy&lt;br /&gt;
&lt;br /&gt;
=====Pre-compiled Hackish Install=====&lt;br /&gt;
For those people that prefer to use the pre-compiled version of PyMOL, here are the basics for your install.  '''This is a poor method of installing Cealign.  I suggest users compile and install their own PyMOL.'''  The final goal is to get &lt;br /&gt;
# '''ccealign.so''' module into '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# numpy installed (get the numpy directory into (or linked into) '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# and be able to run cealign.py and qkabsch.py from PyMOL.&lt;br /&gt;
If you can do the above three steps, '''cealign''' should run from the pre-compiled PyMOL.&lt;br /&gt;
&lt;br /&gt;
In more detail, on a completely fictitious machine --- that is, I created the following commands from a fake machine and I don't expect a copy/paste of this to work '''anywhere''', but the commands should be helpful enough to those who need it:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# NOTES:&lt;br /&gt;
# This is fake code: don't copy/paste it.&lt;br /&gt;
#&lt;br /&gt;
# PYMOL='dir to precompiled PyMOL install'&lt;br /&gt;
# CEALIGN='dir where you will unpack cealign'&lt;br /&gt;
# replace lib with lib64 for x86-64&lt;br /&gt;
# install numpy&lt;br /&gt;
apt-get install numpy&lt;br /&gt;
&lt;br /&gt;
# link numpy to PyMOL&lt;br /&gt;
ln -s /usr/local/lib/python2.4/site-packages/numpy PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# download and install Cealign&lt;br /&gt;
wget http://www.pymolwiki.org/images/e/ed/Cealign-0.6.tar.bz2&lt;br /&gt;
tar -jxvf Cealign-0.6.tar.bz2&lt;br /&gt;
cd cealign-0.6&lt;br /&gt;
sudo python setup.py build&lt;br /&gt;
cp build/lib-XYZ-linux/ccealign.so PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# run pymol and try it out&lt;br /&gt;
pymol&lt;br /&gt;
run CEALIGN/cealign.py&lt;br /&gt;
run CEALIGN/qkabsch.py&lt;br /&gt;
fetch 1cew 1mol, async=0&lt;br /&gt;
cealign 1c, 1m&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Code ==&lt;br /&gt;
Please unpack and read the documentation.  All comments/questions should be directed to Jason Vertrees (javertre _at_ utmb ...dot... edu).  &lt;br /&gt;
&lt;br /&gt;
'''LATEST IS v0.8-RBS'''.  (Dedicated to Bryan Sutton for allowing me to use his computer for testing.)&lt;br /&gt;
&lt;br /&gt;
=== Version 0.8-RBS ===&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.tar.bz2|CE Align v0.8-RBS]] (bz2)'''&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.zip|CE Align v0.8-RBS]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
=== Beta Version 0.9 ===&lt;br /&gt;
Use at your own peril.  Please report any problems or inconsistent alignments to this discussion page, or to me directly; my email address all over this page.&lt;br /&gt;
&lt;br /&gt;
'''Improvements/Changes''':&lt;br /&gt;
* All C++&lt;br /&gt;
** So, faster&lt;br /&gt;
** comes with the dependencies built in&lt;br /&gt;
* No numpy&lt;br /&gt;
&lt;br /&gt;
''' Download: [[Media:Cealign-0.9.zip|CE Align v0.9]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
== Coming Soon ==&lt;br /&gt;
* Windows binary&lt;br /&gt;
* Linux Binaries (32bit, x86-64)&lt;br /&gt;
* Better instructions for precompiled distributions&lt;br /&gt;
* Optimization&lt;br /&gt;
&lt;br /&gt;
== Updates ==&lt;br /&gt;
&lt;br /&gt;
=== 2008-03-25 ===&lt;br /&gt;
Pure C++ code released.  See the beta version above.&lt;br /&gt;
&lt;br /&gt;
=== 2007-04-14 ===&lt;br /&gt;
v0.8-RBS source updated.  Found the bug that had been plaguing 32-bit machines.  This should be the last release for a little while.&lt;br /&gt;
&lt;br /&gt;
Also, I provide the option of aligning based solely upon RMSD or upon the better CE-Score.  See the '''References''' for information on the '''CE Score'''.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Post your problems/solutions here.&lt;br /&gt;
&lt;br /&gt;
=== Unicode Issues in Python/Numpy ===&lt;br /&gt;
'''Problem''': Running/Installing cealign gives&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parser.py&amp;quot;,&lt;br /&gt;
line 308, in parse&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parsing.py&amp;quot;,&lt;br /&gt;
line 410, in run_file&lt;br /&gt;
  File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
    import numpy&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 36, in ?&lt;br /&gt;
    import core&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/core/__init__.py&amp;quot;, line 5, in ?&lt;br /&gt;
    import multiarray&lt;br /&gt;
ImportError: /home/byron/software/pymol/ext/lib/python2.4/site-packages/numpy/core/multiarray.so:&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where the important line is&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This problem indicates that your Numpy Unicode is using a different byte-size for unicode characters than is the Python distribution your PyMOL is running from.  For example, this can happen if you use the pre-built PyMOL and some other pre-built Numpy package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': Hand-install Numpy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LinAlg Module Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parser.py&amp;quot;, line 285, in parse&lt;br /&gt;
parsing.run_file(exp_path(args[nest][0]),pymol_names,pymol_names)&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parsing.py&amp;quot;, line 407, in run_file&lt;br /&gt;
execfile(file,global_ns,local_ns)&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 40, in ?&lt;br /&gt;
import linalg&lt;br /&gt;
ImportError: No module named linalg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': You do not have the linear algebra module installed (or Python can't find it) on your machine.  One workaround is to install [http://www.scipy.org/ Scientific Python]. (on debian/ubuntu this can be done by: sudo apt-get install python-scipy) Another is to reinstall the Numpy package from source, ensuring that you have the necessary requirements for the linear algebra module (linpack, lapack, fft, etc.).&lt;br /&gt;
&lt;br /&gt;
=== CCEAlign &amp;amp; NumPy Modules Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;run cealign.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
  File &amp;quot;/usr/local/pymol/scripts/cealign-0.1/cealign.py&amp;quot;, line 59, in ?&lt;br /&gt;
    from ccealign import ccealign&lt;br /&gt;
ImportError: No module named ccealign&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
ImportError: No module named numpy&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': This problem occurs under [http://www.apple.com/macosx Apple Mac OS X] if (a) the Apple's python executable on your machine (/usr/bin/python, currently version 2.3.5) is superseded by [http://fink.sourceforge.net/ Fink]'s python executable (/sw/bin/python, currently version 2.5) and (b) you are using [http://delsci.com/rel/099/#MacOSX precompiled versions of PyMOL] (MacPyMOL, PyMOLX11Hybrid or PyMOL for Mac OS X/X11). These executables ignore Fink's python and instead use Apple's - so, in order to run CE Align, one must install NumPy (as well as CE Align itself) using Apple's python. To do so, first download the [http://sourceforge.net/project/showfiles.php?group_id=1369&amp;amp;package_id=175103 Numpy source code archive] (currently version 1.0.1), unpack it, change directory to numpy-1.0.1 and specify the full path to Apple's python executable during installation: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;. Then, donwload the [http://www.pymolwiki.org/index.php/Cealign#The_Code CE Align source code archive] (currently version 0.2), unpack it, change directory to cealign-0.2 and finally install CE Align as follows: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;.&lt;br /&gt;
[[User:Lucajovine|Luca Jovine]] 05:11, 25 January 2007 (CST).&lt;br /&gt;
&lt;br /&gt;
=== The Function SimpAlign() is not found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;cealign 1CLL,1GGZ&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;C:\Program Files (x86)\DeLano Scientific\PyMOL/modules\pymol\parser.py&amp;quot;, line 203, in parse&lt;br /&gt;
    result=apply(kw[nest][0],args[nest],kw_args[nest])&lt;br /&gt;
  File &amp;quot;py24/Lib/cealign.py&amp;quot;, line 177, in cealign&lt;br /&gt;
    curScore = simpAlign( matA, matB, mol1, mol2, stored.mol1, stored.mol2, align=0, L=len(matA) )&lt;br /&gt;
NameError: global name 'simpAlign' is not defined&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
I am running PyMOL v. 0.99rc6 on Win XP Professional x64 edition version 2003 sp2 and have followed the windows install procedure as described above.&lt;br /&gt;
&lt;br /&gt;
'''Answer''': This simply means that PyMOL couldn't find the simplAlign function.  To let PyMOL know about this, you must run the following commands before running [[cealign]]:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run /your/path/to/cealign/qkabsch.py&lt;br /&gt;
run /your/path/to/cealign/cealign.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
but most people that use cealign would just put these two lines in their '''.pymolrc''' file.&lt;br /&gt;
&lt;br /&gt;
=== Short Alignments Don't Work ===&lt;br /&gt;
If you are trying to align fewer than 16 residues then use [[align]], [[super]], or [[optAlign]].  CE uses a window size of 8; and to build a path of more than one window, you need 2*8=16 residues.  I will insert some code to re-route small alignments to one of the aforementioned alignment algorithms.&lt;br /&gt;
&lt;br /&gt;
=== It Worked A Second Ago! ===&lt;br /&gt;
[[Image:Rewind.png|thumb|right|Showing the rewind button to rewind to state 1.]]&lt;br /&gt;
&lt;br /&gt;
If you were using cealign (or alignto) and now the commands don't work -- that is, they return an RMSD, but don't actually superimpose the objects, then you have a simple problem dealing with states.  Most likely the cause of this oddness was (1) when you issued &amp;quot;cealign prot1, prot2&amp;quot; one of them was actually an ensemble of states or (2) you are trying to align to proteins with only one state, but are not looking at state one (because the last protein you were considering had more than one state and you quit editing that protein on a state that's not state 1).  To fix this, use the rewind button to get the proteins back into state 1 &amp;amp; reissue the cealign/alignto command.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Text taken from PubMed and formatted for the wiki.  The first reference is the most important for this code.&lt;br /&gt;
&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''Protein structure alignment by incremental combinatorial extension (CE) of the optimal path.'''  ''Protein Eng.'' 1998 Sep;11(9):739-47.  PMID: 9796821 [PubMed - indexed for MEDLINE]&lt;br /&gt;
# Jia Y, Dewey TG, Shindyalov IN, Bourne PE. '''A new scoring function and associated statistical significance for structure alignment by CE.'''  ''J Comput Biol.'' 2004;11(5):787-99. PMID: 15700402 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Pekurovsky D, Shindyalov IN, Bourne PE. '''A case study of high-throughput biological data processing on parallel platforms.'''  ''Bioinformatics.'' 2004 Aug 12;20(12):1940-7. Epub 2004 Mar 25.  PMID: 15044237 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''An alternative view of protein fold space.'''  ''Proteins.'' 2000 Feb 15;38(3):247-60.  PMID: 10713986 [PubMed - indexed for MEDLINE]&lt;br /&gt;
&lt;br /&gt;
== License ==&lt;br /&gt;
The CEAlign and all its subprograms that I wrote, are released under the open source Free BSD License (BSDL).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Structure_Alignment|Cealign]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Cealign&amp;diff=2967</id>
		<title>Cealign</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cealign&amp;diff=2967"/>
		<updated>2009-06-08T07:43:28Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
'''Go directly to [[Cealign#Version_0.8-RBS|DOWNLOAD]]'''&lt;br /&gt;
&lt;br /&gt;
This page is the home page of the open-source CEAlign PyMOL plugin.  The CE algorithm is a fast and accurate protein structure alignment algorithm, pioneered by Drs. Shindyalov and Bourne (See &lt;br /&gt;
References).  There are a few changes from the original CE publication (See Notes).  &lt;br /&gt;
&lt;br /&gt;
The source code is implemented in C with the rotations finally done by Numpy in Python.  Because the computationally complex portion of the code is written in C, it's quick.  That is, on my machines --- relatively fast 64-bit machines --- I can align two 400+ amino acid structures in about 0.300 s with the C++ implementation.&lt;br /&gt;
&lt;br /&gt;
This plugs into PyMol very easily.  See [[Cealign#The_Code|the code]] and [[Cealign#Examples|examples]] for installation and usage.&lt;br /&gt;
&lt;br /&gt;
== Comparison to PyMol ==&lt;br /&gt;
'''Why should you use this?'''&lt;br /&gt;
&lt;br /&gt;
PyMOL's structure alignment algorithm is fast and robust.  However, its first step is to perform a sequence alignment of the two selections.  Thus, proteins in the '''twilight zone''' or those having a low sequence identity, may not align well.  Because CE is a structure-based alignment, this is not a problem.  Consider the following example.  The image at LEFT was the result of CE-aligning two proteins (1C0M chain B to 1BCO).  The result is '''152''' aligned (alpha carbons) residues (not atoms) at '''4.96 Angstroms'''.  The image on the RIGHT shows the results from PyMol's align command: an alignment of '''221 atoms''' (not residues) at an RMSD of '''15.7 Angstroms'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:cealign_ex1.png|Cealign's results (152 aligned; 4.96 Ang.)&lt;br /&gt;
Image:pymol_align.png|PyMol's results (763 atoms; 18.4 Ang. )&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit vs. optAlign ===&lt;br /&gt;
====Take Home messages====&lt;br /&gt;
* [[fit]] and [[optAlign]] perform nearly equally as well&lt;br /&gt;
* if you need an algorithm with an appropriate reference, use [[optAlign]] (references at bottom of page).&lt;br /&gt;
* [[fit]] is faster -- if you're aligning many structures, use it over [[optAlign]]&lt;br /&gt;
&lt;br /&gt;
====Discussion====&lt;br /&gt;
[[optAlign]] is a function within the [[Cealign]] package that performs the optimal superposition of two objects of equal length.  [[optAlign]] follows the Kabsch algorithm which is a closed form, and provably optimal solution to the problem.  [[fit]] on the other hand uses the Jacobi rotations to iteratively arrive at the solution of optimal superposition.  The difference in error between [[optAilgn]] and [[fit]] seems to be a non-issue (see below) as they both arrive at equivalent solutions for the rotation matrix.  The two algorithms are undertake different approaches to orthogonally diagonalizing the correlation matrix.&lt;br /&gt;
&lt;br /&gt;
PyMOL's [[fit]] is fast and works well.  If you have to use something with a known reference then check out the &amp;quot;optAlign&amp;quot; function from the qkabsch.py file that comes with this [[Calign]] package.  If not, you can just use [[fit]] and avoid installing new software.  :-)&lt;br /&gt;
&lt;br /&gt;
optAlign is slower than fit.  I just tested both on a sample NMR ensemble; and, while not an extensive validation of &amp;quot;fit&amp;quot; it shows that (1) fit is faster; and (2) fit gets the same exact RMSD as &amp;quot;optAlign&amp;quot; (when optAlign is told to use all atoms, not just CA).  To make optAlign use all atoms and not just the alpha-carbon backbones, comment out (that is, put a &amp;quot;#&amp;quot; at the start of lines 183 and 184 in qkabsch.py, where it says &amp;quot;CUT HERE&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fetch 1nmr&lt;br /&gt;
split_states 1nmr&lt;br /&gt;
delete 1nmr&lt;br /&gt;
&lt;br /&gt;
# compare fit and optAlign RMSDs&lt;br /&gt;
for x in cmd.get_names(): print cmd.fit(&amp;quot;1nmr_0001&amp;quot;, x)&lt;br /&gt;
for x in cmd.get_names(): optAlign(x, &amp;quot;1nmr_0001&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source  lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# results from fit&lt;br /&gt;
0.0&lt;br /&gt;
4.50344991684&lt;br /&gt;
5.33588504791&lt;br /&gt;
5.78613853455&lt;br /&gt;
7.25597000122&lt;br /&gt;
6.67145586014&lt;br /&gt;
3.25131297112&lt;br /&gt;
3.36766290665&lt;br /&gt;
6.74802017212&lt;br /&gt;
5.1579709053&lt;br /&gt;
5.96959495544&lt;br /&gt;
6.68093347549&lt;br /&gt;
4.13217163086&lt;br /&gt;
5.51539039612&lt;br /&gt;
6.24266338348&lt;br /&gt;
6.03838825226&lt;br /&gt;
5.01363992691&lt;br /&gt;
5.33336305618&lt;br /&gt;
6.87617444992&lt;br /&gt;
7.797062397&lt;br /&gt;
&lt;br /&gt;
#results from optAlign&lt;br /&gt;
RMSD=0.000000&lt;br /&gt;
RMSD=4.503450&lt;br /&gt;
RMSD=5.335886&lt;br /&gt;
RMSD=5.786138&lt;br /&gt;
RMSD=7.255970&lt;br /&gt;
RMSD=6.671456&lt;br /&gt;
RMSD=3.251313&lt;br /&gt;
RMSD=3.367663&lt;br /&gt;
RMSD=6.748021&lt;br /&gt;
RMSD=5.157971&lt;br /&gt;
RMSD=5.969595&lt;br /&gt;
RMSD=6.680934&lt;br /&gt;
RMSD=4.132172&lt;br /&gt;
RMSD=5.515390&lt;br /&gt;
RMSD=6.242664&lt;br /&gt;
RMSD=6.038388&lt;br /&gt;
RMSD=5.013640&lt;br /&gt;
RMSD=5.333363&lt;br /&gt;
RMSD=6.876174&lt;br /&gt;
RMSD=7.797062&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
=== Usage ===&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&lt;br /&gt;
CEAlign has the semantic, and syntactic formalism of&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign MASTER, TARGET&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where a post-condition of the algorithm is that the coordinates of the '''MASTER''' protein are unchanged.  This allows for easier multi-protein alignments.  For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1AUE, 1BZ4&lt;br /&gt;
cealign 1AUE, 1B68&lt;br /&gt;
cealign 1AUE, 1A7V&lt;br /&gt;
cealign 1AUE, 1CPR&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will superimpose all the TARGETS onto the MASTER.&lt;br /&gt;
&lt;br /&gt;
=====Examples=====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1cll and i. 42-55, 1ggz and c. A&lt;br /&gt;
cealign 1kao, 1ctq&lt;br /&gt;
cealign 1fao, 1eaz&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Multiple Structure Alignments=====&lt;br /&gt;
Use the '''alignto''' command, now provided with cealign.  Just type,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
alignto PROT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to align all your proteins in PyMOL to the one called, '''PROT'''.&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
See '''Changes''' for updates.  But, overall, the results here are great.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:v7_1fao_1eaz.png|EASY: 1FAO vs. 1EAZ; 96 residues, 1.28 Ang&lt;br /&gt;
Image:v7_1cbs_1hmt.png|EASY: 1CBS vs. 1HMT; 128 residues, 2.01 Ang&lt;br /&gt;
Image:v7_1a15_1b50.png|MODERATE: 1A15 vs 1B50; 56 residues, 2.54 Ang.&lt;br /&gt;
Image:v7_1oan_1s6n.png|EASY: 1OAN vs. 1S6N (state 1); 96 residues aligned to 3.83 Ang. RMSD.&lt;br /&gt;
Image:v7_1rlw_1byn.png|HARD: 1RLW to 1BYN; 104 residues; 2.21 Ang.&lt;br /&gt;
Image:v7_1ten_3hhr.png|HARD: 1TEN vs. 3HHR; 80 residues, 2.91 Ang.&lt;br /&gt;
Image:v7_2sim_1nsb.png|HARD: 2SIM vs. 1NSB; 272 residues, 4.93 Ang.&lt;br /&gt;
Image:v7_1cew_1mol.png|HARD: 1CEW vs. 1MOL; 80 residues, 4.03 Ang.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
===Mac OS X (10.5)===&lt;br /&gt;
[[Image:Cealign mac os x.png|300px|thumb|center|CEAlign running on Mac OS X (10.5)]]&lt;br /&gt;
* Install PyMOL under fink.&lt;br /&gt;
* Install Numpy for fink:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
/sw/bin/fink install scipy-core-py25&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* Download and install cealign (download instructions below)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo /sw/bin/python setup.py install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* In PyMOL, run the two scripts needed for cealing: &amp;quot;cealign.py&amp;quot; and &amp;quot;qkabsch.py&amp;quot;. These are located in the cealign directory you previously downloaded.&lt;br /&gt;
* Voila!&lt;br /&gt;
* Note that the above python version must match the same version that is used by PyMOL. If you are using the pre-compiled version of MacPyMOL, the above instructions won't work.&lt;br /&gt;
&lt;br /&gt;
===Windows systems===&lt;br /&gt;
This is a quick and dirty method to get it working on Win32 right now, more details coming soon.&lt;br /&gt;
====Requirements====&lt;br /&gt;
* Latest PyMol, installed on your system&lt;br /&gt;
* Numpy for python 2.4 -- quick download of just what's needed: http://users.umassmed.edu/Shivender.Shandilya/pymol/numpy.zip[Note: the numpy.zip here are corrupt, users may download the latest 'Numpy for python 2.4' directly from SourceForge.net &amp;lt;[[User:Zhentg|Dr. Zhenting Gao]] 07:43, 8 June 2009 (UTC)&amp;gt;]&lt;br /&gt;
* Pre-compiled ccealign.pyd python module: http://users.umassmed.edu/Shivender.Shandilya/pymol/ccealign.zip&lt;br /&gt;
* Modified pymolrc: http://users.umassmed.edu/Shivender.Shandilya/pymol/pymolrc&lt;br /&gt;
* cealign.py and qkabsch.py from the Cealign-0.8-RBS package: download below&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# Unzip the numpy.zip file, which will give you a folder named '''numpy'''&lt;br /&gt;
# Move this entire folder to: C:\Program Files\DeLano Scientific\PyMOL\modules\  (or the corresponding location on your system)&lt;br /&gt;
# Unzip ccealign.zip, which will give you a file called  '''ccealign.pyd'''&lt;br /&gt;
# Move this pyd file to: C:\Program Files\DeLano Scientific\PyMOL\py24\DLLs\  (or the corresponding location on your system)&lt;br /&gt;
# Copy the downloaded '''pymolrc''' file to: C:\Program Files\DeLano Scientific\PyMOL\   (or the corresponding location on your system)&lt;br /&gt;
# Extract and copy the files cealign.py and qkabsch.py from the Cealign-0.8-RBS package to: C:\Program Files\DeLano Scientific\PyMOL\py24\Lib\   (or the corresponding location on your system)&lt;br /&gt;
# Run PyMol and load some molecules&lt;br /&gt;
# Run this command in Pymol: '''cealign molecule1, molecule2'''&lt;br /&gt;
# Enjoy!&lt;br /&gt;
&lt;br /&gt;
===Gentoo Linux===&lt;br /&gt;
Add the science overlay via&lt;br /&gt;
 layman -a sci&lt;br /&gt;
and emerge the cealign plugin&lt;br /&gt;
 emerge pymol-plugins-cealign&lt;br /&gt;
&lt;br /&gt;
===*nix systems===&lt;br /&gt;
====Requirements====&lt;br /&gt;
* C compiler&lt;br /&gt;
* Python 2.4+ with distutils&lt;br /&gt;
* Numpy&lt;br /&gt;
** for User-compiled PyMOL: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install&amp;lt;/source&amp;gt;&lt;br /&gt;
** for the precompiled version of PyMOL &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR_TO/pymol/ext/&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# uncompress the distribution file '''cealign-VERSION.tgz'''&lt;br /&gt;
# cd cealign-VERSION&lt;br /&gt;
# sudo python setup.py install  # if you installed by PyMOL by hand&lt;br /&gt;
## python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR/TO/pymol/ext/  # if you are using the precompiled binary download&lt;br /&gt;
# insert &amp;quot;run DIR_TO_CEALIGN/cealign.py&amp;quot; and &amp;quot;run DIR_TO_CEALIGN/qkabsch.py&amp;quot; into your '''.pymolrc''' file, or just run the two Python scripts by hand.&lt;br /&gt;
# load some molecules&lt;br /&gt;
# run, '''cealign molecule1, molecule2'''&lt;br /&gt;
# enjoy&lt;br /&gt;
&lt;br /&gt;
=====Pre-compiled Hackish Install=====&lt;br /&gt;
For those people that prefer to use the pre-compiled version of PyMOL, here are the basics for your install.  '''This is a poor method of installing Cealign.  I suggest users compile and install their own PyMOL.'''  The final goal is to get &lt;br /&gt;
# '''ccealign.so''' module into '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# numpy installed (get the numpy directory into (or linked into) '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# and be able to run cealign.py and qkabsch.py from PyMOL.&lt;br /&gt;
If you can do the above three steps, '''cealign''' should run from the pre-compiled PyMOL.&lt;br /&gt;
&lt;br /&gt;
In more detail, on a completely fictitious machine --- that is, I created the following commands from a fake machine and I don't expect a copy/paste of this to work '''anywhere''', but the commands should be helpful enough to those who need it:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# NOTES:&lt;br /&gt;
# This is fake code: don't copy/paste it.&lt;br /&gt;
#&lt;br /&gt;
# PYMOL='dir to precompiled PyMOL install'&lt;br /&gt;
# CEALIGN='dir where you will unpack cealign'&lt;br /&gt;
# replace lib with lib64 for x86-64&lt;br /&gt;
# install numpy&lt;br /&gt;
apt-get install numpy&lt;br /&gt;
&lt;br /&gt;
# link numpy to PyMOL&lt;br /&gt;
ln -s /usr/local/lib/python2.4/site-packages/numpy PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# download and install Cealign&lt;br /&gt;
wget http://www.pymolwiki.org/images/e/ed/Cealign-0.6.tar.bz2&lt;br /&gt;
tar -jxvf Cealign-0.6.tar.bz2&lt;br /&gt;
cd cealign-0.6&lt;br /&gt;
sudo python setup.py build&lt;br /&gt;
cp build/lib-XYZ-linux/ccealign.so PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# run pymol and try it out&lt;br /&gt;
pymol&lt;br /&gt;
run CEALIGN/cealign.py&lt;br /&gt;
run CEALIGN/qkabsch.py&lt;br /&gt;
fetch 1cew 1mol, async=0&lt;br /&gt;
cealign 1c, 1m&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Code ==&lt;br /&gt;
Please unpack and read the documentation.  All comments/questions should be directed to Jason Vertrees (javertre _at_ utmb ...dot... edu).  &lt;br /&gt;
&lt;br /&gt;
'''LATEST IS v0.8-RBS'''.  (Dedicated to Bryan Sutton for allowing me to use his computer for testing.)&lt;br /&gt;
&lt;br /&gt;
=== Version 0.8-RBS ===&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.tar.bz2|CE Align v0.8-RBS]] (bz2)'''&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.zip|CE Align v0.8-RBS]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
=== Beta Version 0.9 ===&lt;br /&gt;
Use at your own peril.  Please report any problems or inconsistent alignments to this discussion page, or to me directly; my email address all over this page.&lt;br /&gt;
&lt;br /&gt;
'''Improvements/Changes''':&lt;br /&gt;
* All C++&lt;br /&gt;
** So, faster&lt;br /&gt;
** comes with the dependencies built in&lt;br /&gt;
* No numpy&lt;br /&gt;
&lt;br /&gt;
''' Download: [[Media:Cealign-0.9.zip|CE Align v0.9]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
== Coming Soon ==&lt;br /&gt;
* Windows binary&lt;br /&gt;
* Linux Binaries (32bit, x86-64)&lt;br /&gt;
* Better instructions for precompiled distributions&lt;br /&gt;
* Optimization&lt;br /&gt;
&lt;br /&gt;
== Updates ==&lt;br /&gt;
&lt;br /&gt;
=== 2008-03-25 ===&lt;br /&gt;
Pure C++ code released.  See the beta version above.&lt;br /&gt;
&lt;br /&gt;
=== 2007-04-14 ===&lt;br /&gt;
v0.8-RBS source updated.  Found the bug that had been plaguing 32-bit machines.  This should be the last release for a little while.&lt;br /&gt;
&lt;br /&gt;
Also, I provide the option of aligning based solely upon RMSD or upon the better CE-Score.  See the '''References''' for information on the '''CE Score'''.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Post your problems/solutions here.&lt;br /&gt;
&lt;br /&gt;
=== Unicode Issues in Python/Numpy ===&lt;br /&gt;
'''Problem''': Running/Installing cealign gives&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parser.py&amp;quot;,&lt;br /&gt;
line 308, in parse&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parsing.py&amp;quot;,&lt;br /&gt;
line 410, in run_file&lt;br /&gt;
  File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
    import numpy&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 36, in ?&lt;br /&gt;
    import core&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/core/__init__.py&amp;quot;, line 5, in ?&lt;br /&gt;
    import multiarray&lt;br /&gt;
ImportError: /home/byron/software/pymol/ext/lib/python2.4/site-packages/numpy/core/multiarray.so:&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where the important line is&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This problem indicates that your Numpy Unicode is using a different byte-size for unicode characters than is the Python distribution your PyMOL is running from.  For example, this can happen if you use the pre-built PyMOL and some other pre-built Numpy package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': Hand-install Numpy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LinAlg Module Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parser.py&amp;quot;, line 285, in parse&lt;br /&gt;
parsing.run_file(exp_path(args[nest][0]),pymol_names,pymol_names)&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parsing.py&amp;quot;, line 407, in run_file&lt;br /&gt;
execfile(file,global_ns,local_ns)&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 40, in ?&lt;br /&gt;
import linalg&lt;br /&gt;
ImportError: No module named linalg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': You do not have the linear algebra module installed (or Python can't find it) on your machine.  One workaround is to install [http://www.scipy.org/ Scientific Python]. (on debian/ubuntu this can be done by: sudo apt-get install python-scipy) Another is to reinstall the Numpy package from source, ensuring that you have the necessary requirements for the linear algebra module (linpack, lapack, fft, etc.).&lt;br /&gt;
&lt;br /&gt;
=== CCEAlign &amp;amp; NumPy Modules Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;run cealign.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
  File &amp;quot;/usr/local/pymol/scripts/cealign-0.1/cealign.py&amp;quot;, line 59, in ?&lt;br /&gt;
    from ccealign import ccealign&lt;br /&gt;
ImportError: No module named ccealign&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
ImportError: No module named numpy&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': This problem occurs under [http://www.apple.com/macosx Apple Mac OS X] if (a) the Apple's python executable on your machine (/usr/bin/python, currently version 2.3.5) is superseded by [http://fink.sourceforge.net/ Fink]'s python executable (/sw/bin/python, currently version 2.5) and (b) you are using [http://delsci.com/rel/099/#MacOSX precompiled versions of PyMOL] (MacPyMOL, PyMOLX11Hybrid or PyMOL for Mac OS X/X11). These executables ignore Fink's python and instead use Apple's - so, in order to run CE Align, one must install NumPy (as well as CE Align itself) using Apple's python. To do so, first download the [http://sourceforge.net/project/showfiles.php?group_id=1369&amp;amp;package_id=175103 Numpy source code archive] (currently version 1.0.1), unpack it, change directory to numpy-1.0.1 and specify the full path to Apple's python executable during installation: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;. Then, donwload the [http://www.pymolwiki.org/index.php/Cealign#The_Code CE Align source code archive] (currently version 0.2), unpack it, change directory to cealign-0.2 and finally install CE Align as follows: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;.&lt;br /&gt;
[[User:Lucajovine|Luca Jovine]] 05:11, 25 January 2007 (CST).&lt;br /&gt;
&lt;br /&gt;
=== The Function SimpAlign() is not found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;cealign 1CLL,1GGZ&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;C:\Program Files (x86)\DeLano Scientific\PyMOL/modules\pymol\parser.py&amp;quot;, line 203, in parse&lt;br /&gt;
    result=apply(kw[nest][0],args[nest],kw_args[nest])&lt;br /&gt;
  File &amp;quot;py24/Lib/cealign.py&amp;quot;, line 177, in cealign&lt;br /&gt;
    curScore = simpAlign( matA, matB, mol1, mol2, stored.mol1, stored.mol2, align=0, L=len(matA) )&lt;br /&gt;
NameError: global name 'simpAlign' is not defined&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
I am running PyMOL v. 0.99rc6 on Win XP Professional x64 edition version 2003 sp2 and have followed the windows install procedure as described above.&lt;br /&gt;
&lt;br /&gt;
'''Answer''': This simply means that PyMOL couldn't find the simplAlign function.  To let PyMOL know about this, you must run the following commands before running [[cealign]]:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run /your/path/to/cealign/qkabsch.py&lt;br /&gt;
run /your/path/to/cealign/cealign.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
but most people that use cealign would just put these two lines in their '''.pymolrc''' file.&lt;br /&gt;
&lt;br /&gt;
=== Short Alignments Don't Work ===&lt;br /&gt;
If you are trying to align fewer than 16 residues then use [[align]], [[super]], or [[optAlign]].  CE uses a window size of 8; and to build a path of more than one window, you need 2*8=16 residues.  I will insert some code to re-route small alignments to one of the aforementioned alignment algorithms.&lt;br /&gt;
&lt;br /&gt;
=== It Worked A Second Ago! ===&lt;br /&gt;
[[Image:Rewind.png|thumb|right|Showing the rewind button to rewind to state 1.]]&lt;br /&gt;
&lt;br /&gt;
If you were using cealign (or alignto) and now the commands don't work -- that is, they return an RMSD, but don't actually superimpose the objects, then you have a simple problem dealing with states.  Most likely the cause of this oddness was (1) when you issued &amp;quot;cealign prot1, prot2&amp;quot; one of them was actually an ensemble of states or (2) you are trying to align to proteins with only one state, but are not looking at state one (because the last protein you were considering had more than one state and you quit editing that protein on a state that's not state 1).  To fix this, use the rewind button to get the proteins back into state 1 &amp;amp; reissue the cealign/alignto command.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Text taken from PubMed and formatted for the wiki.  The first reference is the most important for this code.&lt;br /&gt;
&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''Protein structure alignment by incremental combinatorial extension (CE) of the optimal path.'''  ''Protein Eng.'' 1998 Sep;11(9):739-47.  PMID: 9796821 [PubMed - indexed for MEDLINE]&lt;br /&gt;
# Jia Y, Dewey TG, Shindyalov IN, Bourne PE. '''A new scoring function and associated statistical significance for structure alignment by CE.'''  ''J Comput Biol.'' 2004;11(5):787-99. PMID: 15700402 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Pekurovsky D, Shindyalov IN, Bourne PE. '''A case study of high-throughput biological data processing on parallel platforms.'''  ''Bioinformatics.'' 2004 Aug 12;20(12):1940-7. Epub 2004 Mar 25.  PMID: 15044237 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''An alternative view of protein fold space.'''  ''Proteins.'' 2000 Feb 15;38(3):247-60.  PMID: 10713986 [PubMed - indexed for MEDLINE]&lt;br /&gt;
&lt;br /&gt;
== License ==&lt;br /&gt;
The CEAlign and all its subprograms that I wrote, are released under the open source Free BSD License (BSDL).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Structure_Alignment|Cealign]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Cealign_plugin&amp;diff=13274</id>
		<title>Cealign plugin</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cealign_plugin&amp;diff=13274"/>
		<updated>2009-06-08T07:41:45Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
'''Go directly to [[Cealign#Version_0.8-RBS|DOWNLOAD]]'''&lt;br /&gt;
&lt;br /&gt;
This page is the home page of the open-source CEAlign PyMOL plugin.  The CE algorithm is a fast and accurate protein structure alignment algorithm, pioneered by Drs. Shindyalov and Bourne (See &lt;br /&gt;
References).  There are a few changes from the original CE publication (See Notes).  &lt;br /&gt;
&lt;br /&gt;
The source code is implemented in C with the rotations finally done by Numpy in Python.  Because the computationally complex portion of the code is written in C, it's quick.  That is, on my machines --- relatively fast 64-bit machines --- I can align two 400+ amino acid structures in about 0.300 s with the C++ implementation.&lt;br /&gt;
&lt;br /&gt;
This plugs into PyMol very easily.  See [[Cealign#The_Code|the code]] and [[Cealign#Examples|examples]] for installation and usage.&lt;br /&gt;
&lt;br /&gt;
== Comparison to PyMol ==&lt;br /&gt;
'''Why should you use this?'''&lt;br /&gt;
&lt;br /&gt;
PyMOL's structure alignment algorithm is fast and robust.  However, its first step is to perform a sequence alignment of the two selections.  Thus, proteins in the '''twilight zone''' or those having a low sequence identity, may not align well.  Because CE is a structure-based alignment, this is not a problem.  Consider the following example.  The image at LEFT was the result of CE-aligning two proteins (1C0M chain B to 1BCO).  The result is '''152''' aligned (alpha carbons) residues (not atoms) at '''4.96 Angstroms'''.  The image on the RIGHT shows the results from PyMol's align command: an alignment of '''221 atoms''' (not residues) at an RMSD of '''15.7 Angstroms'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:cealign_ex1.png|Cealign's results (152 aligned; 4.96 Ang.)&lt;br /&gt;
Image:pymol_align.png|PyMol's results (763 atoms; 18.4 Ang. )&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit vs. optAlign ===&lt;br /&gt;
====Take Home messages====&lt;br /&gt;
* [[fit]] and [[optAlign]] perform nearly equally as well&lt;br /&gt;
* if you need an algorithm with an appropriate reference, use [[optAlign]] (references at bottom of page).&lt;br /&gt;
* [[fit]] is faster -- if you're aligning many structures, use it over [[optAlign]]&lt;br /&gt;
&lt;br /&gt;
====Discussion====&lt;br /&gt;
[[optAlign]] is a function within the [[Cealign]] package that performs the optimal superposition of two objects of equal length.  [[optAlign]] follows the Kabsch algorithm which is a closed form, and provably optimal solution to the problem.  [[fit]] on the other hand uses the Jacobi rotations to iteratively arrive at the solution of optimal superposition.  The difference in error between [[optAilgn]] and [[fit]] seems to be a non-issue (see below) as they both arrive at equivalent solutions for the rotation matrix.  The two algorithms are undertake different approaches to orthogonally diagonalizing the correlation matrix.&lt;br /&gt;
&lt;br /&gt;
PyMOL's [[fit]] is fast and works well.  If you have to use something with a known reference then check out the &amp;quot;optAlign&amp;quot; function from the qkabsch.py file that comes with this [[Calign]] package.  If not, you can just use [[fit]] and avoid installing new software.  :-)&lt;br /&gt;
&lt;br /&gt;
optAlign is slower than fit.  I just tested both on a sample NMR ensemble; and, while not an extensive validation of &amp;quot;fit&amp;quot; it shows that (1) fit is faster; and (2) fit gets the same exact RMSD as &amp;quot;optAlign&amp;quot; (when optAlign is told to use all atoms, not just CA).  To make optAlign use all atoms and not just the alpha-carbon backbones, comment out (that is, put a &amp;quot;#&amp;quot; at the start of lines 183 and 184 in qkabsch.py, where it says &amp;quot;CUT HERE&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fetch 1nmr&lt;br /&gt;
split_states 1nmr&lt;br /&gt;
delete 1nmr&lt;br /&gt;
&lt;br /&gt;
# compare fit and optAlign RMSDs&lt;br /&gt;
for x in cmd.get_names(): print cmd.fit(&amp;quot;1nmr_0001&amp;quot;, x)&lt;br /&gt;
for x in cmd.get_names(): optAlign(x, &amp;quot;1nmr_0001&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source  lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# results from fit&lt;br /&gt;
0.0&lt;br /&gt;
4.50344991684&lt;br /&gt;
5.33588504791&lt;br /&gt;
5.78613853455&lt;br /&gt;
7.25597000122&lt;br /&gt;
6.67145586014&lt;br /&gt;
3.25131297112&lt;br /&gt;
3.36766290665&lt;br /&gt;
6.74802017212&lt;br /&gt;
5.1579709053&lt;br /&gt;
5.96959495544&lt;br /&gt;
6.68093347549&lt;br /&gt;
4.13217163086&lt;br /&gt;
5.51539039612&lt;br /&gt;
6.24266338348&lt;br /&gt;
6.03838825226&lt;br /&gt;
5.01363992691&lt;br /&gt;
5.33336305618&lt;br /&gt;
6.87617444992&lt;br /&gt;
7.797062397&lt;br /&gt;
&lt;br /&gt;
#results from optAlign&lt;br /&gt;
RMSD=0.000000&lt;br /&gt;
RMSD=4.503450&lt;br /&gt;
RMSD=5.335886&lt;br /&gt;
RMSD=5.786138&lt;br /&gt;
RMSD=7.255970&lt;br /&gt;
RMSD=6.671456&lt;br /&gt;
RMSD=3.251313&lt;br /&gt;
RMSD=3.367663&lt;br /&gt;
RMSD=6.748021&lt;br /&gt;
RMSD=5.157971&lt;br /&gt;
RMSD=5.969595&lt;br /&gt;
RMSD=6.680934&lt;br /&gt;
RMSD=4.132172&lt;br /&gt;
RMSD=5.515390&lt;br /&gt;
RMSD=6.242664&lt;br /&gt;
RMSD=6.038388&lt;br /&gt;
RMSD=5.013640&lt;br /&gt;
RMSD=5.333363&lt;br /&gt;
RMSD=6.876174&lt;br /&gt;
RMSD=7.797062&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
=== Usage ===&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&lt;br /&gt;
CEAlign has the semantic, and syntactic formalism of&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign MASTER, TARGET&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where a post-condition of the algorithm is that the coordinates of the '''MASTER''' protein are unchanged.  This allows for easier multi-protein alignments.  For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1AUE, 1BZ4&lt;br /&gt;
cealign 1AUE, 1B68&lt;br /&gt;
cealign 1AUE, 1A7V&lt;br /&gt;
cealign 1AUE, 1CPR&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will superimpose all the TARGETS onto the MASTER.&lt;br /&gt;
&lt;br /&gt;
=====Examples=====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1cll and i. 42-55, 1ggz and c. A&lt;br /&gt;
cealign 1kao, 1ctq&lt;br /&gt;
cealign 1fao, 1eaz&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Multiple Structure Alignments=====&lt;br /&gt;
Use the '''alignto''' command, now provided with cealign.  Just type,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
alignto PROT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to align all your proteins in PyMOL to the one called, '''PROT'''.&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
See '''Changes''' for updates.  But, overall, the results here are great.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:v7_1fao_1eaz.png|EASY: 1FAO vs. 1EAZ; 96 residues, 1.28 Ang&lt;br /&gt;
Image:v7_1cbs_1hmt.png|EASY: 1CBS vs. 1HMT; 128 residues, 2.01 Ang&lt;br /&gt;
Image:v7_1a15_1b50.png|MODERATE: 1A15 vs 1B50; 56 residues, 2.54 Ang.&lt;br /&gt;
Image:v7_1oan_1s6n.png|EASY: 1OAN vs. 1S6N (state 1); 96 residues aligned to 3.83 Ang. RMSD.&lt;br /&gt;
Image:v7_1rlw_1byn.png|HARD: 1RLW to 1BYN; 104 residues; 2.21 Ang.&lt;br /&gt;
Image:v7_1ten_3hhr.png|HARD: 1TEN vs. 3HHR; 80 residues, 2.91 Ang.&lt;br /&gt;
Image:v7_2sim_1nsb.png|HARD: 2SIM vs. 1NSB; 272 residues, 4.93 Ang.&lt;br /&gt;
Image:v7_1cew_1mol.png|HARD: 1CEW vs. 1MOL; 80 residues, 4.03 Ang.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
===Mac OS X (10.5)===&lt;br /&gt;
[[Image:Cealign mac os x.png|300px|thumb|center|CEAlign running on Mac OS X (10.5)]]&lt;br /&gt;
* Install PyMOL under fink.&lt;br /&gt;
* Install Numpy for fink:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
/sw/bin/fink install scipy-core-py25&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* Download and install cealign (download instructions below)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo /sw/bin/python setup.py install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* In PyMOL, run the two scripts needed for cealing: &amp;quot;cealign.py&amp;quot; and &amp;quot;qkabsch.py&amp;quot;. These are located in the cealign directory you previously downloaded.&lt;br /&gt;
* Voila!&lt;br /&gt;
* Note that the above python version must match the same version that is used by PyMOL. If you are using the pre-compiled version of MacPyMOL, the above instructions won't work.&lt;br /&gt;
&lt;br /&gt;
===Windows systems===&lt;br /&gt;
This is a quick and dirty method to get it working on Win32 right now, more details coming soon.&lt;br /&gt;
====Requirements====&lt;br /&gt;
* Latest PyMol, installed on your system&lt;br /&gt;
* Numpy for python 2.4 -- quick download of just what's needed: http://users.umassmed.edu/Shivender.Shandilya/pymol/numpy.zip[Note: the numpy.zip here are corrupt, users may download the latest 'Numpy for python 2.4' directly from SourceForge.net]&lt;br /&gt;
* Pre-compiled ccealign.pyd python module: http://users.umassmed.edu/Shivender.Shandilya/pymol/ccealign.zip&lt;br /&gt;
* Modified pymolrc: http://users.umassmed.edu/Shivender.Shandilya/pymol/pymolrc&lt;br /&gt;
* cealign.py and qkabsch.py from the Cealign-0.8-RBS package: download below&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# Unzip the numpy.zip file, which will give you a folder named '''numpy'''&lt;br /&gt;
# Move this entire folder to: C:\Program Files\DeLano Scientific\PyMOL\modules\  (or the corresponding location on your system)&lt;br /&gt;
# Unzip ccealign.zip, which will give you a file called  '''ccealign.pyd'''&lt;br /&gt;
# Move this pyd file to: C:\Program Files\DeLano Scientific\PyMOL\py24\DLLs\  (or the corresponding location on your system)&lt;br /&gt;
# Copy the downloaded '''pymolrc''' file to: C:\Program Files\DeLano Scientific\PyMOL\   (or the corresponding location on your system)&lt;br /&gt;
# Extract and copy the files cealign.py and qkabsch.py from the Cealign-0.8-RBS package to: C:\Program Files\DeLano Scientific\PyMOL\py24\Lib\   (or the corresponding location on your system)&lt;br /&gt;
# Run PyMol and load some molecules&lt;br /&gt;
# Run this command in Pymol: '''cealign molecule1, molecule2'''&lt;br /&gt;
# Enjoy!&lt;br /&gt;
&lt;br /&gt;
===Gentoo Linux===&lt;br /&gt;
Add the science overlay via&lt;br /&gt;
 layman -a sci&lt;br /&gt;
and emerge the cealign plugin&lt;br /&gt;
 emerge pymol-plugins-cealign&lt;br /&gt;
&lt;br /&gt;
===*nix systems===&lt;br /&gt;
====Requirements====&lt;br /&gt;
* C compiler&lt;br /&gt;
* Python 2.4+ with distutils&lt;br /&gt;
* Numpy&lt;br /&gt;
** for User-compiled PyMOL: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install&amp;lt;/source&amp;gt;&lt;br /&gt;
** for the precompiled version of PyMOL &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR_TO/pymol/ext/&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# uncompress the distribution file '''cealign-VERSION.tgz'''&lt;br /&gt;
# cd cealign-VERSION&lt;br /&gt;
# sudo python setup.py install  # if you installed by PyMOL by hand&lt;br /&gt;
## python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR/TO/pymol/ext/  # if you are using the precompiled binary download&lt;br /&gt;
# insert &amp;quot;run DIR_TO_CEALIGN/cealign.py&amp;quot; and &amp;quot;run DIR_TO_CEALIGN/qkabsch.py&amp;quot; into your '''.pymolrc''' file, or just run the two Python scripts by hand.&lt;br /&gt;
# load some molecules&lt;br /&gt;
# run, '''cealign molecule1, molecule2'''&lt;br /&gt;
# enjoy&lt;br /&gt;
&lt;br /&gt;
=====Pre-compiled Hackish Install=====&lt;br /&gt;
For those people that prefer to use the pre-compiled version of PyMOL, here are the basics for your install.  '''This is a poor method of installing Cealign.  I suggest users compile and install their own PyMOL.'''  The final goal is to get &lt;br /&gt;
# '''ccealign.so''' module into '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# numpy installed (get the numpy directory into (or linked into) '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# and be able to run cealign.py and qkabsch.py from PyMOL.&lt;br /&gt;
If you can do the above three steps, '''cealign''' should run from the pre-compiled PyMOL.&lt;br /&gt;
&lt;br /&gt;
In more detail, on a completely fictitious machine --- that is, I created the following commands from a fake machine and I don't expect a copy/paste of this to work '''anywhere''', but the commands should be helpful enough to those who need it:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# NOTES:&lt;br /&gt;
# This is fake code: don't copy/paste it.&lt;br /&gt;
#&lt;br /&gt;
# PYMOL='dir to precompiled PyMOL install'&lt;br /&gt;
# CEALIGN='dir where you will unpack cealign'&lt;br /&gt;
# replace lib with lib64 for x86-64&lt;br /&gt;
# install numpy&lt;br /&gt;
apt-get install numpy&lt;br /&gt;
&lt;br /&gt;
# link numpy to PyMOL&lt;br /&gt;
ln -s /usr/local/lib/python2.4/site-packages/numpy PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# download and install Cealign&lt;br /&gt;
wget http://www.pymolwiki.org/images/e/ed/Cealign-0.6.tar.bz2&lt;br /&gt;
tar -jxvf Cealign-0.6.tar.bz2&lt;br /&gt;
cd cealign-0.6&lt;br /&gt;
sudo python setup.py build&lt;br /&gt;
cp build/lib-XYZ-linux/ccealign.so PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# run pymol and try it out&lt;br /&gt;
pymol&lt;br /&gt;
run CEALIGN/cealign.py&lt;br /&gt;
run CEALIGN/qkabsch.py&lt;br /&gt;
fetch 1cew 1mol, async=0&lt;br /&gt;
cealign 1c, 1m&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Code ==&lt;br /&gt;
Please unpack and read the documentation.  All comments/questions should be directed to Jason Vertrees (javertre _at_ utmb ...dot... edu).  &lt;br /&gt;
&lt;br /&gt;
'''LATEST IS v0.8-RBS'''.  (Dedicated to Bryan Sutton for allowing me to use his computer for testing.)&lt;br /&gt;
&lt;br /&gt;
=== Version 0.8-RBS ===&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.tar.bz2|CE Align v0.8-RBS]] (bz2)'''&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.zip|CE Align v0.8-RBS]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
=== Beta Version 0.9 ===&lt;br /&gt;
Use at your own peril.  Please report any problems or inconsistent alignments to this discussion page, or to me directly; my email address all over this page.&lt;br /&gt;
&lt;br /&gt;
'''Improvements/Changes''':&lt;br /&gt;
* All C++&lt;br /&gt;
** So, faster&lt;br /&gt;
** comes with the dependencies built in&lt;br /&gt;
* No numpy&lt;br /&gt;
&lt;br /&gt;
''' Download: [[Media:Cealign-0.9.zip|CE Align v0.9]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
== Coming Soon ==&lt;br /&gt;
* Windows binary&lt;br /&gt;
* Linux Binaries (32bit, x86-64)&lt;br /&gt;
* Better instructions for precompiled distributions&lt;br /&gt;
* Optimization&lt;br /&gt;
&lt;br /&gt;
== Updates ==&lt;br /&gt;
&lt;br /&gt;
=== 2008-03-25 ===&lt;br /&gt;
Pure C++ code released.  See the beta version above.&lt;br /&gt;
&lt;br /&gt;
=== 2007-04-14 ===&lt;br /&gt;
v0.8-RBS source updated.  Found the bug that had been plaguing 32-bit machines.  This should be the last release for a little while.&lt;br /&gt;
&lt;br /&gt;
Also, I provide the option of aligning based solely upon RMSD or upon the better CE-Score.  See the '''References''' for information on the '''CE Score'''.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Post your problems/solutions here.&lt;br /&gt;
&lt;br /&gt;
=== Unicode Issues in Python/Numpy ===&lt;br /&gt;
'''Problem''': Running/Installing cealign gives&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parser.py&amp;quot;,&lt;br /&gt;
line 308, in parse&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parsing.py&amp;quot;,&lt;br /&gt;
line 410, in run_file&lt;br /&gt;
  File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
    import numpy&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 36, in ?&lt;br /&gt;
    import core&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/core/__init__.py&amp;quot;, line 5, in ?&lt;br /&gt;
    import multiarray&lt;br /&gt;
ImportError: /home/byron/software/pymol/ext/lib/python2.4/site-packages/numpy/core/multiarray.so:&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where the important line is&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This problem indicates that your Numpy Unicode is using a different byte-size for unicode characters than is the Python distribution your PyMOL is running from.  For example, this can happen if you use the pre-built PyMOL and some other pre-built Numpy package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': Hand-install Numpy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LinAlg Module Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parser.py&amp;quot;, line 285, in parse&lt;br /&gt;
parsing.run_file(exp_path(args[nest][0]),pymol_names,pymol_names)&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parsing.py&amp;quot;, line 407, in run_file&lt;br /&gt;
execfile(file,global_ns,local_ns)&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 40, in ?&lt;br /&gt;
import linalg&lt;br /&gt;
ImportError: No module named linalg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': You do not have the linear algebra module installed (or Python can't find it) on your machine.  One workaround is to install [http://www.scipy.org/ Scientific Python]. (on debian/ubuntu this can be done by: sudo apt-get install python-scipy) Another is to reinstall the Numpy package from source, ensuring that you have the necessary requirements for the linear algebra module (linpack, lapack, fft, etc.).&lt;br /&gt;
&lt;br /&gt;
=== CCEAlign &amp;amp; NumPy Modules Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;run cealign.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
  File &amp;quot;/usr/local/pymol/scripts/cealign-0.1/cealign.py&amp;quot;, line 59, in ?&lt;br /&gt;
    from ccealign import ccealign&lt;br /&gt;
ImportError: No module named ccealign&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
ImportError: No module named numpy&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': This problem occurs under [http://www.apple.com/macosx Apple Mac OS X] if (a) the Apple's python executable on your machine (/usr/bin/python, currently version 2.3.5) is superseded by [http://fink.sourceforge.net/ Fink]'s python executable (/sw/bin/python, currently version 2.5) and (b) you are using [http://delsci.com/rel/099/#MacOSX precompiled versions of PyMOL] (MacPyMOL, PyMOLX11Hybrid or PyMOL for Mac OS X/X11). These executables ignore Fink's python and instead use Apple's - so, in order to run CE Align, one must install NumPy (as well as CE Align itself) using Apple's python. To do so, first download the [http://sourceforge.net/project/showfiles.php?group_id=1369&amp;amp;package_id=175103 Numpy source code archive] (currently version 1.0.1), unpack it, change directory to numpy-1.0.1 and specify the full path to Apple's python executable during installation: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;. Then, donwload the [http://www.pymolwiki.org/index.php/Cealign#The_Code CE Align source code archive] (currently version 0.2), unpack it, change directory to cealign-0.2 and finally install CE Align as follows: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;.&lt;br /&gt;
[[User:Lucajovine|Luca Jovine]] 05:11, 25 January 2007 (CST).&lt;br /&gt;
&lt;br /&gt;
=== The Function SimpAlign() is not found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;cealign 1CLL,1GGZ&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;C:\Program Files (x86)\DeLano Scientific\PyMOL/modules\pymol\parser.py&amp;quot;, line 203, in parse&lt;br /&gt;
    result=apply(kw[nest][0],args[nest],kw_args[nest])&lt;br /&gt;
  File &amp;quot;py24/Lib/cealign.py&amp;quot;, line 177, in cealign&lt;br /&gt;
    curScore = simpAlign( matA, matB, mol1, mol2, stored.mol1, stored.mol2, align=0, L=len(matA) )&lt;br /&gt;
NameError: global name 'simpAlign' is not defined&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
I am running PyMOL v. 0.99rc6 on Win XP Professional x64 edition version 2003 sp2 and have followed the windows install procedure as described above.&lt;br /&gt;
&lt;br /&gt;
'''Answer''': This simply means that PyMOL couldn't find the simplAlign function.  To let PyMOL know about this, you must run the following commands before running [[cealign]]:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run /your/path/to/cealign/qkabsch.py&lt;br /&gt;
run /your/path/to/cealign/cealign.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
but most people that use cealign would just put these two lines in their '''.pymolrc''' file.&lt;br /&gt;
&lt;br /&gt;
=== Short Alignments Don't Work ===&lt;br /&gt;
If you are trying to align fewer than 16 residues then use [[align]], [[super]], or [[optAlign]].  CE uses a window size of 8; and to build a path of more than one window, you need 2*8=16 residues.  I will insert some code to re-route small alignments to one of the aforementioned alignment algorithms.&lt;br /&gt;
&lt;br /&gt;
=== It Worked A Second Ago! ===&lt;br /&gt;
[[Image:Rewind.png|thumb|right|Showing the rewind button to rewind to state 1.]]&lt;br /&gt;
&lt;br /&gt;
If you were using cealign (or alignto) and now the commands don't work -- that is, they return an RMSD, but don't actually superimpose the objects, then you have a simple problem dealing with states.  Most likely the cause of this oddness was (1) when you issued &amp;quot;cealign prot1, prot2&amp;quot; one of them was actually an ensemble of states or (2) you are trying to align to proteins with only one state, but are not looking at state one (because the last protein you were considering had more than one state and you quit editing that protein on a state that's not state 1).  To fix this, use the rewind button to get the proteins back into state 1 &amp;amp; reissue the cealign/alignto command.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Text taken from PubMed and formatted for the wiki.  The first reference is the most important for this code.&lt;br /&gt;
&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''Protein structure alignment by incremental combinatorial extension (CE) of the optimal path.'''  ''Protein Eng.'' 1998 Sep;11(9):739-47.  PMID: 9796821 [PubMed - indexed for MEDLINE]&lt;br /&gt;
# Jia Y, Dewey TG, Shindyalov IN, Bourne PE. '''A new scoring function and associated statistical significance for structure alignment by CE.'''  ''J Comput Biol.'' 2004;11(5):787-99. PMID: 15700402 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Pekurovsky D, Shindyalov IN, Bourne PE. '''A case study of high-throughput biological data processing on parallel platforms.'''  ''Bioinformatics.'' 2004 Aug 12;20(12):1940-7. Epub 2004 Mar 25.  PMID: 15044237 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''An alternative view of protein fold space.'''  ''Proteins.'' 2000 Feb 15;38(3):247-60.  PMID: 10713986 [PubMed - indexed for MEDLINE]&lt;br /&gt;
&lt;br /&gt;
== License ==&lt;br /&gt;
The CEAlign and all its subprograms that I wrote, are released under the open source Free BSD License (BSDL).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Structure_Alignment|Cealign]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Cealign&amp;diff=2966</id>
		<title>Cealign</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cealign&amp;diff=2966"/>
		<updated>2009-06-08T07:41:45Z</updated>

		<summary type="html">&lt;p&gt;Zhentg: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
'''Go directly to [[Cealign#Version_0.8-RBS|DOWNLOAD]]'''&lt;br /&gt;
&lt;br /&gt;
This page is the home page of the open-source CEAlign PyMOL plugin.  The CE algorithm is a fast and accurate protein structure alignment algorithm, pioneered by Drs. Shindyalov and Bourne (See &lt;br /&gt;
References).  There are a few changes from the original CE publication (See Notes).  &lt;br /&gt;
&lt;br /&gt;
The source code is implemented in C with the rotations finally done by Numpy in Python.  Because the computationally complex portion of the code is written in C, it's quick.  That is, on my machines --- relatively fast 64-bit machines --- I can align two 400+ amino acid structures in about 0.300 s with the C++ implementation.&lt;br /&gt;
&lt;br /&gt;
This plugs into PyMol very easily.  See [[Cealign#The_Code|the code]] and [[Cealign#Examples|examples]] for installation and usage.&lt;br /&gt;
&lt;br /&gt;
== Comparison to PyMol ==&lt;br /&gt;
'''Why should you use this?'''&lt;br /&gt;
&lt;br /&gt;
PyMOL's structure alignment algorithm is fast and robust.  However, its first step is to perform a sequence alignment of the two selections.  Thus, proteins in the '''twilight zone''' or those having a low sequence identity, may not align well.  Because CE is a structure-based alignment, this is not a problem.  Consider the following example.  The image at LEFT was the result of CE-aligning two proteins (1C0M chain B to 1BCO).  The result is '''152''' aligned (alpha carbons) residues (not atoms) at '''4.96 Angstroms'''.  The image on the RIGHT shows the results from PyMol's align command: an alignment of '''221 atoms''' (not residues) at an RMSD of '''15.7 Angstroms'''.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:cealign_ex1.png|Cealign's results (152 aligned; 4.96 Ang.)&lt;br /&gt;
Image:pymol_align.png|PyMol's results (763 atoms; 18.4 Ang. )&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fit vs. optAlign ===&lt;br /&gt;
====Take Home messages====&lt;br /&gt;
* [[fit]] and [[optAlign]] perform nearly equally as well&lt;br /&gt;
* if you need an algorithm with an appropriate reference, use [[optAlign]] (references at bottom of page).&lt;br /&gt;
* [[fit]] is faster -- if you're aligning many structures, use it over [[optAlign]]&lt;br /&gt;
&lt;br /&gt;
====Discussion====&lt;br /&gt;
[[optAlign]] is a function within the [[Cealign]] package that performs the optimal superposition of two objects of equal length.  [[optAlign]] follows the Kabsch algorithm which is a closed form, and provably optimal solution to the problem.  [[fit]] on the other hand uses the Jacobi rotations to iteratively arrive at the solution of optimal superposition.  The difference in error between [[optAilgn]] and [[fit]] seems to be a non-issue (see below) as they both arrive at equivalent solutions for the rotation matrix.  The two algorithms are undertake different approaches to orthogonally diagonalizing the correlation matrix.&lt;br /&gt;
&lt;br /&gt;
PyMOL's [[fit]] is fast and works well.  If you have to use something with a known reference then check out the &amp;quot;optAlign&amp;quot; function from the qkabsch.py file that comes with this [[Calign]] package.  If not, you can just use [[fit]] and avoid installing new software.  :-)&lt;br /&gt;
&lt;br /&gt;
optAlign is slower than fit.  I just tested both on a sample NMR ensemble; and, while not an extensive validation of &amp;quot;fit&amp;quot; it shows that (1) fit is faster; and (2) fit gets the same exact RMSD as &amp;quot;optAlign&amp;quot; (when optAlign is told to use all atoms, not just CA).  To make optAlign use all atoms and not just the alpha-carbon backbones, comment out (that is, put a &amp;quot;#&amp;quot; at the start of lines 183 and 184 in qkabsch.py, where it says &amp;quot;CUT HERE&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
fetch 1nmr&lt;br /&gt;
split_states 1nmr&lt;br /&gt;
delete 1nmr&lt;br /&gt;
&lt;br /&gt;
# compare fit and optAlign RMSDs&lt;br /&gt;
for x in cmd.get_names(): print cmd.fit(&amp;quot;1nmr_0001&amp;quot;, x)&lt;br /&gt;
for x in cmd.get_names(): optAlign(x, &amp;quot;1nmr_0001&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source  lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# results from fit&lt;br /&gt;
0.0&lt;br /&gt;
4.50344991684&lt;br /&gt;
5.33588504791&lt;br /&gt;
5.78613853455&lt;br /&gt;
7.25597000122&lt;br /&gt;
6.67145586014&lt;br /&gt;
3.25131297112&lt;br /&gt;
3.36766290665&lt;br /&gt;
6.74802017212&lt;br /&gt;
5.1579709053&lt;br /&gt;
5.96959495544&lt;br /&gt;
6.68093347549&lt;br /&gt;
4.13217163086&lt;br /&gt;
5.51539039612&lt;br /&gt;
6.24266338348&lt;br /&gt;
6.03838825226&lt;br /&gt;
5.01363992691&lt;br /&gt;
5.33336305618&lt;br /&gt;
6.87617444992&lt;br /&gt;
7.797062397&lt;br /&gt;
&lt;br /&gt;
#results from optAlign&lt;br /&gt;
RMSD=0.000000&lt;br /&gt;
RMSD=4.503450&lt;br /&gt;
RMSD=5.335886&lt;br /&gt;
RMSD=5.786138&lt;br /&gt;
RMSD=7.255970&lt;br /&gt;
RMSD=6.671456&lt;br /&gt;
RMSD=3.251313&lt;br /&gt;
RMSD=3.367663&lt;br /&gt;
RMSD=6.748021&lt;br /&gt;
RMSD=5.157971&lt;br /&gt;
RMSD=5.969595&lt;br /&gt;
RMSD=6.680934&lt;br /&gt;
RMSD=4.132172&lt;br /&gt;
RMSD=5.515390&lt;br /&gt;
RMSD=6.242664&lt;br /&gt;
RMSD=6.038388&lt;br /&gt;
RMSD=5.013640&lt;br /&gt;
RMSD=5.333363&lt;br /&gt;
RMSD=6.876174&lt;br /&gt;
RMSD=7.797062&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
=== Usage ===&lt;br /&gt;
==== Syntax ====&lt;br /&gt;
&lt;br /&gt;
CEAlign has the semantic, and syntactic formalism of&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign MASTER, TARGET&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where a post-condition of the algorithm is that the coordinates of the '''MASTER''' protein are unchanged.  This allows for easier multi-protein alignments.  For example,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1AUE, 1BZ4&lt;br /&gt;
cealign 1AUE, 1B68&lt;br /&gt;
cealign 1AUE, 1A7V&lt;br /&gt;
cealign 1AUE, 1CPR&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
will superimpose all the TARGETS onto the MASTER.&lt;br /&gt;
&lt;br /&gt;
=====Examples=====&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cealign 1cll and i. 42-55, 1ggz and c. A&lt;br /&gt;
cealign 1kao, 1ctq&lt;br /&gt;
cealign 1fao, 1eaz&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=====Multiple Structure Alignments=====&lt;br /&gt;
Use the '''alignto''' command, now provided with cealign.  Just type,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
alignto PROT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to align all your proteins in PyMOL to the one called, '''PROT'''.&lt;br /&gt;
&lt;br /&gt;
=== Results ===&lt;br /&gt;
See '''Changes''' for updates.  But, overall, the results here are great.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:v7_1fao_1eaz.png|EASY: 1FAO vs. 1EAZ; 96 residues, 1.28 Ang&lt;br /&gt;
Image:v7_1cbs_1hmt.png|EASY: 1CBS vs. 1HMT; 128 residues, 2.01 Ang&lt;br /&gt;
Image:v7_1a15_1b50.png|MODERATE: 1A15 vs 1B50; 56 residues, 2.54 Ang.&lt;br /&gt;
Image:v7_1oan_1s6n.png|EASY: 1OAN vs. 1S6N (state 1); 96 residues aligned to 3.83 Ang. RMSD.&lt;br /&gt;
Image:v7_1rlw_1byn.png|HARD: 1RLW to 1BYN; 104 residues; 2.21 Ang.&lt;br /&gt;
Image:v7_1ten_3hhr.png|HARD: 1TEN vs. 3HHR; 80 residues, 2.91 Ang.&lt;br /&gt;
Image:v7_2sim_1nsb.png|HARD: 2SIM vs. 1NSB; 272 residues, 4.93 Ang.&lt;br /&gt;
Image:v7_1cew_1mol.png|HARD: 1CEW vs. 1MOL; 80 residues, 4.03 Ang.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
===Mac OS X (10.5)===&lt;br /&gt;
[[Image:Cealign mac os x.png|300px|thumb|center|CEAlign running on Mac OS X (10.5)]]&lt;br /&gt;
* Install PyMOL under fink.&lt;br /&gt;
* Install Numpy for fink:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
/sw/bin/fink install scipy-core-py25&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* Download and install cealign (download instructions below)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo /sw/bin/python setup.py install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* In PyMOL, run the two scripts needed for cealing: &amp;quot;cealign.py&amp;quot; and &amp;quot;qkabsch.py&amp;quot;. These are located in the cealign directory you previously downloaded.&lt;br /&gt;
* Voila!&lt;br /&gt;
* Note that the above python version must match the same version that is used by PyMOL. If you are using the pre-compiled version of MacPyMOL, the above instructions won't work.&lt;br /&gt;
&lt;br /&gt;
===Windows systems===&lt;br /&gt;
This is a quick and dirty method to get it working on Win32 right now, more details coming soon.&lt;br /&gt;
====Requirements====&lt;br /&gt;
* Latest PyMol, installed on your system&lt;br /&gt;
* Numpy for python 2.4 -- quick download of just what's needed: http://users.umassmed.edu/Shivender.Shandilya/pymol/numpy.zip[Note: the numpy.zip here are corrupt, users may download the latest 'Numpy for python 2.4' directly from SourceForge.net]&lt;br /&gt;
* Pre-compiled ccealign.pyd python module: http://users.umassmed.edu/Shivender.Shandilya/pymol/ccealign.zip&lt;br /&gt;
* Modified pymolrc: http://users.umassmed.edu/Shivender.Shandilya/pymol/pymolrc&lt;br /&gt;
* cealign.py and qkabsch.py from the Cealign-0.8-RBS package: download below&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# Unzip the numpy.zip file, which will give you a folder named '''numpy'''&lt;br /&gt;
# Move this entire folder to: C:\Program Files\DeLano Scientific\PyMOL\modules\  (or the corresponding location on your system)&lt;br /&gt;
# Unzip ccealign.zip, which will give you a file called  '''ccealign.pyd'''&lt;br /&gt;
# Move this pyd file to: C:\Program Files\DeLano Scientific\PyMOL\py24\DLLs\  (or the corresponding location on your system)&lt;br /&gt;
# Copy the downloaded '''pymolrc''' file to: C:\Program Files\DeLano Scientific\PyMOL\   (or the corresponding location on your system)&lt;br /&gt;
# Extract and copy the files cealign.py and qkabsch.py from the Cealign-0.8-RBS package to: C:\Program Files\DeLano Scientific\PyMOL\py24\Lib\   (or the corresponding location on your system)&lt;br /&gt;
# Run PyMol and load some molecules&lt;br /&gt;
# Run this command in Pymol: '''cealign molecule1, molecule2'''&lt;br /&gt;
# Enjoy!&lt;br /&gt;
&lt;br /&gt;
===Gentoo Linux===&lt;br /&gt;
Add the science overlay via&lt;br /&gt;
 layman -a sci&lt;br /&gt;
and emerge the cealign plugin&lt;br /&gt;
 emerge pymol-plugins-cealign&lt;br /&gt;
&lt;br /&gt;
===*nix systems===&lt;br /&gt;
====Requirements====&lt;br /&gt;
* C compiler&lt;br /&gt;
* Python 2.4+ with distutils&lt;br /&gt;
* Numpy&lt;br /&gt;
** for User-compiled PyMOL: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install&amp;lt;/source&amp;gt;&lt;br /&gt;
** for the precompiled version of PyMOL &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR_TO/pymol/ext/&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Directions====&lt;br /&gt;
# uncompress the distribution file '''cealign-VERSION.tgz'''&lt;br /&gt;
# cd cealign-VERSION&lt;br /&gt;
# sudo python setup.py install  # if you installed by PyMOL by hand&lt;br /&gt;
## python setup.py install --prefix &amp;quot;&amp;quot; --root /DIR/TO/pymol/ext/  # if you are using the precompiled binary download&lt;br /&gt;
# insert &amp;quot;run DIR_TO_CEALIGN/cealign.py&amp;quot; and &amp;quot;run DIR_TO_CEALIGN/qkabsch.py&amp;quot; into your '''.pymolrc''' file, or just run the two Python scripts by hand.&lt;br /&gt;
# load some molecules&lt;br /&gt;
# run, '''cealign molecule1, molecule2'''&lt;br /&gt;
# enjoy&lt;br /&gt;
&lt;br /&gt;
=====Pre-compiled Hackish Install=====&lt;br /&gt;
For those people that prefer to use the pre-compiled version of PyMOL, here are the basics for your install.  '''This is a poor method of installing Cealign.  I suggest users compile and install their own PyMOL.'''  The final goal is to get &lt;br /&gt;
# '''ccealign.so''' module into '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# numpy installed (get the numpy directory into (or linked into) '''PYMOL/ext/lib/python2.4/site-packages'''&lt;br /&gt;
# and be able to run cealign.py and qkabsch.py from PyMOL.&lt;br /&gt;
If you can do the above three steps, '''cealign''' should run from the pre-compiled PyMOL.&lt;br /&gt;
&lt;br /&gt;
In more detail, on a completely fictitious machine --- that is, I created the following commands from a fake machine and I don't expect a copy/paste of this to work '''anywhere''', but the commands should be helpful enough to those who need it:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# NOTES:&lt;br /&gt;
# This is fake code: don't copy/paste it.&lt;br /&gt;
#&lt;br /&gt;
# PYMOL='dir to precompiled PyMOL install'&lt;br /&gt;
# CEALIGN='dir where you will unpack cealign'&lt;br /&gt;
# replace lib with lib64 for x86-64&lt;br /&gt;
# install numpy&lt;br /&gt;
apt-get install numpy&lt;br /&gt;
&lt;br /&gt;
# link numpy to PyMOL&lt;br /&gt;
ln -s /usr/local/lib/python2.4/site-packages/numpy PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# download and install Cealign&lt;br /&gt;
wget http://www.pymolwiki.org/images/e/ed/Cealign-0.6.tar.bz2&lt;br /&gt;
tar -jxvf Cealign-0.6.tar.bz2&lt;br /&gt;
cd cealign-0.6&lt;br /&gt;
sudo python setup.py build&lt;br /&gt;
cp build/lib-XYZ-linux/ccealign.so PYMOL/ext/lib/python2.4/site-packages&lt;br /&gt;
&lt;br /&gt;
# run pymol and try it out&lt;br /&gt;
pymol&lt;br /&gt;
run CEALIGN/cealign.py&lt;br /&gt;
run CEALIGN/qkabsch.py&lt;br /&gt;
fetch 1cew 1mol, async=0&lt;br /&gt;
cealign 1c, 1m&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== The Code ==&lt;br /&gt;
Please unpack and read the documentation.  All comments/questions should be directed to Jason Vertrees (javertre _at_ utmb ...dot... edu).  &lt;br /&gt;
&lt;br /&gt;
'''LATEST IS v0.8-RBS'''.  (Dedicated to Bryan Sutton for allowing me to use his computer for testing.)&lt;br /&gt;
&lt;br /&gt;
=== Version 0.8-RBS ===&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.tar.bz2|CE Align v0.8-RBS]] (bz2)'''&lt;br /&gt;
* '''Download: [[Media:Cealign-0.8-RBS.zip|CE Align v0.8-RBS]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
=== Beta Version 0.9 ===&lt;br /&gt;
Use at your own peril.  Please report any problems or inconsistent alignments to this discussion page, or to me directly; my email address all over this page.&lt;br /&gt;
&lt;br /&gt;
'''Improvements/Changes''':&lt;br /&gt;
* All C++&lt;br /&gt;
** So, faster&lt;br /&gt;
** comes with the dependencies built in&lt;br /&gt;
* No numpy&lt;br /&gt;
&lt;br /&gt;
''' Download: [[Media:Cealign-0.9.zip|CE Align v0.9]] (zip)'''&lt;br /&gt;
&lt;br /&gt;
== Coming Soon ==&lt;br /&gt;
* Windows binary&lt;br /&gt;
* Linux Binaries (32bit, x86-64)&lt;br /&gt;
* Better instructions for precompiled distributions&lt;br /&gt;
* Optimization&lt;br /&gt;
&lt;br /&gt;
== Updates ==&lt;br /&gt;
&lt;br /&gt;
=== 2008-03-25 ===&lt;br /&gt;
Pure C++ code released.  See the beta version above.&lt;br /&gt;
&lt;br /&gt;
=== 2007-04-14 ===&lt;br /&gt;
v0.8-RBS source updated.  Found the bug that had been plaguing 32-bit machines.  This should be the last release for a little while.&lt;br /&gt;
&lt;br /&gt;
Also, I provide the option of aligning based solely upon RMSD or upon the better CE-Score.  See the '''References''' for information on the '''CE Score'''.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Post your problems/solutions here.&lt;br /&gt;
&lt;br /&gt;
=== Unicode Issues in Python/Numpy ===&lt;br /&gt;
'''Problem''': Running/Installing cealign gives&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parser.py&amp;quot;,&lt;br /&gt;
line 308, in parse&lt;br /&gt;
  File &amp;quot;/home/byron/software/pymol_1.00b17/pymol/modules/pymol/parsing.py&amp;quot;,&lt;br /&gt;
line 410, in run_file&lt;br /&gt;
  File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
    import numpy&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 36, in ?&lt;br /&gt;
    import core&lt;br /&gt;
  File &amp;quot;/usr/lib/python2.4/site-packages/numpy/core/__init__.py&amp;quot;, line 5, in ?&lt;br /&gt;
    import multiarray&lt;br /&gt;
ImportError: /home/byron/software/pymol/ext/lib/python2.4/site-packages/numpy/core/multiarray.so:&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where the important line is&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
undefined symbol: _PyUnicodeUCS4_IsWhitespace&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This problem indicates that your Numpy Unicode is using a different byte-size for unicode characters than is the Python distribution your PyMOL is running from.  For example, this can happen if you use the pre-built PyMOL and some other pre-built Numpy package.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': Hand-install Numpy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== LinAlg Module Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parser.py&amp;quot;, line 285, in parse&lt;br /&gt;
parsing.run_file(exp_path(args[nest][0]),pymol_names,pymol_names)&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/pymol/parsing.py&amp;quot;, line 407, in run_file&lt;br /&gt;
execfile(file,global_ns,local_ns)&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
File &amp;quot;/usr/lib/python2.4/site-packages/numpy/__init__.py&amp;quot;, line 40, in ?&lt;br /&gt;
import linalg&lt;br /&gt;
ImportError: No module named linalg&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': You do not have the linear algebra module installed (or Python can't find it) on your machine.  One workaround is to install [http://www.scipy.org/ Scientific Python]. (on debian/ubuntu this can be done by: sudo apt-get install python-scipy) Another is to reinstall the Numpy package from source, ensuring that you have the necessary requirements for the linear algebra module (linpack, lapack, fft, etc.).&lt;br /&gt;
&lt;br /&gt;
=== CCEAlign &amp;amp; NumPy Modules Not Found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;run cealign.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
  File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
  File &amp;quot;/usr/local/pymol/scripts/cealign-0.1/cealign.py&amp;quot;, line 59, in ?&lt;br /&gt;
    from ccealign import ccealign&lt;br /&gt;
ImportError: No module named ccealign&lt;br /&gt;
run qkabsch.py&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parser.py&amp;quot;, line 297, in parse&lt;br /&gt;
File &amp;quot;/home/local/warren/MacPyMOL060530/build/Deployment/MacPyMOL.app/pymol/modules/pymol/parsing.py&amp;quot;, line 408, in run_file&lt;br /&gt;
File &amp;quot;qkabsch.py&amp;quot;, line 86, in ?&lt;br /&gt;
import numpy&lt;br /&gt;
ImportError: No module named numpy&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Solution''': This problem occurs under [http://www.apple.com/macosx Apple Mac OS X] if (a) the Apple's python executable on your machine (/usr/bin/python, currently version 2.3.5) is superseded by [http://fink.sourceforge.net/ Fink]'s python executable (/sw/bin/python, currently version 2.5) and (b) you are using [http://delsci.com/rel/099/#MacOSX precompiled versions of PyMOL] (MacPyMOL, PyMOLX11Hybrid or PyMOL for Mac OS X/X11). These executables ignore Fink's python and instead use Apple's - so, in order to run CE Align, one must install NumPy (as well as CE Align itself) using Apple's python. To do so, first download the [http://sourceforge.net/project/showfiles.php?group_id=1369&amp;amp;package_id=175103 Numpy source code archive] (currently version 1.0.1), unpack it, change directory to numpy-1.0.1 and specify the full path to Apple's python executable during installation: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;. Then, donwload the [http://www.pymolwiki.org/index.php/Cealign#The_Code CE Align source code archive] (currently version 0.2), unpack it, change directory to cealign-0.2 and finally install CE Align as follows: &amp;lt;tt&amp;gt;sudo /usr/bin/python setup.py install | tee install.log&amp;lt;/tt&amp;gt;.&lt;br /&gt;
[[User:Lucajovine|Luca Jovine]] 05:11, 25 January 2007 (CST).&lt;br /&gt;
&lt;br /&gt;
=== The Function SimpAlign() is not found ===&lt;br /&gt;
'''Problem''': Running CE Align gives the following error message:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;cealign 1CLL,1GGZ&lt;br /&gt;
Traceback (most recent call last):&lt;br /&gt;
  File &amp;quot;C:\Program Files (x86)\DeLano Scientific\PyMOL/modules\pymol\parser.py&amp;quot;, line 203, in parse&lt;br /&gt;
    result=apply(kw[nest][0],args[nest],kw_args[nest])&lt;br /&gt;
  File &amp;quot;py24/Lib/cealign.py&amp;quot;, line 177, in cealign&lt;br /&gt;
    curScore = simpAlign( matA, matB, mol1, mol2, stored.mol1, stored.mol2, align=0, L=len(matA) )&lt;br /&gt;
NameError: global name 'simpAlign' is not defined&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
I am running PyMOL v. 0.99rc6 on Win XP Professional x64 edition version 2003 sp2 and have followed the windows install procedure as described above.&lt;br /&gt;
&lt;br /&gt;
'''Answer''': This simply means that PyMOL couldn't find the simplAlign function.  To let PyMOL know about this, you must run the following commands before running [[cealign]]:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
run /your/path/to/cealign/qkabsch.py&lt;br /&gt;
run /your/path/to/cealign/cealign.py&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
but most people that use cealign would just put these two lines in their '''.pymolrc''' file.&lt;br /&gt;
&lt;br /&gt;
=== Short Alignments Don't Work ===&lt;br /&gt;
If you are trying to align fewer than 16 residues then use [[align]], [[super]], or [[optAlign]].  CE uses a window size of 8; and to build a path of more than one window, you need 2*8=16 residues.  I will insert some code to re-route small alignments to one of the aforementioned alignment algorithms.&lt;br /&gt;
&lt;br /&gt;
=== It Worked A Second Ago! ===&lt;br /&gt;
[[Image:Rewind.png|thumb|right|Showing the rewind button to rewind to state 1.]]&lt;br /&gt;
&lt;br /&gt;
If you were using cealign (or alignto) and now the commands don't work -- that is, they return an RMSD, but don't actually superimpose the objects, then you have a simple problem dealing with states.  Most likely the cause of this oddness was (1) when you issued &amp;quot;cealign prot1, prot2&amp;quot; one of them was actually an ensemble of states or (2) you are trying to align to proteins with only one state, but are not looking at state one (because the last protein you were considering had more than one state and you quit editing that protein on a state that's not state 1).  To fix this, use the rewind button to get the proteins back into state 1 &amp;amp; reissue the cealign/alignto command.&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
Text taken from PubMed and formatted for the wiki.  The first reference is the most important for this code.&lt;br /&gt;
&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''Protein structure alignment by incremental combinatorial extension (CE) of the optimal path.'''  ''Protein Eng.'' 1998 Sep;11(9):739-47.  PMID: 9796821 [PubMed - indexed for MEDLINE]&lt;br /&gt;
# Jia Y, Dewey TG, Shindyalov IN, Bourne PE. '''A new scoring function and associated statistical significance for structure alignment by CE.'''  ''J Comput Biol.'' 2004;11(5):787-99. PMID: 15700402 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Pekurovsky D, Shindyalov IN, Bourne PE. '''A case study of high-throughput biological data processing on parallel platforms.'''  ''Bioinformatics.'' 2004 Aug 12;20(12):1940-7. Epub 2004 Mar 25.  PMID: 15044237 [PubMed - indexed for MEDLINE]&lt;br /&gt;
#  Shindyalov IN, Bourne PE. '''An alternative view of protein fold space.'''  ''Proteins.'' 2000 Feb 15;38(3):247-60.  PMID: 10713986 [PubMed - indexed for MEDLINE]&lt;br /&gt;
&lt;br /&gt;
== License ==&lt;br /&gt;
The CEAlign and all its subprograms that I wrote, are released under the open source Free BSD License (BSDL).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Structure_Alignment|Cealign]]&lt;/div&gt;</summary>
		<author><name>Zhentg</name></author>
	</entry>
</feed>