entities.MoleculeSelector

entities.MoleculeSelector(self, mol=None)

A helper to create selections for Molecules and AtomArrays.

The selection (self.mask) is not computed or returned until the evaluate_on_array method is called. Until then methods are stored for later evaluation.

Parameters

Name Type Description Default
mol Molecule The molecule object to select from. None

Attributes

Name Type Description
mol Molecule The molecule object to select from.
mask ndarray or None Boolean array for the selection on the most recently evaluated array.
pending_selections list List of selection operations to be applied once evaluate_on_array is called.

Methods

Name Description
atom_name Select atoms by their name.
chain_id Select atoms by chain identifier.
element Select atoms by element symbol.
evaluate_on_array Evaluate this selection on the AtomArray.
is_amino_acid Select amino acid residues.
is_backbone Select backbone atoms for peptide and nucleotide.
is_canonical_amino_acid Select canonical amino acid residues.
is_canonical_nucleotide Select canonical nucleotide residues.
is_carbohydrate Select carbohydrate residues.
is_hetero Select hetero atoms.
is_ligand Select ligand atoms.
is_monoatomic_ion Select monoatomic ions.
is_nucleotide Select nucleotide residues.
is_peptide_backbone Select peptide backbone atoms.
is_phosphate_backbone Select phosphate backbone atoms.
is_polymer Select polymer atoms.
is_solvent Select solvent atoms.
linear_bond_continuity Select atoms with linear bond continuity.
not_amino_acids Select non-amino acid residues.
not_atom_names Select atoms not matching the specified atom names.
not_canonical_amino_acids Select non-canonical amino acid residues.
not_canonical_nucleotides Select non-canonical nucleotide residues.
not_carbohydrates Select non-carbohydrate residues.
not_chain_id Select atoms not in the specified chains.
not_element Select atoms not matching the specified elements.
not_hetero Select non-hetero atoms.
not_monoatomic_ions Select non-monoatomic ion atoms.
not_nucleotides Select non-nucleotide residues.
not_peptide_backbone Select non-peptide backbone atoms.
not_phosphate_backbone Select non-phosphate backbone atoms.
not_polymer Select non-polymer atoms.
not_res_id Select atoms not matching the specified residue IDs.
not_res_name Select atoms not matching the specified residue names.
not_solvent Select non-solvent atoms.
res_id Select atoms by residue ID.
res_name Select atoms by residue name.
reset Reset all pending selections and the mask
store_selection Evaluate and store the current selection as a named attribute on the Molecule

atom_name

entities.MoleculeSelector.atom_name(atom_name)

Select atoms by their name.

Parameters

Name Type Description Default
atom_name str or list of str or tuple of str or ndarray The atom name(s) to select. required

Returns

Name Type Description
Selector Returns self for method chaining.

chain_id

entities.MoleculeSelector.chain_id(chain_id)

Select atoms by chain identifier.

Parameters

Name Type Description Default
chain_id list of str or tuple of str or ndarray The chain identifier(s) to select. required

Returns

Name Type Description
Selector Returns self for method chaining.

element

entities.MoleculeSelector.element(element)

Select atoms by element symbol.

Parameters

Name Type Description Default
element list of str or tuple of str or ndarray The element symbol(s) to select. required

Returns

Name Type Description
Selector Returns self for method chaining.

evaluate_on_array

entities.MoleculeSelector.evaluate_on_array(array)

Evaluate this selection on the AtomArray.

Parameters

Name Type Description Default
array AtomArray or AtomArrayStack The atomic structure to evaluate the selection on. required

Returns

Name Type Description
ndarray Boolean mask array indicating which atoms match the selection criteria.

Notes

All of the selection operations that have been staged for this Selector are evaluated and combined with a logical AND, using the AtomArray as input.

is_amino_acid

entities.MoleculeSelector.is_amino_acid()

Select amino acid residues.

Returns

Name Type Description
Selector Returns self for method chaining.

is_backbone

entities.MoleculeSelector.is_backbone()

Select backbone atoms for peptide and nucleotide.

is_canonical_amino_acid

entities.MoleculeSelector.is_canonical_amino_acid()

Select canonical amino acid residues.

Returns

Name Type Description
Selector Returns self for method chaining.

is_canonical_nucleotide

entities.MoleculeSelector.is_canonical_nucleotide()

Select canonical nucleotide residues.

Returns

Name Type Description
Selector Returns self for method chaining.

is_carbohydrate

entities.MoleculeSelector.is_carbohydrate()

Select carbohydrate residues.

Returns

Name Type Description
Selector Returns self for method chaining.

is_hetero

entities.MoleculeSelector.is_hetero()

Select hetero atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

is_ligand

entities.MoleculeSelector.is_ligand()

Select ligand atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

