CalcArea: Difference between revisions
Jump to navigation
Jump to search
(New page: =Overview= This code will calculate the area of a given selection. If you have a bunch of disparate selections, or one selection made up of various objects then you can use this to find t...) |
No edit summary |
||
Line 4: | Line 4: | ||
=The Code= | =The Code= | ||
<source lang="python"> | <source lang="python"> | ||
def calcArea(sel): | def calcArea(sel, ASA=0, density=3, quiet=1): | ||
""" | """ | ||
DESCRIPTION | |||
Calculate the area of an object or selection (as if it were one complete object). | |||
ARGUMENTS | |||
sel = string: atom selection | |||
ASA = 0/1: solvent excluded or solvent accessible surface area | |||
density = int: sampling quality {default: 3} | |||
""" | """ | ||
tName = "__temp__for__doArea__" | tName = "__temp__for__doArea__" | ||
cmd.create(tName, sel) | cmd.create(tName, sel) | ||
cmd.flag("ignore", tName, "clear") | |||
cmd.set("dot_solvent", int(ASA), tName) | |||
cmd.set("dot_density", int(density), tName) | |||
theArea = cmd.get_area(tName) | theArea = cmd.get_area(tName) | ||
cmd.delete(tName) | cmd.delete(tName) | ||
if not int(quiet): | |||
print 'Area (solvent %s): %.3f Angstroms^2' % (['excluded', | |||
'accessible'][int(ASA)], theArea) | |||
return theArea | return theArea | ||
cmd.extend('calcArea', calcArea) | |||
</source> | </source> | ||
Latest revision as of 02:31, 9 June 2011
Overview
This code will calculate the area of a given selection. If you have a bunch of disparate selections, or one selection made up of various objects then you can use this to find the area.
The Code
def calcArea(sel, ASA=0, density=3, quiet=1):
"""
DESCRIPTION
Calculate the area of an object or selection (as if it were one complete object).
ARGUMENTS
sel = string: atom selection
ASA = 0/1: solvent excluded or solvent accessible surface area
density = int: sampling quality {default: 3}
"""
tName = "__temp__for__doArea__"
cmd.create(tName, sel)
cmd.flag("ignore", tName, "clear")
cmd.set("dot_solvent", int(ASA), tName)
cmd.set("dot_density", int(density), tName)
theArea = cmd.get_area(tName)
cmd.delete(tName)
if not int(quiet):
print 'Area (solvent %s): %.3f Angstroms^2' % (['excluded',
'accessible'][int(ASA)], theArea)
return theArea
cmd.extend('calcArea', calcArea)