<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Kabsch</id>
	<title>Kabsch - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Kabsch"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;action=history"/>
	<updated>2026-06-26T05:57:42Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=14596&amp;oldid=prev</id>
		<title>Cchem: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=14596&amp;oldid=prev"/>
		<updated>2019-04-29T03:23:32Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 03:23, 29 April 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Cchem</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=14595&amp;oldid=prev</id>
		<title>Speleo3: legacy note</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=14595&amp;oldid=prev"/>
		<updated>2019-04-18T12:33:02Z</updated>

		<summary type="html">&lt;p&gt;legacy note&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:33, 18 April 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;div style=&amp;quot;background-color: #9f9; padding: 10px; margin-bottom: 20px&amp;quot;&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;'''Note:''' PyMOL has built-in commands to do RMSD fitting. This script is typically not needed.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In particular, &amp;lt;code&amp;gt;optAlign (sele1), (sele2)&amp;lt;/code&amp;gt; is identical to &amp;lt;code&amp;gt;fit (sele1), (sele2), matchmaker=-1&amp;lt;/code&amp;gt;.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;See also: [[fit]], [[align]].&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;lt;/div&amp;gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Infobox script-repo&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Infobox script-repo&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|type      = script&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|type      = script&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l203&quot; &gt;Line 203:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 211:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.sel2.pop(0)&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.sel2.pop(0)&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	print &amp;quot;RMSD=%f&amp;quot; % RMSD&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	print&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(&lt;/ins&gt;&amp;quot;RMSD=%f&amp;quot; % RMSD&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# make the alignment OBVIOUS&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# make the alignment OBVIOUS&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Speleo3</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12168&amp;oldid=prev</id>
		<title>Bell: 43 revisions</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12168&amp;oldid=prev"/>
		<updated>2014-10-20T15:32:15Z</updated>

		<summary type="html">&lt;p&gt;43 revisions&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:32, 20 October 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Bell</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12167&amp;oldid=prev</id>
		<title>Speleo3: Infobox script-repo</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12167&amp;oldid=prev"/>
		<updated>2014-09-29T21:15:56Z</updated>

		<summary type="html">&lt;p&gt;Infobox script-repo&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:15, 29 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{Infobox script-repo&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|type      = script&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|author    = [[User:Inchoate|Jason Vertrees]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;|license   = GPL&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Intro==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Intro==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Kabsch algorithm uses linear and vector algebra to find the optimal rotation and translation of two sets of points in N-dimensional space as to minimize the RMSD between them.  The following program is a Python implementation of the Kabsch algorithm.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The Kabsch algorithm uses linear and vector algebra to find the optimal rotation and translation of two sets of points in N-dimensional space as to minimize the RMSD between them.  The following program is a Python implementation of the Kabsch algorithm.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Speleo3</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=8045&amp;oldid=prev</id>
		<title>Pyadmin: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=8045&amp;oldid=prev"/>
		<updated>2014-03-28T02:16:29Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 02:16, 28 March 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Pyadmin</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=8044&amp;oldid=prev</id>
		<title>Newacct at 08:13, 26 February 2010</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=8044&amp;oldid=prev"/>
		<updated>2010-02-26T08:13:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;//wiki.pymol.org/index.php?title=Kabsch&amp;amp;diff=8044&amp;amp;oldid=12166&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12166&amp;oldid=prev</id>
		<title>Cowsandmilk: /* The Code */ indentation changes</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12166&amp;oldid=prev"/>
		<updated>2010-02-14T19:17:43Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;The Code: &lt;/span&gt; indentation changes&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 19:17, 14 February 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l60&quot; &gt;Line 60:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 60:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!python&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#!python&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;##############################################################################&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;##############################################################################&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l87&quot; &gt;Line 87:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 87:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#############################################################################&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#############################################################################&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from array import *&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from array import *&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# system stuff&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# system stuff&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import os&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import os&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import copy&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import copy&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# pretty printing&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# pretty printing&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import pprint&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import pprint&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# for importing as a plugin into PyMol&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# for importing as a plugin into PyMol&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pymol import cmd&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pymol import cmd&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pymol import stored&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pymol import stored&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pymol import selector&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;from pymol import selector&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# using numpy for linear algebra&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# using numpy for linear algebra&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import numpy&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;import numpy&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;def optAlign( sel1, sel2 ):&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;def optAlign( sel1, sel2 ):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l108&quot; &gt;Line 108:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 108:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Two RMSDs are returned.  One comes from the Kabsch algorithm and the other from&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	Two RMSDs are returned.  One comes from the Kabsch algorithm and the other from&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	PyMol based upon your selections.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	PyMol based upon your selections.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	By default, this program will optimally align the ALPHA CARBONS of the selections provided.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	By default, this program will optimally align the ALPHA CARBONS of the selections provided.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	To turn off this feature remove the lines between the commented &amp;quot;REMOVE ALPHA CARBONS&amp;quot; below.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	To turn off this feature remove the lines between the commented &amp;quot;REMOVE ALPHA CARBONS&amp;quot; below.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	@param sel1: First PyMol selection with N-atoms&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	@param sel1: First PyMol selection with N-atoms&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	@param sel2: Second PyMol selection with N-atoms&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	@param sel2: Second PyMol selection with N-atoms&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.reset()&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.reset()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# make the lists for holding coordinates&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# make the lists for holding coordinates&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# partial lists&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# partial lists&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l127&quot; &gt;Line 127:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 127:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.mol1 = []&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.mol1 = []&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.mol2 = []&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.mol2 = []&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# -- CUT HERE&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# -- CUT HERE&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	sel1 = sel1 + &amp;quot; and N. CA&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	sel1 = sel1 + &amp;quot; and N. CA&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	sel2 = sel2 + &amp;quot; and N. CA&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	sel2 = sel2 + &amp;quot; and N. CA&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# -- CUT HERE&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# -- CUT HERE&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# Get the selected coordinates.  We&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# Get the selected coordinates.  We&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# align these coords.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# align these coords.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, selector.process(sel1), &amp;quot;stored.sel1.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, selector.process(sel1), &amp;quot;stored.sel1.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, selector.process(sel2), &amp;quot;stored.sel2.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, selector.process(sel2), &amp;quot;stored.sel2.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# get molecule name&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# get molecule name&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	mol1 = cmd.identify(sel1,1)[0][0]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	mol1 = cmd.identify(sel1,1)[0][0]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	mol2 = cmd.identify(sel2,1)[0][0]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	mol2 = cmd.identify(sel2,1)[0][0]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# Get all molecule coords.  We do this because&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# Get all molecule coords.  We do this because&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# we have to rotate the whole molcule, not just&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# we have to rotate the whole molcule, not just&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l147&quot; &gt;Line 147:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 147:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, mol1, &amp;quot;stored.mol1.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, mol1, &amp;quot;stored.mol1.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, mol2, &amp;quot;stored.mol2.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.iterate_state(1, mol2, &amp;quot;stored.mol2.append([x,y,z])&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# check for consistency&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# check for consistency&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	assert( len(stored.sel1) == len(stored.sel2))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	assert( len(stored.sel1) == len(stored.sel2))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	L = len(stored.sel1)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	L = len(stored.sel1)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	assert( L &amp;gt; 0 )&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	assert( L &amp;gt; 0 )&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# must alway center the two proteins to avoid&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# must alway center the two proteins to avoid&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# affine transformations.  Center the two proteins&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# affine transformations.  Center the two proteins&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l160&quot; &gt;Line 160:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 160:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel1 = stored.sel1 - COM1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel1 = stored.sel1 - COM1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel2 = stored.sel2 - COM2&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel2 = stored.sel2 - COM2&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# Initial residual, see Kabsch.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# Initial residual, see Kabsch.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	E0 = numpy.sum( numpy.sum(stored.sel1 * stored.sel1,axis=0),axis=0) + numpy.sum( numpy.sum(stored.sel2 * stored.sel2,axis=0),axis=0)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	E0 = numpy.sum( numpy.sum(stored.sel1 * stored.sel1,axis=0),axis=0) + numpy.sum( numpy.sum(stored.sel2 * stored.sel2,axis=0),axis=0)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	#&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# This beautiful step provides the answer.  V and Wt are the orthonormal&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# This beautiful step provides the answer.  V and Wt are the orthonormal&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# bases that when multiplied by each other give us the rotation matrix, U.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# bases that when multiplied by each other give us the rotation matrix, U.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# S, (Sigma, from SVD) provides us with the error!  Isn't SVD great!&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# S, (Sigma, from SVD) provides us with the error!  Isn't SVD great!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt; 	&lt;/del&gt;V, S, Wt = numpy.linalg.svd( numpy.dot( numpy.transpose(stored.sel2), stored.sel1))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/ins&gt;V, S, Wt = numpy.linalg.svd( numpy.dot( numpy.transpose(stored.sel2), stored.sel1))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# we already have our solution, in the results from SVD.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# we already have our solution, in the results from SVD.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# we just need to check for reflections and then produce&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# we just need to check for reflections and then produce&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# the rotation.  V and Wt are orthonormal, so their det's&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# the rotation.  V and Wt are orthonormal, so their det's&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# are +/-1.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# are +/-1.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;        &lt;/del&gt;reflect = float(str(float(numpy.linalg.det(V) * numpy.linalg.det(Wt))))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/ins&gt;reflect = float(str(float(numpy.linalg.det(V) * numpy.linalg.det(Wt))))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;        &lt;/del&gt;if reflect == -1.0:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/ins&gt;if reflect == -1.0:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;                &lt;/del&gt;S[-1] = -S[-1]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;		&lt;/ins&gt;S[-1] = -S[-1]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;                &lt;/del&gt;V[:,-1] = -V[:,-1]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;		&lt;/ins&gt;V[:,-1] = -V[:,-1]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;		&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	RMSD = E0 - (2.0 * sum(S))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	RMSD = E0 - (2.0 * sum(S))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	RMSD = numpy.sqrt(abs(RMSD / L))&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	RMSD = numpy.sqrt(abs(RMSD / L))&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	#U is simply V*Wt&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	#U is simply V*Wt&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	U = numpy.dot(V, Wt)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	U = numpy.dot(V, Wt)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# rotate and translate the molecule&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# rotate and translate the molecule&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel2 = numpy.dot((stored.mol2 - COM2), U)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel2 = numpy.dot((stored.mol2 - COM2), U)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l192&quot; &gt;Line 192:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 192:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel1 = stored.mol1 - COM1&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel1 = stored.mol1 - COM1&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel1 = stored.sel1.tolist()&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	stored.sel1 = stored.sel1.tolist()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# let PyMol know about the changes to the coordinates&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# let PyMol know about the changes to the coordinates&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.alter_state(1,mol1,&amp;quot;(x,y,z)=stored.sel1.pop(0)&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.alter_state(1,mol1,&amp;quot;(x,y,z)=stored.sel1.pop(0)&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.sel2.pop(0)&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.sel2.pop(0)&amp;quot;)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	print &amp;quot;RMSD=%f&amp;quot; % RMSD&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	print &amp;quot;RMSD=%f&amp;quot; % RMSD&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;	&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# make the alignment OBVIOUS&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	# make the alignment OBVIOUS&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.hide('everything')&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.hide('everything')&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l209&quot; &gt;Line 209:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 209:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.orient()&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.orient()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.zoom('visible')&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	cmd.zoom('visible')&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;cmd.extend(&amp;quot;optAlign&amp;quot;, optAlign)	&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;cmd.extend(&amp;quot;optAlign&amp;quot;, optAlign)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Cowsandmilk</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12165&amp;oldid=prev</id>
		<title>Newacct at 07:58, 27 November 2009</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12165&amp;oldid=prev"/>
		<updated>2009-11-27T07:58:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Intro==&lt;br /&gt;
The Kabsch algorithm uses linear and vector algebra to find the optimal rotation and translation of two sets of points in N-dimensional space as to minimize the RMSD between them.  The following program is a Python implementation of the Kabsch algorithm.&lt;br /&gt;
&lt;br /&gt;
This program when called will align the two selections, optimally, convert the proteins in the selection to ribbons and change the color of the selections to show the matched alignments.&lt;br /&gt;
&lt;br /&gt;
'''WHAT THIS DOESN'T DO''': This program does NOT provide a pairwise alignment of two structures from scratch.  You have to tell it what the equivlanced items are.  See [[Cealign]].&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' This has '''NOT''' been tested on any other machine than mine, by me.  It works on all PyMols 0.97 and newer (haven't tested earlier versions) and I use Python 2.3's Numeric Version 23.3.&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' I have added new Kabsch code.  The new code uses SVD, and fixed an old bug.  For ease of use, try the new code (requires numpy, though).&lt;br /&gt;
&lt;br /&gt;
==To use==&lt;br /&gt;
&lt;br /&gt;
# Save this script to Kabsch.py&lt;br /&gt;
# Open PyMol&lt;br /&gt;
# Load the alignment script: '''run Kabsch.py'''  (The command '''optAlign''' is now defined in PyMol.)&lt;br /&gt;
# Load your proteins&lt;br /&gt;
# Align the proper segments (see below examples)&lt;br /&gt;
&lt;br /&gt;
To align two equivalent sets of residues do:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
optAlign SEL1 and n. CA and i. a-b, SEL2 and n. CA and i. c-d&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
* '''SEL1''' is the first protein&lt;br /&gt;
* '''a-b''' is the range of residues to align in the first protein&lt;br /&gt;
* '''SEL2''' is the second protein&lt;br /&gt;
* '''c-d''' is the range of residues to align in the second protein&lt;br /&gt;
&lt;br /&gt;
===Caveats===&lt;br /&gt;
* Ensure that you're equivalencing '''N''' atoms to '''N''' atoms (run [[Count_Atoms]] over your two selections to ensure they are the same length).&lt;br /&gt;
* Sometimes PyMol doesn't seem to superimpose them right the first time.  Hit the up-arrow and rerun the program if this happens.  It always superimposes the correctly the second time.  I think it has something to do with the orientation.  I'll fix this when I find the error.&lt;br /&gt;
* The RMSD is only between the equivlanced atoms.  Use PyMol's [[Rms_Cur]] if you want a full RMSD.&lt;br /&gt;
* Make sure your atom selections are numbered correctly.  Many times PDB files start residue numbers at something other than 0 or 1.  To ensure you're aligning the right things, do &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;set seq_view,1&amp;lt;/source&amp;gt; to turn on the sequence viewer and double check your residue numbers.  If a protein has residue one numbered as something other than one, say 2064, simply run &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;alter (SEL), resi=str(int(resi)-2064)&amp;lt;/source&amp;gt; and then &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;sort&amp;lt;/source&amp;gt; where '''SEL''' is the name of the protein and 2064 is the offset to adjust by.  Your protein will now work as needed.  See [[Alter]].  This capability is also provided in a script; See [[zero_residues]].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt;Windows users are having problems running the script.  Python tells them first off &amp;quot;TypeError: Can't convert rank-0 arrays to Python scalars.&amp;quot;  The fix to that breaks some code in Numeric -- which I don't maintain.&amp;lt;/li&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;However, to make this work, you can change the code in &amp;lt;b&amp;gt;Numeric.py&amp;lt;/b&amp;gt; supplied with Pymol, located in the folder &amp;quot;&amp;lt;Pymol Home&amp;gt;\modules\Numeric\&amp;quot; (for example:  &amp;quot;C:\Program Files\DeLano Scientific\PyMOL\modules\Numeric&amp;quot;).&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Essentially, you need to search for the line: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt; if axis2 &amp;lt; 0: axis2 = axis1 + n  # (should be around line 250) &amp;lt;/source&amp;gt; and replace it with: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;if axis2 &amp;lt; 0: axis2 = axis2 + n &amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
 optAlign 1cll and n. CA and i. 4-20+30-60, 1ggz and n. CA and i. 4-20+30-60&lt;br /&gt;
&lt;br /&gt;
 optAlign 1kao and n. CA and i. 20-50, 1ctq and n. CA and i. 20-50&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:OptAlign1.png|1cll and 1ggz loaded&lt;br /&gt;
Image:OptAlign2.png|1cll and 1ggz aligned to residues 5-50+55-80 shown in red&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kabsch can also align hetero-atoms:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
load 1cll.pdb&lt;br /&gt;
load 1ggz.pdb&lt;br /&gt;
optAlign 1cll and e. CA, 1ggz and e. CA&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The above aligns the 4 Calciums in each structure.&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;
#!python&lt;br /&gt;
&lt;br /&gt;
##############################################################################&lt;br /&gt;
#&lt;br /&gt;
# @SUMMARY: -- QKabsch.py.  A python implementation of the optimal superposition&lt;br /&gt;
#     of two sets of vectors as proposed by Kabsch 1976 &amp;amp; 1978.&lt;br /&gt;
#&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# @COPYRIGHT: Jason Vertrees (C), 2005-2007&lt;br /&gt;
# @LICENSE: Released under GPL:&lt;br /&gt;
# This program is free software; you can redistribute it and/or modify&lt;br /&gt;
#    it under the terms of the GNU General Public License as published by&lt;br /&gt;
#    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
#    (at your option) any later version.&lt;br /&gt;
# This program is distributed in the hope that it will be useful, but WITHOUT&lt;br /&gt;
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&lt;br /&gt;
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.&lt;br /&gt;
#&lt;br /&gt;
# You should have received a copy of the GNU General Public License along with&lt;br /&gt;
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin&lt;br /&gt;
# Street, Fifth Floor, Boston, MA 02110-1301, USA &lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2007-01-01&lt;br /&gt;
# REV   : 2&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
#&lt;br /&gt;
#############################################################################&lt;br /&gt;
from array import *&lt;br /&gt;
&lt;br /&gt;
# system stuff&lt;br /&gt;
import os&lt;br /&gt;
import copy&lt;br /&gt;
&lt;br /&gt;
# pretty printing&lt;br /&gt;
import pprint&lt;br /&gt;
&lt;br /&gt;
# for importing as a plugin into PyMol&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
from pymol import selector&lt;br /&gt;
&lt;br /&gt;
# using numpy for linear algebra&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def optAlign( sel1, sel2 ):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	optAlign performs the Kabsch alignment algorithm upon the alpha-carbons of two selections.&lt;br /&gt;
	Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&lt;br /&gt;
	Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&lt;br /&gt;
	&lt;br /&gt;
	Two RMSDs are returned.  One comes from the Kabsch algorithm and the other from&lt;br /&gt;
	PyMol based upon your selections.&lt;br /&gt;
&lt;br /&gt;
	By default, this program will optimally align the ALPHA CARBONS of the selections provided.&lt;br /&gt;
	To turn off this feature remove the lines between the commented &amp;quot;REMOVE ALPHA CARBONS&amp;quot; below.&lt;br /&gt;
	&lt;br /&gt;
	@param sel1: First PyMol selection with N-atoms&lt;br /&gt;
	@param sel2: Second PyMol selection with N-atoms&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	cmd.reset()&lt;br /&gt;
	&lt;br /&gt;
	# make the lists for holding coordinates&lt;br /&gt;
	# partial lists&lt;br /&gt;
	stored.sel1 = []&lt;br /&gt;
	stored.sel2 = []&lt;br /&gt;
	# full lists&lt;br /&gt;
	stored.mol1 = []&lt;br /&gt;
	stored.mol2 = []&lt;br /&gt;
&lt;br /&gt;
	# -- CUT HERE&lt;br /&gt;
	sel1 = sel1 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	sel2 = sel2 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	# -- CUT HERE&lt;br /&gt;
&lt;br /&gt;
	# Get the selected coordinates.  We&lt;br /&gt;
	# align these coords.&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel1), &amp;quot;stored.sel1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel2), &amp;quot;stored.sel2.append([x,y,z])&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	# get molecule name&lt;br /&gt;
	mol1 = cmd.identify(sel1,1)[0][0]&lt;br /&gt;
	mol2 = cmd.identify(sel2,1)[0][0]&lt;br /&gt;
	&lt;br /&gt;
	# Get all molecule coords.  We do this because&lt;br /&gt;
	# we have to rotate the whole molcule, not just&lt;br /&gt;
	# the aligned selection&lt;br /&gt;
	cmd.iterate_state(1, mol1, &amp;quot;stored.mol1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, mol2, &amp;quot;stored.mol2.append([x,y,z])&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	# check for consistency&lt;br /&gt;
	assert( len(stored.sel1) == len(stored.sel2))&lt;br /&gt;
	L = len(stored.sel1)&lt;br /&gt;
	assert( L &amp;gt; 0 )&lt;br /&gt;
&lt;br /&gt;
	# must alway center the two proteins to avoid&lt;br /&gt;
	# affine transformations.  Center the two proteins&lt;br /&gt;
	# to their selections.&lt;br /&gt;
	COM1 = numpy.sum(stored.sel1,axis=0) / float(L)&lt;br /&gt;
	COM2 = numpy.sum(stored.sel2,axis=0) / float(L)&lt;br /&gt;
	stored.sel1 = stored.sel1 - COM1&lt;br /&gt;
	stored.sel2 = stored.sel2 - COM2&lt;br /&gt;
	&lt;br /&gt;
	# Initial residual, see Kabsch.&lt;br /&gt;
	E0 = numpy.sum( numpy.sum(stored.sel1 * stored.sel1,axis=0),axis=0) + numpy.sum( numpy.sum(stored.sel2 * stored.sel2,axis=0),axis=0)&lt;br /&gt;
	&lt;br /&gt;
	#&lt;br /&gt;
	# This beautiful step provides the answer.  V and Wt are the orthonormal&lt;br /&gt;
	# bases that when multiplied by each other give us the rotation matrix, U.&lt;br /&gt;
	# S, (Sigma, from SVD) provides us with the error!  Isn't SVD great!&lt;br /&gt;
 	V, S, Wt = numpy.linalg.svd( numpy.dot( numpy.transpose(stored.sel2), stored.sel1))&lt;br /&gt;
	&lt;br /&gt;
	# we already have our solution, in the results from SVD.&lt;br /&gt;
	# we just need to check for reflections and then produce&lt;br /&gt;
	# the rotation.  V and Wt are orthonormal, so their det's&lt;br /&gt;
	# are +/-1.&lt;br /&gt;
        reflect = float(str(float(numpy.linalg.det(V) * numpy.linalg.det(Wt))))&lt;br /&gt;
&lt;br /&gt;
        if reflect == -1.0:&lt;br /&gt;
                S[-1] = -S[-1]&lt;br /&gt;
                V[:,-1] = -V[:,-1]&lt;br /&gt;
		&lt;br /&gt;
	RMSD = E0 - (2.0 * sum(S))&lt;br /&gt;
	RMSD = numpy.sqrt(abs(RMSD / L))&lt;br /&gt;
	&lt;br /&gt;
	#U is simply V*Wt&lt;br /&gt;
	U = numpy.dot(V, Wt)&lt;br /&gt;
	&lt;br /&gt;
	# rotate and translate the molecule&lt;br /&gt;
	stored.sel2 = numpy.dot((stored.mol2 - COM2), U)&lt;br /&gt;
	stored.sel2 = stored.sel2.tolist()&lt;br /&gt;
	# center the molecule&lt;br /&gt;
	stored.sel1 = stored.mol1 - COM1&lt;br /&gt;
	stored.sel1 = stored.sel1.tolist()&lt;br /&gt;
	&lt;br /&gt;
	# let PyMol know about the changes to the coordinates&lt;br /&gt;
	cmd.alter_state(1,mol1,&amp;quot;(x,y,z)=stored.sel1.pop(0)&amp;quot;)&lt;br /&gt;
	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.sel2.pop(0)&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	print &amp;quot;RMSD=%f&amp;quot; % RMSD&lt;br /&gt;
	&lt;br /&gt;
	# make the alignment OBVIOUS&lt;br /&gt;
	cmd.hide('everything')&lt;br /&gt;
	cmd.show('ribbon', sel1 + ' or ' + sel2)&lt;br /&gt;
	cmd.color('gray70', mol1 )&lt;br /&gt;
	cmd.color('paleyellow', mol2 )&lt;br /&gt;
	cmd.color('red', 'visible')&lt;br /&gt;
	cmd.show('ribbon', 'not visible')&lt;br /&gt;
	cmd.center('visible')&lt;br /&gt;
	cmd.orient()&lt;br /&gt;
	cmd.zoom('visible')&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;optAlign&amp;quot;, optAlign)	&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The Old Code ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!python&lt;br /&gt;
&lt;br /&gt;
##############################################################################&lt;br /&gt;
#&lt;br /&gt;
# @SUMMARY: -- Kabsch.py.  A python implementation of the optimal superposition&lt;br /&gt;
#     of two sets of vectors as proposed by Kabsch 1976 &amp;amp; 1978.&lt;br /&gt;
#&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# @COPYRIGHT: Jason Vertrees (C), 2005-2007&lt;br /&gt;
# @LICENSE: Released under GPL:&lt;br /&gt;
# This program is free software; you can redistribute it and/or modify&lt;br /&gt;
#    it under the terms of the GNU General Public License as published by&lt;br /&gt;
#    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
#    (at your option) any later version.&lt;br /&gt;
# This program is distributed in the hope that it will be useful, but WITHOUT&lt;br /&gt;
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&lt;br /&gt;
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.&lt;br /&gt;
#&lt;br /&gt;
# You should have received a copy of the GNU General Public License along with&lt;br /&gt;
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin&lt;br /&gt;
# Street, Fifth Floor, Boston, MA 02110-1301, USA &lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2005-04-07&lt;br /&gt;
# REV   : 2&lt;br /&gt;
# NOTES: Updated RMSD, notes, cleaned up the code a little.&lt;br /&gt;
#&lt;br /&gt;
#############################################################################&lt;br /&gt;
# math imports&lt;br /&gt;
import math&lt;br /&gt;
import Numeric&lt;br /&gt;
import LinearAlgebra&lt;br /&gt;
import Matrix&lt;br /&gt;
&lt;br /&gt;
from array import *&lt;br /&gt;
&lt;br /&gt;
# system stuff&lt;br /&gt;
import os&lt;br /&gt;
import copy&lt;br /&gt;
&lt;br /&gt;
# pretty printing&lt;br /&gt;
import pprint&lt;br /&gt;
&lt;br /&gt;
# for importing as a plugin into PyMol&lt;br /&gt;
#import tkSimpleDialog&lt;br /&gt;
#import tkMessageBox&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
from pymol import selector&lt;br /&gt;
&lt;br /&gt;
class kabsch:&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	Kabsch alignment of two set of vectors to produce and optimal alignemnt.&lt;br /&gt;
&lt;br /&gt;
	Steps&lt;br /&gt;
	=====	&lt;br /&gt;
		1.  Calculate the center of mass for each protein.  Then, move the protein&lt;br /&gt;
		to its center of mass.  We choose as a convention, to use the origin as &lt;br /&gt;
		the center of mass of the first set of coordinates.  This will allow us to&lt;br /&gt;
		return one translation vector, instead of two.&lt;br /&gt;
		&lt;br /&gt;
		Update: Since any rotation around a point that's not the origin, is in fact&lt;br /&gt;
		an affine rotation.  So, to beat that, we translate both to the center.&lt;br /&gt;
		&lt;br /&gt;
		NAME: superpose(c1, c2)&lt;br /&gt;
		POST: T is now defined.&lt;br /&gt;
		&lt;br /&gt;
		2.  Calculate the matrix, R, by (eq7, 1976).  r_{i,j} = sum_n w_n * y_{ni} * x_{nj},&lt;br /&gt;
		where y_{ni} is the ith component of the vector y_n.&lt;br /&gt;
		NAME: calcR&lt;br /&gt;
		POST: R is now defined&lt;br /&gt;
		&lt;br /&gt;
		3.  Calculate RtR (R-transpose * R).&lt;br /&gt;
		NAME: calcRtR&lt;br /&gt;
		POST: RtR is now defined&lt;br /&gt;
		&lt;br /&gt;
		4.  Calculate the corresponding eigenpairs for RtR, and sort them accordingly:&lt;br /&gt;
		m1 &amp;gt;= m2 &amp;gt;= m3; set v3 = v1 x v2 to ensure a RHS&lt;br /&gt;
		NAME: calcEigenPairs&lt;br /&gt;
		POST: The eigen pairs are calculated, sorted such that m1 &amp;gt;= m2 &amp;gt;= m3 and&lt;br /&gt;
		v3 = v1 x v2.&lt;br /&gt;
		&lt;br /&gt;
		5.  Calculate R*v_k and normalize the first two vectors to obtain b_1, b_2 and set&lt;br /&gt;
		b_3 = b_1 x b_2.  This also takes care of m1 &amp;gt; m2 = 0. &lt;br /&gt;
		NAME: calcBVectors&lt;br /&gt;
		POST: b-Vectors are defined and returned&lt;br /&gt;
		&lt;br /&gt;
		6.  Calculate U=(u_{ij})=(sum n b_{ki} * a_{kj}) to obtain the best rotation.  Set&lt;br /&gt;
		sigma_3 = -1 if b3(Ra3) &amp;lt; 0 else sigma_3 = +1.&lt;br /&gt;
		NAME: calcU&lt;br /&gt;
		POST: U is defined&lt;br /&gt;
		&lt;br /&gt;
		7.  Calculate the RMSD.  The residual error is then&lt;br /&gt;
		The E = E0 - sqrt(m1) - sqrt(m2) - sigma_3(sqrt(m3)).&lt;br /&gt;
		NAME: calcRMSD&lt;br /&gt;
		POST: RMSD is computed.&lt;br /&gt;
	&lt;br /&gt;
	 @note: This should be a static method that takes three parameters&lt;br /&gt;
		&lt;br /&gt;
		1. The first protein's coordinates, f.  This program will &lt;br /&gt;
		accept coordinates in the form an array of 3D vectors/lists&lt;br /&gt;
		&lt;br /&gt;
		2. The second protein's coordinates, g.&lt;br /&gt;
		&lt;br /&gt;
		3. The array of integer pairs representing the pairs to align.&lt;br /&gt;
		Coordinates should be formatted as as array of 2D vectors/lists.&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	def __init__(self):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Constructor.  @see kabsch.align.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		#&lt;br /&gt;
		# Instance Variables:  All three of these will be updated&lt;br /&gt;
		# every time the user calls ~.align.  Just to warn ya'.&lt;br /&gt;
		#		&lt;br /&gt;
		# U, the rotation matrix&lt;br /&gt;
		self.U = []&lt;br /&gt;
		# T, the translation vector&lt;br /&gt;
		self.T = []&lt;br /&gt;
		# R, the RMSD&lt;br /&gt;
		self.R = -1.0&lt;br /&gt;
&lt;br /&gt;
		#self.menuBar.addmenuitem('Plugin', 'command', 'Kabsch Align', label = &amp;quot;Align Selections to Optial RMSD&amp;quot;, command = lamda s=self: fetchPDBDialog(s))&lt;br /&gt;
		&lt;br /&gt;
				&lt;br /&gt;
	def align(self, c1, c2, pairs):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Finds the best alignment of c1 and c2's pairs resulting in&lt;br /&gt;
		the smallest possible RMSD.&lt;br /&gt;
&lt;br /&gt;
				&lt;br /&gt;
		@note:&lt;br /&gt;
			- All weights in this first version are set to 1.  Kabsch allows,&lt;br /&gt;
			differential weighting.  In the future, I may extend to this option,&lt;br /&gt;
			and then pairs may become 3D (r1, r2, weight) or I may add another&lt;br /&gt;
			parameter.&lt;br /&gt;
		&lt;br /&gt;
			- Helper functions will soon be provided such that the user may&lt;br /&gt;
			just use this package alone to compute the rotation.&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param pairs: the list of pairs as an array of 2D pairs.&lt;br /&gt;
		@type  pairs: Python list of 2D lists.&lt;br /&gt;
		&lt;br /&gt;
		@return: U, the rotation matrix that gives the optimal rotation between the two proteins.&lt;br /&gt;
			&lt;br /&gt;
			T, the translation vector given to align the two objects centers of mass.&lt;br /&gt;
			&lt;br /&gt;
			R, the RMSD of the final rotation.&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		#&lt;br /&gt;
		# First we move the center of mass of one protein, to the&lt;br /&gt;
		# center of mass of the other.  This removes any translation&lt;br /&gt;
		# between the two.&lt;br /&gt;
		#&lt;br /&gt;
		T1, T2, c1, c2 = self.superpose(c1, c2)&lt;br /&gt;
		# Calculate the initial RMSD&lt;br /&gt;
		E0 = self.calcE0(c1, c2)&lt;br /&gt;
		# Calculate R via eq. 7.&lt;br /&gt;
		R = self.calcR(c1, c2)&lt;br /&gt;
		# Calculate R(transpose)*R&lt;br /&gt;
		RtR = self.calcRtR(R)&lt;br /&gt;
		# Determined the eigenpairs for the matrix RtR.&lt;br /&gt;
		eValues, eVectors = self.calcEigenPairs(RtR)&lt;br /&gt;
		# Determine the bVectors as required&lt;br /&gt;
		bVectors = self.calcBVectors(R, eVectors)&lt;br /&gt;
		# Calculate the roation matrix&lt;br /&gt;
		U = self.calcU(eVectors, bVectors)&lt;br /&gt;
		# Calculate the final RMSD using U.&lt;br /&gt;
		RMSD = self.calcRMSD(E0, eValues, eVectors, bVectors, R, len(c1))&lt;br /&gt;
		&lt;br /&gt;
		return U, T1, T2, RMSD, c1, c2&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	def superpose(self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the center of mass for each protein.  Then, move the protein&lt;br /&gt;
		to its center of mass.  We choose as a convention, to use the origin as &lt;br /&gt;
		the center of mass of the first set of coordinates.  This will allow us to&lt;br /&gt;
		return one translation vector, instead of two.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@precondition: c1 and c2 are well defined lists of N-dimensional points with length &amp;gt; 0.&lt;br /&gt;
		@postcondition: T is now defined.&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
		&lt;br /&gt;
		@return: T the translation vector.&lt;br /&gt;
		&lt;br /&gt;
			c2 one list of coordinates that of c2 translated to the COM of c1.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		# make sure we don't get bad data&lt;br /&gt;
		if (len(c1) != len(c2)):&lt;br /&gt;
			print &amp;quot;Two different length selections, with lengths, %d and %d.&amp;quot; % (len(c1), len(c2))&lt;br /&gt;
			print &amp;quot;This algorithm must be used with selections of the same length.&amp;quot;	&lt;br /&gt;
			print &amp;quot;In PyMol, type 'count_atoms sel1' where sel1 are your selections to find out their lengths.&amp;quot;&lt;br /&gt;
			print &amp;quot;Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&amp;quot;&lt;br /&gt;
        		print &amp;quot;Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
			&lt;br /&gt;
		assert(len(c1) == len(c2) != 0)&lt;br /&gt;
&lt;br /&gt;
		L = len(c1)&lt;br /&gt;
		&lt;br /&gt;
		#&lt;br /&gt;
		# Centers of Mass&lt;br /&gt;
		#&lt;br /&gt;
		c1COM = Numeric.zeros((3,1), Numeric.Float64)&lt;br /&gt;
		c2COM = Numeric.zeros((3,1), Numeric.Float64)&lt;br /&gt;
&lt;br /&gt;
		# calculate the CsOM		&lt;br /&gt;
		for i in range(0, L):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				c1COM[j] = c1COM[j] + c1[i][j]&lt;br /&gt;
				c2COM[j] = c2COM[j] + c2[i][j]&lt;br /&gt;
		&lt;br /&gt;
		T1 = - c1COM / L&lt;br /&gt;
		T2 = - c2COM / L&lt;br /&gt;
&lt;br /&gt;
		# move everything back to the origin.&lt;br /&gt;
		for i in range(0, L):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				c1[i][j] = c1[i][j] + T1[j]&lt;br /&gt;
				c2[i][j] = c2[i][j] + T2[j]&lt;br /&gt;
				&lt;br /&gt;
		return T1, T2, c1, c2&lt;br /&gt;
&lt;br /&gt;
					&lt;br /&gt;
	def calcR( self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the matrix, R, by (eq7, 1976).  M{r_{i,j} = sum_n w_n * y_{ni} * x_{nj}},&lt;br /&gt;
		where M{y_{ni}} is the ith component of the vector M{y_n}.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
&lt;br /&gt;
		@postcondition: R is now defined.&lt;br /&gt;
		&lt;br /&gt;
		@return: R&lt;br /&gt;
		@rtype : 3x3 matrix&lt;br /&gt;
				&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		# Create the 3x3 matrix&lt;br /&gt;
		R = Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
		L = len(c1)&lt;br /&gt;
		&lt;br /&gt;
		for k in range(0, L):&lt;br /&gt;
			for i in range(0, 3):&lt;br /&gt;
				for j in range(0, 3):&lt;br /&gt;
					R[i][j] = R[i][j] + (c2[k][i] * c1[k][j])&lt;br /&gt;
		&lt;br /&gt;
		# return R the 3x3 PSD Matrix.&lt;br /&gt;
		return R&lt;br /&gt;
		&lt;br /&gt;
	&lt;br /&gt;
	def calcRtR( self, R ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate RtR (R-transpose * R).&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@param R: Matrix&lt;br /&gt;
		@type  R: 3x3 Matrix&lt;br /&gt;
		&lt;br /&gt;
		@precondition: R is a the well formed matrix as per Kabsch.&lt;br /&gt;
		@postcondition: RtR is now defined&lt;br /&gt;
		&lt;br /&gt;
		@return: M{R^tR}&lt;br /&gt;
		@rtype : 3x3 matrix&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		RtR = Numeric.matrixmultiply(Numeric.transpose(R), R)&lt;br /&gt;
		&lt;br /&gt;
		return RtR&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	def calcEigenPairs( self, RtR ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the corresponding eigenpairs for RtR, and sort them accordingly:&lt;br /&gt;
		M{m1 &amp;gt;= m2 &amp;gt;= m3}; set M{v3 = v1 x v2} to ensure a RHS&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: The eigen pairs are calculated, sorted such that M{m1 &amp;gt;= m2 &amp;gt;= m3} and&lt;br /&gt;
		M{v3 = v1 x v2}.&lt;br /&gt;
		&lt;br /&gt;
		@param RtR: 3x3 Matrix of M{R^t * R}.&lt;br /&gt;
		@type  RtR: 3x3 Matrix&lt;br /&gt;
		@return : Eigenpairs for the RtR matrix.&lt;br /&gt;
		@rtype  : List of stuff&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		eVal, eVec = LinearAlgebra.eigenvectors(RtR)&lt;br /&gt;
&lt;br /&gt;
		# This is cool.  We sort it using Numeric.sort(eVal)&lt;br /&gt;
		# then we reverse it using nifty-crazy ass notation [::-1].&lt;br /&gt;
		eVal2 = Numeric.sort(eVal)[::-1]&lt;br /&gt;
		eVec2 = [[],[],[]] #Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
				&lt;br /&gt;
		# Map the vectors to their appropriate owners		&lt;br /&gt;
		if ( eVal2[0] == eVal[0]):&lt;br /&gt;
			eVec2[0] = eVec[0]&lt;br /&gt;
			if ( eVal2[1] == eVal[1] ):&lt;br /&gt;
				eVec2[1] = eVec[1]&lt;br /&gt;
				eVec2[2] = eVec[2]&lt;br /&gt;
			else:&lt;br /&gt;
				eVec2[1] = eVec[2]&lt;br /&gt;
				eVec2[2] = eVec[1]&lt;br /&gt;
		elif( eVal2[0] == eVal[1]):&lt;br /&gt;
			eVec2[0] = eVec[1]&lt;br /&gt;
			if ( eVal2[1] == eVal[0] ):&lt;br /&gt;
				eVec2[1] = eVec[0]&lt;br /&gt;
				eVec2[2] = eVec[2]&lt;br /&gt;
			else:&lt;br /&gt;
				eVec2[1] = eVec[2]&lt;br /&gt;
				eVec2[2] = eVec[0]&lt;br /&gt;
		elif( eVal2[0] == eVal[2]):&lt;br /&gt;
			eVec2[0] = eVec[2]&lt;br /&gt;
			if ( eVal2[1] == eVal[1] ):&lt;br /&gt;
				eVec2[1] = eVec[1]&lt;br /&gt;
				eVec2[2] = eVec[0]&lt;br /&gt;
			else:&lt;br /&gt;
				eVec2[1] = eVec[0]&lt;br /&gt;
				eVec2[2] = eVec[1]&lt;br /&gt;
&lt;br /&gt;
		eVec2[2][0] = eVec2[0][1]*eVec2[1][2] - eVec2[0][2]*eVec2[1][1]&lt;br /&gt;
		eVec2[2][1] = eVec2[0][2]*eVec2[1][0] - eVec2[0][0]*eVec2[1][2]&lt;br /&gt;
		eVec2[2][2] = eVec2[0][0]*eVec2[1][1] - eVec2[0][1]*eVec2[1][0]&lt;br /&gt;
		&lt;br /&gt;
		return [eVal2, eVec2]&lt;br /&gt;
		&lt;br /&gt;
	&lt;br /&gt;
	def calcBVectors( self, R, eVectors ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate M{R*a_k} and normalize the first two vectors to obtain M{b_1, b_2} and set&lt;br /&gt;
		M{b_3 = b_1 x b_2}.  This also takes care of {m2 &amp;gt; m3 = 0}. &lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: b-Vectors are defined and returned&lt;br /&gt;
		&lt;br /&gt;
		@return: The three B-vectors&lt;br /&gt;
		@rtype: List of 3D vectors (Python LOL).&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		bVectors = Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
&lt;br /&gt;
		for i in range(0,3):&lt;br /&gt;
			bVectors[i] = Numeric.matrixmultiply(R, eVectors[i])&lt;br /&gt;
&lt;br /&gt;
		bVectors[0] = bVectors[0] / Numeric.sqrt(Numeric.add.reduce(bVectors[0]**2))&lt;br /&gt;
		bVectors[1] = bVectors[1] / Numeric.sqrt(Numeric.add.reduce(bVectors[1]**2))&lt;br /&gt;
		bVectors[2] = bVectors[2] / Numeric.sqrt(Numeric.add.reduce(bVectors[2]**2))&lt;br /&gt;
		&lt;br /&gt;
		bVectors[2][0] = bVectors[0][1]*bVectors[1][2] - bVectors[0][2]*bVectors[1][1]&lt;br /&gt;
		bVectors[2][1] = bVectors[0][2]*bVectors[1][0] - bVectors[0][0]*bVectors[1][2]&lt;br /&gt;
		bVectors[2][2] = bVectors[0][0]*bVectors[1][1] - bVectors[0][1]*bVectors[1][0]&lt;br /&gt;
		&lt;br /&gt;
		return bVectors&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	def calcU( self, eVectors, bVectors ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate M{U=(u_{ij})=(sum n b_{ki} * a_{kj})} to obtain the best rotation.  Set&lt;br /&gt;
		M{sigma_3 = -1 if b3(Ra3) &amp;lt; 0 else sigma_3 = +1}.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: U is defined&lt;br /&gt;
		&lt;br /&gt;
		@param eVectors: Eigenvectors for the system.&lt;br /&gt;
		@type  eVectors: Eigenvectors&lt;br /&gt;
		&lt;br /&gt;
		@param bVectors: BVectors as described by Kabsch.&lt;br /&gt;
		@type  bVectors: BVectors&lt;br /&gt;
		&lt;br /&gt;
		@return: U the rotation matrix.&lt;br /&gt;
		@rtype  :3x3 matrix.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		U = Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
		&lt;br /&gt;
		for k in range(0,3):&lt;br /&gt;
			for i in range(0,3):&lt;br /&gt;
				for j in range(0,3):&lt;br /&gt;
					U[i][j] = U[i][j] + Numeric.matrixmultiply(bVectors[k][i], eVectors[k][j])&lt;br /&gt;
		&lt;br /&gt;
		return U&lt;br /&gt;
	&lt;br /&gt;
		&lt;br /&gt;
	def calcE0( self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculates the initial RMSD, which Kacbsch called E0.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
		&lt;br /&gt;
		@return: E0 the initial RMSD.&lt;br /&gt;
		@rtype : float.&lt;br /&gt;
				&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		E0 = 0.0&lt;br /&gt;
		&lt;br /&gt;
		L = len(c1)&lt;br /&gt;
		for i in range( 0, L ):&lt;br /&gt;
			for j in range(0, 3):&lt;br /&gt;
				E0 = E0 + 0.5*( (c1[i][j]*c1[i][j])+(c2[i][j]*c2[i][j]))&lt;br /&gt;
		&lt;br /&gt;
		return E0&lt;br /&gt;
	&lt;br /&gt;
	def calcRMSD( self, E0, eValues, eVectors, bVectors, R, N):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the RMSD.  The residual error is then&lt;br /&gt;
		The M{E = E0 - sqrt(m1) - sqrt(m2) - sigma_3(sqrt(m3))}.&lt;br /&gt;
		&lt;br /&gt;
		@param E0: Initial RMSD as calculated in L{calcE0}.&lt;br /&gt;
		@type  E0: float.&lt;br /&gt;
		&lt;br /&gt;
		@param eVectors: Eigenvectors as calculated from L{calcEigenPairs}&lt;br /&gt;
		@type eVectors: vectors, dammit!&lt;br /&gt;
		&lt;br /&gt;
		@param bVectors: B-vectors as calc. from L{calcBVectors}&lt;br /&gt;
		@type  bVectors: More vectors.&lt;br /&gt;
		&lt;br /&gt;
		@param R: The matrix R, from L{calcR}.&lt;br /&gt;
		@type  R: 3x3 matrix.		&lt;br /&gt;
&lt;br /&gt;
		@param N: Number of equivalenced points&lt;br /&gt;
		@type  N: integer&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: RMSD is computed.&lt;br /&gt;
		@return: The RMSD.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		sigma3 = 0&lt;br /&gt;
		if ( Numeric.matrixmultiply(bVectors[2], Numeric.matrixmultiply( R, eVectors[2])) &amp;lt; 0):&lt;br /&gt;
			sigma3 = -1&lt;br /&gt;
		else:&lt;br /&gt;
			sigma3 = 1&lt;br /&gt;
&lt;br /&gt;
		E = math.sqrt( 2*(E0 - math.sqrt(eValues[0]) - math.sqrt(eValues[1]) - sigma3*(math.sqrt(eValues[2]))) / N)&lt;br /&gt;
		&lt;br /&gt;
		return E&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	def calcSimpleRMSD( self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculates the usual concept of RMSD between two set of points.  The CalcRMSD above&lt;br /&gt;
		sticks to Kabsch's alignment method protocol and calculates something much different.&lt;br /&gt;
		@see kabsch.calcRMSD&lt;br /&gt;
		&lt;br /&gt;
		@param c1: List of points #1&lt;br /&gt;
		@type  c1: LOL&lt;br /&gt;
		&lt;br /&gt;
		@param c2: List of points #2&lt;br /&gt;
		@type  c2: LOL&lt;br /&gt;
		&lt;br /&gt;
		@return: RMSD between the two&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		RMSD = 0.0&lt;br /&gt;
		for i in range(0, len(c1)):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				RMSD = RMSD + (c2[i][j]-c1[i][j])**2&lt;br /&gt;
				&lt;br /&gt;
		RMSD = RMSD / len(c1)&lt;br /&gt;
		RMSD = Numeric.sqrt(RMSD)&lt;br /&gt;
		return RMSD&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	#####################################################################&lt;br /&gt;
	#&lt;br /&gt;
	# UTIL Functions&lt;br /&gt;
	def rotatePoints(self, U, c2):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Rotate all points in c2 based on the rotation matrix U.&lt;br /&gt;
		&lt;br /&gt;
		@param U: 3x3 Rotation matrix&lt;br /&gt;
		@type  U: 3x3 matrix&lt;br /&gt;
		&lt;br /&gt;
		@param c2: List of points to rotate&lt;br /&gt;
		@type  c2: List of 3D vectors&lt;br /&gt;
		&lt;br /&gt;
		@return: List of rotated points&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
		L = len(c2)&lt;br /&gt;
&lt;br /&gt;
		for n in range(0,L):&lt;br /&gt;
			c2[n][0] = c2[n][0] * U[0][0] + c2[n][1] * U[1][0] + c2[n][2] * U[2][0]&lt;br /&gt;
			c2[n][1] = c2[n][0] * U[0][1] + c2[n][1] * U[1][1] + c2[n][2] * U[2][1]&lt;br /&gt;
			c2[n][2] = c2[n][0] * U[0][2] + c2[n][1] * U[1][2] + c2[n][2] * U[2][2]&lt;br /&gt;
		&lt;br /&gt;
		return c2&lt;br /&gt;
	&lt;br /&gt;
	def writeU( self, U, fileName ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Convenience function.  Writes U to disk.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		if ( len(fileName) == 0 ):&lt;br /&gt;
			fileName = &amp;quot;./U&amp;quot;&lt;br /&gt;
			&lt;br /&gt;
		outFile = open( fileName, &amp;quot;wb&amp;quot;)&lt;br /&gt;
		for i in range(0,3):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				outFile.write( str(U[i][j]).ljust(20) )&lt;br /&gt;
			outFile.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
		outFile.close()		&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
def optAlign( sel1, sel2 ):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	optAlign performs the Kabsch alignment algorithm upon the alpha-carbons of two selections.&lt;br /&gt;
	Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&lt;br /&gt;
	Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&lt;br /&gt;
	&lt;br /&gt;
	Two RMSDs are returned.  One comes from the Kabsch algorithm and the other from&lt;br /&gt;
	PyMol based upon your selections.&lt;br /&gt;
&lt;br /&gt;
	By default, this program will optimally align the ALPHA CARBONS of the selections provided.&lt;br /&gt;
	To turn off this feature remove the lines between the commented &amp;quot;REMOVE ALPHA CARBONS&amp;quot; below.&lt;br /&gt;
	&lt;br /&gt;
	@param sel1: First PyMol selection with N-atoms&lt;br /&gt;
	@param sel2: Second PyMol selection with N-atoms&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	cmd.reset()&lt;br /&gt;
&lt;br /&gt;
	# make the lists for holding coordinates&lt;br /&gt;
	# partial lists&lt;br /&gt;
	stored.sel1 = []&lt;br /&gt;
	stored.sel2 = []&lt;br /&gt;
	# full lists&lt;br /&gt;
	stored.mol1 = []&lt;br /&gt;
	stored.mol2 = []&lt;br /&gt;
&lt;br /&gt;
	# now put the coordinates into a list&lt;br /&gt;
	# partials&lt;br /&gt;
&lt;br /&gt;
	# -- REMOVE ALPHA CARBONS&lt;br /&gt;
	sel1 = sel1 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	sel2 = sel2 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	# -- REMOVE ALPHA CARBONS&lt;br /&gt;
&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel1), &amp;quot;stored.sel1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel2), &amp;quot;stored.sel2.append([x,y,z])&amp;quot;)&lt;br /&gt;
	# full molecule&lt;br /&gt;
	mol1 = cmd.identify(sel1,1)[0][0]&lt;br /&gt;
	mol2 = cmd.identify(sel2,1)[0][0]&lt;br /&gt;
	cmd.iterate_state(1, mol1, &amp;quot;stored.mol1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, mol2, &amp;quot;stored.mol2.append([x,y,z])&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	K = kabsch()&lt;br /&gt;
	U, T1, T2, RMSD, c1, c2 = K.align(stored.sel1, stored.sel2, [])&lt;br /&gt;
&lt;br /&gt;
	stored.mol2 = map(lambda v:[T2[0]+((v[0]*U[0][0])+(v[1]*U[1][0])+(v[2]*U[2][0])),T2[1]+((v[0]*U[0][1])+(v[1]*U[1][1])+(v[2]*U[2][1])),T2[2]+((v[0]*U[0][2])+(v[1]*U[1][2])+(v[2]*U[2][2]))],stored.mol2)&lt;br /&gt;
	#stored.mol1 = map(lambda v:[ v[0]+T1[0], v[1]+T1[1], v[2]+T1[2] ], stored.mol1)&lt;br /&gt;
	stored.mol1 = map(lambda v:[ v[0]+T1[0], v[1]+T1[1], v[2]+T1[2] ], stored.mol1)&lt;br /&gt;
&lt;br /&gt;
	cmd.alter_state(1,mol1,&amp;quot;(x,y,z)=stored.mol1.pop(0)&amp;quot;)&lt;br /&gt;
	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.mol2.pop(0)&amp;quot;)&lt;br /&gt;
	cmd.alter( 'all',&amp;quot;segi=''&amp;quot;)&lt;br /&gt;
	cmd.alter('all', &amp;quot;chain=''&amp;quot;)&lt;br /&gt;
	print &amp;quot;RMSD=%f&amp;quot; % cmd.rms_cur(sel1, sel2)&lt;br /&gt;
	print &amp;quot;MY RMSD=%f&amp;quot; % RMSD&lt;br /&gt;
	cmd.hide('everything')&lt;br /&gt;
	cmd.show('ribbon', sel1 + ' or ' + sel2)&lt;br /&gt;
	cmd.color('gray70', mol1 )&lt;br /&gt;
	cmd.color('paleyellow', mol2 )&lt;br /&gt;
	cmd.color('red', 'visible')&lt;br /&gt;
	cmd.show('ribbon', 'not visible')&lt;br /&gt;
	cmd.center('visible')&lt;br /&gt;
	cmd.orient()&lt;br /&gt;
	cmd.zoom('visible')&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;optAlign&amp;quot;, optAlign)	&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
'''[Kabsch, 1976]''' Kabsch, W. (1976).&lt;br /&gt;
A solution for the best rotation to relate two sets of vectors.&lt;br /&gt;
''Acta. Crystal'', 32A:922-923.&lt;br /&gt;
&lt;br /&gt;
'''[Kabsch, 1978]''' Kabsch, W. (1978).&lt;br /&gt;
A discussion of the solution for the best rotation to related two sets of vectors.&lt;br /&gt;
''Acta. Crystal'', 34A:827-828.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|Kabsch Alignment]]&lt;br /&gt;
[[Category:Structure_Alignment|Kabsch Alignment]]&lt;/div&gt;</summary>
		<author><name>Newacct</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12159&amp;oldid=prev</id>
		<title>Bobcat hokie: /* To use */</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12159&amp;oldid=prev"/>
		<updated>2007-01-20T00:48:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;To use&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:48, 20 January 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l20&quot; &gt;Line 20:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 20:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To align two equivalent sets of residues do:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To align two equivalent sets of residues do:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;optAlign SEL1 and n. CA and i. a-b, SEL2 and n. CA and c-d&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;optAlign SEL1 and n. CA and i. a-b, SEL2 and n. CA and &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;i. &lt;/ins&gt;c-d&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/source&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;where&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;where&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bobcat hokie</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12158&amp;oldid=prev</id>
		<title>72.181.94.94: /* Examples */</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Kabsch&amp;diff=12158&amp;oldid=prev"/>
		<updated>2007-01-18T03:19:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Examples&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Intro==&lt;br /&gt;
The Kabsch algorithm uses linear and vector algebra to find the optimal rotation and translation of two sets of points in N-dimensional space as to minimize the RMSD between them.  The following program is a Python implementation of the Kabsch algorithm.&lt;br /&gt;
&lt;br /&gt;
This program when called will align the two selections, optimally, convert the proteins in the selection to ribbons and change the color of the selections to show the matched alignments.&lt;br /&gt;
&lt;br /&gt;
'''WHAT THIS DOESN'T DO''': This program does NOT provide a pairwise alignment of two structures from scratch.  You have to tell it what the equivlanced items are.  See [[Cealign]].&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' This has '''NOT''' been tested on any other machine than mine, by me.  It works on all PyMols 0.97 and newer (haven't tested earlier versions) and I use Python 2.3's Numeric Version 23.3.&lt;br /&gt;
&lt;br /&gt;
'''NOTE:''' I have added new Kabsch code.  The new code uses SVD, and fixed an old bug.  For ease of use, try the new code (requires numpy, though).&lt;br /&gt;
&lt;br /&gt;
==To use==&lt;br /&gt;
&lt;br /&gt;
# Save this script to Kabsch.py&lt;br /&gt;
# Open PyMol&lt;br /&gt;
# Load the alignment script: '''run Kabsch.py'''  (The command '''optAlign''' is now defined in PyMol.)&lt;br /&gt;
# Load your proteins&lt;br /&gt;
# Align the proper segments (see below examples)&lt;br /&gt;
&lt;br /&gt;
To align two equivalent sets of residues do:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
optAlign SEL1 and n. CA and i. a-b, SEL2 and n. CA and c-d&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
where&lt;br /&gt;
* '''SEL1''' is the first protein&lt;br /&gt;
* '''a-b''' is the range of residues to align in the first protein&lt;br /&gt;
* '''SEL2''' is the second protein&lt;br /&gt;
* '''c-d''' is the range of residues to align in the second protein&lt;br /&gt;
&lt;br /&gt;
===Caveats===&lt;br /&gt;
* Ensure that you're equivalencing '''N''' atoms to '''N''' atoms (run [[Count_Atoms]] over your two selections to ensure they are the same length).&lt;br /&gt;
* Sometimes PyMol doesn't seem to superimpose them right the first time.  Hit the up-arrow and rerun the program if this happens.  It always superimposes the correctly the second time.  I think it has something to do with the orientation.  I'll fix this when I find the error.&lt;br /&gt;
* The RMSD is only between the equivlanced atoms.  Use PyMol's [[Rms_Cur]] if you want a full RMSD.&lt;br /&gt;
* Make sure your atom selections are numbered correctly.  Many times PDB files start residue numbers at something other than 0 or 1.  To ensure you're aligning the right things, do &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;set seq_view,1&amp;lt;/source&amp;gt; to turn on the sequence viewer and double check your residue numbers.  If a protein has residue one numbered as something other than one, say 2064, simply run &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;alter (SEL), resi=str(int(resi)-2064)&amp;lt;/source&amp;gt; and then &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;sort&amp;lt;/source&amp;gt; where '''SEL''' is the name of the protein and 2064 is the offset to adjust by.  Your protein will now work as needed.  See [[Alter]].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&amp;lt;ol&amp;gt;&amp;lt;li&amp;gt;Windows users are having problems running the script.  Python tells them first off &amp;quot;TypeError: Can't convert rank-0 arrays to Python scalars.&amp;quot;  The fix to that breaks some code in Numeric -- which I don't maintain.&amp;lt;/li&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;However, to make this work, you can change the code in &amp;lt;b&amp;gt;Numeric.py&amp;lt;/b&amp;gt; supplied with Pymol, located in the folder &amp;quot;&amp;lt;Pymol Home&amp;gt;\modules\Numeric\&amp;quot; (for example:  &amp;quot;C:\Program Files\DeLano Scientific\PyMOL\modules\Numeric&amp;quot;).&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Essentially, you need to search for the line: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt; if axis2 &amp;lt; 0: axis2 = axis1 + n  # (should be around line 250) &amp;lt;/source&amp;gt; and replace it with: &amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;if axis2 &amp;lt; 0: axis2 = axis2 + n &amp;lt;/source&amp;gt;&amp;lt;/li&amp;gt;&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
 optAlign 1cll and n. CA and i. 4-20+30-60, 1ggz and n. CA and i. 4-20+30-60&lt;br /&gt;
&lt;br /&gt;
 optAlign 1kao and n. CA and i. 20-50, 1ctq and n. CA and i. 20-50&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:OptAlign1.png|1cll and 1ggz loaded&lt;br /&gt;
Image:OptAlign2.png|1cll and 1ggz aligned to residues 5-50+55-80 shown in red&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kabsch can also align hetero-atoms:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
load 1cll.pdb&lt;br /&gt;
load 1ggz.pdb&lt;br /&gt;
optAlign 1cll and e. CA, 1ggz and e. CA&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The above aligns the 4 Calciums in each structure.&lt;br /&gt;
&lt;br /&gt;
==The Code==&lt;br /&gt;
&lt;br /&gt;
=== Update ===&lt;br /&gt;
I have reworked the code.  The new code fixes the problem of rotating before translating, thus all alignments will be correct -- no need to run them twice.  Also, this version uses SVD from the Numpy package.&lt;br /&gt;
&lt;br /&gt;
Provided here for ease of use is the Python code.  This plugs directly into PyMol as-is.  Contact Jason dot Vertrees _at_ gmail _DoT_ com for questions or comments.&lt;br /&gt;
&lt;br /&gt;
=== The New Code ===&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!python&lt;br /&gt;
&lt;br /&gt;
##############################################################################&lt;br /&gt;
#&lt;br /&gt;
# @SUMMARY: -- QKabsch.py.  A python implementation of the optimal superposition&lt;br /&gt;
#     of two sets of vectors as proposed by Kabsch 1976 &amp;amp; 1978.&lt;br /&gt;
#&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# @COPYRIGHT: Jason Vertrees (C), 2005-2007&lt;br /&gt;
# @LICENSE: Released under GPL:&lt;br /&gt;
# This program is free software; you can redistribute it and/or modify&lt;br /&gt;
#    it under the terms of the GNU General Public License as published by&lt;br /&gt;
#    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
#    (at your option) any later version.&lt;br /&gt;
# This program is distributed in the hope that it will be useful, but WITHOUT&lt;br /&gt;
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&lt;br /&gt;
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.&lt;br /&gt;
#&lt;br /&gt;
# You should have received a copy of the GNU General Public License along with&lt;br /&gt;
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin&lt;br /&gt;
# Street, Fifth Floor, Boston, MA 02110-1301, USA &lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2007-01-01&lt;br /&gt;
# REV   : 2&lt;br /&gt;
# REQUIREMENTS: numpy&lt;br /&gt;
#&lt;br /&gt;
#############################################################################&lt;br /&gt;
from array import *&lt;br /&gt;
&lt;br /&gt;
# system stuff&lt;br /&gt;
import os&lt;br /&gt;
import copy&lt;br /&gt;
&lt;br /&gt;
# pretty printing&lt;br /&gt;
import pprint&lt;br /&gt;
import string&lt;br /&gt;
&lt;br /&gt;
# for importing as a plugin into PyMol&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
from pymol import selector&lt;br /&gt;
&lt;br /&gt;
# using numpy for linear algebra&lt;br /&gt;
import numpy&lt;br /&gt;
&lt;br /&gt;
def optAlign( sel1, sel2 ):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	optAlign performs the Kabsch alignment algorithm upon the alpha-carbons of two selections.&lt;br /&gt;
	Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&lt;br /&gt;
	Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&lt;br /&gt;
	&lt;br /&gt;
	Two RMSDs are returned.  One comes from the Kabsch algorithm and the other from&lt;br /&gt;
	PyMol based upon your selections.&lt;br /&gt;
&lt;br /&gt;
	By default, this program will optimally align the ALPHA CARBONS of the selections provided.&lt;br /&gt;
	To turn off this feature remove the lines between the commented &amp;quot;REMOVE ALPHA CARBONS&amp;quot; below.&lt;br /&gt;
	&lt;br /&gt;
	@param sel1: First PyMol selection with N-atoms&lt;br /&gt;
	@param sel2: Second PyMol selection with N-atoms&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	cmd.reset()&lt;br /&gt;
	&lt;br /&gt;
	# make the lists for holding coordinates&lt;br /&gt;
	# partial lists&lt;br /&gt;
	stored.sel1 = []&lt;br /&gt;
	stored.sel2 = []&lt;br /&gt;
	# full lists&lt;br /&gt;
	stored.mol1 = []&lt;br /&gt;
	stored.mol2 = []&lt;br /&gt;
&lt;br /&gt;
	# -- CUT HERE&lt;br /&gt;
	sel1 = sel1 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	sel2 = sel2 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	# -- CUT HERE&lt;br /&gt;
&lt;br /&gt;
	# Get the selected coordinates.  We&lt;br /&gt;
	# align these coords.&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel1), &amp;quot;stored.sel1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel2), &amp;quot;stored.sel2.append([x,y,z])&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	# get molecule name&lt;br /&gt;
	mol1 = cmd.identify(sel1,1)[0][0]&lt;br /&gt;
	mol2 = cmd.identify(sel2,1)[0][0]&lt;br /&gt;
	&lt;br /&gt;
	# Get all molecule coords.  We do this because&lt;br /&gt;
	# we have to rotate the whole molcule, not just&lt;br /&gt;
	# the aligned selection&lt;br /&gt;
	cmd.iterate_state(1, mol1, &amp;quot;stored.mol1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, mol2, &amp;quot;stored.mol2.append([x,y,z])&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	# check for consistency&lt;br /&gt;
	assert( len(stored.sel1) == len(stored.sel2))&lt;br /&gt;
	L = len(stored.sel1)&lt;br /&gt;
	assert( L &amp;gt; 0 )&lt;br /&gt;
&lt;br /&gt;
	# must alway center the two proteins to avoid&lt;br /&gt;
	# affine transformations.  Center the two proteins&lt;br /&gt;
	# to their selections.&lt;br /&gt;
	COM1 = numpy.sum(stored.sel1,axis=0) / float(L)&lt;br /&gt;
	COM2 = numpy.sum(stored.sel2,axis=0) / float(L)&lt;br /&gt;
	stored.sel1 = stored.sel1 - COM1&lt;br /&gt;
	stored.sel2 = stored.sel2 - COM2&lt;br /&gt;
	&lt;br /&gt;
	# Initial residual, see Kabsch.&lt;br /&gt;
	E0 = numpy.sum( numpy.sum(stored.sel1 * stored.sel1,axis=0),axis=0) + numpy.sum( numpy.sum(stored.sel2 * stored.sel2,axis=0),axis=0)&lt;br /&gt;
	&lt;br /&gt;
	#&lt;br /&gt;
	# This beautiful step provides the answer.  V and Wt are the orthonormal&lt;br /&gt;
	# bases that when multiplied by each other give us the rotation matrix, U.&lt;br /&gt;
	# S, (Sigma, from SVD) provides us with the error!  Isn't SVD great!&lt;br /&gt;
 	V, S, Wt = numpy.linalg.svd( numpy.dot( numpy.transpose(stored.sel2), stored.sel1))&lt;br /&gt;
	&lt;br /&gt;
	# we already have our solution, in the results from SVD.&lt;br /&gt;
	# we just need to check for reflections and then produce&lt;br /&gt;
	# the rotation.  V and Wt are orthonormal, so their det's&lt;br /&gt;
	# are +/-1.&lt;br /&gt;
	reflect = numpy.linalg.det(V) * numpy.linalg.det(Wt)&lt;br /&gt;
	if reflect == -1:&lt;br /&gt;
		S[-1] = -S[-1]&lt;br /&gt;
		V[-1,:] = -V[-1,:]&lt;br /&gt;
		&lt;br /&gt;
	RMSD = E0 - (2.0 * sum(S))&lt;br /&gt;
	RMSD = numpy.sqrt(abs(RMSD / L))&lt;br /&gt;
	&lt;br /&gt;
	#U is simply V*Wt&lt;br /&gt;
	U = numpy.dot(V, Wt)&lt;br /&gt;
	&lt;br /&gt;
	# rotate and translate the molecule&lt;br /&gt;
	stored.sel2 = numpy.dot((stored.mol2 - COM2), U)&lt;br /&gt;
	stored.sel2 = stored.sel2.tolist()&lt;br /&gt;
	# center the molecule&lt;br /&gt;
	stored.sel1 = stored.mol1 - COM1&lt;br /&gt;
	stored.sel1 = stored.sel1.tolist()&lt;br /&gt;
	&lt;br /&gt;
	# let PyMol know about the changes to the coordinates&lt;br /&gt;
	cmd.alter_state(1,mol1,&amp;quot;(x,y,z)=stored.sel1.pop(0)&amp;quot;)&lt;br /&gt;
	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.sel2.pop(0)&amp;quot;)&lt;br /&gt;
	&lt;br /&gt;
	print &amp;quot;RMSD=%f&amp;quot; % RMSD&lt;br /&gt;
	&lt;br /&gt;
	# make the alignment OBVIOUS&lt;br /&gt;
	cmd.hide('everything')&lt;br /&gt;
	cmd.show('ribbon', sel1 + ' or ' + sel2)&lt;br /&gt;
	cmd.color('gray70', mol1 )&lt;br /&gt;
	cmd.color('paleyellow', mol2 )&lt;br /&gt;
	cmd.color('red', 'visible')&lt;br /&gt;
	cmd.show('ribbon', 'not visible')&lt;br /&gt;
	cmd.center('visible')&lt;br /&gt;
	cmd.orient()&lt;br /&gt;
	cmd.zoom('visible')&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;optAlign&amp;quot;, optAlign)	&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== The Old Code ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!python&lt;br /&gt;
&lt;br /&gt;
##############################################################################&lt;br /&gt;
#&lt;br /&gt;
# @SUMMARY: -- Kabsch.py.  A python implementation of the optimal superposition&lt;br /&gt;
#     of two sets of vectors as proposed by Kabsch 1976 &amp;amp; 1978.&lt;br /&gt;
#&lt;br /&gt;
# @AUTHOR: Jason Vertrees&lt;br /&gt;
# @COPYRIGHT: Jason Vertrees (C), 2005-2007&lt;br /&gt;
# @LICENSE: Released under GPL:&lt;br /&gt;
# This program is free software; you can redistribute it and/or modify&lt;br /&gt;
#    it under the terms of the GNU General Public License as published by&lt;br /&gt;
#    the Free Software Foundation; either version 2 of the License, or&lt;br /&gt;
#    (at your option) any later version.&lt;br /&gt;
# This program is distributed in the hope that it will be useful, but WITHOUT&lt;br /&gt;
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS&lt;br /&gt;
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.&lt;br /&gt;
#&lt;br /&gt;
# You should have received a copy of the GNU General Public License along with&lt;br /&gt;
# this program; if not, write to the Free Software Foundation, Inc., 51 Franklin&lt;br /&gt;
# Street, Fifth Floor, Boston, MA 02110-1301, USA &lt;br /&gt;
#&lt;br /&gt;
# DATE  : 2005-04-07&lt;br /&gt;
# REV   : 2&lt;br /&gt;
# NOTES: Updated RMSD, notes, cleaned up the code a little.&lt;br /&gt;
#&lt;br /&gt;
#############################################################################&lt;br /&gt;
# math imports&lt;br /&gt;
import math&lt;br /&gt;
import Numeric&lt;br /&gt;
import LinearAlgebra&lt;br /&gt;
import Matrix&lt;br /&gt;
&lt;br /&gt;
from array import *&lt;br /&gt;
&lt;br /&gt;
# system stuff&lt;br /&gt;
import os&lt;br /&gt;
import copy&lt;br /&gt;
&lt;br /&gt;
# pretty printing&lt;br /&gt;
import pprint&lt;br /&gt;
import string&lt;br /&gt;
&lt;br /&gt;
# for importing as a plugin into PyMol&lt;br /&gt;
#import tkSimpleDialog&lt;br /&gt;
#import tkMessageBox&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
from pymol import stored&lt;br /&gt;
from pymol import selector&lt;br /&gt;
&lt;br /&gt;
class kabsch:&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	Kabsch alignment of two set of vectors to produce and optimal alignemnt.&lt;br /&gt;
&lt;br /&gt;
	Steps&lt;br /&gt;
	=====	&lt;br /&gt;
		1.  Calculate the center of mass for each protein.  Then, move the protein&lt;br /&gt;
		to its center of mass.  We choose as a convention, to use the origin as &lt;br /&gt;
		the center of mass of the first set of coordinates.  This will allow us to&lt;br /&gt;
		return one translation vector, instead of two.&lt;br /&gt;
		&lt;br /&gt;
		Update: Since any rotation around a point that's not the origin, is in fact&lt;br /&gt;
		an affine rotation.  So, to beat that, we translate both to the center.&lt;br /&gt;
		&lt;br /&gt;
		NAME: superpose(c1, c2)&lt;br /&gt;
		POST: T is now defined.&lt;br /&gt;
		&lt;br /&gt;
		2.  Calculate the matrix, R, by (eq7, 1976).  r_{i,j} = sum_n w_n * y_{ni} * x_{nj},&lt;br /&gt;
		where y_{ni} is the ith component of the vector y_n.&lt;br /&gt;
		NAME: calcR&lt;br /&gt;
		POST: R is now defined&lt;br /&gt;
		&lt;br /&gt;
		3.  Calculate RtR (R-transpose * R).&lt;br /&gt;
		NAME: calcRtR&lt;br /&gt;
		POST: RtR is now defined&lt;br /&gt;
		&lt;br /&gt;
		4.  Calculate the corresponding eigenpairs for RtR, and sort them accordingly:&lt;br /&gt;
		m1 &amp;gt;= m2 &amp;gt;= m3; set v3 = v1 x v2 to ensure a RHS&lt;br /&gt;
		NAME: calcEigenPairs&lt;br /&gt;
		POST: The eigen pairs are calculated, sorted such that m1 &amp;gt;= m2 &amp;gt;= m3 and&lt;br /&gt;
		v3 = v1 x v2.&lt;br /&gt;
		&lt;br /&gt;
		5.  Calculate R*v_k and normalize the first two vectors to obtain b_1, b_2 and set&lt;br /&gt;
		b_3 = b_1 x b_2.  This also takes care of m1 &amp;gt; m2 = 0. &lt;br /&gt;
		NAME: calcBVectors&lt;br /&gt;
		POST: b-Vectors are defined and returned&lt;br /&gt;
		&lt;br /&gt;
		6.  Calculate U=(u_{ij})=(sum n b_{ki} * a_{kj}) to obtain the best rotation.  Set&lt;br /&gt;
		sigma_3 = -1 if b3(Ra3) &amp;lt; 0 else sigma_3 = +1.&lt;br /&gt;
		NAME: calcU&lt;br /&gt;
		POST: U is defined&lt;br /&gt;
		&lt;br /&gt;
		7.  Calculate the RMSD.  The residual error is then&lt;br /&gt;
		The E = E0 - sqrt(m1) - sqrt(m2) - sigma_3(sqrt(m3)).&lt;br /&gt;
		NAME: calcRMSD&lt;br /&gt;
		POST: RMSD is computed.&lt;br /&gt;
	&lt;br /&gt;
	 @note: This should be a static method that takes three parameters&lt;br /&gt;
		&lt;br /&gt;
		1. The first protein's coordinates, f.  This program will &lt;br /&gt;
		accept coordinates in the form an array of 3D vectors/lists&lt;br /&gt;
		&lt;br /&gt;
		2. The second protein's coordinates, g.&lt;br /&gt;
		&lt;br /&gt;
		3. The array of integer pairs representing the pairs to align.&lt;br /&gt;
		Coordinates should be formatted as as array of 2D vectors/lists.&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
	def __init__(self):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Constructor.  @see kabsch.align.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
		#&lt;br /&gt;
		# Instance Variables:  All three of these will be updated&lt;br /&gt;
		# every time the user calls ~.align.  Just to warn ya'.&lt;br /&gt;
		#		&lt;br /&gt;
		# U, the rotation matrix&lt;br /&gt;
		self.U = []&lt;br /&gt;
		# T, the translation vector&lt;br /&gt;
		self.T = []&lt;br /&gt;
		# R, the RMSD&lt;br /&gt;
		self.R = -1.0&lt;br /&gt;
&lt;br /&gt;
		#self.menuBar.addmenuitem('Plugin', 'command', 'Kabsch Align', label = &amp;quot;Align Selections to Optial RMSD&amp;quot;, command = lamda s=self: fetchPDBDialog(s))&lt;br /&gt;
		&lt;br /&gt;
				&lt;br /&gt;
	def align(self, c1, c2, pairs):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Finds the best alignment of c1 and c2's pairs resulting in&lt;br /&gt;
		the smallest possible RMSD.&lt;br /&gt;
&lt;br /&gt;
				&lt;br /&gt;
		@note:&lt;br /&gt;
			- All weights in this first version are set to 1.  Kabsch allows,&lt;br /&gt;
			differential weighting.  In the future, I may extend to this option,&lt;br /&gt;
			and then pairs may become 3D (r1, r2, weight) or I may add another&lt;br /&gt;
			parameter.&lt;br /&gt;
		&lt;br /&gt;
			- Helper functions will soon be provided such that the user may&lt;br /&gt;
			just use this package alone to compute the rotation.&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param pairs: the list of pairs as an array of 2D pairs.&lt;br /&gt;
		@type  pairs: Python list of 2D lists.&lt;br /&gt;
		&lt;br /&gt;
		@return: U, the rotation matrix that gives the optimal rotation between the two proteins.&lt;br /&gt;
			&lt;br /&gt;
			T, the translation vector given to align the two objects centers of mass.&lt;br /&gt;
			&lt;br /&gt;
			R, the RMSD of the final rotation.&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		#&lt;br /&gt;
		# First we move the center of mass of one protein, to the&lt;br /&gt;
		# center of mass of the other.  This removes any translation&lt;br /&gt;
		# between the two.&lt;br /&gt;
		#&lt;br /&gt;
		T1, T2, c1, c2 = self.superpose(c1, c2)&lt;br /&gt;
		# Calculate the initial RMSD&lt;br /&gt;
		E0 = self.calcE0(c1, c2)&lt;br /&gt;
		# Calculate R via eq. 7.&lt;br /&gt;
		R = self.calcR(c1, c2)&lt;br /&gt;
		# Calculate R(transpose)*R&lt;br /&gt;
		RtR = self.calcRtR(R)&lt;br /&gt;
		# Determined the eigenpairs for the matrix RtR.&lt;br /&gt;
		eValues, eVectors = self.calcEigenPairs(RtR)&lt;br /&gt;
		# Determine the bVectors as required&lt;br /&gt;
		bVectors = self.calcBVectors(R, eVectors)&lt;br /&gt;
		# Calculate the roation matrix&lt;br /&gt;
		U = self.calcU(eVectors, bVectors)&lt;br /&gt;
		# Calculate the final RMSD using U.&lt;br /&gt;
		RMSD = self.calcRMSD(E0, eValues, eVectors, bVectors, R, len(c1))&lt;br /&gt;
		&lt;br /&gt;
		return U, T1, T2, RMSD, c1, c2&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	def superpose(self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the center of mass for each protein.  Then, move the protein&lt;br /&gt;
		to its center of mass.  We choose as a convention, to use the origin as &lt;br /&gt;
		the center of mass of the first set of coordinates.  This will allow us to&lt;br /&gt;
		return one translation vector, instead of two.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@precondition: c1 and c2 are well defined lists of N-dimensional points with length &amp;gt; 0.&lt;br /&gt;
		@postcondition: T is now defined.&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
		&lt;br /&gt;
		@return: T the translation vector.&lt;br /&gt;
		&lt;br /&gt;
			c2 one list of coordinates that of c2 translated to the COM of c1.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		# make sure we don't get bad data&lt;br /&gt;
		if (len(c1) != len(c2)):&lt;br /&gt;
			print &amp;quot;Two different length selections, with lengths, %d and %d.&amp;quot; % (len(c1), len(c2))&lt;br /&gt;
			print &amp;quot;This algorithm must be used with selections of the same length.&amp;quot;	&lt;br /&gt;
			print &amp;quot;In PyMol, type 'count_atoms sel1' where sel1 are your selections to find out their lengths.&amp;quot;&lt;br /&gt;
			print &amp;quot;Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&amp;quot;&lt;br /&gt;
        		print &amp;quot;Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&amp;quot;&lt;br /&gt;
&lt;br /&gt;
			&lt;br /&gt;
		assert(len(c1) == len(c2) != 0)&lt;br /&gt;
&lt;br /&gt;
		L = len(c1)&lt;br /&gt;
		&lt;br /&gt;
		#&lt;br /&gt;
		# Centers of Mass&lt;br /&gt;
		#&lt;br /&gt;
		c1COM = Numeric.zeros((3,1), Numeric.Float64)&lt;br /&gt;
		c2COM = Numeric.zeros((3,1), Numeric.Float64)&lt;br /&gt;
&lt;br /&gt;
		# calculate the CsOM		&lt;br /&gt;
		for i in range(0, L):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				c1COM[j] = c1COM[j] + c1[i][j]&lt;br /&gt;
				c2COM[j] = c2COM[j] + c2[i][j]&lt;br /&gt;
		&lt;br /&gt;
		T1 = - c1COM / L&lt;br /&gt;
		T2 = - c2COM / L&lt;br /&gt;
&lt;br /&gt;
		# move everything back to the origin.&lt;br /&gt;
		for i in range(0, L):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				c1[i][j] = c1[i][j] + T1[j]&lt;br /&gt;
				c2[i][j] = c2[i][j] + T2[j]&lt;br /&gt;
				&lt;br /&gt;
		return T1, T2, c1, c2&lt;br /&gt;
&lt;br /&gt;
					&lt;br /&gt;
	def calcR( self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the matrix, R, by (eq7, 1976).  M{r_{i,j} = sum_n w_n * y_{ni} * x_{nj}},&lt;br /&gt;
		where M{y_{ni}} is the ith component of the vector M{y_n}.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
&lt;br /&gt;
		@postcondition: R is now defined.&lt;br /&gt;
		&lt;br /&gt;
		@return: R&lt;br /&gt;
		@rtype : 3x3 matrix&lt;br /&gt;
				&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		# Create the 3x3 matrix&lt;br /&gt;
		R = Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
		L = len(c1)&lt;br /&gt;
		&lt;br /&gt;
		for k in range(0, L):&lt;br /&gt;
			for i in range(0, 3):&lt;br /&gt;
				for j in range(0, 3):&lt;br /&gt;
					R[i][j] = R[i][j] + (c2[k][i] * c1[k][j])&lt;br /&gt;
		&lt;br /&gt;
		# return R the 3x3 PSD Matrix.&lt;br /&gt;
		return R&lt;br /&gt;
		&lt;br /&gt;
	&lt;br /&gt;
	def calcRtR( self, R ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate RtR (R-transpose * R).&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@param R: Matrix&lt;br /&gt;
		@type  R: 3x3 Matrix&lt;br /&gt;
		&lt;br /&gt;
		@precondition: R is a the well formed matrix as per Kabsch.&lt;br /&gt;
		@postcondition: RtR is now defined&lt;br /&gt;
		&lt;br /&gt;
		@return: M{R^tR}&lt;br /&gt;
		@rtype : 3x3 matrix&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		RtR = Numeric.matrixmultiply(Numeric.transpose(R), R)&lt;br /&gt;
		&lt;br /&gt;
		return RtR&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	def calcEigenPairs( self, RtR ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the corresponding eigenpairs for RtR, and sort them accordingly:&lt;br /&gt;
		M{m1 &amp;gt;= m2 &amp;gt;= m3}; set M{v3 = v1 x v2} to ensure a RHS&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: The eigen pairs are calculated, sorted such that M{m1 &amp;gt;= m2 &amp;gt;= m3} and&lt;br /&gt;
		M{v3 = v1 x v2}.&lt;br /&gt;
		&lt;br /&gt;
		@param RtR: 3x3 Matrix of M{R^t * R}.&lt;br /&gt;
		@type  RtR: 3x3 Matrix&lt;br /&gt;
		@return : Eigenpairs for the RtR matrix.&lt;br /&gt;
		@rtype  : List of stuff&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		eVal, eVec = LinearAlgebra.eigenvectors(RtR)&lt;br /&gt;
&lt;br /&gt;
		# This is cool.  We sort it using Numeric.sort(eVal)&lt;br /&gt;
		# then we reverse it using nifty-crazy ass notation [::-1].&lt;br /&gt;
		eVal2 = Numeric.sort(eVal)[::-1]&lt;br /&gt;
		eVec2 = [[],[],[]] #Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
				&lt;br /&gt;
		# Map the vectors to their appropriate owners		&lt;br /&gt;
		if ( eVal2[0] == eVal[0]):&lt;br /&gt;
			eVec2[0] = eVec[0]&lt;br /&gt;
			if ( eVal2[1] == eVal[1] ):&lt;br /&gt;
				eVec2[1] = eVec[1]&lt;br /&gt;
				eVec2[2] = eVec[2]&lt;br /&gt;
			else:&lt;br /&gt;
				eVec2[1] = eVec[2]&lt;br /&gt;
				eVec2[2] = eVec[1]&lt;br /&gt;
		elif( eVal2[0] == eVal[1]):&lt;br /&gt;
			eVec2[0] = eVec[1]&lt;br /&gt;
			if ( eVal2[1] == eVal[0] ):&lt;br /&gt;
				eVec2[1] = eVec[0]&lt;br /&gt;
				eVec2[2] = eVec[2]&lt;br /&gt;
			else:&lt;br /&gt;
				eVec2[1] = eVec[2]&lt;br /&gt;
				eVec2[2] = eVec[0]&lt;br /&gt;
		elif( eVal2[0] == eVal[2]):&lt;br /&gt;
			eVec2[0] = eVec[2]&lt;br /&gt;
			if ( eVal2[1] == eVal[1] ):&lt;br /&gt;
				eVec2[1] = eVec[1]&lt;br /&gt;
				eVec2[2] = eVec[0]&lt;br /&gt;
			else:&lt;br /&gt;
				eVec2[1] = eVec[0]&lt;br /&gt;
				eVec2[2] = eVec[1]&lt;br /&gt;
&lt;br /&gt;
		eVec2[2][0] = eVec2[0][1]*eVec2[1][2] - eVec2[0][2]*eVec2[1][1]&lt;br /&gt;
		eVec2[2][1] = eVec2[0][2]*eVec2[1][0] - eVec2[0][0]*eVec2[1][2]&lt;br /&gt;
		eVec2[2][2] = eVec2[0][0]*eVec2[1][1] - eVec2[0][1]*eVec2[1][0]&lt;br /&gt;
		&lt;br /&gt;
		return [eVal2, eVec2]&lt;br /&gt;
		&lt;br /&gt;
	&lt;br /&gt;
	def calcBVectors( self, R, eVectors ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate M{R*a_k} and normalize the first two vectors to obtain M{b_1, b_2} and set&lt;br /&gt;
		M{b_3 = b_1 x b_2}.  This also takes care of {m2 &amp;gt; m3 = 0}. &lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: b-Vectors are defined and returned&lt;br /&gt;
		&lt;br /&gt;
		@return: The three B-vectors&lt;br /&gt;
		@rtype: List of 3D vectors (Python LOL).&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		bVectors = Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
&lt;br /&gt;
		for i in range(0,3):&lt;br /&gt;
			bVectors[i] = Numeric.matrixmultiply(R, eVectors[i])&lt;br /&gt;
&lt;br /&gt;
		bVectors[0] = bVectors[0] / Numeric.sqrt(Numeric.add.reduce(bVectors[0]**2))&lt;br /&gt;
		bVectors[1] = bVectors[1] / Numeric.sqrt(Numeric.add.reduce(bVectors[1]**2))&lt;br /&gt;
		bVectors[2] = bVectors[2] / Numeric.sqrt(Numeric.add.reduce(bVectors[2]**2))&lt;br /&gt;
		&lt;br /&gt;
		bVectors[2][0] = bVectors[0][1]*bVectors[1][2] - bVectors[0][2]*bVectors[1][1]&lt;br /&gt;
		bVectors[2][1] = bVectors[0][2]*bVectors[1][0] - bVectors[0][0]*bVectors[1][2]&lt;br /&gt;
		bVectors[2][2] = bVectors[0][0]*bVectors[1][1] - bVectors[0][1]*bVectors[1][0]&lt;br /&gt;
		&lt;br /&gt;
		return bVectors&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	def calcU( self, eVectors, bVectors ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate M{U=(u_{ij})=(sum n b_{ki} * a_{kj})} to obtain the best rotation.  Set&lt;br /&gt;
		M{sigma_3 = -1 if b3(Ra3) &amp;lt; 0 else sigma_3 = +1}.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: U is defined&lt;br /&gt;
		&lt;br /&gt;
		@param eVectors: Eigenvectors for the system.&lt;br /&gt;
		@type  eVectors: Eigenvectors&lt;br /&gt;
		&lt;br /&gt;
		@param bVectors: BVectors as described by Kabsch.&lt;br /&gt;
		@type  bVectors: BVectors&lt;br /&gt;
		&lt;br /&gt;
		@return: U the rotation matrix.&lt;br /&gt;
		@rtype  :3x3 matrix.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		U = Numeric.zeros((3,3), Numeric.Float64)&lt;br /&gt;
		&lt;br /&gt;
		for k in range(0,3):&lt;br /&gt;
			for i in range(0,3):&lt;br /&gt;
				for j in range(0,3):&lt;br /&gt;
					U[i][j] = U[i][j] + Numeric.matrixmultiply(bVectors[k][i], eVectors[k][j])&lt;br /&gt;
		&lt;br /&gt;
		return U&lt;br /&gt;
	&lt;br /&gt;
		&lt;br /&gt;
	def calcE0( self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculates the initial RMSD, which Kacbsch called E0.&lt;br /&gt;
		(CORRECT)&lt;br /&gt;
		&lt;br /&gt;
		@param c1: coordinats of the first vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c1: Python list&lt;br /&gt;
		   &lt;br /&gt;
		@param c2: coordinates of the second set of vectors, as an array of 3D vectors.&lt;br /&gt;
		@type  c2: Python list&lt;br /&gt;
		&lt;br /&gt;
		@return: E0 the initial RMSD.&lt;br /&gt;
		@rtype : float.&lt;br /&gt;
				&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		E0 = 0.0&lt;br /&gt;
		&lt;br /&gt;
		L = len(c1)&lt;br /&gt;
		for i in range( 0, L ):&lt;br /&gt;
			for j in range(0, 3):&lt;br /&gt;
				E0 = E0 + 0.5*( (c1[i][j]*c1[i][j])+(c2[i][j]*c2[i][j]))&lt;br /&gt;
		&lt;br /&gt;
		return E0&lt;br /&gt;
	&lt;br /&gt;
	def calcRMSD( self, E0, eValues, eVectors, bVectors, R, N):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculate the RMSD.  The residual error is then&lt;br /&gt;
		The M{E = E0 - sqrt(m1) - sqrt(m2) - sigma_3(sqrt(m3))}.&lt;br /&gt;
		&lt;br /&gt;
		@param E0: Initial RMSD as calculated in L{calcE0}.&lt;br /&gt;
		@type  E0: float.&lt;br /&gt;
		&lt;br /&gt;
		@param eVectors: Eigenvectors as calculated from L{calcEigenPairs}&lt;br /&gt;
		@type eVectors: vectors, dammit!&lt;br /&gt;
		&lt;br /&gt;
		@param bVectors: B-vectors as calc. from L{calcBVectors}&lt;br /&gt;
		@type  bVectors: More vectors.&lt;br /&gt;
		&lt;br /&gt;
		@param R: The matrix R, from L{calcR}.&lt;br /&gt;
		@type  R: 3x3 matrix.		&lt;br /&gt;
&lt;br /&gt;
		@param N: Number of equivalenced points&lt;br /&gt;
		@type  N: integer&lt;br /&gt;
		&lt;br /&gt;
		@postcondition: RMSD is computed.&lt;br /&gt;
		@return: The RMSD.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		sigma3 = 0&lt;br /&gt;
		if ( Numeric.matrixmultiply(bVectors[2], Numeric.matrixmultiply( R, eVectors[2])) &amp;lt; 0):&lt;br /&gt;
			sigma3 = -1&lt;br /&gt;
		else:&lt;br /&gt;
			sigma3 = 1&lt;br /&gt;
&lt;br /&gt;
		E = math.sqrt( 2*(E0 - math.sqrt(eValues[0]) - math.sqrt(eValues[1]) - sigma3*(math.sqrt(eValues[2]))) / N)&lt;br /&gt;
		&lt;br /&gt;
		return E&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	def calcSimpleRMSD( self, c1, c2 ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Calculates the usual concept of RMSD between two set of points.  The CalcRMSD above&lt;br /&gt;
		sticks to Kabsch's alignment method protocol and calculates something much different.&lt;br /&gt;
		@see kabsch.calcRMSD&lt;br /&gt;
		&lt;br /&gt;
		@param c1: List of points #1&lt;br /&gt;
		@type  c1: LOL&lt;br /&gt;
		&lt;br /&gt;
		@param c2: List of points #2&lt;br /&gt;
		@type  c2: LOL&lt;br /&gt;
		&lt;br /&gt;
		@return: RMSD between the two&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		RMSD = 0.0&lt;br /&gt;
		for i in range(0, len(c1)):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				RMSD = RMSD + (c2[i][j]-c1[i][j])**2&lt;br /&gt;
				&lt;br /&gt;
		RMSD = RMSD / len(c1)&lt;br /&gt;
		RMSD = Numeric.sqrt(RMSD)&lt;br /&gt;
		return RMSD&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	#####################################################################&lt;br /&gt;
	#&lt;br /&gt;
	# UTIL Functions&lt;br /&gt;
	def rotatePoints(self, U, c2):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Rotate all points in c2 based on the rotation matrix U.&lt;br /&gt;
		&lt;br /&gt;
		@param U: 3x3 Rotation matrix&lt;br /&gt;
		@type  U: 3x3 matrix&lt;br /&gt;
		&lt;br /&gt;
		@param c2: List of points to rotate&lt;br /&gt;
		@type  c2: List of 3D vectors&lt;br /&gt;
		&lt;br /&gt;
		@return: List of rotated points&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
		L = len(c2)&lt;br /&gt;
&lt;br /&gt;
		for n in range(0,L):&lt;br /&gt;
			c2[n][0] = c2[n][0] * U[0][0] + c2[n][1] * U[1][0] + c2[n][2] * U[2][0]&lt;br /&gt;
			c2[n][1] = c2[n][0] * U[0][1] + c2[n][1] * U[1][1] + c2[n][2] * U[2][1]&lt;br /&gt;
			c2[n][2] = c2[n][0] * U[0][2] + c2[n][1] * U[1][2] + c2[n][2] * U[2][2]&lt;br /&gt;
		&lt;br /&gt;
		return c2&lt;br /&gt;
	&lt;br /&gt;
	def writeU( self, U, fileName ):&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		Convenience function.  Writes U to disk.&lt;br /&gt;
		&lt;br /&gt;
		&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
		&lt;br /&gt;
		if ( len(fileName) == 0 ):&lt;br /&gt;
			fileName = &amp;quot;./U&amp;quot;&lt;br /&gt;
			&lt;br /&gt;
		outFile = open( fileName, &amp;quot;wb&amp;quot;)&lt;br /&gt;
		for i in range(0,3):&lt;br /&gt;
			for j in range(0,3):&lt;br /&gt;
				outFile.write( string.ljust(str(U[i][j]),20) )&lt;br /&gt;
			outFile.write(&amp;quot;\n&amp;quot;)&lt;br /&gt;
		outFile.close()		&lt;br /&gt;
&lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
def optAlign( sel1, sel2 ):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	optAlign performs the Kabsch alignment algorithm upon the alpha-carbons of two selections.&lt;br /&gt;
	Example:   optAlign MOL1 and i. 20-40, MOL2 and i. 102-122&lt;br /&gt;
	Example 2: optAlign 1GGZ and i. 4-146 and n. CA, 1CLL and i. 4-146 and n. CA&lt;br /&gt;
	&lt;br /&gt;
	Two RMSDs are returned.  One comes from the Kabsch algorithm and the other from&lt;br /&gt;
	PyMol based upon your selections.&lt;br /&gt;
&lt;br /&gt;
	By default, this program will optimally align the ALPHA CARBONS of the selections provided.&lt;br /&gt;
	To turn off this feature remove the lines between the commented &amp;quot;REMOVE ALPHA CARBONS&amp;quot; below.&lt;br /&gt;
	&lt;br /&gt;
	@param sel1: First PyMol selection with N-atoms&lt;br /&gt;
	@param sel2: Second PyMol selection with N-atoms&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	cmd.reset()&lt;br /&gt;
&lt;br /&gt;
	# make the lists for holding coordinates&lt;br /&gt;
	# partial lists&lt;br /&gt;
	stored.sel1 = []&lt;br /&gt;
	stored.sel2 = []&lt;br /&gt;
	# full lists&lt;br /&gt;
	stored.mol1 = []&lt;br /&gt;
	stored.mol2 = []&lt;br /&gt;
&lt;br /&gt;
	# now put the coordinates into a list&lt;br /&gt;
	# partials&lt;br /&gt;
&lt;br /&gt;
	# -- REMOVE ALPHA CARBONS&lt;br /&gt;
	sel1 = sel1 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	sel2 = sel2 + &amp;quot; and N. CA&amp;quot;&lt;br /&gt;
	# -- REMOVE ALPHA CARBONS&lt;br /&gt;
&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel1), &amp;quot;stored.sel1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, selector.process(sel2), &amp;quot;stored.sel2.append([x,y,z])&amp;quot;)&lt;br /&gt;
	# full molecule&lt;br /&gt;
	mol1 = cmd.identify(sel1,1)[0][0]&lt;br /&gt;
	mol2 = cmd.identify(sel2,1)[0][0]&lt;br /&gt;
	cmd.iterate_state(1, mol1, &amp;quot;stored.mol1.append([x,y,z])&amp;quot;)&lt;br /&gt;
	cmd.iterate_state(1, mol2, &amp;quot;stored.mol2.append([x,y,z])&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
	K = kabsch()&lt;br /&gt;
	U, T1, T2, RMSD, c1, c2 = K.align(stored.sel1, stored.sel2, [])&lt;br /&gt;
&lt;br /&gt;
	stored.mol2 = map(lambda v:[T2[0]+((v[0]*U[0][0])+(v[1]*U[1][0])+(v[2]*U[2][0])),T2[1]+((v[0]*U[0][1])+(v[1]*U[1][1])+(v[2]*U[2][1])),T2[2]+((v[0]*U[0][2])+(v[1]*U[1][2])+(v[2]*U[2][2]))],stored.mol2)&lt;br /&gt;
	#stored.mol1 = map(lambda v:[ v[0]+T1[0], v[1]+T1[1], v[2]+T1[2] ], stored.mol1)&lt;br /&gt;
	stored.mol1 = map(lambda v:[ v[0]+T1[0], v[1]+T1[1], v[2]+T1[2] ], stored.mol1)&lt;br /&gt;
&lt;br /&gt;
	cmd.alter_state(1,mol1,&amp;quot;(x,y,z)=stored.mol1.pop(0)&amp;quot;)&lt;br /&gt;
	cmd.alter_state(1,mol2,&amp;quot;(x,y,z)=stored.mol2.pop(0)&amp;quot;)&lt;br /&gt;
	cmd.alter( 'all',&amp;quot;segi=''&amp;quot;)&lt;br /&gt;
	cmd.alter('all', &amp;quot;chain=''&amp;quot;)&lt;br /&gt;
	print &amp;quot;RMSD=%f&amp;quot; % cmd.rms_cur(sel1, sel2)&lt;br /&gt;
	print &amp;quot;MY RMSD=%f&amp;quot; % RMSD&lt;br /&gt;
	cmd.hide('everything')&lt;br /&gt;
	cmd.show('ribbon', sel1 + ' or ' + sel2)&lt;br /&gt;
	cmd.color('gray70', mol1 )&lt;br /&gt;
	cmd.color('paleyellow', mol2 )&lt;br /&gt;
	cmd.color('red', 'visible')&lt;br /&gt;
	cmd.show('ribbon', 'not visible')&lt;br /&gt;
	cmd.center('visible')&lt;br /&gt;
	cmd.orient()&lt;br /&gt;
	cmd.zoom('visible')&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;optAlign&amp;quot;, optAlign)	&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
'''[Kabsch, 1976]''' Kabsch, W. (1976).&lt;br /&gt;
A solution for the best rotation to relate two sets of vectors.&lt;br /&gt;
''Acta. Crystal'', 32A:922-923.&lt;br /&gt;
&lt;br /&gt;
'''[Kabsch, 1978]''' Kabsch, W. (1978).&lt;br /&gt;
A discussion of the solution for the best rotation to related two sets of vectors.&lt;br /&gt;
''Acta. Crystal'', 34A:827-828.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|Kabsch Alignment]]&lt;/div&gt;</summary>
		<author><name>72.181.94.94</name></author>
	</entry>
</feed>