IMP logo
IMP Reference Guide  2.17.0
The Integrative Modeling Platform
IMP::atom::Selection Class Reference

Select hierarchy particles identified by the biological name. More...

#include <IMP/atom/Selection.h>

+ Inheritance diagram for IMP::atom::Selection:

Detailed Description

Select hierarchy particles identified by the biological name.

Given an atom.Hierarchy (or atom.Hierarchies) this will select a subset of the child particles by the biological name.

For example (in Python)

Selection(hierarchy=h, molecule="myprotein", terminus=Selection.C)
Selection(hierarchy=h, molecule="myprotein", residue_index=133)
Selection(hierarchy=h, molecule="myprotein", residue_indexes=range(133,138))

each select the C-terminus of the protein "myprotein" (assuming the last residue index is 133, and the residues are leaves, containing no atoms). (In C++, use one of the other constructors, then call one or more of the set_* methods.)

Selection objects can be combined using basic set operations (union, intersection, difference, symmetric difference). In Python the equivalent operators (|, &, -, ^ respectively) can be used (the similar in-place |=, &=, -= and ^= operators also work). This requires that all of the objects being combined use the same hierarchy or hierarchies. For example (in Python)

Selection(hierarchy=h, residue_type=IMP.atom.ASP) \
- (Selection(hierarchy=h, atom_type=IMP.atom.AT_CG)
| Selection(hierarchy=h, terminus=Selection.C))

selects all atoms in ASP residues except for CG or at the C-terminus. The resulting Selection makes a copy of the Selections it was combined from, so changing the original Selections does not change that Selection.

To actually get the selected particles, call get_selected_particle_indexes() or get_selected_particles().

This class assumes the hierarchies are valid (and if they are not, may not select the correct particles). If in doubt, call IMP::atom::Hierarchy::get_is_valid() on each one first to verify this.

Note
The highest resolution representation that fits is returned. If you want lower resolution, use the resolution parameter to select the desired resolution (pass a very large number to get the coarsest representation).

Definition at line 70 of file Selection.h.

Public Types

enum  Terminus { NONE, C, N }
 

Public Member Functions

 Selection (Hierarchy hierarchy=None, Hierarchies hierarchies=[], Strings molecules=[], Ints residue_indexes=[], Strings chain_ids=[], AtomTypes atom_types=[], ResidueTypes residue_types=[], Strings domains=[], double resolution=0, RepresentationType representation_type=IMP.atom.BALLS, std::string molecule=None, int residue_index=None, std::string chain_id=None, AtomType atom_type=None, ResidueType residue_type=None, Ints hierarchy_types=None, Element element=None, Terminus terminus=None, std::string domain=None, core::ParticleType particle_type=None, core::ParticleTypes particle_types=[], int copy_index=-1, Ints copy_indexes=[], int state_index=-1, Ints state_indexes=[])
 
 Selection (Hierarchy h)
 
 Selection (Particle *h)
 
 Selection (Model *m, const ParticleIndexes &pis)
 
 Selection (const Hierarchies &h)
 
 Selection (const ParticlesTemp &h)
 
Selection create_clone ()
 Make a clone of this Selection. More...
 
Hierarchies get_hierarchies () const
 Return the hierarchies that the Selection was constructed with. More...
 
ParticleIndexes get_selected_particle_indexes (bool with_representation=true) const
 Get the indexes of the selected particles. More...
 
ParticlesTemp get_selected_particles (bool with_representation=true) const
 Get the selected particles. More...
 
 operator ParticleIndexes () const
 
 operator ParticlesTemp () const
 
void set_atom_type (AtomType types)
 Select atoms with only the passed type. More...
 
void set_atom_types (AtomTypes types)
 Select atoms whose types are in the list, eg AT_CA. More...
 
void set_chain_id (std::string c)
 Select with the passed chain id. More...
 
void set_chain_ids (Strings chains)
 Select particles in chains with the given ids. More...
 
