Atom selection is the primary method to access information about the atoms in a molecule. It works in two steps. The first step is to create a selection given the selection text, molecule id, and optional frame number. This is done by a function called atomselect, which returns the name of the new atom selection. the second step is to use the created selection to access the information about the atoms in the selections.
If no selection is given, the macro for the given name is returned.
If no name is given, a list of all macro names is returned.
If a macro already exists for the given name, the old selection will be replaced with the new selection. Singlewords that are not defined as macros, like protein and water, cannot be redefined with the macro command.
Some examples are:
vmd> atomselect top "name CA" atomselect0 vmd> atomselect 3 "resid 25" frame last atomselect1 vmd> atomselect top "within 5 of resname LYR" frame 23 atomselect2
The newly created atom selection is a Tcl proc, which takes the following options:
Example:
set sel [atomselect top all] set mass [$sel get mass] set xyz [$sel get {x y z}] $sel set beta 0 # all values are set to zero $sel set beta $mass # copy mass to beta # set occupancy to x, mass to y, beta to z $sel set {occupancy mass beta} $xyz
It is an error to set integer or floating point keywords using non-numeric values. If floating point values are passed to integer keywords, they will be converted to integers, and vice versa.
The set command immediately updates all representations of the selected molecule. If speed is an issue, delete all representations of the molecule before setting the values.
See section 12.2 for more on using atom selections for fun and profit, as well as issues relating to speed of analysis scripts.