Selection

This module defines Selection class for handling arbitrary subsets of atom.

class Selection(ag, indices, selstr, acsi=None, **kwargs)[source]

A class for accessing and manipulating attributes of selection of atoms in an AtomGroup instance. Instances can be generated using select() method. Following built-in functions are customized for this class:

copy()

Returns a copy of atoms (and atomic data) in an AtomGroup instance.

getACSIndex()

Returns index of the coordinate set.

getACSLabel()

Returns active coordinate set label.

getAltlocs()

Return a copy of alternate location indicators. Alternate location indicators can be used in atom selections, e.g. 'altloc A B', 'altloc _'.

getAnisous()

Return a copy of anisotropic temperature factors.

getAnistds()

Return a copy of standard deviations for anisotropic temperature factors.

getAtomGroup()

Returns associated atom group.

getBetas()

Return a copy of β-values (or temperature factors). β-values can be used in atom selections, e.g. 'beta 555.55', 'beta 0 to 500', 'beta 0:500', 'beta < 500'.

getCSLabels()

Returns coordinate set labels.

getCharges()

Return a copy of partial charges. Partial charges can be used in atom selections, e.g. 'charge 1', 'abs(charge) == 1', 'charge < 0'.

getChids()

Return a copy of chain identifiers. Chain identifiers can be used in atom selections, e.g. 'chain A', 'chid A B C', 'chain _'. Note that chid is a synonym for chain.

getChindices()

Return a copy of chain indices. Chain indices are assigned to subsets of atoms with distinct pairs of chain identifier and segment name. Chain indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Chain indices can be used in atom selections, e.g. 'chindex 0'.

getCoords()

Returns a copy of coordinates from the active coordinate set.

getCoordsets(indices=None)

Returns coordinate set(s) at given indices, which may be an integer or a list/array of integers.

getData(label)

Returns a copy of data associated with label, if it is present.

getDataLabels(which=None)

Returns data labels. For which='user', return only labels of user provided data.

getDataType(label)

Returns type of the data (i.e. data.dtype) associated with label, or None label is not used.

getElements()

Return a copy of element symbols. Element symbols can be used in atom selections, e.g. 'element C O N'.

getFlagLabels(which=None)

Returns flag labels. For which='user', return labels of user or parser (e.g. hetatm) provided flags, for which='all' return all possible Atom Flags labels in addition to those present in the instance.

getFlags(label)

Returns a copy of atom flags for given label, or None when flags for label is not set.

getFragindices()

Return a copy of fragment indices. Fragment indices are assigned to connected subsets of atoms. Bonds needs to be set using AtomGroup.setBonds() or AtomGroup.inferBonds(). Fragment indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Fragment indices can be used in atom selections, e.g. 'fragindex 0', 'fragment 1'. Note that fragment is a synonym for fragindex.

getHierView(**kwargs)[source]

Returns a hierarchical view of the atom selection.

getIcodes()

Return a copy of insertion codes. Insertion codes can be used in atom selections, e.g. 'icode A', 'icode _'.

getIndices()

Returns a copy of the indices of atoms.

getMasses()

Return a copy of masses. Masses can be used in atom selections, e.g. '12 <= mass <= 13.5'.

getNames()

Return a copy of names. Names can be used in atom selections, e.g. 'name CA CB'.

getOccupancies()

Return a copy of occupancy values. Occupancy values can be used in atom selections, e.g. 'occupancy 1', 'occupancy > 0'.

getRadii()

Return a copy of radii. Radii can be used in atom selections, e.g. 'radii < 1.5', 'radii ** 2 < 2.3'.

getResindices()

Return a copy of residue indices. Residue indices are assigned to subsets of atoms with distinct sequences of residue number, insertion code, chain identifier, and segment name. Residue indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Residue indices can be used in atom selections, e.g. 'resindex 0'.

getResnames()

Return a copy of residue names. Residue names can be used in atom selections, e.g. 'resname ALA GLY'.

getResnums()

Return a copy of residue numbers. Residue numbers can be used in atom selections, e.g. 'resnum 1 2 3', 'resnum 120A 120B', 'resnum 10 to 20', 'resnum 10:20:2', 'resnum < 10'. Note that resid is a synonym for resnum.

getSecclasses()

Return a copy of secondary structure classs. Secondary structure classs can be used in atom selections, e.g. 'secclass 2', 'secclass -1'.

getSecids()

Return a copy of secondary structure identifiers. Secondary structure identifiers can be used in atom selections, e.g. 'secid A B', 'secid 1 2'.

getSecindices()

Return a copy of secondary structure indexs. Secondary structure indexs can be used in atom selections, e.g. 's', 'e', 'c', 'i', 'n', 'd', 'e', 'x', ' ', '2'.

getSecstrs()

Return a copy of secondary structure assignments. Secondary structure assignments can be used in atom selections, e.g. 'secondary H E', 'secstr H E'. Note that secstr is a synonym for secondary.

getSegindices()

Return a copy of segment indices. Segment indices are assigned to subsets of atoms with distinct segment names. Segment indices start from zero, are incremented by one, and are assigned in the order of appearance in AtomGroup instance. Segment indices can be used in atom selections, e.g. 'segindex 0'.

getSegnames()

Return a copy of segment names. Segment names can be used in atom selections, e.g. 'segment PROT', 'segname PROT'. Note that segname is a synonym for segment.

getSelstr()[source]

Returns selection string that selects this atom subset.

getSequence(**kwargs)

