This is a read-only mirror of pymolwiki.org

Difference between revisions of "Iterate"

From PyMOL Wiki
Jump to navigation Jump to search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
===DESCRIPTION===
 
===DESCRIPTION===
 +
'''iterate''' iterates over an expression with a separate name space for each atom.  However, unlike the "alter" command, atomic properties can not be altered.  Thus, '''iterate''' is more efficient than '''alter'''.
 
   
 
   
−
  "iterate" iterates over an expression with a separate name space
+
It can be used to perform operations and aggregations using atomic selections, and store the results in any global object, such as the predefined '''stored''' object.
−
  for each atom.  However, unlike the "alter" command, atomic
 
−
  properties can not be altered.  Thus, "iterate" is more efficient
 
−
  than "alter".
 
−
 
−
  It can be used to perform operations and aggregations using atomic
 
−
  selections, and store the results in any global object, such as the
 
−
  predefined "stored" object.
 
−
 
−
  The local namespace for "iterate" contains the following names
 
−
 
−
      name, resn, resi, chain, alt, elem,
 
−
      q, b, segi, and type (ATOM,HETATM),
 
−
      partial_charge, formal_charge,
 
−
      text_type, numeric_type, ID
 
−
 
−
  All strings in the expression must be explicitly quoted.  This
 
−
  operation typically takes a second per thousand atoms.
 
−
 
−
===USAGE==
 
−
 
−
  iterate (selection),expression
 
 
   
 
   
 +
The local namespace for "iterate" contains the following names:
 +
*name
 +
*resn
 +
*resi
 +
*chain
 +
*alt
 +
*elem
 +
*q
 +
*b
 +
*segi
 +
*type (ATOM,HETATM)
 +
*formal_charge
 +
*partial_charge
 +
*numeric_type
 +
*text_type
 +
*ID
 +
*vdw
 +
 +
All strings in the expression must be explicitly quoted.  This operation typically takes a second per thousand atoms.
 +
 +
===USAGE===
 +
iterate (selection),expression
 +
 
===EXAMPLES===
 
===EXAMPLES===
−
+
*The following example calculates the net charge on an object.
−
  stored.net_charge = 0
+
<source lang="python">
−
  iterate (all),stored.net_charge = stored.net_charge + partial_charge
+
stored.net_charge = 0
−
+
iterate (all),stored.net_charge = stored.net_charge + partial_charge
−
  stored.names = []
+
</source>
−
  iterate (all),stored.names.append(name)
+
 
−
+
 
 +
*The following example fills an array, '''stored.names''' with the names of all the residues.
 +
<source lang="python">
 +
stored.names = []
 +
iterate (all),stored.names.append(name)
 +
</source>
 +
 
 +
 
 +
*The following prints the b-factors for all atoms around residue #1.
 +
<source lang="python">
 +
iterate resi 1, print round(b,2)
 +
</source>
 +
 
 
===SEE ALSO===
 
===SEE ALSO===
−
+
[[Cmd iterate_state]], [[Cmd alter]], [[Cmd alter_state]]
−
  [[Cmd iterate_state]], [[Cmd alter]], [[Cmd alter_state]]]
 
  
 
[[Category:Commands|iterate]]
 
[[Category:Commands|iterate]]

Revision as of 08:49, 16 January 2007

DESCRIPTION

iterate iterates over an expression with a separate name space for each atom. However, unlike the "alter" command, atomic properties can not be altered. Thus, iterate is more efficient than alter.

It can be used to perform operations and aggregations using atomic selections, and store the results in any global object, such as the predefined stored object.

The local namespace for "iterate" contains the following names:

  • name
  • resn
  • resi
  • chain
  • alt
  • elem
  • q
  • b
  • segi
  • type (ATOM,HETATM)
  • formal_charge
  • partial_charge
  • numeric_type
  • text_type
  • ID
  • vdw

All strings in the expression must be explicitly quoted. This operation typically takes a second per thousand atoms.

USAGE

iterate (selection),expression

EXAMPLES

  • The following example calculates the net charge on an object.
stored.net_charge = 0
iterate (all),stored.net_charge = stored.net_charge + partial_charge


  • The following example fills an array, stored.names with the names of all the residues.
stored.names = []
iterate (all),stored.names.append(name)


  • The following prints the b-factors for all atoms around residue #1.
iterate resi 1, print round(b,2)

SEE ALSO

Cmd iterate_state, Cmd alter, Cmd alter_state