RMSD Mean Service
GitHub Link to Code.
Mean RMSD service implementation.
- class mdxplain.analysis.structure.services.rmsd_mean_service.RMSDMeanService(pipeline_data: PipelineData | None)
Expose mean RMSD workflows.
The service mediates between the pipeline-facing API and the numerical
RMSDCalculator. It resolves trajectory selections and atom filters, ensures consistent reference handling, and delegates the computation using the mean metric.Examples
>>> service = RMSDMeanService(pipeline_data) >>> service.metric 'mean'
- __init__(pipeline_data: PipelineData | None) None
Store pipeline context with mean metric.
Ensures that valid pipeline data is supplied before storing configuration values for later use.
Parameters
- pipeline_dataPipelineData | None
Pipeline configuration controlling chunk size and memmap usage. Must not be
None.
Returns
- None
This initializer returns
None.
Examples
>>> service = RMSDMeanService(pipeline_data) >>> service.metric 'mean'
- to_reference(reference_traj: int = 0, reference_frame: int = 0, traj_selection: int | str | List[int | str] | all = 'all', atom_selection: str = 'all') Dict[str, ndarray]
Calculate RMSD against a fixed reference frame using mean metric.
Selects the requested trajectories, extracts the reference frame and delegates the numerical work to the calculator using the mean metric.
Parameters
- reference_trajint, optional
Index of the trajectory containing the reference frame. Defaults to
0.- reference_frameint, optional
Frame index within the reference trajectory. Defaults to
0.- traj_selectionUnion[int, str, list[Union[int, str]], ‘all’], optional
Selection describing the trajectories to process. Defaults to
"all".- atom_selectionstr, optional
MDTraj atom selection string forwarded to the calculation. Defaults to
"all".
Returns
- dict[str, np.ndarray]
Mapping of trajectory names to RMSD arrays.
Examples
>>> service = RMSDMeanService(pipeline_data) >>> service.to_reference() {'traj_0': array([...])}
- frame_to_frame(lag: int = 1, traj_selection: int | str | List[int | str] | all = 'all', atom_selection: str = 'all') Dict[str, ndarray]
Calculate RMSD between lag-separated frames using mean metric.
Resolves the requested trajectories and atom selection, then evaluates RMSD values between frames separated by
lagusing the mean metric.Parameters
- lagint, optional
Distance between frames. Must be positive. Defaults to
1.- traj_selectionUnion[int, str, list[Union[int, str]], ‘all’], optional
Selection describing the trajectories to process. Defaults to
"all".- atom_selectionstr, optional
MDTraj atom selection string. Defaults to
"all".
Returns
- dict[str, np.ndarray]
Mapping of trajectory names to RMSD arrays computed for the requested lag.
Examples
>>> service = RMSDMeanService(pipeline_data) >>> service.frame_to_frame(lag=1) {'traj_0': array([...])}
- window_frame_to_start(window_size: int, stride: int | None = None, traj_selection: int | str | List[int | str] | all = 'all', atom_selection: str = 'all') Dict[str, ndarray]
Calculate window-wise RMSD using first frame as reference.
Sliding windows are extracted per trajectory, aligned to the window’s first frame and condensed via the mean metric into a single RMSD value per window.
Parameters
- window_sizeint
Number of frames within each window.
- strideint, optional
Step size between windows. Defaults to
window_sizewhen omitted.- traj_selectionUnion[int, str, list[Union[int, str]], ‘all’], optional
Selection describing the trajectories to process. Defaults to
"all".- atom_selectionstr, optional
MDTraj atom selection string. Defaults to
"all".
Returns
- dict[str, np.ndarray]
Mapping of trajectory names to window-wise RMSD arrays.
Examples
>>> service = RMSDMeanService(pipeline_data) >>> service.window_frame_to_start(window_size=3) {'traj_0': array([...])}
- window_frame_to_frame(window_size: int, stride: int | None = None, lag: int = 1, traj_selection: int | str | List[int | str] | all = 'all', atom_selection: str = 'all') Dict[str, ndarray]
Calculate window-wise RMSD between lag-separated frames.
Sliding windows are processed with lag-separated frame pairs and condensed using the mean metric.
Parameters
- window_sizeint
Number of frames within each window.
- strideint, optional
Step size between windows. Defaults to
window_sizewhen omitted.- lagint, optional
Lag between frames inside each window. Defaults to
1.- traj_selectionUnion[int, str, list[Union[int, str]], ‘all’], optional
Selection describing the trajectories to process. Defaults to
"all".- atom_selectionstr, optional
MDTraj atom selection string. Defaults to
"all".
Returns
- dict[str, np.ndarray]
Mapping of trajectory names to window-wise RMSD arrays.
Examples
>>> service = RMSDMeanService(pipeline_data) >>> service.window_frame_to_frame(window_size=4, lag=1) {'traj_0': array([...])}