<?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=Cluster_Count</id>
	<title>Cluster Count - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Cluster_Count"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cluster_Count&amp;action=history"/>
	<updated>2026-05-09T06:00:17Z</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=Cluster_Count&amp;diff=6687&amp;oldid=prev</id>
		<title>Pyadmin: 1 revision</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cluster_Count&amp;diff=6687&amp;oldid=prev"/>
		<updated>2014-03-28T01:49:16Z</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 01:49, 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=Cluster_Count&amp;diff=6686&amp;oldid=prev</id>
		<title>MartinChristen: New script to get statistics on b-factors ~~~~</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Cluster_Count&amp;diff=6686&amp;oldid=prev"/>
		<updated>2013-02-14T11:30:54Z</updated>

		<summary type="html">&lt;p&gt;New script to get statistics on b-factors ~~~~&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&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>
</feed>