Registry / data / biotraj

biotraj

JSON →
library1.2.2pypypi✓ verified 24d ago

Biotraj provides basic functionality to load and handle molecular dynamics trajectory files, specifically designed for use with the Biotite package. It is a lightweight fork of MDTraj, with MDTraj's C-extensions and analysis functionality removed, focusing purely on efficient trajectory I/O. The current version is 1.2.2, with releases typically aligned with the Biotite ecosystem.

pip install biotraj
INSTALL
IMPORT
SIG · BIOTRAJ
B
biotraj
datapythonv1.2.2
Install
7.4s avg
Import
263ms
Disk
233MB
Pass rate
4/ 10
Env Coverage4 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.2.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 7.3s
py 3.11
✕ build_error
✓ 7.3s
py 3.12
✕ build_error
✓ 7.6s
py 3.13
✕ build_error
✓ 7.4s
py 3.9
✕ build_error
✕ build_error
233MB installed
● package 233MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

DCDTrajectoryFile
from biotraj import DCDTrajectoryFile
from biotraj import Trajectory
NetCDFTrajectoryFile
from biotraj import NetCDFTrajectoryFile
TRRTrajectoryFile
from biotraj import TRRTrajectoryFile

This quickstart demonstrates how to create a simple `biotite.structure.AtomArrayStack`, save it to an XTC file using Biotite's I/O, and then load it as a `biotraj.Trajectory` object. It illustrates the core process of reading trajectory data into a usable object within the Biotite ecosystem.

import biotite.structure as struc import biotite.structure.io.xtc as xtc import biotraj as bt import numpy as np import os # 1. Create a dummy AtomArray to represent a molecule atom1 = struc.Atom([0.0, 0.0, 0.0], atom_name="CA", res_name="ALA", chain_id="A", res_id=1, element="C") atom2 = struc.Atom([1.0, 0.0, 0.0], atom_name="N", res_name="ALA", chain_id="A", res_id=1, element="N") # 2. Create a 2-frame trajectory (AtomArrayStack) trajectory_coords = np.array([ [[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]], # Frame 1 [[0.1, 0.1, 0.1], [1.1, 0.1, 0.1]] # Frame 2 ]) traj_array = struc.AtomArray(trajectory_coords[0]) # Start with first frame's atoms traj_array = traj_array.stack_as_trajectory(struc.AtomArrayStack(trajectory_coords)) # 3. Save the AtomArrayStack as an XTC file using Biotite's I/O xtc_file = "dummy.xtc" with xtc.XTCFile(xtc_file, "w") as f: f.write(traj_array) # 4. Load the trajectory file using biotraj try: traj = bt.load(xtc_file) print(f"Loaded trajectory with {traj.n_frames} frames and {traj.n_atoms} atoms.") print(f"First frame coordinates:\n{traj.xyz[0]}") print(f"Second frame coordinates:\n{traj.xyz[1]}") except Exception as e: print(f"Error loading trajectory: {e}") finally: # Clean up the dummy file if os.path.exists(xtc_file): os.remove(xtc_file)
Debug
Known issues
gotchaBiotraj is a fork of MDTraj, but it specifically removes MDTraj's C-extensions and analysis capabilities. It is intended *only* for trajectory I/O and basic handling within the Biotite ecosystem, not as a drop-in replacement for MDTraj's full feature set.
fix
Use MDTraj if full analysis functionality is required. Use biotraj only for I/O with Biotite structures.
affects: All versions
gotchaBiotraj is tightly integrated with the Biotite ecosystem and primarily works with 'biotite.structure.AtomArray' and 'AtomArrayStack' objects. Users coming from other molecular dynamics libraries may need to convert their structures to Biotite's format before using biotraj for I/O.
fix
Ensure your molecular structures are converted to biotite.structure.AtomArray or AtomArrayStack objects. Refer to Biotite's documentation for structure conversion utilities.
affects: All versions
gotchaUnlike MDTraj, `biotraj.Trajectory` objects do not have an `atom_slice` property for generating a view of a subset of atoms. Instead, use the `select_atoms()` method, which returns a *new* Trajectory object containing only the selected atoms.
fix
Replace `traj.atom_slice(indices)` with `traj.select_atoms(indices)` and assign the result to a new variable.
affects: All versions
Upgrade
Version history
1.2.2latest on PyPI · released Nov 2, 2024
Audit
Dependencies
biotiterequiredCore dependency providing molecular structure data types and C-extensions for processing.
numpyrequiredFundamental package for numerical operations and array handling.
scipyrequiredScientific computing library, often used for advanced numerical operations.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
biotraj — pip install biotraj · libregistry