trajectory_adapters
Optional trajectory adapters for analysis libraries.
These helpers intentionally import MDAnalysis and MDTraj lazily so the core MLX engine remains dependency-light.
import mlx_atomistic.trajectory_adapters
Classes
Section titled “Classes”OptionalTrajectoryDependencyError
Section titled “OptionalTrajectoryDependencyError”class OptionalTrajectoryDependencyError(RuntimeError)Raised when an optional trajectory analysis dependency is unavailable.
Functions
Section titled “Functions”load_mdanalysis_universe
Section titled “load_mdanalysis_universe”def load_mdanalysis_universe(topology_path: str | Path, trajectory_path: str | Path | None = None, **kwargs = {})Load a topology/trajectory pair as an MDAnalysis Universe.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
topology_path | str | Path | ||
trajectory_path | str | Path | None | None | |
**kwargs | {} |
mdanalysis_universe_from_arrays
Section titled “mdanalysis_universe_from_arrays”def mdanalysis_universe_from_arrays(topology_path: str | Path, positions_angstrom: np.ndarray, *, time_ps: np.ndarray | None = None, dt_ps: float | None = None)Attach in-memory Angstrom coordinates to an MDAnalysis topology.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
topology_path | str | Path | ||
positions_angstrom | np.ndarray | ||
time_ps | np.ndarray | None | None | |
dt_ps | float | None | None |
trajectory_record_to_mdanalysis
Section titled “trajectory_record_to_mdanalysis”def trajectory_record_to_mdanalysis(topology_path: str | Path, record: TrajectoryRecord)Convert a native MLX trajectory record into an MDAnalysis Universe.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
topology_path | str | Path | ||
record | TrajectoryRecord |
trajectory_record_to_mdtraj
Section titled “trajectory_record_to_mdtraj”def trajectory_record_to_mdtraj(topology_path: str | Path, record: TrajectoryRecord)Convert a native MLX trajectory record into an MDTraj Trajectory.
mlx_atomistic stores coordinates in Angstrom. MDTraj stores coordinates in
nanometers, so coordinates are converted by dividing by 10.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
topology_path | str | Path | ||
record | TrajectoryRecord |
write_mdtraj_trajectory
Section titled “write_mdtraj_trajectory”def write_mdtraj_trajectory(topology_path: str | Path, record: TrajectoryRecord, trajectory_path: str | Path, *, file_format: str | None = None) -> PathWrite a native MLX trajectory record through MDTraj.
Supported first-class runner formats are DCD and XTC. MLX stores
coordinates in Angstrom; trajectory_record_to_mdtraj handles MDTraj’s
nanometer convention before writing.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
topology_path | str | Path | ||
record | TrajectoryRecord | ||
trajectory_path | str | Path | ||
file_format | str | None | None |
Returns
Path