Trajectory Service Helper
GitHub Link to Code.
Helper for common trajectory service operations.
- class mdxplain.analysis.structure.helper.trajectory_service_helper.TrajectoryServiceHelper(pipeline_data: PipelineData)
Helper class for common operations in trajectory services.
Eliminates code duplication between RMSF services by providing common trajectory resolution, atom selection, and result mapping.
- __init__(pipeline_data: PipelineData) None
Initialize helper with pipeline data.
Parameters
- pipeline_dataPipelineData
Pipeline context with trajectory data and settings.
- resolve_trajectories_and_atoms(traj_selection: int | str | List[int | str] | all, atom_selection: str) Tuple[List[Trajectory], List[str], ndarray]
Resolve trajectory and atom selections to concrete objects.
Parameters
- traj_selectionUnion[int, str, list[Union[int, str]], ‘all’]
Selection describing which trajectories to analyze.
- atom_selectionstr
MDTraj atom selection string.
Returns
- tuple
Trajectories, trajectory names, and atom indices.
- build_result_map(trajectory_names: List[str], arrays: List[ndarray], cross_trajectory: bool) Dict[str, ndarray]
Create mapping from trajectory names to result arrays.
Parameters
- trajectory_nameslist[str]
Names of processed trajectories.
- arrayslist[np.ndarray]
Result arrays for each trajectory.
- cross_trajectorybool
Whether calculation was cross-trajectory.
Returns
- dict[str, np.ndarray]
Mapping of names to arrays.
- map_reference_to_local_index(traj_selection: int | str | List[int | str] | all, reference_traj_selection: int | str | List[int | str] | all) int
Map global reference trajectory index to local index within selection.
Parameters
- traj_selectionUnion[int, str, list[Union[int, str]], ‘all’]
Selection describing which trajectories are selected.
- reference_traj_selectionUnion[int, str, list[Union[int, str]], ‘all’]
Selection describing the reference trajectory.
Returns
- int
Local index of reference trajectory within selected trajectories.
Raises
- ValueError
If reference trajectory is not in selected trajectories.
Examples
>>> helper.map_reference_to_local_index([1, 2, 3], 2) 1