mdtraj
MDTraj: A modern, open library for the analysis of molecular dynamics trajectories
What it is and what it does
MDTraj is a Python library for reading, writing, and analyzing molecular dynamics simulation trajectories. It abstracts over many trajectory file formats (xtc, trr, dcd, pdb, netcdf, gsd, and others) and provides a unified interface for structural analysis. The library emphasizes speed and vectorized operations, with optimized RMSD calculations and built-in functions for computing bonds, angles, dihedrals, hydrogen bonding networks, and secondary structure assignments.
The package is designed for computational chemistry and biophysics researchers who need to post-process MD simulations. It depends on numpy, scipy, pyparsing, and packaging. The library is in maintenance mode—bug fixes and documentation improvements are welcome, but major new features are not actively planned. It requires Python 3.11 or later and is available as prebuilt wheels for current Python versions on macOS, Linux, and Windows.
Use it for:
- Load and convert molecular dynamics trajectories between different file formats (xtc, dcd, pdb, netcdf) for interoperability.
- Calculate root-mean-square deviation (RMSD) between protein conformations to measure structural similarity over time.
- Identify and analyze hydrogen bonding patterns and networks within a trajectory ensemble.
- Assign secondary structure (alpha helix, beta sheet) to protein residues across trajectory frames.
- Extract and analyze dihedral angles, bond lengths, and other geometric properties for validation or feature extraction.
- Prepare trajectory data for downstream machine learning or statistical analysis pipelines.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
MDTraj reads, writes, and analyzes molecular dynamics trajectories in multiple formats, providing fast RMSD calculations and structural analysis functions like hydrogen bonding and secondary structure assignment.
Yes, if you work with molecular dynamics simulations and need trajectory analysis. The library is stable, well-maintained for bug fixes, and provides a comprehensive API for common MD post-processing tasks. The LGPLv2.1+ copyleft license requires careful review if you plan to distribute derivative works or link it into proprietary software. No known security vulnerabilities.
Install
mdtraj on PyPI
pip
pip install mdtrajuv
uv add mdtrajpoetry
poetry add mdtrajInstalling mdtraj
Before you install
Medium install friction with prebuilt wheels for Python 3.11–3.14 across macOS, Linux, and Windows. Last release 37 days ago; repository active but in maintenance mode with no major feature development planned.
License in practice
Licensed under LGPLv2.1+, a copyleft license. Derivative works and modifications must be distributed under compatible terms; proprietary use requires careful review of linking and distribution obligations.
Quickstart
import mdtraj as md
traj = md.load('trajectory.xtc', top='topology.pdb')
rmsd = md.rmsd(traj, traj[0])
print(rmsd)
Requires a molecular dynamics trajectory file and topology file in a supported format (e.g., xtc, pdb, dcd, netcdf).
Verify before relying
- Whether the package's C extensions require compilation or system libraries on all supported platforms.
- Current state of community support and response time given maintenance-mode status.
- Performance characteristics of analysis functions beyond RMSD on large trajectories.
Package facts
| License | LGPLv2.1+ (copyleft) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 4 — numpy, scipy, pyparsing, packaging |
| Maintenance | actively maintained — 37 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 221,121/month — #9,284 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mdtraj-1.11.1.post2-cp311-cp311-macosx_10_9_universal2.whl; mdtraj-1.11.1.post2-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; mdtraj-1.11.1.post2-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; mdtraj-1.11.1.post2-cp311-cp311-win_amd64.whl; mdtraj-1.11.1.post2-cp312-cp312-macosx_10_13_universal2.whl; mdtraj-1.11.1.post2-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; mdtraj-1.11.1.post2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; mdtraj-1.11.1.post2-cp312-cp312-win_amd64.whl; mdtraj-1.11.1.post2-cp313-cp313-macosx_10_13_universal2.whl; mdtraj-1.11.1.post2-cp313-cp313-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; mdtraj-1.11.1.post2-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; mdtraj-1.11.1.post2-cp313-cp313-win_amd64.whl; mdtraj-1.11.1.post2-cp314-cp314-macosx_10_15_universal2.whl; mdtraj-1.11.1.post2-cp314-cp314-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl; mdtraj-1.11.1.post2-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; mdtraj-1.11.1.post2-cp314-cp314-win_amd64.whl
Tags
More Bio-Informatics packages
NetworkX provides data structures and…
permissive · top 1,000 on PyPI
biopythonBiopython provides Python tools for…
unclear · top 5,000 on PyPI
firecrawl-pyClient library for the Firecrawl API that…
permissive · top 5,000 on PyPI
intervaltreeA self-balancing interval tree data structure…
permissive · top 5,000 on PyPI
albumentationsAlbumentations applies image transformations to…
permissive · top 5,000 on PyPI
PubChemPyPubChemPy is a Python wrapper around the…
permissive · top 5,000 on PyPI
biotrajReads and writes molecular dynamics trajectory…
copyleft · top 5,000 on PyPI
MDAnalysisMDAnalysis reads and analyzes molecular…
copyleft · top 15,000 on PyPI
pydsspPyDSSP assigns protein secondary structure…
permissive · top 15,000 on PyPI
alchemlybalchemlyb parses molecular dynamics simulation…
permissive · top 15,000 on PyPI
pdb2pqrPDB2PQR prepares protein structures from PDB…
permissive · top 15,000 on PyPI
OpenMMOpenMM is a Python wrapper for a C++ molecular…
permissive · top 15,000 on PyPI
prolifProLIF generates interaction fingerprints from…
permissive · top 15,000 on PyPI
ViennaRNAViennaRNA provides Python bindings to a C…
unclear · top 15,000 on PyPI
aseASE provides Python tools for setting up,…
copyleft · top 5,000 on PyPI
py3DmolEmbeds an interactive 3D molecular viewer in…
permissive · top 15,000 on PyPI