Returns one-letter sequence string for amino acids. When allres keyword argument is True, sequence will include all residues (e.g. water molecules) in the chain and X will be used for non-standard residue names.

getSerials()

Return a copy of serial numbers (from file). Serial numbers can be used in atom selections, e.g. 'serial 1 2 3', 'serial 1 to 10', 'serial 1:10:2', 'serial < 10'.

getTitle()

Returns title of the instance.

getTypes()

Return a copy of types. Types can be used in atom selections, e.g. 'type CT1 CT2 CT3'.

isDataLabel(label)

Returns True if data associated with label is present.

isFlagLabel(label)

Returns True if flags associated with label are present.

iterAcceptors()

Yield acceptors formed by the atom. Use setAcceptors() for setting acceptors.

iterAngles()

Yield angles formed by the atom. Use setAngles() for setting angles.

iterAtoms()

Yield atoms.

iterBonds()

Yield bonds formed by the atom. Use setBonds() or inferBonds() for setting bonds.

iterCoordsets()

Yield copies of coordinate sets.

iterCrossterms()

Yield crossterms formed by the atom. Use setCrossterms() for setting crossterms.

iterDihedrals()

Yield dihedrals formed by the atom. Use setDihedrals() for setting dihedrals.

iterDonors()

Yield donors formed by the atom. Use setDonors() for setting donors.

iterImpropers()

Yield impropers formed by the atom. Use setImpropers() for setting impropers.

iterNBExclusions()

Yield nbexclusions formed by the atom. Use setNBExclusions() for setting nbexclusions.

numAtoms(flag=None)

Returns number of atoms, or number of atoms with given flag.

numCoordsets()

Returns number of coordinate sets.

select(selstr, **kwargs)

Returns atoms matching selstr criteria. See select module documentation for details and usage examples.

setACSIndex(index)

Set coordinates at index active.

setAltlocs(data)

Set alternate location indicators. Alternate location indicators can be used in atom selections, e.g. 'altloc A B', 'altloc _'.

setAnisous(data)

Set anisotropic temperature factors.

setAnistds(data)

Set standard deviations for anisotropic temperature factors.

setBetas(data)

Set β-values (or temperature factors). β-values can be used in atom selections, e.g. 'beta 555.55', 'beta 0 to 500', 'beta 0:500', 'beta < 500'.

setCharges(data)

Set partial charges. Partial charges can be used in atom selections, e.g. 'charge 1', 'abs(charge) == 1', 'charge < 0'.

setChids(data)

Set chain identifiers. Chain identifiers can be used in atom selections, e.g. 'chain A', 'chid A B C', 'chain _'. Note that chid is a synonym for chain.

setCoords(coords)

Set coordinates in the active coordinate set.

setData(label, data)

Update data associated with label.

Raises:AttributeError – when label is not in use or read-only
setElements(data)

Set element symbols. Element symbols can be used in atom selections, e.g. 'element C O N'.

setFlags(label, value)

Update flag associated with label.

Raises:AttributeError – when label is not in use or read-only
setIcodes(data)

Set insertion codes. Insertion codes can be used in atom selections, e.g. 'icode A', 'icode _'.

setMasses(data)

Set masses. Masses can be used in atom selections, e.g. '12 <= mass <= 13.5'.

setNames(data)

Set names. Names can be used in atom selections, e.g. 'name CA CB'.

setOccupancies(data)

Set occupancy values. Occupancy values can be used in atom selections, e.g. 'occupancy 1', 'occupancy > 0'.

setRadii(data)

Set radii. Radii can be used in atom selections, e.g. 'radii < 1.5', 'radii ** 2 < 2.3'.

setResnames(data)

Set residue names. Residue names can be used in atom selections, e.g. 'resname ALA GLY'.

setResnums(data)

Set residue numbers. Residue numbers can be used in atom selections, e.g. 'resnum 1 2 3', 'resnum 120A 120B', 'resnum 10 to 20', 'resnum 10:20:2', 'resnum < 10'. Note that resid is a synonym for resnum.

setSecclasses(data)

Set secondary structure classs. Secondary structure classs can be used in atom selections, e.g. 'secclass 2', 'secclass -1'.

setSecids(data)

Set secondary structure identifiers. Secondary structure identifiers can be used in atom selections, e.g. 'secid A B', 'secid 1 2'.

setSecindices(data)

Set secondary structure indexs. Secondary structure indexs can be used in atom selections, e.g. 's', 'e', 'c', 'i', 'n', 'd', 'e', 'x', ' ', '2'.

setSecstrs(data)

Set secondary structure assignments. Secondary structure assignments can be used in atom selections, e.g. 'secondary H E', 'secstr H E'. Note that secstr is a synonym for secondary.

setSegnames(data)

Set segment names. Segment names can be used in atom selections, e.g. 'segment PROT', 'segname PROT'. Note that segname is a synonym for segment.

setSerials(data)

Set serial numbers (from file). Serial numbers can be used in atom selections, e.g. 'serial 1 2 3', 'serial 1 to 10', 'serial 1:10:2', 'serial < 10'.

setTypes(data)

Set types. Types can be used in atom selections, e.g. 'type CT1 CT2 CT3'.

toAtomGroup()

Returns a copy of atoms (and atomic data) in an AtomGroup instance.

toTEMPyAtoms()

Returns a BioPy.PDB Atom or Structure object as appropriate

toTEMPyStructure()

Returns a BioPy.PDB Atom or Structure object as appropriate

update()[source]

Update selection.