void set_copy_index (unsigned int copy)
 Select elements with Copy::get_copy_index() that match. More...
 
void set_copy_indexes (Ints copies)
 Select elements with Copy::get_copy_index() that are in the list. More...
 
void set_difference (const Selection &s)
 Select elements that are in this Selection but not the passed one. More...
 
void set_domain (std::string name)
 Select only the single domain with that name. More...
 
void set_domains (Strings names)
 Select domains with the specified names. More...
 
void set_element (Element e)
 Select atoms of the given Element. More...
 
void set_hierarchy_types (Ints types)
 
void set_intersection (const Selection &s)
 Select elements that are in both this Selection and the passed one. More...
 
void set_molecule (std::string mol)
 Select a molecule with the passed name. More...
 
void set_molecules (Strings mols)
 Select based on the molecule name. More...
 
void set_particle_type (core::ParticleType t)
 Select elements that match the core::ParticleType. More...
 
void set_particle_types (core::ParticleTypes t)
 Select elements that match the core::ParticleType. More...
 
void set_representation_type (RepresentationType t)
 Try to find this representation type. More...
 
void set_residue_index (int i)
 Select only residues with the passed index. More...
 
void set_residue_indexes (Ints indexes)
 Select residues whose indexes are in the passed list. More...
 
void set_residue_type (ResidueType type)
 Select only residues with the passed type. More...
 
void set_residue_types (ResidueTypes types)
 Select residues whose types are in the list. More...
 
void set_resolution (double r)
 Select at a Representation node with a resolution close to r. More...
 
void set_state_index (int state)
 Select State with the passed index. More...
 
void set_state_indexes (Ints states)
 Select State with the passed indexes. More...
 
void set_symmetric_difference (const Selection &s)
 Select elements that are in this Selection or the passed one but not both. More...
 
void set_terminus (Terminus t)
 Select the leaf particles at the N or C terminus. More...
 
void set_union (const Selection &s)
 Select elements that are in either this Selection or the passed one. More...
 
void show (std::ostream &out=std::cout) const
 

Constructor & Destructor Documentation

IMP::atom::Selection::Selection ( Hierarchy  hierarchy = None,
Hierarchies  hierarchies = [],
Strings  molecules = [],
Ints  residue_indexes = [],
Strings  chain_ids = [],
AtomTypes  atom_types = [],
ResidueTypes  residue_types = [],
Strings  domains = [],
double  resolution = 0,
RepresentationType  representation_type = IMP.atom.BALLS,
std::string  molecule = None,
int  residue_index = None,
std::string  chain_id = None,
AtomType  atom_type = None,
ResidueType  residue_type = None,
Ints  hierarchy_types = None,
Element  element = None,
Terminus  terminus = None,
std::string  domain = None,
core::ParticleType  particle_type = None,
core::ParticleTypes  particle_types = [],
int  copy_index = -1,
Ints  copy_indexes = [],
int  state_index = -1,
Ints  state_indexes = [] 
)

When using Python, you have much more control over construction due to the use of keyword arguments. You can provide any subset of the arguments (although one of hierarchy or hierarchies must be provided).

Member Function Documentation

Selection IMP::atom::Selection::create_clone ( )

Make a clone of this Selection.

The clone will initially contain the same predicates as the original, but adding new predicates to either Selection will not affect the other (as opposed to simply copy the Selection object, where both copies share the same list of predicates).

Hierarchies IMP::atom::Selection::get_hierarchies ( ) const

Return the hierarchies that the Selection was constructed with.

ParticleIndexes IMP::atom::Selection::get_selected_particle_indexes ( bool  with_representation = true) const

Get the indexes of the selected particles.

Note
The particles are those selected at the time this method is called, not when the Selection object was created.
Parameters
with_representationIf true (the default) then extend the search down the hierarchy to find all representational particles that match - that is, those with x,y,z coordinates. For example, selecting a residue name will typically return all of the Atom particles in that residue (not the Residue particle itself). If false, stop the search at the highest level of the hierarchy that matches (so, in the case above, return the Residue particle).
Returns
the indexes of the selected particles.
ParticlesTemp IMP::atom::Selection::get_selected_particles ( bool  with_representation = true) const

