VMD has a rather powerful atom selection language (but it seems like everyone says that about their selection method :). It is based around the assumption that every atom has a value which can be accessed through a keyword. This value could be a boolean (is this a protein atom?), a numeric value (as in the atom index or atomic mass), or a string (the atom name). The value can even be reference via a Tcl array.
To start off, here are some examples of valid selection commands in VMD . Following will be a more in depth description of how selections work.
name CA resid 35 name CA and resname ALA backbone not protein protein (backbone or name H) name 'A 1' name 'A *' name "C.*" mass < 5 numbonds = 2 abs(charge) > 1 x < 6 and x > 3 sqr(x-5)+sqr(y+4)+sqr(z) > sqr(5) within 5 of name FE protein within 5 of nucleic same resname as (protein within 5 of nucleic) protein sequence "C..C" annmm ??? name eq \$atomname ??? protein and @myselection
There are two types of selection modes. The first is the keyword followed by a list of either values or range of values. For example,
name CAselects all atoms with the name CA (which could be a C-alpha or a calcium);
resname ALA PHE ASPselects all atoms inside either alanine, phenylalanine, or asparagine;
index 5selects the 6th atom (in the internal vmd numbering scheme).
VMD can also do range selections, similar to X-PLOR's `:' notation:
mass 5 to 11.5selects atoms with mass between 5 and 11.5 inclusive,
resname ALA to CYS TYRselects atoms in alanine, arginine, asparagine, aspartic acid, cystine, and also tyrosine.
The keyword selection works by checking each term on the list
following the keyword. The term is either a single word (eg,
name CA
) or a range (eg resid 35 to 90
).
The method for determining the range checking is determined
from the keyword data type; numeric comparisons are different than
string comparisons. The comparison should work as expected so that
``8'' is between ``1'' and ``11'' in a numeric context but not in a
string one. This may lead to some peculiar problems. Some keywords,
such as segname, can take on string values but can also be used by
some people as a number field. Suppose someone labeled the
segname field with the numbers 1 through 12 on the assumption that
they are numbers. That person would be rather confused to find that
segname 1 to 11
only returns two segments. Also, strings
will be converted (via atof()) to a number so if the string
isn't a number, it will be given the value of 0. It is possible to
force a search to be done in a either a string or numeric context
using the
relational operator
Selections can be combined with the boolean operators and and or, collected inside of parenthesis, and modified by not, as in
(name CA or name CB) and mass 12 to 17which selects all atoms name CA or CB and have masses between 12 and 17 amu (this could be used to distinguish a C-alpha from a calcium). VMD has operator precedence similar to C so leaving the parentheis out of the previous expression, as in:
name CA or name CB and mass 12 to 17actually selects all atoms named CA or those that are named CB and have the appropriate mass.