Average b: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 4: | Line 4: | ||
==usage== | ==usage== | ||
*copy code to text file and save as average_b.py. | * copy code to text file and save as average_b.py | ||
* | * type "run average_b.py" in PyMOL | ||
* then type "average_b (selection)" | |||
==author== | ==author== | ||
Line 14: | Line 15: | ||
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: " | print("Your selection: %s" % selection) | ||
print "sum of B factors: " | print("sum of B factors: %s" % stored.tempfactor) | ||
print "number of atoms: " | print("number of atoms: %s" % stored.atomnumber) | ||
averagetempfactor=stored.tempfactor/stored.atomnumber | averagetempfactor = stored.tempfactor / stored.atomnumber | ||
print "average B of ' | print("average B of '%s': %s" % (selection, averagetempfactor)) | ||
cmd.extend("average_b",average_b) | cmd.extend("average_b", average_b) | ||
</source> | </source> | ||
[[Category:Script_Library]] | [[Category:Script_Library]] | ||
[[Category:Structural_Biology_Scripts]] | |||
[[Category:Biochemical_Scripts]] |
Latest revision as of 12:55, 26 April 2023
average_b.py
- calculate the average B-factor of a selection.
usage
- copy code to text file and save as average_b.py
- type "run average_b.py" in PyMOL
- 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)