skillfed

mdtraj

MDTraj: A modern, open library for the analysis of molecular dynamics trajectories

mdtraj v1.11.1.post2 221.1K downloads/30d#9,284 on PyPI0
Copyleft license LGPLv2.1+ Active released

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 mdtraj

uv

uv add mdtraj

poetry

poetry add mdtraj

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: Science/ResearchLicense :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)Operating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: UnixProgramming Language :: CProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Bio-InformaticsTopic :: Scientific/Engineering :: Chemistry

Tags

molecular dynamics trajectory analysisMD trajectory file format conversionRMSD calculations proteinhydrogen bonding analysissecondary structure prediction MDmolecular dynamics post-processingtrajectory file reader writer
molecular-dynamicscomputational-chemistrytrajectory-analysis

More Bio-Informatics packages