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
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)
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.