Skip to content

Core objects

dynome.Ensemble

Conformations of one molecular system.

Unlike a trajectory, an ensemble need not be ordered in time: frames may come from MD, from a generative emulator or from a structure predictor. Each frame has a statistical weight, and the ensemble records where it came from.

Parameters

xyz : array, shape (n_frames, n_atoms, 3) or (n_atoms, 3), nanometres topology : Topology time : array (n_frames,) in picoseconds, or None when frames have no time order unitcell_lengths, unitcell_angles : arrays (n_frames, 3) or (3,), nm and degrees, or None weights : array (n_frames,), unnormalised statistical weights; None means uniform annotations : dict of named arrays, per atom or per residue (e.g. predictor confidence) provenance : dict describing the source (e.g. {"source": "md", "engine": "openmm"}) members : int array (n_frames,), which independent run or sample batch a frame belongs to

effective_sample_size property

Kish effective number of frames: 1 / sum(w^2). Equals n_frames for uniform weights.

weights property writable

Normalised per-frame weights (sum to 1). Uniform unless set.

atom_slice(atom_indices)

A new ensemble with only the given atoms (indices must be increasing).

average(values)

Weighted ensemble average of a per-frame observable (first axis = frames).

center_coordinates(mass_weighted=False)

Move each frame's centre (of geometry, or of mass) to the origin, in place.

join(other, check_topology=True)

Append the frames of one or more ensembles. Each joined ensemble becomes new members.

Time is kept only if every part has it. Weights are kept as given, so parts that carry weights should use a common scale; an unweighted part counts 1 per frame.

resample(n, seed=None)

Draw n frames with probability equal to their weights; the result is unweighted.

stack(other)

Combine the atoms of two ensembles with the same number of frames.

superpose(reference=None, frame=0, atom_indices=None, ref_atom_indices=None, parallel=True)

Rotate and translate every frame onto reference[frame], in place (least squares).

dynome.Topology

Atoms grouped into residues grouped into chains, stored as flat NumPy arrays.

Atoms of one residue are contiguous, and residues of one chain are contiguous.

join(other)

This topology followed by other (atoms, residues and chains appended).

select(selection)

Atom indices matching an MDTraj-style selection string, e.g. "name CA and resid 0 to 9".

select_pairs(selection1, selection2)

Unique atom pairs (i < j) with one atom from each selection.

subset(atom_indices)

A new topology holding only the given atoms, in the order given (must be increasing).

dynome.load(path, top=None, stride=None, atom_indices=None)

Load an ensemble from a file.

top is a Topology, an Ensemble, or the path of a structure file; it is needed for coordinate-only formats such as XTC or DCD.

dynome.save(ens, path, **kwargs)

Write an ensemble; the format follows the file extension.