Skip to content
BaratiLabPublic

About

Analysis and simulation of molecular ensembles. Works with MDTraj scripts. Plugins for simulation, Markov models, prediction and agents.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Dynome

Website and documentation: https://baratilab.github.io/dynome/

Analysis and simulation of molecular ensembles. Dynome is built to replace MDTraj as the community default: existing MDTraj scripts keep working, and the same object holds conformations from MD, generative emulators and structure predictors.

The name means the complete set of a molecule's motions, as "genome" means the complete set of genes.

Status: 0.4.0. The core, native PDB, mmCIF and XYZ readers, the compatibility layer, the analysis functions below and the chunked on-disk store are implemented and tested against MDTraj. RMSD, distances and surface area have an optional PyTorch backend. Seven plugins are implemented: kinetics (plugins/dynome-kinetics), simulation (plugins/dynome-sim), the agent interface (plugins/dynome-agents), the viewer (plugins/dynome-view), structure prediction with Boltz-2 (plugins/dynome-predict), emulation with BioEmu-2 (plugins/dynome-emulate) and compiled kernels (plugins/dynome-accel).

Install

pip install dynome              # core: needs only NumPy
pip install "dynome[formats]"   # adds XTC, DCD, HDF5, NetCDF and others through MDTraj

Use

import dynome as dn

ens = dn.load("protein.pdb")
ca = ens.topology.select("protein and name CA")
r = dn.rmsd(ens, ens, frame=0, atom_indices=ca)      # nm
phi_idx, phi = dn.compute_phi(ens)                    # radians
sasa = dn.shrake_rupley(ens, mode="residue")          # nm^2

Moving from MDTraj

Change one line:

import dynome.compat as md      # was: import mdtraj as md

t = md.load("traj.xtc", top="protein.pdb")
md.rmsd(t, t, 0)
md.compute_contacts(t, scheme="closest-heavy")

Covered so far: load, load_pdb, load_frame, load_topology, join, Trajectory, Topology, the selection language, rmsd, rmsf, compute_distances, compute_displacements, compute_angles, compute_dihedrals, compute_phi, compute_psi, compute_omega, compute_rg, compute_center_of_mass, compute_center_of_geometry, compute_contacts, compute_neighbors and shrake_rupley.

Not yet covered: secondary structure (compute_dssp), hydrogen-bond detection, NMR observables and compute_chi*. Topologies read from PDB carry only CONECT bonds; standard residue bonds are not generated yet.

Known differences from MDTraj, each pinned by a test:

  • Atom names are kept as written in the file. MDTraj renames some by default; pass standard_names=False to MDTraj to get the same names.
  • rmsf with atom_indices equals the RMSF of those atoms sliced out first. MDTraj's own two routes to that number disagree with each other.
  • shrake_rupley treats frames independently. MDTraj's value for a frame can shift by about 0.1% depending on which frames are computed with it.

Ensembles are 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.

Backends and speed

dn.set_backend("auto")              # GPU through PyTorch when one is visible, else NumPy
with dn.use_backend("torch", device="cuda"):
    dn.shrake_rupley(ens)

The PyTorch backend covers rmsd, compute_distances and shrake_rupley. It is tested on CPU against the NumPy kernels and was checked on an NVIDIA A40 (see below).

pip install dynome-accel adds a compiled, multi-threaded RMSD kernel that the NumPy backend uses by itself; it is about twice as fast as MDTraj (8.5 ms against 18.4 ms for 20,000 frames of 423 atoms on 2 cores). dn.use_compiled(False) switches it off.

Without it, the NumPy kernels are slower than MDTraj's compiled ones. python benchmarks/run.py prints the current numbers. On a 2-core machine, 423 atoms:

dynome (NumPy) MDTraj
RMSD, 1000 frames 5.3 ms 0.9 ms
Distances, 1000 frames x 5000 pairs 27 ms 19.8 ms
Contacts, 20 frames 9.1 ms 8.2 ms
Surface area, 5 frames 140 ms 72 ms

Plugins

Other packages add sources (things that make ensembles), analyses and sinks through the dynome.plugins entry-point group. See dynome/plugins.py for the contract.

Plugin Status
dynome-kinetics Implemented: Markov state models from any time-ordered ensemble
dynome-sim Implemented: OpenMM preparation, runs written to stores, adaptive sampling
dynome-agents Implemented: a dynome command line and an MCP server over 14 typed tools
dynome-view Implemented: self-contained interactive 3D pages with linked plots, figures, exports to PyMOL, VMD and ChimeraX
dynome-predict Implemented: Boltz-2 predictions as ensembles with confidence annotations
dynome-emulate Implemented: BioEmu-2 equilibrium samples as ensembles
dynome-accel Implemented: compiled, multi-threaded RMSD, about twice as fast as MDTraj

Together the two plugins close the loop from starting structures to a kinetic model:

import dynome as dn, dynome_sim as ds, dynome_kinetics as dk

system, starts = ds.prepare(seeds, frames=range(seeds.n_frames), solvent="implicit")
data, history = ds.adaptive_sampling(system, starts, rounds=10, runs_per_round=8,
                                     n_steps=50_000, report_interval=500,
                                     features=["backbone_torsions"], store="adaptive.dynome")
model = dk.build_msm(data, lag=20)
print(model.summary())

Units

Nanometres, radians, picoseconds and degrees for unit-cell angles, as in MDTraj.

Tests

pip install -e ".[test]"
pytest

The suite compares every function with MDTraj on a 20-model NMR ensemble (PDB entry 2EQQ).

Licence

MIT. Dynome contains no MDTraj source code; MDTraj is an optional dependency used for file formats and as the reference in tests.

Measured on a GPU

docs/gpu-verification-2026-11-27.md records a run on an NVIDIA A40: the PyTorch backend against NumPy and MDTraj, a 16 ns OpenMM simulation into a store with a Markov model built from it, and Boltz-2 predictions carried into simulation. Short version: GPU surface area is about 7x faster than MDTraj and distances are level.

docs/gpu-verification-2026-11-28.md records BioEmu-2 run through dynome-emulate on an A100, and the compiled RMSD kernel against MDTraj at 1, 8 and 31 threads.

About

Analysis and simulation of molecular ensembles. Works with MDTraj scripts. Plugins for simulation, Markov models, prediction and agents.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages