RMSF Per Residue Service

GitHub Link to Code.

Per-residue RMSF service variant.

class mdxplain.analysis.structure.services.rmsf_per_residue_service.RMSFPerResidueService(pipeline_data: PipelineData | None, metric: Literal['mean', 'median', 'mad'], aggregator: Literal['mean', 'median', 'rms', 'rms_median'])

Provide residue-wise RMSF computations for a fixed metric and aggregator.

The service resolves trajectory selections, derives atom subsets and delegates residue-level RMSF calculations to RMSFCalculator using a fixed deviation metric and residue aggregator.

__init__(pipeline_data: PipelineData | None, metric: Literal['mean', 'median', 'mad'], aggregator: Literal['mean', 'median', 'rms', 'rms_median']) None

Store pipeline settings, deviation metric and residue aggregator.

Ensures pipeline data is available and records both the deviation metric and residue aggregator for subsequent computations.

Parameters

pipeline_dataPipelineData, optional

Pipeline context carrying chunking and memmap configuration.

metric{‘mean’, ‘median’, ‘mad’}

Robust deviation metric applied to squared deviations.

aggregator{‘mean’, ‘median’, ‘rms’, ‘rms_median’}

Aggregator used when condensing per-atom values to residue level.

Returns

None

The initializer does not return anything.

Examples

>>> service = RMSFPerResidueService(pipeline_data, metric="mean", aggregator="median")
>>> service._aggregator
'median'
to_mean_reference(traj_selection: int | str | List[int | str] | all = 'all', atom_selection: str = 'all', cross_trajectory: bool = False, reference_traj_selection: int | str | List[int | str] | all | None = None) Dict[str, ndarray]

Compute per-residue RMSF relative to the mean structure.

Derives a mean reference structure across the selected trajectories and condenses per-atom RMSF values to residue level using the configured aggregator. Optional parameters allow combining trajectories into a single RMSF profile and choosing which trajectory supplies the topology for residue grouping.

Parameters

traj_selectionUnion[int, str, List[Union[int, str]], ‘all’], optional

Selection describing which trajectories to analyse.

atom_selectionstr, optional

MDTraj atom selection string. Defaults to "all".

cross_trajectorybool, optional

When True, all selected trajectories are combined into a single RMSF profile before residue aggregation.

reference_traj_selectionoptional

Selection describing which trajectory provides the topology for residue aggregation. None defaults to the first trajectory from traj_selection.

Returns

dict

Mapping of trajectory names – or 'combined' when cross_trajectory is True – to per-residue RMSF arrays.

Examples

>>> service = RMSFPerResidueService(pipeline_data, metric="mean", aggregator="mean")
>>> result = service.to_mean_reference()
>>> isinstance(result, dict)
True
to_median_reference(traj_selection: int | str | List[int | str] | all = 'all', atom_selection: str = 'all', cross_trajectory: bool = False, reference_traj_selection: int | str | List[int | str] | all | None = None) Dict[str, ndarray]

Compute per-residue RMSF relative to the median structure.

Uses the median reference structure for the selected trajectories and aggregates per-atom RMSF values to residue level. Optional parameters mirror to_mean_reference() for cross-trajectory computation and reference topology selection.

Parameters

traj_selectionUnion[int, str, List[Union[int, str]], ‘all’], optional

Selection describing which trajectories to analyse.

atom_selectionstr, optional

MDTraj atom selection string. Defaults to "all".

cross_trajectorybool, optional

When True, all selected trajectories are combined into a single RMSF profile before residue aggregation.

reference_traj_selectionoptional

Selection describing which trajectory provides the topology for residue aggregation. None defaults to the first trajectory from traj_selection.

Returns

dict

Mapping of trajectory names – or 'combined' when cross_trajectory is True – to per-residue RMSF arrays.

Examples

>>> service = RMSFPerResidueService(pipeline_data, metric="median", aggregator="rms")
>>> result = service.to_median_reference()
>>> isinstance(result, dict)
True