next up previous contents index
Next: Comparison Operators Up: Selection Methods Previous: Double Quotes and Regular   Contents   Index


Comparison selections

Comparisons can be used in VMD to do atom selections like mass < 5, which selects atoms with mass less than 5 amu, and name eq CA, which is another way of choosing the CA atoms. The underlying idea for the comparison selection is also based on the concept that every atom has a property as specified by a keyword. When the keyword is given in the expression, the array (or vector) of the corresponding values is constructed, and the size of the array is the same as the number of atoms in the molecule. (If a single number or string is given instead of a keyword, the array consists of copies of that given value.) The operations, like addition, multiplication, string matching, and comparison, are then applied element-wise along the array. This type of selection is similar to the vector statement in X-PLOR.

Take the example mass < 5 when applied on water, which has an oxygen of mass 15.9994 and two hydrogens of mass 1.008. VMD sees the keyword mass and constructs the array [15.9994, 1.008, 1.008], then sees the ``5'' and makes the array [5, 5, 5]. It then compares each term of the array and returns with the boolean array [False, True, True] (since 15.9994 is not less than 5, but 1.008 is). This final boolean array is then used to determine which atoms are selected; in this case, the hydrogens.

More complicated comparison selections can be constructed, either from arithmetic operations or by using some of the standard math functions (the functions are listed in Table 5.7). Probably the most often used function will be sqr, which squares each element of the array. Thus, the command to select all atoms within 5 Å of a point (x,y,z) = (3,4,-5) in space is:

        sqr(x-3)+sqr(y-4)+sqr(z+5) <= sqr(5)


next up previous contents index
Next: Comparison Operators Up: Selection Methods Previous: Double Quotes and Regular   Contents   Index
vmd@ks.uiuc.edu