<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MartinChristen</id>
	<title>PyMOL Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MartinChristen"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php/Special:Contributions/MartinChristen"/>
	<updated>2026-05-06T16:47:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5229</id>
		<title>Contact Surface</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5229"/>
		<updated>2013-02-15T15:11:59Z</updated>

		<summary type="html">&lt;p&gt;MartinChristen: /* The Code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This script calculates individual or global contact areas between a receptor molecule and a (multimodel) bundle of docked ligand structures.&lt;br /&gt;
The exact contact surface area values (in Angstrom^2) are printed to the screen and also appended to a file called contactareas.txt.&lt;br /&gt;
If only a single global contact surface is calculated, a selection named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within 3.9A of any ligand atom to illustrate the ''approximate'' contact surface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The parameters are:&lt;br /&gt;
&lt;br /&gt;
'''receptor''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the receptor protein&lt;br /&gt;
&lt;br /&gt;
'''ligand''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the ligand&lt;br /&gt;
:: Note that this may be another protein!&lt;br /&gt;
&lt;br /&gt;
'''states''' ''(integer)'', default:0&lt;br /&gt;
:: Calculate contact surface between the receptor and the first n states of the ligand.&lt;br /&gt;
:: If states = 0, the script calculates a global contact surface which takes  all possible ligand states into account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
contact_surface receptor, ligand, [states=0]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#contact_surface v.3.0&lt;br /&gt;
#Copyleft Martin Christen, 2013&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd,stored&lt;br /&gt;
def contact_surface(receptor,ligand,states=0):&lt;br /&gt;
&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	AUTHOR&lt;br /&gt;
	Martin Christen&lt;br /&gt;
	&lt;br /&gt;
	DESCRIPTION&lt;br /&gt;
	This script calculates individual or global contact surfaces between a&lt;br /&gt;
	receptor molecule and a bundle of docked ligand structures (which have&lt;br /&gt;
	to be loaded into PyMOL as a multimodel object).&lt;br /&gt;
	&lt;br /&gt;
	The exact contact surface area values (in Angstrom^2) are printed to&lt;br /&gt;
	the screen and also appended to a file called contactareas.txt&lt;br /&gt;
	&lt;br /&gt;
	If only a single global contact surface is calculated, a selection&lt;br /&gt;
	named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within&lt;br /&gt;
	3.9A of any ligand atom.&lt;br /&gt;
	&lt;br /&gt;
	USAGE&lt;br /&gt;
	contact_surface receptor, ligand, [states=0]&lt;br /&gt;
	&lt;br /&gt;
	PARAMETERS&lt;br /&gt;
	&lt;br /&gt;
	receptor (string)&lt;br /&gt;
	The name of the selection/object representing the receptor protein&lt;br /&gt;
	&lt;br /&gt;
	ligand (string)&lt;br /&gt;
	The name of the selection/object representing the ligand.&lt;br /&gt;
	Note that this may be another protein!&lt;br /&gt;
	&lt;br /&gt;
	states (integer)&lt;br /&gt;
	Calculate contact surface between the receptor and the first n states&lt;br /&gt;
	of the ligand. If states = 0 (default), the script calculates a global&lt;br /&gt;
	contact surface which takes  all possible ligand states into account.&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	# sanity check the number of states&lt;br /&gt;
	states = abs(int(states))&lt;br /&gt;
	&lt;br /&gt;
	# make sure all atoms within an object occlude one another&lt;br /&gt;
	cmd.flag('ignore','none')&lt;br /&gt;
	&lt;br /&gt;
	# use solvent-accessible surface with high sampling density&lt;br /&gt;
	cmd.set('dot_solvent','1')&lt;br /&gt;
	cmd.set('dot_density','3')&lt;br /&gt;
	&lt;br /&gt;
	#if the 'states' parameter = 0 create a superposition of all ligand states&lt;br /&gt;
	if states == 0:&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		cmd.group('ligandtemp',ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
		cmd.create(ligand+&amp;quot;_all&amp;quot;,'ligandtemp')&lt;br /&gt;
		cmd.delete('ligandtemp')&lt;br /&gt;
		&lt;br /&gt;
		#create complex&lt;br /&gt;
		cmd.create('complextemp',ligand+&amp;quot;_all &amp;quot;+receptor)&lt;br /&gt;
	&lt;br /&gt;
		#measure area&lt;br /&gt;
		ligand_area=cmd.get_area(ligand+&amp;quot;_all&amp;quot;)&lt;br /&gt;
		receptor_area=cmd.get_area(receptor)&lt;br /&gt;
		complex_area=cmd.get_area('complextemp')&lt;br /&gt;
		#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
		contact_area=((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
		#delete complex&lt;br /&gt;
		cmd.delete('complextemp')&lt;br /&gt;
		&lt;br /&gt;
		#create the contact surface&lt;br /&gt;
		cmd.select('contact',&amp;quot;(&amp;quot;+receptor+&amp;quot; and (&amp;quot;+ligand+&amp;quot;_all around 3.9))&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		#print contact surface area&lt;br /&gt;
		f=open('contactareas.txt','a')&lt;br /&gt;
		print &amp;quot;%s - %s : &amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s\t&amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
		print contact_area&lt;br /&gt;
		f.close()&lt;br /&gt;
		print &amp;quot;The GLOBAL contact area between &amp;quot;+receptor+ &amp;quot; and &amp;quot;+ligand+&amp;quot; is (A^2):&amp;quot;&lt;br /&gt;
		print ((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
	&lt;br /&gt;
	#If 'states' &amp;lt;&amp;gt; 0 calculate the contact areas to the first 'states' ligand states.&lt;br /&gt;
	#No individual contact surface objects are created to avoid overloading PyMOL.&lt;br /&gt;
	else:&lt;br /&gt;
		#create an object for each ligand state&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#sanity check: do not exceed that maximum number of states&lt;br /&gt;
		if states &amp;gt; cmd.count_states(ligand):&lt;br /&gt;
			states = cmd.count_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#calculate contact surface area&lt;br /&gt;
		print &amp;quot;The contact areas between &amp;quot;+receptor+&amp;quot; and &amp;quot;+ligand+&amp;quot; [states 1 - &amp;quot;+str(states)+&amp;quot;] are (A^2):&amp;quot;&lt;br /&gt;
		#start looping&lt;br /&gt;
		for s in range(1,states+1):&lt;br /&gt;
			#create complex&lt;br /&gt;
			cmd.create(&amp;quot;tmp&amp;quot;,ligand,s,1)&lt;br /&gt;
			cmd.create('complextemp',&amp;quot;tmp &amp;quot;+receptor)&lt;br /&gt;
			#measure areas&lt;br /&gt;
			ligand_area=cmd.get_area('tmp')&lt;br /&gt;
			receptor_area=cmd.get_area(receptor)&lt;br /&gt;
			complex_area=cmd.get_area('complextemp')&lt;br /&gt;
			#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
			contact_area=((ligand_area + receptor_area) - complex_area)/2&lt;br /&gt;
			#delete temporary files&lt;br /&gt;
			cmd.delete('tmp')&lt;br /&gt;
			cmd.delete(ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
			cmd.delete('complextemp')&lt;br /&gt;
			#print contact surface area&lt;br /&gt;
			f=open('contactareas.txt','a')&lt;br /&gt;
			print &amp;quot;%s - %s_%-5s: &amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s_%-5s\t&amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
			print contact_area&lt;br /&gt;
			f.close()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;contact_surface&amp;quot;,contact_surface)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>MartinChristen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5228</id>
		<title>Contact Surface</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5228"/>
		<updated>2013-02-15T15:11:12Z</updated>

		<summary type="html">&lt;p&gt;MartinChristen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This script calculates individual or global contact areas between a receptor molecule and a (multimodel) bundle of docked ligand structures.&lt;br /&gt;
The exact contact surface area values (in Angstrom^2) are printed to the screen and also appended to a file called contactareas.txt.&lt;br /&gt;
If only a single global contact surface is calculated, a selection named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within 3.9A of any ligand atom to illustrate the ''approximate'' contact surface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The parameters are:&lt;br /&gt;
&lt;br /&gt;
'''receptor''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the receptor protein&lt;br /&gt;
&lt;br /&gt;
'''ligand''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the ligand&lt;br /&gt;
:: Note that this may be another protein!&lt;br /&gt;
&lt;br /&gt;
'''states''' ''(integer)'', default:0&lt;br /&gt;
:: Calculate contact surface between the receptor and the first n states of the ligand.&lt;br /&gt;
:: If states = 0, the script calculates a global contact surface which takes  all possible ligand states into account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
contact_surface receptor, ligand, [states=0]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#contact_surface v.3.0&lt;br /&gt;
#Copyleft Martin Christen, 2013&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd,stored&lt;br /&gt;
def contact_surface(receptor,ligand,states=0):&lt;br /&gt;
&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	AUTHOR&lt;br /&gt;
	Martin Christen&lt;br /&gt;
	&lt;br /&gt;
	DESCRIPTION&lt;br /&gt;
	This script calculates individual or global contact surfaces between a&lt;br /&gt;
	receptor molecule and a bundle of docked ligand structures (which have&lt;br /&gt;
	to be loaded into PyMOL as a multimodel object).&lt;br /&gt;
	&lt;br /&gt;
	The exact contact surface area values (in Angstrom^2) are printed to&lt;br /&gt;
	the screen and also appended to a file called contactareas.txt&lt;br /&gt;
	&lt;br /&gt;
	If only a single global contact surface is calculated, a selection&lt;br /&gt;
	named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within&lt;br /&gt;
	3.9A of any ligand atom.&lt;br /&gt;
	&lt;br /&gt;
	USAGE&lt;br /&gt;
	contact_surface receptor, ligand, [states=0]&lt;br /&gt;
	&lt;br /&gt;
	PARAMETERS&lt;br /&gt;
	&lt;br /&gt;
	receptor (string)&lt;br /&gt;
	The name of the selection/object representing the receptor protein&lt;br /&gt;
	&lt;br /&gt;
	ligand (string)&lt;br /&gt;
	The name of the selection/object representing the ligand.&lt;br /&gt;
	Note that this may be another protein!&lt;br /&gt;
	&lt;br /&gt;
	states (integer)&lt;br /&gt;
	Calculate contact surface between the receptor and the first n states&lt;br /&gt;
	of the ligand. If states = 0 (default), the script calculates a global&lt;br /&gt;
	contact surface which takes  all possible ligand states into account.&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	# sanity check the number of states&lt;br /&gt;
	states = abs(int(states))&lt;br /&gt;
	&lt;br /&gt;
	# make sure all atoms within an object occlude one another&lt;br /&gt;
	cmd.flag('ignore','none')&lt;br /&gt;
	&lt;br /&gt;
	# use solvent-accessible surface with high sampling density&lt;br /&gt;
	cmd.set('dot_solvent','1')&lt;br /&gt;
	cmd.set('dot_density','3')&lt;br /&gt;
	&lt;br /&gt;
	#if the 'states' parameter = 0 create a superposition of all ligand states&lt;br /&gt;
	if states == 0:&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		cmd.group('ligandtemp',ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
		cmd.create(ligand+&amp;quot;_all&amp;quot;,'ligandtemp')&lt;br /&gt;
		cmd.delete('ligandtemp')&lt;br /&gt;
		&lt;br /&gt;
		#create complex&lt;br /&gt;
		cmd.create('complextemp',ligand+&amp;quot;_all &amp;quot;+receptor)&lt;br /&gt;
	&lt;br /&gt;
		#measure area&lt;br /&gt;
		ligand_area=cmd.get_area(ligand+&amp;quot;_all&amp;quot;)&lt;br /&gt;
		receptor_area=cmd.get_area(receptor)&lt;br /&gt;
		complex_area=cmd.get_area('complextemp')&lt;br /&gt;
		#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
		contact_area=((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
		#delete complex&lt;br /&gt;
		cmd.delete('complextemp')&lt;br /&gt;
		&lt;br /&gt;
		#create the contact surface&lt;br /&gt;
		cmd.select('contact',&amp;quot;(&amp;quot;+receptor+&amp;quot; and (&amp;quot;+ligand+&amp;quot;_all around 3.9))&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		#print contact surface area&lt;br /&gt;
		f=open('contactareas.txt','a')&lt;br /&gt;
		print &amp;quot;%s - %s : &amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s\t&amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
		print contact_area&lt;br /&gt;
		f.close()&lt;br /&gt;
		print &amp;quot;The GLOBAL contact area between &amp;quot;+receptor+ &amp;quot; and &amp;quot;+ligand+&amp;quot; is (A^2):&amp;quot;&lt;br /&gt;
		print ((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
	&lt;br /&gt;
	#If 'states' &amp;lt;&amp;gt; 0 calculate the contact areas to the first 'states' ligand states.&lt;br /&gt;
	#No individual contact surface objects are created to avoid overloading PyMOL.&lt;br /&gt;
	else:&lt;br /&gt;
		#create an object for each ligand state&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#sanity check: do not exceed that maximum number of states&lt;br /&gt;
		if states &amp;gt; cmd.count_states(ligand):&lt;br /&gt;
			states = cmd.count_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#calculate contact surface area&lt;br /&gt;
		print &amp;quot;The contact areas between &amp;quot;+receptor+&amp;quot; and &amp;quot;+ligand+&amp;quot; [states 1 - &amp;quot;+str(states)+&amp;quot;] are (A^2):&amp;quot;&lt;br /&gt;
		#start looping&lt;br /&gt;
		#for s in range(1,cmd.count_states(ligand)+1):&lt;br /&gt;
		for s in range(1,states+1):&lt;br /&gt;
			#create complex&lt;br /&gt;
			cmd.create(&amp;quot;tmp&amp;quot;,ligand,s,1)&lt;br /&gt;
			cmd.create('complextemp',&amp;quot;tmp &amp;quot;+receptor)&lt;br /&gt;
			#measure areas&lt;br /&gt;
			ligand_area=cmd.get_area('tmp')&lt;br /&gt;
			receptor_area=cmd.get_area(receptor)&lt;br /&gt;
			complex_area=cmd.get_area('complextemp')&lt;br /&gt;
			#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
			contact_area=((ligand_area + receptor_area) - complex_area)/2&lt;br /&gt;
			#delete temporary files&lt;br /&gt;
			cmd.delete('tmp')&lt;br /&gt;
			cmd.delete(ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
			cmd.delete('complextemp')&lt;br /&gt;
			#print contact surface area&lt;br /&gt;
			f=open('contactareas.txt','a')&lt;br /&gt;
			print &amp;quot;%s - %s_%-5s: &amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s_%-5s\t&amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
			print contact_area&lt;br /&gt;
			f.close()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;contact_surface&amp;quot;,contact_surface)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>MartinChristen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5227</id>
		<title>Contact Surface</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5227"/>
		<updated>2013-02-15T15:10:45Z</updated>

		<summary type="html">&lt;p&gt;MartinChristen: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This script calculates individual or global contact areas between a receptor molecule and a (multimodel) bundle of docked ligand structures.&lt;br /&gt;
The exact contact surface area values (in Angstrom^2) are printed to the screen and also appended to a file called contactareas.txt.&lt;br /&gt;
If only a single global contact surface is calculated, a selection named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within 3.9A of any ligand atom to illustrate the ''approximate'' contact surface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The parameters are:&lt;br /&gt;
&lt;br /&gt;
'''receptor''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the receptor protein&lt;br /&gt;
&lt;br /&gt;
'''ligand''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the ligand&lt;br /&gt;
:: Note that this may be another protein!&lt;br /&gt;
&lt;br /&gt;
'''receptor''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the receptor protein&lt;br /&gt;
	&lt;br /&gt;
'''states''' ''(integer)'', default:0&lt;br /&gt;
:: Calculate contact surface between the receptor and the first n states of the ligand.&lt;br /&gt;
:: If states = 0, the script calculates a global contact surface which takes  all possible ligand states into account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
contact_surface receptor, ligand, [states=0]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#contact_surface v.3.0&lt;br /&gt;
#Copyleft Martin Christen, 2013&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd,stored&lt;br /&gt;
def contact_surface(receptor,ligand,states=0):&lt;br /&gt;
&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	AUTHOR&lt;br /&gt;
	Martin Christen&lt;br /&gt;
	&lt;br /&gt;
	DESCRIPTION&lt;br /&gt;
	This script calculates individual or global contact surfaces between a&lt;br /&gt;
	receptor molecule and a bundle of docked ligand structures (which have&lt;br /&gt;
	to be loaded into PyMOL as a multimodel object).&lt;br /&gt;
	&lt;br /&gt;
	The exact contact surface area values (in Angstrom^2) are printed to&lt;br /&gt;
	the screen and also appended to a file called contactareas.txt&lt;br /&gt;
	&lt;br /&gt;
	If only a single global contact surface is calculated, a selection&lt;br /&gt;
	named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within&lt;br /&gt;
	3.9A of any ligand atom.&lt;br /&gt;
	&lt;br /&gt;
	USAGE&lt;br /&gt;
	contact_surface receptor, ligand, [states=0]&lt;br /&gt;
	&lt;br /&gt;
	PARAMETERS&lt;br /&gt;
	&lt;br /&gt;
	receptor (string)&lt;br /&gt;
	The name of the selection/object representing the receptor protein&lt;br /&gt;
	&lt;br /&gt;
	ligand (string)&lt;br /&gt;
	The name of the selection/object representing the ligand.&lt;br /&gt;
	Note that this may be another protein!&lt;br /&gt;
	&lt;br /&gt;
	states (integer)&lt;br /&gt;
	Calculate contact surface between the receptor and the first n states&lt;br /&gt;
	of the ligand. If states = 0 (default), the script calculates a global&lt;br /&gt;
	contact surface which takes  all possible ligand states into account.&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	# sanity check the number of states&lt;br /&gt;
	states = abs(int(states))&lt;br /&gt;
	&lt;br /&gt;
	# make sure all atoms within an object occlude one another&lt;br /&gt;
	cmd.flag('ignore','none')&lt;br /&gt;
	&lt;br /&gt;
	# use solvent-accessible surface with high sampling density&lt;br /&gt;
	cmd.set('dot_solvent','1')&lt;br /&gt;
	cmd.set('dot_density','3')&lt;br /&gt;
	&lt;br /&gt;
	#if the 'states' parameter = 0 create a superposition of all ligand states&lt;br /&gt;
	if states == 0:&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		cmd.group('ligandtemp',ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
		cmd.create(ligand+&amp;quot;_all&amp;quot;,'ligandtemp')&lt;br /&gt;
		cmd.delete('ligandtemp')&lt;br /&gt;
		&lt;br /&gt;
		#create complex&lt;br /&gt;
		cmd.create('complextemp',ligand+&amp;quot;_all &amp;quot;+receptor)&lt;br /&gt;
	&lt;br /&gt;
		#measure area&lt;br /&gt;
		ligand_area=cmd.get_area(ligand+&amp;quot;_all&amp;quot;)&lt;br /&gt;
		receptor_area=cmd.get_area(receptor)&lt;br /&gt;
		complex_area=cmd.get_area('complextemp')&lt;br /&gt;
		#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
		contact_area=((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
		#delete complex&lt;br /&gt;
		cmd.delete('complextemp')&lt;br /&gt;
		&lt;br /&gt;
		#create the contact surface&lt;br /&gt;
		cmd.select('contact',&amp;quot;(&amp;quot;+receptor+&amp;quot; and (&amp;quot;+ligand+&amp;quot;_all around 3.9))&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		#print contact surface area&lt;br /&gt;
		f=open('contactareas.txt','a')&lt;br /&gt;
		print &amp;quot;%s - %s : &amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s\t&amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
		print contact_area&lt;br /&gt;
		f.close()&lt;br /&gt;
		print &amp;quot;The GLOBAL contact area between &amp;quot;+receptor+ &amp;quot; and &amp;quot;+ligand+&amp;quot; is (A^2):&amp;quot;&lt;br /&gt;
		print ((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
	&lt;br /&gt;
	#If 'states' &amp;lt;&amp;gt; 0 calculate the contact areas to the first 'states' ligand states.&lt;br /&gt;
	#No individual contact surface objects are created to avoid overloading PyMOL.&lt;br /&gt;
	else:&lt;br /&gt;
		#create an object for each ligand state&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#sanity check: do not exceed that maximum number of states&lt;br /&gt;
		if states &amp;gt; cmd.count_states(ligand):&lt;br /&gt;
			states = cmd.count_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#calculate contact surface area&lt;br /&gt;
		print &amp;quot;The contact areas between &amp;quot;+receptor+&amp;quot; and &amp;quot;+ligand+&amp;quot; [states 1 - &amp;quot;+str(states)+&amp;quot;] are (A^2):&amp;quot;&lt;br /&gt;
		#start looping&lt;br /&gt;
		#for s in range(1,cmd.count_states(ligand)+1):&lt;br /&gt;
		for s in range(1,states+1):&lt;br /&gt;
			#create complex&lt;br /&gt;
			cmd.create(&amp;quot;tmp&amp;quot;,ligand,s,1)&lt;br /&gt;
			cmd.create('complextemp',&amp;quot;tmp &amp;quot;+receptor)&lt;br /&gt;
			#measure areas&lt;br /&gt;
			ligand_area=cmd.get_area('tmp')&lt;br /&gt;
			receptor_area=cmd.get_area(receptor)&lt;br /&gt;
			complex_area=cmd.get_area('complextemp')&lt;br /&gt;
			#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
			contact_area=((ligand_area + receptor_area) - complex_area)/2&lt;br /&gt;
			#delete temporary files&lt;br /&gt;
			cmd.delete('tmp')&lt;br /&gt;
			cmd.delete(ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
			cmd.delete('complextemp')&lt;br /&gt;
			#print contact surface area&lt;br /&gt;
			f=open('contactareas.txt','a')&lt;br /&gt;
			print &amp;quot;%s - %s_%-5s: &amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s_%-5s\t&amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
			print contact_area&lt;br /&gt;
			f.close()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;contact_surface&amp;quot;,contact_surface)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>MartinChristen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5226</id>
		<title>Contact Surface</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Contact_Surface&amp;diff=5226"/>
		<updated>2013-02-15T15:10:05Z</updated>

		<summary type="html">&lt;p&gt;MartinChristen: Script to calculate and display the contact surface area between a receptor and one or more ligand molecules. ~~~~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This script calculates individual or global contact areas between a receptor molecule and a (multimodel) bundle of docked ligand structures.&lt;br /&gt;
The exact contact surface area values (in Angstrom^2) are printed to the screen and also appended to a file called contactareas.txt&lt;br /&gt;
If only a single global contact surface is calculated, a selection named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within 3.9A of any ligand atom to illustrate the ''approximate'' contact surface.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The parameters are:&lt;br /&gt;
&lt;br /&gt;
'''receptor''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the receptor protein&lt;br /&gt;
&lt;br /&gt;
'''ligand''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the ligand&lt;br /&gt;
:: Note that this may be another protein!&lt;br /&gt;
&lt;br /&gt;
'''receptor''' ''(string)''&lt;br /&gt;
:: The name of the selection/object representing the receptor protein&lt;br /&gt;
	&lt;br /&gt;
'''states''' ''(integer)'', default:0&lt;br /&gt;
:: Calculate contact surface between the receptor and the first n states of the ligand.&lt;br /&gt;
:: If states = 0, the script calculates a global contact surface which takes  all possible ligand states into account.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
contact_surface receptor, ligand, [states=0]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#contact_surface v.3.0&lt;br /&gt;
#Copyleft Martin Christen, 2013&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd,stored&lt;br /&gt;
def contact_surface(receptor,ligand,states=0):&lt;br /&gt;
&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	AUTHOR&lt;br /&gt;
	Martin Christen&lt;br /&gt;
	&lt;br /&gt;
	DESCRIPTION&lt;br /&gt;
	This script calculates individual or global contact surfaces between a&lt;br /&gt;
	receptor molecule and a bundle of docked ligand structures (which have&lt;br /&gt;
	to be loaded into PyMOL as a multimodel object).&lt;br /&gt;
	&lt;br /&gt;
	The exact contact surface area values (in Angstrom^2) are printed to&lt;br /&gt;
	the screen and also appended to a file called contactareas.txt&lt;br /&gt;
	&lt;br /&gt;
	If only a single global contact surface is calculated, a selection&lt;br /&gt;
	named &amp;quot;contact&amp;quot; is created that includes all receptor atoms within&lt;br /&gt;
	3.9A of any ligand atom.&lt;br /&gt;
	&lt;br /&gt;
	USAGE&lt;br /&gt;
	contact_surface receptor, ligand, [states=0]&lt;br /&gt;
	&lt;br /&gt;
	PARAMETERS&lt;br /&gt;
	&lt;br /&gt;
	receptor (string)&lt;br /&gt;
	The name of the selection/object representing the receptor protein&lt;br /&gt;
	&lt;br /&gt;
	ligand (string)&lt;br /&gt;
	The name of the selection/object representing the ligand.&lt;br /&gt;
	Note that this may be another protein!&lt;br /&gt;
	&lt;br /&gt;
	states (integer)&lt;br /&gt;
	Calculate contact surface between the receptor and the first n states&lt;br /&gt;
	of the ligand. If states = 0 (default), the script calculates a global&lt;br /&gt;
	contact surface which takes  all possible ligand states into account.&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	# sanity check the number of states&lt;br /&gt;
	states = abs(int(states))&lt;br /&gt;
	&lt;br /&gt;
	# make sure all atoms within an object occlude one another&lt;br /&gt;
	cmd.flag('ignore','none')&lt;br /&gt;
	&lt;br /&gt;
	# use solvent-accessible surface with high sampling density&lt;br /&gt;
	cmd.set('dot_solvent','1')&lt;br /&gt;
	cmd.set('dot_density','3')&lt;br /&gt;
	&lt;br /&gt;
	#if the 'states' parameter = 0 create a superposition of all ligand states&lt;br /&gt;
	if states == 0:&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		cmd.group('ligandtemp',ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
		cmd.create(ligand+&amp;quot;_all&amp;quot;,'ligandtemp')&lt;br /&gt;
		cmd.delete('ligandtemp')&lt;br /&gt;
		&lt;br /&gt;
		#create complex&lt;br /&gt;
		cmd.create('complextemp',ligand+&amp;quot;_all &amp;quot;+receptor)&lt;br /&gt;
	&lt;br /&gt;
		#measure area&lt;br /&gt;
		ligand_area=cmd.get_area(ligand+&amp;quot;_all&amp;quot;)&lt;br /&gt;
		receptor_area=cmd.get_area(receptor)&lt;br /&gt;
		complex_area=cmd.get_area('complextemp')&lt;br /&gt;
		#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
		contact_area=((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
		#delete complex&lt;br /&gt;
		cmd.delete('complextemp')&lt;br /&gt;
		&lt;br /&gt;
		#create the contact surface&lt;br /&gt;
		cmd.select('contact',&amp;quot;(&amp;quot;+receptor+&amp;quot; and (&amp;quot;+ligand+&amp;quot;_all around 3.9))&amp;quot;)&lt;br /&gt;
		&lt;br /&gt;
		#print contact surface area&lt;br /&gt;
		f=open('contactareas.txt','a')&lt;br /&gt;
		print &amp;quot;%s - %s : &amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s\t&amp;quot; % (receptor,ligand),&lt;br /&gt;
		print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
		print contact_area&lt;br /&gt;
		f.close()&lt;br /&gt;
		print &amp;quot;The GLOBAL contact area between &amp;quot;+receptor+ &amp;quot; and &amp;quot;+ligand+&amp;quot; is (A^2):&amp;quot;&lt;br /&gt;
		print ((ligand_area + receptor_area) - complex_area) / 2&lt;br /&gt;
	&lt;br /&gt;
	#If 'states' &amp;lt;&amp;gt; 0 calculate the contact areas to the first 'states' ligand states.&lt;br /&gt;
	#No individual contact surface objects are created to avoid overloading PyMOL.&lt;br /&gt;
	else:&lt;br /&gt;
		#create an object for each ligand state&lt;br /&gt;
		cmd.split_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#sanity check: do not exceed that maximum number of states&lt;br /&gt;
		if states &amp;gt; cmd.count_states(ligand):&lt;br /&gt;
			states = cmd.count_states(ligand)&lt;br /&gt;
		&lt;br /&gt;
		#calculate contact surface area&lt;br /&gt;
		print &amp;quot;The contact areas between &amp;quot;+receptor+&amp;quot; and &amp;quot;+ligand+&amp;quot; [states 1 - &amp;quot;+str(states)+&amp;quot;] are (A^2):&amp;quot;&lt;br /&gt;
		#start looping&lt;br /&gt;
		#for s in range(1,cmd.count_states(ligand)+1):&lt;br /&gt;
		for s in range(1,states+1):&lt;br /&gt;
			#create complex&lt;br /&gt;
			cmd.create(&amp;quot;tmp&amp;quot;,ligand,s,1)&lt;br /&gt;
			cmd.create('complextemp',&amp;quot;tmp &amp;quot;+receptor)&lt;br /&gt;
			#measure areas&lt;br /&gt;
			ligand_area=cmd.get_area('tmp')&lt;br /&gt;
			receptor_area=cmd.get_area(receptor)&lt;br /&gt;
			complex_area=cmd.get_area('complextemp')&lt;br /&gt;
			#normalize since the area is counted TWICE (once on receptor and once on ligand)&lt;br /&gt;
			contact_area=((ligand_area + receptor_area) - complex_area)/2&lt;br /&gt;
			#delete temporary files&lt;br /&gt;
			cmd.delete('tmp')&lt;br /&gt;
			cmd.delete(ligand+&amp;quot;_*&amp;quot;)&lt;br /&gt;
			cmd.delete('complextemp')&lt;br /&gt;
			#print contact surface area&lt;br /&gt;
			f=open('contactareas.txt','a')&lt;br /&gt;
			print &amp;quot;%s - %s_%-5s: &amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s\t%-s_%-5s\t&amp;quot; % (receptor,ligand,s),&lt;br /&gt;
			print &amp;gt;&amp;gt;f, &amp;quot;%-s&amp;quot; % (contact_area)&lt;br /&gt;
			print contact_area&lt;br /&gt;
			f.close()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;contact_surface&amp;quot;,contact_surface)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Math_Scripts]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>MartinChristen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Cluster_Count&amp;diff=6686</id>
		<title>Cluster Count</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cluster_Count&amp;diff=6686"/>
		<updated>2013-02-14T11:30:54Z</updated>

		<summary type="html">&lt;p&gt;MartinChristen: New script to get statistics on b-factors ~~~~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This script calculates statistics on the B-values for all atoms in the selected object, prints the information on screen and appends it to a file called &amp;quot;cluster_count.txt&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cluster_count object&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Example =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cluster_count 1ubq&lt;br /&gt;
&lt;br /&gt;
#output on screen:&lt;br /&gt;
&lt;br /&gt;
Number of atoms in ' 1ubq ':  602&lt;br /&gt;
Minimum and Maximum B-values:  2.0 42.75&lt;br /&gt;
Average B-value:  13.4131063029&lt;br /&gt;
Standard deviation of the B-values:  8.70767140923&lt;br /&gt;
This data will be appended to cluster_count.txt&lt;br /&gt;
&lt;br /&gt;
#output in file cluster_count.txt; the format is:&lt;br /&gt;
#objectname N minB maxB aveB stdevB&lt;br /&gt;
1ubq            602    2.000   42.750   13.413    8.708&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# Script: cluster_count.py&lt;br /&gt;
# Copyleft 2010 Martin Christen&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd,stored&lt;br /&gt;
def cluster_count(selection):&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
 AUTHOR&lt;br /&gt;
 &lt;br /&gt;
 Martin Christen&lt;br /&gt;
 &lt;br /&gt;
 DESCRIPTION&lt;br /&gt;
 &lt;br /&gt;
 This script calculates statistics on the B-values for all atoms in&lt;br /&gt;
 the selected object, prints the information on screen and appends&lt;br /&gt;
 it to the file &amp;quot;cluster_count.txt&amp;quot;.&lt;br /&gt;
 &lt;br /&gt;
 Output format on screen:&lt;br /&gt;
 ------------------------&lt;br /&gt;
 Number of atoms in 'selection': 0&lt;br /&gt;
 Minimum and Maximum B-values:  0.0&lt;br /&gt;
 Average B-value :  0.0&lt;br /&gt;
 Standard deviation of the B-values (best): 0.0 (0.0)&lt;br /&gt;
 This data will be appended to cluster_count.txt&lt;br /&gt;
&lt;br /&gt;
 Output format in cluster_count.txt:&lt;br /&gt;
 -----------------------------------&lt;br /&gt;
 selection N minB maxB aveB stdevB&lt;br /&gt;
&lt;br /&gt;
 EXAMPLE&lt;br /&gt;
&lt;br /&gt;
 cluster_count 1ubq&lt;br /&gt;
&lt;br /&gt;
 Number of atoms in ' 1ubq ':  602&lt;br /&gt;
 Minimum and Maximum B-values:  2.0 42.75&lt;br /&gt;
 Average B-value:  13.4131063029&lt;br /&gt;
 Standard deviation of the B-values:  8.70767140923&lt;br /&gt;
 This data will be appended to cluster_count.txt&lt;br /&gt;
&lt;br /&gt;
 (in cluster_count.txt:)&lt;br /&gt;
 1ubq            602    2.000   42.750   13.413    8.708&lt;br /&gt;
&lt;br /&gt;
 USAGE&lt;br /&gt;
&lt;br /&gt;
 cluster_count selection&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	&lt;br /&gt;
# get list of B-factors from selection&lt;br /&gt;
	m = cmd.get_model(selection)&lt;br /&gt;
	sel = []&lt;br /&gt;
	b_list = []&lt;br /&gt;
	dummy = []&lt;br /&gt;
	for i in range(len(m.atom)):&lt;br /&gt;
		b_list.append(m.atom[i].b)&lt;br /&gt;
&lt;br /&gt;
#determine min and max&lt;br /&gt;
	try: max_b = max(b_list)&lt;br /&gt;
	except ValueError: max_b=0&lt;br /&gt;
	try: min_b = min(b_list)&lt;br /&gt;
	except ValueError: min_b=0&lt;br /&gt;
&lt;br /&gt;
#determine average&lt;br /&gt;
	try: average_b= float(sum(b_list)) / len(b_list)&lt;br /&gt;
	except ZeroDivisionError: average_b=0&lt;br /&gt;
&lt;br /&gt;
#determine standard deviation&lt;br /&gt;
	for i in range(len(m.atom)):&lt;br /&gt;
		if m.atom[i]&amp;gt;average_b:&lt;br /&gt;
			dummy.append((m.atom[i].b-average_b)**2)&lt;br /&gt;
		if m.atom[i]&amp;lt;average_b:&lt;br /&gt;
			dummy.append((average_b-m.atom[i].b)**2)&lt;br /&gt;
	try: stdev_b= (sum(dummy) / (len(m.atom)-1))**(1/2.0)&lt;br /&gt;
	except ZeroDivisionError: stdev_b=0&lt;br /&gt;
&lt;br /&gt;
#print values on screen&lt;br /&gt;
	print &amp;quot;Number of atoms in '&amp;quot;, selection,&amp;quot;': &amp;quot;, len(b_list)&lt;br /&gt;
	print &amp;quot;Minimum and Maximum B-values: &amp;quot;, min_b, max_b&lt;br /&gt;
	print &amp;quot;Average B-value: &amp;quot;, average_b&lt;br /&gt;
	print &amp;quot;Standard deviation of the B-values: &amp;quot;, stdev_b&lt;br /&gt;
	print &amp;quot;This data will be appended to cluster_count.txt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#write information to cluster_count.txt&lt;br /&gt;
	f=open('cluster_count.txt','a')&lt;br /&gt;
	print &amp;gt;&amp;gt;f, '%-10s %8d %8.3f %8.3f %8.3f %8.3f' % (selection, len(m.atom), min_b, max_b, average_b, stdev_b)&lt;br /&gt;
	f.close()&lt;br /&gt;
cmd.extend(&amp;quot;cluster_count&amp;quot;,cluster_count)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:ObjSel_Scripts]]&lt;/div&gt;</summary>
		<author><name>MartinChristen</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Make_Figures&amp;diff=6920</id>
		<title>Make Figures</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Make_Figures&amp;diff=6920"/>
		<updated>2013-02-13T16:56:46Z</updated>

		<summary type="html">&lt;p&gt;MartinChristen: New script to easily create figures. ~~~~&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Overview =&lt;br /&gt;
This script will aid you in making publication quality figures for the currently displayed scene.&lt;br /&gt;
It understands a variety of preset &amp;quot;modes&amp;quot; and sizes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
make_figure filename [, mode] [, size (default=900 pixels)] [,opaque]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The parameters are:&lt;br /&gt;
&lt;br /&gt;
'''filename''' : The name of the resulting image file.&lt;br /&gt;
::''The extension '''.png''' is added automatically.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''NOTE'': if no further arguments are given, the script generates quick figures for general use:&lt;br /&gt;
::* figures are not ray-traced&lt;br /&gt;
::* TWO figures at 300 x 300 px, 72 dpi&lt;br /&gt;
::* views are rotated 180° about y (front and back view)&lt;br /&gt;
::* _front_quick and _back_quick are appended to the filename&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''mode''' : Type of figure desired. Possible values are as follows:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''''single''''' = &amp;quot;single view&amp;quot;&lt;br /&gt;
::* one ray-traced 300 dpi figure of the current view&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''''fb''''' = &amp;quot;front and back view&amp;quot;&lt;br /&gt;
::* TWO ray-traced 300 dpi figures&lt;br /&gt;
::* views are rotated 180° about y&lt;br /&gt;
::* _front and _back are appended to the filename&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
::'''''sides''''' = &amp;quot;four side views&amp;quot;&lt;br /&gt;
::* FOUR ray-traced 300 dpi figures&lt;br /&gt;
::* view is incrementally rotated by 90° about y&lt;br /&gt;
::* _1, _2, _3, and _4 are appended to the filename&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
::'''''stereo''''' = &amp;quot;stereoview&amp;quot;&lt;br /&gt;
::* TWO ray-traced 300 dpi figures&lt;br /&gt;
::* views are shifted by +/- 3 degrees&lt;br /&gt;
::* image dimensions are fixed at 750 x 750 pixels (size arguments are ignored)&lt;br /&gt;
::* _L and _R are appended to the filename&lt;br /&gt;
::* the output files are meant to be combined side by side to generate a stereo image&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''size''' : Size of the figure(s) in pixels or in &amp;quot;panels&amp;quot;&lt;br /&gt;
::* DEFAULT = 900 pixels if a mode is specified&lt;br /&gt;
::* if size is 12 or smaller, the script interprets it as a number of &amp;quot;panels&amp;quot; to make.&lt;br /&gt;
::* panel sizes in pixels are hardcoded in the source but can easily be modified.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''opaque''' : Create an opaque background.&lt;br /&gt;
::* By default the figure background is 100% transparent.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#quick 'n' dirty front and back views of the scene&lt;br /&gt;
#300x300 pixels at 72 dpi, transparent background&lt;br /&gt;
# filenames will be output_front_quick.png and output_back_quick.png&lt;br /&gt;
make_figure output&lt;br /&gt;
&lt;br /&gt;
# one ray-traced PNG file 975x975 pixels at 300dpi, with opaque background&lt;br /&gt;
# filename will be output.png&lt;br /&gt;
make_figure output, single, 975, opaque&lt;br /&gt;
&lt;br /&gt;
# two panels (1350x1350 px each at 300dpi) of the &amp;quot;front&amp;quot; and &amp;quot;back&amp;quot; view on transparent background&lt;br /&gt;
# filenames will be output_front.png and output_back.png&lt;br /&gt;
make_figure output, fb, 2&lt;br /&gt;
&lt;br /&gt;
# four panels (900x900 px each) where the view is incrementally rotated by 90° about y, transparent background&lt;br /&gt;
# filenames will be output_1.png, output_2.png, output_3.png and output_4.png&lt;br /&gt;
make_figure output, sides,4&lt;br /&gt;
&lt;br /&gt;
#stereoview of the current scene with opaque background&lt;br /&gt;
#size is fixed to 2x 750x750px&lt;br /&gt;
# filenames will be output_L.png and output_R.png&lt;br /&gt;
make_figure output, stereo, opaque&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#make_figure v.3.0&lt;br /&gt;
#Copyleft Martin Christen, 2010&lt;br /&gt;
&lt;br /&gt;
from pymol import cmd&lt;br /&gt;
def make_figure(output='', mode='',size=900,opaque='transparent'):&lt;br /&gt;
&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
AUTHOR&lt;br /&gt;
&lt;br /&gt;
	Martin Christen&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
DESCRIPTION&lt;br /&gt;
&lt;br /&gt;
	&amp;quot;make_figure&amp;quot; creates publication-quality figures of the current scene.&lt;br /&gt;
	It understands several predefined &amp;quot;modes&amp;quot; and sizes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
USAGE&lt;br /&gt;
&lt;br /&gt;
	make_figure filename [, mode] [, size (default=900 pixels)] [,opaque]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ARGUMENTS&lt;br /&gt;
&lt;br /&gt;
	mode = string: type of desired figure (single, fb, sides, stereo or -nothing-)&lt;br /&gt;
	size = integer: size of the figure in pixels OR # panels (if &amp;lt;= 12)&lt;br /&gt;
	opaque = specify an opaque background.&lt;br /&gt;
	         By default, the script makes the background transparent.&lt;br /&gt;
EXAMPLES&lt;br /&gt;
&lt;br /&gt;
	make_figure output&lt;br /&gt;
	make_figure output, single, 975, opaque&lt;br /&gt;
	make_figure output, fb, 2&lt;br /&gt;
	make_figure output, sides,4&lt;br /&gt;
	make_figure output, stereo&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
NOTES&lt;br /&gt;
&lt;br /&gt;
	&amp;quot;single&amp;quot; mode makes a single 300 dpi figure&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;fb&amp;quot; mode makes TWO 300 dpi figure&lt;br /&gt;
	(&amp;quot;front&amp;quot; and &amp;quot;back&amp;quot;, rotating by 180 degrees about y)&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;sides&amp;quot; mode makes FOUR 300 dpi figures&lt;br /&gt;
	(&amp;quot;front&amp;quot; &amp;quot;left&amp;quot; &amp;quot;right&amp;quot; and back, rotating by 90 degrees clockwise about y)&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;stereo&amp;quot; generates two 300 dpi, 750 px figures&lt;br /&gt;
	(&amp;quot;L&amp;quot; and &amp;quot;R&amp;quot;, to be combined as a stereo image)&lt;br /&gt;
	If you specify the stereo mode, the size argument is IGNORED.&lt;br /&gt;
		&lt;br /&gt;
	If no mode argument is given, the script generates quick figures&lt;br /&gt;
	for general	use: TWO figures (front and back) at 300 x 300 px, 72 dpi.&lt;br /&gt;
	&lt;br /&gt;
	Size is interpreted as pixels, except if the number is ridiculously small&lt;br /&gt;
	(&amp;lt;=12),	in which case the script as &amp;quot;number of panels&amp;quot; to make.&lt;br /&gt;
&lt;br /&gt;
	Edit the script manually to define corresponding values.&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	#define sizes here (in pixels)&lt;br /&gt;
	panel1 = 1800&lt;br /&gt;
	panel2 = 1350&lt;br /&gt;
	panel3 = 900&lt;br /&gt;
	panel4 = 900&lt;br /&gt;
	panel5 = 750&lt;br /&gt;
	panel6 = 750&lt;br /&gt;
	panel7 = 675&lt;br /&gt;
	panel8 = 675&lt;br /&gt;
	panel9 = 600&lt;br /&gt;
	panel10 = 585&lt;br /&gt;
	panel11 = 585&lt;br /&gt;
	panel12 = 585&lt;br /&gt;
	&lt;br /&gt;
	#verify size is an integer number and convert to pixels&lt;br /&gt;
	size = int(size)&lt;br /&gt;
	if size &amp;gt; 12:&lt;br /&gt;
		pixels = size&lt;br /&gt;
	&lt;br /&gt;
	elif size == 1:&lt;br /&gt;
		pixels = panel1&lt;br /&gt;
	&lt;br /&gt;
	elif size == 2:&lt;br /&gt;
		pixels = panel2&lt;br /&gt;
	&lt;br /&gt;
	elif size == 3:&lt;br /&gt;
		pixels = panel3&lt;br /&gt;
	&lt;br /&gt;
	elif size == 4:&lt;br /&gt;
		pixels = panel4&lt;br /&gt;
	&lt;br /&gt;
	elif size == 5:&lt;br /&gt;
		pixels = panel5&lt;br /&gt;
	&lt;br /&gt;
	elif size == 6:&lt;br /&gt;
		pixels = panel6&lt;br /&gt;
	&lt;br /&gt;
	elif size == 7:&lt;br /&gt;
		pixels = panel7&lt;br /&gt;
	&lt;br /&gt;
	elif size == 8:&lt;br /&gt;
		pixels = panel8&lt;br /&gt;
	&lt;br /&gt;
	elif size == 9:&lt;br /&gt;
		pixels = panel9&lt;br /&gt;
	&lt;br /&gt;
	elif size == 10:&lt;br /&gt;
		pixels = panel10&lt;br /&gt;
	&lt;br /&gt;
	elif size == 11:&lt;br /&gt;
		pixels = panel11&lt;br /&gt;
	&lt;br /&gt;
	elif size == 3:&lt;br /&gt;
		pixels = panel12&lt;br /&gt;
&lt;br /&gt;
	#change background&lt;br /&gt;
	cmd.unset('opaque_background')&lt;br /&gt;
	if opaque == 'opaque':&lt;br /&gt;
		cmd.set('opaque_background')&lt;br /&gt;
	&lt;br /&gt;
	#apply mode&lt;br /&gt;
	if output == '':&lt;br /&gt;
		print 'no output filename defined\n'&lt;br /&gt;
		print 'try: \'make_figure filename\''&lt;br /&gt;
		return -1&lt;br /&gt;
		# abort if no output file name given&lt;br /&gt;
&lt;br /&gt;
	if mode =='':&lt;br /&gt;
		cmd.set('surface_quality',1)&lt;br /&gt;
		cmd.set('opaque_background')&lt;br /&gt;
		cmd.png(output+&amp;quot;_back_quick&amp;quot;,300,300,dpi=72)&lt;br /&gt;
		cmd.turn('y',180)&lt;br /&gt;
		cmd.png(output+&amp;quot;_front_quick&amp;quot;,300,300,dpi=72)&lt;br /&gt;
		cmd.turn('y',180)&lt;br /&gt;
		cmd.set('surface_quality',0)&lt;br /&gt;
		# make front and back figures for quick mode&lt;br /&gt;
&lt;br /&gt;
	elif mode == 'single':&lt;br /&gt;
		cmd.set('surface_quality',1)&lt;br /&gt;
		cmd.set('ray_shadow',0)&lt;br /&gt;
		cmd.ray(pixels, pixels)&lt;br /&gt;
		cmd.png(output, dpi=300)&lt;br /&gt;
		cmd.set('surface_quality',0)&lt;br /&gt;
		# make a figure for single mode&lt;br /&gt;
		&lt;br /&gt;
	elif mode == 'fb':&lt;br /&gt;
		cmd.set('surface_quality',1)&lt;br /&gt;
		cmd.set('ray_shadow',0)&lt;br /&gt;
		cmd.ray(pixels, pixels)&lt;br /&gt;
		cmd.png(output+&amp;quot;_front&amp;quot;, dpi=300)&lt;br /&gt;
		cmd.turn('y',180)&lt;br /&gt;
		cmd.ray(pixels, pixels)&lt;br /&gt;
		cmd.png(output+&amp;quot;_back&amp;quot;, dpi=300)&lt;br /&gt;
		cmd.turn('y',180)&lt;br /&gt;
		cmd.set('surface_quality',0)&lt;br /&gt;
		# make front and back figures for single mode&lt;br /&gt;
&lt;br /&gt;
	elif mode == 'sides':&lt;br /&gt;
		cmd.set('surface_quality',1)&lt;br /&gt;
		cmd.set('ray_shadow',0)&lt;br /&gt;
		cmd.ray(pixels, pixels)&lt;br /&gt;
		cmd.png(output+&amp;quot;_1&amp;quot;, dpi=300)&lt;br /&gt;
		cmd.turn('y',90)&lt;br /&gt;
		cmd.ray(pixels, pixels)&lt;br /&gt;
		cmd.png(output+&amp;quot;_2&amp;quot;, dpi=300)&lt;br /&gt;
		cmd.turn('y',90)&lt;br /&gt;
		cmd.ray(pixels, pixels)&lt;br /&gt;
		cmd.png(output+&amp;quot;_3&amp;quot;, dpi=300)&lt;br /&gt;
		cmd.turn('y',90)&lt;br /&gt;
		cmd.ray(pixels, pixels)&lt;br /&gt;
		cmd.png(output+&amp;quot;_4&amp;quot;, dpi=300)&lt;br /&gt;
		cmd.turn('y',90)&lt;br /&gt;
		cmd.set('surface_quality',0)&lt;br /&gt;
		# make front and back figures for single mode&lt;br /&gt;
		&lt;br /&gt;
	elif mode == 'stereo':&lt;br /&gt;
		cmd.set('surface_quality',1)&lt;br /&gt;
		cmd.set('ray_shadow',0)&lt;br /&gt;
		cmd.ray(750, 750, angle=-3)&lt;br /&gt;
		cmd.png(output+&amp;quot;_R&amp;quot;, dpi=300)&lt;br /&gt;
		cmd.ray(750, 750, angle=3)&lt;br /&gt;
		cmd.png(output+&amp;quot;_L&amp;quot;, dpi=300)&lt;br /&gt;
		# make stereo figure (for more control use stereo_ray)&lt;br /&gt;
		&lt;br /&gt;
cmd.extend('make_figure',make_figure)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:UI_Scripts]]&lt;/div&gt;</summary>
		<author><name>MartinChristen</name></author>
	</entry>
</feed>