HTMD and moleculekit#

HTMD and moleculekit are two separate Python packages that work together. Knowing which package owns which feature makes both easier to navigate.

moleculekit: structures and frames#

moleculekit is the lower-level library. It handles everything that lives inside a single molecular system:

  • the Molecule class - per-atom arrays, the bond graph, periodic box info, and per-frame trajectory data;

  • file I/O for PDB, mmCIF/BCIF, PSF, PRMTOP, XTC, DCD, TRR, NetCDF, and others;

  • atom selection (string language and boolean masks);

  • geometry: alignment, distances, dihedrals, RMSD/RMSF, projections, interactions;

  • system preparation: protonation, non-standard residues, mutation, missing-sidechain and partial backbone repair, segmentation;

  • visualization via the built-in MolStar viewer and VMD/PyMOL bridges.

If you can do it without launching a simulation, it’s probably in moleculekit.

HTMD: campaigns of simulations#

HTMD builds on top of moleculekit and adds the machinery for running and analysing many simulations at once:

If it involves more than one trajectory, or a job queue, it’s in HTMD.

How they cooperate#

A typical HTMD workflow imports moleculekit objects indirectly through htmd.ui, which re-exports Molecule, the moleculekit projection metrics, viewer helpers, and friends:

from htmd.ui import *

mol = Molecule("3PTB")          # moleculekit Molecule
mol.view(viewer="molstar")      # moleculekit viewer

# moleculekit projection used as input to an HTMD AdaptiveMD run
metric = MetricDistance("name CA", "resname BEN", periodic="selections")

You can import directly from either package; htmd.ui exists for convenience so a single namespace covers everything you need in an analysis script.

Where to look#