Iterate State: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 29: | Line 29: | ||
[[iterate]], [[alter]], [[Alter_State]] | [[iterate]], [[alter]], [[Alter_State]] | ||
[[Category:Commands| | [[Category:Commands|Iterate State]] | ||
[[Category:States]] | [[Category:States|Iterate State]] |
Revision as of 09:09, 20 June 2009
DESCRIPTION
Iterate state can be used to extract position data from an object or selection. The expression can use the variables x, y, and z which are the position of the current atom. One common usage is to extract the positions as a python list to alter then write back to the molecule using alter_state.
USAGE
iterate_state state,(selection),expression
EXAMPLES
From PyMOL command line
To get the sum of x coordinates:
stored.sum_x = 0.0
iterate_state 1,(all),stored.sum_x = stored.sum_x + x
To get a list of the positions in a selection
stored.pos = []
iterate_state 1, (all), stored.pos.append((x,y,z))
From Python
To get a list of positions (import stored first)
from pymol import stored
stored.pos = []
cmd.iterate_state(1, 'all', 'stored.pos.append((x,y,z))')