Skip to content

Ensembles

More than trajectories

ens = dn.Ensemble(xyz, topology,
                  time=None,                       # emulator samples have no time order
                  weights=w,                       # statistical weight per frame
                  annotations={"plddt": plddt},    # per-atom or per-residue arrays
                  provenance={"source": "emulator", "model": "..."})

ens.average(dn.compute_rg(ens))     # weighted ensemble average
ens.effective_sample_size           # Kish effective number of frames
ens.resample(1000, seed=0)          # unweighted draw by weight
ens.save("run.dyn.npz")             # keeps weights, annotations and provenance

Larger than memory

A store is a directory of fixed-size frame chunks in plain NumPy files. It is read lazily, and every analysis function accepts it and works one chunk at a time.

dn.save(ens, "run.dynome")                       # write a store from memory
dn.convert_to_store("traj.xtc", "run.dynome", top="protein.pdb")   # or stream a file into one

lazy = dn.open_store("run.dynome")               # opens instantly; no coordinates read
dn.compute_rg(lazy)                              # streams chunk by chunk
dn.rmsd(lazy, lazy, frame=0)
lazy[10_000:10_100]                              # just those frames, as an in-memory Ensemble
for chunk in lazy.iter_chunks(atom_indices=ca):  # or stream by hand
    ...

sim = dn.create_store("sim.dynome", topology)    # write incrementally, e.g. from a simulation
sim.append(xyz_block, time=t_block)

An interrupted append leaves the store at its previous length. Stores are uncompressed float32, so they take about 12 bytes per atom per frame. A stored ensemble is never modified in place: superpose is not available on it, and load() brings it into memory.