Get the selected particles.

See Also
get_selected_particle_indexes().
void IMP::atom::Selection::set_atom_type ( AtomType  types)

Select atoms with only the passed type.

void IMP::atom::Selection::set_atom_types ( AtomTypes  types)

Select atoms whose types are in the list, eg AT_CA.

void IMP::atom::Selection::set_chain_id ( std::string  c)

Select with the passed chain id.

void IMP::atom::Selection::set_chain_ids ( Strings  chains)

Select particles in chains with the given ids.

void IMP::atom::Selection::set_copy_index ( unsigned int  copy)

Select elements with Copy::get_copy_index() that match.

void IMP::atom::Selection::set_copy_indexes ( Ints  copies)

Select elements with Copy::get_copy_index() that are in the list.

void IMP::atom::Selection::set_difference ( const Selection s)

Select elements that are in this Selection but not the passed one.

Note
both Selections must be on the same Hierarchy or Hierarchies
void IMP::atom::Selection::set_domain ( std::string  name)

Select only the single domain with that name.

void IMP::atom::Selection::set_domains ( Strings  names)

Select domains with the specified names.

void IMP::atom::Selection::set_element ( Element  e)

Select atoms of the given Element.

void IMP::atom::Selection::set_hierarchy_types ( Ints  types)

Select only particles whose type matches the passed type, eg Molecule, Fragment, Residue etc. See GetByType for how to specify the types. Ints are used to make swig happy.

void IMP::atom::Selection::set_intersection ( const Selection s)

Select elements that are in both this Selection and the passed one.

Note
both Selections must be on the same Hierarchy or Hierarchies
void IMP::atom::Selection::set_molecule ( std::string  mol)

Select a molecule with the passed name.

void IMP::atom::Selection::set_molecules ( Strings  mols)

Select based on the molecule name.

void IMP::atom::Selection::set_particle_type ( core::ParticleType  t)

Select elements that match the core::ParticleType.

void IMP::atom::Selection::set_particle_types ( core::ParticleTypes  t)

Select elements that match the core::ParticleType.

void IMP::atom::Selection::set_representation_type ( RepresentationType  t)

Try to find this representation type.

Definition at line 152 of file Selection.h.

void IMP::atom::Selection::set_residue_index ( int  i)

Select only residues with the passed index.

void IMP::atom::Selection::set_residue_indexes ( Ints  indexes)

Select residues whose indexes are in the passed list.

void IMP::atom::Selection::set_residue_type ( ResidueType  type)

Select only residues with the passed type.

void IMP::atom::Selection::set_residue_types ( ResidueTypes  types)

Select residues whose types are in the list.

void IMP::atom::Selection::set_resolution ( double  r)

Select at a Representation node with a resolution close to r.

Definition at line 150 of file Selection.h.

void IMP::atom::Selection::set_state_index ( int  state)

Select State with the passed index.

Definition at line 155 of file Selection.h.

void IMP::atom::Selection::set_state_indexes ( Ints  states)

Select State with the passed indexes.

void IMP::atom::Selection::set_symmetric_difference ( const Selection s)

Select elements that are in this Selection or the passed one but not both.

Note
both Selections must be on the same Hierarchy or Hierarchies
void IMP::atom::Selection::set_terminus ( Terminus  t)

Select the leaf particles at the N or C terminus.

If the leaf particles are atoms, a terminus is simply an N or C atom where its parent is also a terminus particle. Otherwise, a terminus particle is the first (for N) or last (for C) child of its parent.

void IMP::atom::Selection::set_union ( const Selection s)

Select elements that are in either this Selection or the passed one.

Note
both Selections must be on the same Hierarchy or Hierarchies

The documentation for this class was generated from the following file: