Trajectory Load Helper
GitHub Link to Code.
MD trajectory loading strategies and utilities.
Handles the loading methodology for MD trajectories from files and directories. This class can be easily replaced or extended for different loading strategies. Supports nested directory structures and trajectory concatenation.
- class mdxplain.trajectory.helper.process_helper.trajectory_load_helper.TrajectoryLoadHelper
Internal utility class for loading MD trajectories from files and directories.
Supports nested directory structures and trajectory concatenation.
- static load_trajectories(data_input: List[Any] | str, concat: bool = False, stride: int = 1, selection: str | None = None, use_memmap: bool = False, chunk_size: int = 1000, cache_dir: str = './cache') Dict[str, List[Any]]
Load trajectories from various input types.
Parameters
- data_inputlist or str
List of trajectory objects or path to directory
- concatbool, default=False
Whether to concatenate trajectories per system
- strideint, default=1
Frame striding parameter
- selectionstr, optional
MDTraj selection string to apply to each trajectory before concatenation
- use_memmapbool, default=False
Whether to use memory-mapped DaskMDTrajectory for large files
- chunk_sizeint, default=1000
Chunk size for DaskMDTrajectory (only used when use_memmap=True)
- cache_dirstr, default=”./cache”
Cache directory for DaskMDTrajectory (only used when use_memmap=True)
Returns
- dict
Dictionary with ‘trajectories’ and ‘names’ keys containing list of loaded trajectory objects and their corresponding names
Examples
>>> # Load from trajectory list >>> trajs = [traj1, traj2, traj3] >>> result = TrajectoryLoadHelper.load_trajectories(trajs, concat=True) >>> print(f"Loaded {len(result['trajectories'])} trajectories") >>> >>> # Load from directory >>> result = TrajectoryLoadHelper.load_trajectories('../data', use_memmap=True) >>> # Load with selection >>> result = TrajectoryLoadHelper.load_trajectories('../data', selection='protein')