is_monoatomic_ion

entities.MoleculeSelector.is_monoatomic_ion()

Select monoatomic ions.

Returns

Name Type Description
Selector Returns self for method chaining.

is_nucleotide

entities.MoleculeSelector.is_nucleotide()

Select nucleotide residues.

Returns

Name Type Description
Selector Returns self for method chaining.

is_peptide_backbone

entities.MoleculeSelector.is_peptide_backbone()

Select peptide backbone atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

is_phosphate_backbone

entities.MoleculeSelector.is_phosphate_backbone()

Select phosphate backbone atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

is_polymer

entities.MoleculeSelector.is_polymer()

Select polymer atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

is_solvent

entities.MoleculeSelector.is_solvent()

Select solvent atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

linear_bond_continuity

entities.MoleculeSelector.linear_bond_continuity()

Select atoms with linear bond continuity.

Returns

Name Type Description
Selector Returns self for method chaining.

not_amino_acids

entities.MoleculeSelector.not_amino_acids()

Select non-amino acid residues.

Returns

Name Type Description
Selector Returns self for method chaining.

not_atom_names

entities.MoleculeSelector.not_atom_names(atomname)

Select atoms not matching the specified atom names.

Parameters

Name Type Description Default
atomname str or list of str The atom name(s) to exclude. required

Returns

Name Type Description
Selector Returns self for method chaining.

not_canonical_amino_acids

entities.MoleculeSelector.not_canonical_amino_acids()

Select non-canonical amino acid residues.

Returns

Name Type Description
Selector Returns self for method chaining.

not_canonical_nucleotides

entities.MoleculeSelector.not_canonical_nucleotides()

Select non-canonical nucleotide residues.

Returns

Name Type Description
Selector Returns self for method chaining.

not_carbohydrates

entities.MoleculeSelector.not_carbohydrates()

Select non-carbohydrate residues.

Returns

Name Type Description
Selector Returns self for method chaining.

not_chain_id

entities.MoleculeSelector.not_chain_id(chain_id)

Select atoms not in the specified chains.

Parameters

Name Type Description Default
chain_id str or list of str The chain identifier(s) to exclude. required

Returns

Name Type Description
Selector Returns self for method chaining.

not_element

entities.MoleculeSelector.not_element(element)

Select atoms not matching the specified elements.

Parameters

Name Type Description Default
element str or list of str The element symbol(s) to exclude. required

Returns

Name Type Description
Selector Returns self for method chaining.

not_hetero

entities.MoleculeSelector.not_hetero()

Select non-hetero atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

not_monoatomic_ions

entities.MoleculeSelector.not_monoatomic_ions()

Select non-monoatomic ion atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

not_nucleotides

entities.MoleculeSelector.not_nucleotides()

Select non-nucleotide residues.

Returns

Name Type Description
Selector Returns self for method chaining.

not_peptide_backbone

entities.MoleculeSelector.not_peptide_backbone()

Select non-peptide backbone atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

not_phosphate_backbone

entities.MoleculeSelector.not_phosphate_backbone()

Select non-phosphate backbone atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

not_polymer

entities.MoleculeSelector.not_polymer()

Select non-polymer atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

not_res_id

entities.MoleculeSelector.not_res_id(num)

Select atoms not matching the specified residue IDs.

Parameters

Name Type Description Default
num int or list of int The residue ID(s) to exclude. required

Returns

Name Type Description
Selector Returns self for method chaining.

not_res_name

entities.MoleculeSelector.not_res_name(res_name)

Select atoms not matching the specified residue names.

Parameters

Name Type Description Default
res_name str or list of str The residue name(s) to exclude. required

Returns

Name Type Description
Selector Returns self for method chaining.

not_solvent

entities.MoleculeSelector.not_solvent()

Select non-solvent atoms.

Returns

Name Type Description
Selector Returns self for method chaining.

res_id

entities.MoleculeSelector.res_id(num)

Select atoms by residue ID.

Parameters

Name Type Description Default
num int or list of int The residue ID(s) to select. required

Returns

Name Type Description
Selector Returns self for method chaining.

res_name

entities.MoleculeSelector.res_name(res_name)

Select atoms by residue name.

Parameters

Name Type Description Default
res_name str or list of str The residue name(s) to select. required

Returns

Name Type Description
Selector Returns self for method chaining.

reset

entities.MoleculeSelector.reset()

Reset all pending selections and the mask

Returns

Name Type Description
self Selector Returns self for method chaining

store_selection

entities.MoleculeSelector.store_selection(name)

Evaluate and store the current selection as a named attribute on the Molecule

Parameters

Name Type Description Default
name str The name to store the selection under. required

Returns

Name Type Description
None

Raises

Name Type Description
ValueError If no selection has been made.