CNS has a powerful atom selection syntax that allows one to select atoms without reference to the internal index and to construct arbitrary logical expressions of selected atoms. The number of selected atoms from the last executed selection statement is stored in the symbol $SELECT. Atom selections are generally fragile, which means that information associated with atom selections is lost when changing the molecular structure. Certain selections are rendered only partially fragile by mapping the selected atoms to the new molecular structure after it has been modified. This applies to all atom properties except for the internal stores, which are fragile. It also applies to the atom-based parameter statements. Note, however, that the atom selections are not applied to any newly created atoms and these atoms are then not selected. (The reason for this is that CNS does not store the strings associated with the selections.)

An atom selection consists of one or more expressions which are combined with the logical operators AND and OR. Parentheses are used to group expressions (see the preceeding documentation for further examples). The following selection statements are possible:

The atomic properties which can be used in the attribute statement are:

Examples

The first example selects all CA carbon atoms between residue number 40 and 100:

  ( name ca and resid 40:100 )

The next example selects all heavy side-chain atoms:

  ( not ( name ca or name n or name c or name o or hydrogen ) ) 

The next example selects all atoms in Phe residues that are within 20Å around residue 1:

  ( resname phe and ( residue 1 around 20.0 ) )

The next example is similar to the previous one, except that all atoms of a particular Phe residue are selected once any atom of this residue is within 20Å from residue 1:

  ( byresidue ( resname phe and ( residue 1 around 20.0 ) ) ) 

Suppose that we want to get the stereochemistry as a function of residue number. The following example tags each residue by using its Ca carbon atom and then computes the rms deviation of bond lengths from ideality for all atoms of the selected residue.

  for $1 in id ( name ca ) loop main 
     igroup 
       interaction ( byresidue ( id $1 ) ) ( byresidue ( id $1 ) )
     end 
     print threshold=0.1 bonds 
     display $result 
  end loop main 
Do, show and identity statements

The do, show and identity statement allow the manipulation and query of atomic properties, such as masses, charges, coordinates, forces, and atom names. Mathematical expressions can be constructed that involve atomic properties. The show statement can also be used to analyze atomic properties and to transfer the information to the $RESULT symbol. The identity statement can be used to define and store an atom selection that can be recalled later.

Atom properties can be reassigned the result of an operation using the DO statement:

  DO ( atom-property = operation ) ( atom-selection )

The SHOW statement show only the result of an operation:

  SHOW ( operation ) ( atom-selection )

The IDENtity statement does not use an operation, only an atomic STORE array and an atom selection:

  IDENtity ( store[i] ) ( atom-selection )

Operations are expressions using:

  atom-property | function | integer | real | string | symbol

Where operators (in order of increasing precedence) are:

Operators with the highest precedence are excuted first. Operators with the same precedence are executed from left to right. Operations have to be meaningful; i.e., the data type of the operands has to match the operation. For strings, only the "+" and "-" operations are allowed.

Functions are as follows. Use of a string requires enclosure in double quotes " ". The data type of the function arguments has to match the data type of the operands.

The complete set of atomic properties is:

Requirements

The molecular structure has to be present. Upon modification of the molecular structure (e.g., delete or patch statement), the contents of the internal stores are destroyed; i.e., they are fragile. However, all other atom properties are conserved; i.e., they are only partially fragile.

Examples

The first example divides the coordinate array Z by the derivative array DX, adds the quotient to the coordinate array Y, and stores the result in the coordinate array X. The operations are carried out component by component for all atoms.

  do ( X = Y + Z / DX ) ( all ) 

The next example computes a Gaussian distribution with standard deviation 1.0 and stores the result in the coordinate array x for all Ca atoms:

  do ( X = GAUSS( 1.0 ) ) ( name ca ) 

The next example provides a listing of the X coordinates of all Tyr residues:

  show element ( X ) ( resname tyr ) 

The next example computes the average of all electric charges in residue 34. This average value is then stored in the symbol $1 by using the evaluate statement.

  show ave ( charge ) ( residue 34 ) 
  evaluate ($1=$RESULT) 

The next example stores the specified atom selection in the array STORE1:

  identity ( store1 ) ( attribute mass > 30.0 ) 

The array STORE1 will be nonzero for the selected atoms and zero otherwise. The values for the selected atoms represent the sequential number of the selected atoms. The array STORE1 can be recalled by using ( store1 ) in a selection statement.


Back to tutorials   Previous section   Next section