This is a read-only mirror of pymolwiki.org

Difference between revisions of "Average b"

From PyMOL Wiki
Jump to navigation Jump to search
(New page: =average_b.py= *calculate the average B-factor of a selection. ==Usage== *copy code to text file and save as average_b.py. Install via Plugin>Install plugin from within PyMOL. *restart P...)
 
m (6 revisions)
 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
*calculate the average B-factor of a selection.
 
*calculate the average B-factor of a selection.
  
==Usage==
+
==usage==
 
*copy code to text file and save as average_b.py. Install via Plugin>Install plugin from within PyMOL.
 
*copy code to text file and save as average_b.py. Install via Plugin>Install plugin from within PyMOL.
 
*restart PyMOL and then type "average_b (selection)"
 
*restart PyMOL and then type "average_b (selection)"
  
==Contact==
+
==author==
Gregor Hagelueken,
+
Gregor Hagelueken
gh50@st-andrews.ac.uk
 
  
==Code==
+
==code==
 
<source lang="python">
 
<source lang="python">
 
from pymol import cmd,stored
 
from pymol import cmd,stored
 
def average_b(selection):
 
def average_b(selection):
stored.tempfactor=0
+
stored.tempfactor = 0
stored.atomnumber=0
+
stored.atomnumber = 0
cmd.iterate(selection,"stored.tempfactor=stored.tempfactor+b")
+
cmd.iterate(selection, "stored.tempfactor = stored.tempfactor + b")
cmd.iterate(selection,"stored.atomnumber=stored.atomnumber+1")
+
cmd.iterate(selection, "stored.atomnumber = stored.atomnumber + 1")
print "Your selection: ", selection
+
print "Your selection: %s" % selection
print "sum of b factors: ", stored.tempfactor
+
print "sum of B factors: %s" % stored.tempfactor
print "number of atoms: ",stored.atomnumber
+
print "number of atoms: %s" % stored.atomnumber
averagetempfactor=stored.tempfactor/stored.atomnumber
+
averagetempfactor = stored.tempfactor / stored.atomnumber
print "average b of '", selection,"': ", averagetempfactor
+
print "average B of '%s': %s" % (selection, averagetempfactor)
cmd.extend("average_b",average_b)
+
cmd.extend("average_b", average_b)
 +
</source>
 +
 
 +
[[Category:Script_Library]]
 +
[[Category:Structural_Biology_Scripts]]
 +
[[Category:Biochemical_Scripts]]

Latest revision as of 01:06, 28 March 2014

average_b.py

  • calculate the average B-factor of a selection.

usage

  • copy code to text file and save as average_b.py. Install via Plugin>Install plugin from within PyMOL.
  • restart PyMOL and then type "average_b (selection)"

author

Gregor Hagelueken

code

from pymol import cmd,stored
def average_b(selection):
	stored.tempfactor = 0
	stored.atomnumber = 0
	cmd.iterate(selection, "stored.tempfactor = stored.tempfactor + b")
	cmd.iterate(selection, "stored.atomnumber = stored.atomnumber + 1")
	print "Your selection: %s" % selection
	print "sum of B factors: %s" % stored.tempfactor
	print "number of atoms: %s" % stored.atomnumber
	averagetempfactor = stored.tempfactor / stored.atomnumber
	print "average B of '%s': %s" % (selection, averagetempfactor)
cmd.extend("average_b", average_b)