Services Helper

GitHub Link to Code.

Helper utilities for feature services.

This submodule contains helper classes that provide common functionality for feature services:

  • AnalysisDataHelper: Manages data selection for analysis operations, handling both trajectory and feature selection with temporary selector creation and cleanup

Analysis Data Helper

Helper for analysis factory data selection operations.

class mdxplain.feature.services.helper.analysis_data_helper.AnalysisDataHelper

Helper class for data selection in analysis factories.

Provides centralized data selection logic that can be used by all analysis factories without code duplication. Handles trajectory selection and feature selection using the existing pipeline infrastructure.

static get_selected_data(pipeline_data: PipelineData, feature_type: str, feature_selector: str | None = None, traj_selection: str | int | List | None = None) np.ndarray

Get selected feature data using pipeline infrastructure.

This method integrates trajectory selection and feature selection to provide the appropriate data matrix for analysis methods.

This method creates temporary selectors as needed and cleans them up afterwards. If no feature_selector is provided, a temporary selector is created for the current feature type.

Parameters

pipeline_dataPipelineData

Pipeline data container

feature_typestr

Feature type name (e.g., “distances”, “contacts”)

feature_selectorstr, optional

Name of existing feature selector. If None, creates temporary selector with all features of the current feature type

traj_selectionstr, int, list, optional

Trajectory selection criteria. If None, uses “all”

Returns

np.ndarray

Selected feature data matrix

Raises

ValueError

If feature_selector contains features from other types or if no features of the required type are found

Examples

>>> data = AnalysisDataHelper.get_selected_data(
...     pipeline_data, "distances", 
...     feature_selector="my_selector",
...     traj_selection=[0, 1, 2]
... )
>>> print(data.shape)  # (n_frames, n_features)