VMD Extension Functions
Iterate a TCL block over all frames

Functions

 forFrames framenum sel block ?step?
 
 forFramesMeasure framenum sel block
 

Detailed Description

Convenience functions to iterate a block of TCL code over a set of frames. See documentation and examples below.

Note. If the selection is subject to changes between frames, do perform a "$sel update" inside the block. If you are using more than one selection, pass only the first as an argument and, if necessary, update the others inside the block.

Example

Iterate and compute secondary structure:

1 forFrames fn $kid {
2  animate goto $fn
3  mol ssrecalc [$kid molid]
4  puts "$fn [vecmean [$kid get alpha_helix]]"
5 }

Function Documentation

◆ forFrames()

forFrames   framenum sel block ?step?  

Iterators over frames in the current selection. While in ''block'', the first argument is set to the (integer) current frame number. The selection is used to get the frame range, and is automatically set with "frame" before executing the block. Note that, like '''for''', the variable name does not require the dollar symbol. Example:

  forFrames fno $sel { puts "$fno: [measure rgyr $sel ]"  }

◆ forFramesMeasure()

forFramesMeasure   framenum sel block  

Similar to forFrames (in fact it is a plug-in replacement). If the block returns a value, also builds a list with the returned values.