#
The `selection` class: handling of sets of atom coordinates

The `selection` class holds a set of atoms from a model. Such selections can be used to perform actions on only some model atoms.

Selections in MODELLER behave almost identically to standard Python sets - see the section in the Python manual on sets for further information. Selections are ‘sets’ in the mathematical sense, and as such can be combined with each other in unions (using the Python `union` function, or the `|` operator) or intersections (using the `intersection` function, or the `&` operator), etc.

All of the atoms in a selection must belong to the same `model` object. Note that the selection is not a copy of the model atoms; if model atoms are changed, the atoms will also be moved in any selection that contains those atoms, and vice versa.

To add objects to a selection, you can list them when you create the selection with the selection() constructor, add them to an existing selection with selection.add(), or combine selections with set operations (see above).

See model.atoms, Sequence.residues, Sequence.chains, model.atom_range(), model.residue_range(), model.get_insertions(), model.get_deletions(), and model.loops() for valid objects (groups of atoms) to add to the selection. You can also add `model` objects and existing `selection` objects to a selection. (Adding a residue adds all atoms in that residue to the selection, adding a model adds all atoms in the model, and so on.)

See also Point.select_sphere(), which creates a new `selection` object.

Once you have a selection, it can be manipulated by standard Python set operations (above), by methods to add new atoms (selection.by_residue(), selection.select_sphere()), or by methods to exclude atom or residue types (selection.only_sidechain(), selection.only_mainchain(), selection.only_atom_types(), selection.only_residue_types(), selection.only_std_residues(), selection.only_no_topology(), selection.only_het_residues(), selection.only_water_residues(), selection.only_defined()).

Subsections

- selection() — create a new selection
- selection.add() — add objects to selection
- selection.extend_by_residue() — extend selection by residue
- selection.by_residue() — make sure all residues are fully selected
- selection.select_sphere() — select all atoms within radius
- selection.only_mainchain() — select only mainchain atoms
- selection.only_sidechain() — select only sidechain atoms
- selection.only_atom_types() — select only atoms of given types
- selection.only_residue_types() — select only atoms of given residue type
- selection.only_std_residues() — select only standard residues
- selection.only_no_topology() — select only residues without topology
- selection.only_het_residues() — select only HETATM residues
- selection.only_water_residues() — select only water residues
- selection.only_defined() — select only atoms with defined coordinates
- selection.write() — write selection coordinates to a file
- selection.translate() — translate all coordinates
- selection.rotate_origin() — rotate coordinates about origin
- selection.rotate_mass_center() — rotate coordinates about mass center
- selection.transform() — transform coordinates with a matrix
- selection.mutate() — mutate selected residues
- selection.randomize_xyz() — randomize selected coordinates
- selection.superpose() — superpose model on selection given alignment
- selection.rotate_dihedrals() — change dihedral angles
- selection.unbuild() — undefine coordinates
- selection.hot_atoms() — atoms violating restraints
- selection.energy() — evaluate atom selection given restraints
- selection.debug_function() — test code self-consistency
- selection.assess_dope() — assess a model selection with the DOPE method
- selection.assess_dopehr() — assess a model with the DOPE-HR method
- selection.get_dope_profile() — get per-residue DOPE profile
- selection.get_dopehr_profile() — get per-residue DOPE-HR profile
- selection.assess() — assess a model selection