Conformational Ensemble

This module defines a class for handling ensembles of conformations.

class Ensemble(title='Unknown')[source]

A class for analysis of arbitrary conformational ensembles.

Indexing (e.g. ens[0]) returns a Conformation instance that points to a coordinate set in the ensemble. Slicing (e.g. ens[0:10]) returns an Ensemble instance that contains a copy of the subset of conformations (coordinate sets).

Instantiate with a title or a Atomic instance. All coordinate sets from atomic instances will be added to the ensemble.

addCoordset(coords, **kwargs)[source]

Add coordinate set(s) to the ensemble.

Parameters:
  • coords – must be a ndarray with suitable data type, shape and dimensionality, or an object with getCoordsets() method.
  • data (dict) – associated data to be added along with coords.
delCoordset(index)[source]

Delete a coordinate set from the ensemble.

delData(label)[source]

Return data associated with label and remove from the instance. If data associated with label is not found, return None.

deselect()[source]

Undoes the selection.

getAtoms(selected=True)[source]

Returns associated/selected atoms.

getConformation(index)[source]

Returns conformation at given index.

getCoords(selected=True)[source]

Returns a copy of reference coordinates for selected atoms.

getCoordsets(indices=None, selected=True)[source]

Returns a copy of coordinate set(s) at given indices, which may be an integer, a list of integers or None. None returns all coordinate sets. For reference coordinates, use getCoords() method.

getData(label)[source]

Returns a copy of the data array associated with label, or None if such data is not present.

getDataLabels(which=None)[source]

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

getDataType(label)[source]

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

getDefvecs(pairwise=False)[source]

Calculate and return deformation vectors (defvecs). Note that you might need to align the conformations using superpose() or iterpose() before calculating defvecs.

Parameters:pairwise (bool) – if True then it will return pairwise defvecs as an n-by-n matrix. n is the number of conformations.
getDeviations()[source]

Returns deviations from reference coordinates for selected atoms. Conformations can be aligned using one of superpose() or iterpose() methods prior to calculating deviations.

getIndices()[source]

Returns a copy of indices of selected columns

getMSFs()[source]

Returns mean square fluctuations (MSFs) for selected atoms. Conformations can be aligned using one of superpose() or iterpose() methods prior to MSF calculation.

getRMSDs(pairwise=False)[source]

Returns root mean square deviations (RMSDs) for selected atoms. Conformations can be aligned using one of superpose() or iterpose() methods prior to RMSD calculation.

Parameters:pairwise (bool) – if True then it will return pairwise RMSDs as an n-by-n matrix. n is the number of conformations.
getRMSFs()[source]

Returns root mean square fluctuations (RMSFs) for selected atoms. Conformations can be aligned using one of superpose() or iterpose() methods prior to RMSF calculation.

getTitle()[source]

Returns title of the ensemble.

getWeights(selected=True)[source]

Returns a copy of weights of selected atoms.

isDataLabel(label)[source]

Returns True if data associated with label is present.

isSelected()[source]

Returns if a subset of atoms are selected.

iterCoordsets()[source]

Iterate over coordinate sets. A copy of each coordinate set for selected atoms is returned. Reference coordinates are not included.

iterpose(rmsd=0.0001, quiet=False)[source]

Iteratively superpose the ensemble until convergence. Initially, all conformations are aligned with the reference coordinates. Then mean coordinates are calculated, and are set as the new reference coordinates. This is repeated until reference coordinates do not change. This is determined by the value of RMSD between the new and old reference coordinates. Note that at the end of the iterative procedure the reference coordinate set will be average of conformations in the ensemble.

Parameters:rmsd (float) – change in reference coordinates to determine convergence, default is 0.0001 Å RMSD
numAtoms(selected=True)[source]

Returns number of atoms.

numConfs()[source]

Returns number of conformations.

numCoordsets()

Returns number of conformations.

numSelected()[source]

Returns number of selected atoms. Number of all atoms will be returned if a selection is not made. A subset of atoms can be selected by passing a selection to setAtoms().

select(selection)[source]

Selects columns corresponding to a part of the atoms.

setAtoms(atoms)[source]

Set atoms or specify a selection of atoms to be considered in calculations and coordinate requests. When a selection is set, corresponding subset of coordinates will be considered in, for example, alignments and RMSD calculations. Setting atoms also allows some functions to access atomic data when needed. For example, Ensemble and Conformation instances become suitable arguments for writePDB(). Passing None as atoms argument will deselect atoms.

setCoords(coords)[source]

Set coords as the ensemble reference coordinate set. coords may be an array with suitable data type, shape, and dimensionality, or an object with getCoords() method.

setData(label, data)[source]

Store atomic data under label, which must:

  • start with a letter
  • contain only alphanumeric characters and underscore
  • not be a reserved word (see listReservedWords())

data must be a list() or a ndarray and its length must be equal to the number of atoms. If the dimension of the data array is 1, i.e. data.ndim==1, label may be used to make atom selections, e.g. "label 1 to 10" or "label C1 C2". Note that, if data with label is present, it will be overwritten.

setTitle(title)[source]

Set title of the ensemble.

setWeights(weights)[source]

Set atomic weights.

superpose(**kwargs)[source]

Superpose the ensemble onto the reference coordinates.

Parameters:ref (int) – index of the reference coordinate. If None, the average coordinate will be assumed as the reference. Default is None