Selecting atoms in CNS is performed using a matching operation. This means that an expression is written which is matched against the properties of the atoms currently stored in memory. Those atoms which match the expression are selected.
Selections may be simple, selecting atoms on the basis of residue number for example. However, the creation of more complex expressions requires the combination of one or more simple expressions with the operators AND, OR and NOT. The meaning of these basic operators must be understood for construction of meaningful selection expressions.
OR: The union between the two sets of atoms selected in the two enclosing expressions.
Example:
(segid A or residue 10)
All atoms which have the segid A OR the residue number 10 are selected. This would select all atoms with the segid A and also any atoms which have the residue number 10.
AND: The intersection between the two sets of atoms selected in the two enclosing expressions.
Example:
(segid A and residue 10)
All atoms which have the segid A AND the residue number 10 are selected. This would only select those atoms which have both the segid A and the residue number 10.
NOT: All atoms outside the set of atoms selected in the following expression.
Example:
(not (residue 10))
All atoms which do not have the residue number 10 are selected.
Simple expressions are grouped using parentheses to make clear the order of selection.
Example:
((segid A or residue 10) and resname TYR)
This would select any atoms with either segid A or residue number 10, which also have the residue name TYR. This should be compared with:
(segid A or (residue 10 and resname TYR))
This would select all atoms with segid A, and also any atoms which have residue number 10 and residue name TYR.
Please see the syntax manual for a full description of the atom selection syntax. Below are some examples which cover many of the common atom selection concepts.
Selections can also be made on the basis of atomic attributes such as coordinates or B-factors. The ATTRIBUTE operator is used:
Example:
(attribute(b > 50))
All atoms which have an atomic B-factor greater than 50 are selected.
Please see the syntax manual for a full description of the attribute syntax and the full set of atomic attributes which can be used for selection. Below are some examples which cover many of the common attribute concepts.
Note that all attribute operators are single character only, there are no such operators as <= or >=. A compound expression must be used instead:
Example:
(attribute(b = 50) or attribute(b > 50))
All atoms which have an atomic B-factor greater than or equal to 50 are selected.
Selection expressions can be compounded to form more complex expressions.
Example:
(attribute(b > 50) and (segid A or residue 10))
All atoms which have an atomic B-factor greater than 50 and segid A or residue number 10 are selected.