ProteinView

class ProteinView(*args, **kwargs)

Bases: MetaView, WalkthroughMixin

Subclass of MetaView for estimating translocating protein size and shape from nanopore blockage events.

Given pore diameter/length, fits a two-population (prolate/oblate) volume-and-shape-factor model via Monte Carlo rejection sampling, either per event (Individual mode) or across the aggregate distribution (Ensemble mode). Also supports subset filtering, per-event trace/histogram inspection, and committing or reporting fit results.

Public Methods

ProteinView.clear_pending_filter_state() None

reset all filters to factory settings

ProteinView.get_current_view() str

Abstract method to get the name of the current view.

Subclasses must override this to return the current view name.

Returns:

The name of the view currently displayed.

Return type:

str

Raises:

NotImplementedError – Always, unless overridden by a subclass.

ProteinView.get_save_filename() str

Open a file dialog for the user to choose a save location.

Returns:

Selected filename.

Return type:

str

ProteinView.get_selected_filters() dict

Get a dict of the filters that the user has indicated should be active for the current plotting task

ProteinView.get_walkthrough_steps() List[Tuple[str, str, str, Callable[[], QWidget | List[QWidget]]]]

Abstract method to retrieve the walkthrough steps for the current view.

Subclasses must override this to return a list of walkthrough steps, each a (title, description, view name, widget getter) tuple.

Returns:

The ordered walkthrough steps for this view.

Return type:

List[WalkthroughStep]

Raises:

NotImplementedError – Always, unless overridden by a subclass.

ProteinView.handle_parameter_change(submodel_name: str, action_name: str, args: tuple) None

Handle changes triggered by UI controls such as updates to axis selection or filters.

Parameters:
  • submodel_name (str) – Name of the submodel that triggered the action.

  • action_name (str) – Name of the action triggered.

  • args (tuple) – Tuple containing action-specific arguments.

ProteinView.notify_plugin_state_changed(metaclass: str, plugin_key: str, reason: str) None

Called when some other plugin instance’s state changed elsewhere in the app. Refreshes this tab’s column list only when the change concerns a MetaDatabaseLoader’s columns and the loader that changed is the one currently selected here; any other metaclass, reason, or a loader that isn’t currently selected in this tab is ignored.

Parameters:
  • metaclass (str) – The metaclass of the plugin instance whose state changed.

  • plugin_key (str) – The unique key identifying the plugin instance that changed.

  • reason (str) – A short string identifying what kind of change occurred.

Returns:

None

Return type:

None

ProteinView.on_raw_filter_validated(valid: bool, error_msg: str) None

Relay callback from validate_filter_query for raw SQL filter validation.

Parameters:
  • valid (bool) – Whether the query is valid.

  • error_msg (str) – Error message if invalid.

ProteinView.relay_query_result(result: DataFrame | None) None

A global signal callback that stores the result of a database query. Used by _rebuild_event_id_cache to receive the list of filtered event_ids.

Shared by the query_database_directly and load_metadata dispatches, which return the same thing: the rows, an empty frame if none matched, or None if the query could not be built or run.

Parameters:

result (Optional[pd.DataFrame]) – DataFrame returned by the query, or None if it failed.

ProteinView.replace_filter_item(name: str) None

Remove any existing filter item with the same name and add the new one.

Parameters:

name (str) – The name of the filter to (re)add.

ProteinView.request_experiment_structure(loader_name: str) None

Get a dict of all experiments and channels available in a specified MetaDatabaseLoader object.

Parameters:

loader_name (str) – the key of the loader

ProteinView.restore_subset_filters(filters: Dict[str, str]) None

Restore subset filters captured in a saved session.

Unlike _load_filter(), this does not re-validate the filters against a database loader, since they were already valid when the session was saved.

Parameters:

filters (Dict[str, str]) – Mapping of filter name to filter expression to restore.

ProteinView.set_alter_database_status(status: bool) None

Sets the success status of a database operation.

Parameters:

status (bool) – True if successful, False otherwise.

ProteinView.set_baseline_duration(duration: float | None) None

A callback from a global_signal call that sets the baseline_duration variable for further processing.

Parameters:

duration (Optional[float]) – total duration of baseline data in the scoped subset, or None if it could not be resolved.

ProteinView.set_channel_db_id(channel_db_id: int | None) None

A global signal callback that provides the channel_db_id for raw query scoping.

Parameters:

channel_db_id (Optional[int]) – Database id of the scoped channel, or None if unresolved.

ProteinView.set_event_data_generator(generator: Iterator[Dict[str, Any]]) None

Set the event data generator for event-based plots.

Parameters:

generator (Iterator[Dict[str, Any]]) – A generator that yields event data.

ProteinView.set_event_plot_data_generator(generator: Iterator[Dict[str, Any]]) None

A callback from a global signal call that sets the generator to be used to construct event plots and overlays.

Parameters:

generator (Iterator[Dict[str, Any]]) – a generator of event data

ProteinView.set_event_query(query: str) None

A global signal callback that provides a valid SQL query for fetching event data.

Parameters:

query (str) – SQL query string for fetching event data.

ProteinView.set_experiment_id(experiment_id: int | None) None

A global signal callback that provides an experiment id for a given filter.

Parameters:

experiment_id (Optional[int]) – the integer id of the experiment in a MetaEventLoader object

ProteinView.set_query(query: str, table_name: str) None

Set the SQL query and table name used in plotting.

Parameters:
  • query (str) – SQL query string.

  • table_name (str) – Name of the database table.

ProteinView.set_table_by_column(table: str | None) None

Get a list of tables affected by an SQL query.

Parameters:

table (Optional[str]) – the name of a table that is implicated in an SQL query to a MetaDatabaseLoader object

ProteinView.set_units(units: Any) None

Set the units returned from the database for use in axis labels.

Parameters:

units (Any) – List or string representing units.

ProteinView.show_edit_filter_dialog(name: str, loader: str) None

Displays the dialog to edit an existing filter, and validates the updated SQL filter syntax via construct_metadata_query before saving it.

Parameters:
  • name (str) – The name of the filter to edit.

  • loader (str) – Name of the active database loader.

ProteinView.show_selection_tree(structure: dict[str, list[str]], loader_name: str, selection: dict[str, list[str]] | None = None) None

Displays the selection tree for a given loader using the full structure and current selection.

ProteinView.update_available_columns(loader: str) None

Request available columns from the database loader.

Parameters:

loader (str) – Name of the active database loader.

ProteinView.update_available_plugins(available_plugins: Dict[str, List[str]]) None

Called whenever a new plugin is instantiated elsewhere in the app, to keep an up-to-date list of possible data sources for use by this plugin.

Parameters:

available_plugins (Dict[str, List[str]]) – dict of lists keyed by MetaClass, listing the identifiers of all instantiated plugins throughout the app.

ProteinView.update_column_names(column_names: List[str]) None

Store available column names for internal use (filter validation, etc.) No UI update is performed.

Parameters:

column_names (List[str]) – List of column names retrieved from the database.

ProteinView.update_filter_name(old_name: str, new_name: str) None

Replace old filter name with new one in the ComboBox, removing any duplicates.

Parameters:
  • old_name (str) – The filter name being replaced.

  • new_name (str) – The filter name to display instead.

ProteinView.update_plot(plot_type: str, data: DataFrame, cols: Sequence[str], units: Sequence[str | None], logscales: Sequence[bool], dataset_label: str = '', bins: Any = None, sizes: bool = False, err_cols: Sequence[str] | None = None) None

update the plot area

ProteinView.update_units(loader: str, column: str, axis: str) None

Request units for a specific column from the loader.

Parameters:
  • loader (str) – Name of the database loader.

  • column (str) – Name of the column to get units for.

  • axis (str) – Axis being updated (‘x_axis’, ‘y_axis’, etc.).

Private Methods

ProteinView.__init__(*args: Any, **kwargs: Any) None

Initialize the MetaTab with a blank plot canvas and a space for controls.

ProteinView._build_dist_page() tuple

Build one distribution page: a histogram canvas and V/M canvas side by side, each with its own navigation toolbar underneath.

Returns:

Tuple of (page_widget, fig_hist, canvas_hist, ax_hist, fig_vm, canvas_vm, ax_vm) for this page.

Return type:

tuple

ProteinView._build_load_event_data_args(sql_filter: str, subset_name: str, exp: str | None, channel: str, exp_and_ch_arg: dict, loader: str) tuple

Build the (filter_or_query, exp_and_ch_or_None) args tuple for load_event_data, handling raw filter scoping automatically.

Parameters:
  • sql_filter (str) – SQL filter string or complete raw query.

  • subset_name (str) – Name of the subset filter, used to detect _raw suffix.

  • exp (Optional[str]) – Experiment name, or None.

  • channel (str) – Channel identifier.

  • exp_and_ch_arg (dict) – Experiment/channel dict for assisted filters.

  • loader (str) – Name of the database loader.

Returns:

Tuple of (query_or_filter, exp_and_ch_or_None) for load_event_data.

Return type:

tuple

ProteinView._clear_figure_state(axis_type: str = '2d', *, create_default_axes: bool = True) None

Canonical figure reset for the event figure.

Parameters:
  • axis_type (str) – Unused, kept for interface compatibility.

  • create_default_axes (bool) – Whether to recreate a default axes after clearing the figure. If False, the figure is left without axes.

Returns:

None

Return type:

None

ProteinView._commit_fits(loader: str) None

Commits fitted data to the database

Parameters:

loader (str) – Name or ID of the database loader plugin.

Raises:

AttributeError – If fit data has not been set on this view.

ProteinView._compute_theoretical_blockages(V: ndarray[tuple[int, ...], dtype[float64]], m: ndarray[tuple[int, ...], dtype[float64]], d: float, L: float) Tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]]]

Vectorized forward model: Calculates theoretical max and min blockages for arrays of volume (V) and shape factor (m).

Parameters:
  • V (npt.NDArray[np.float64]) – array of volumes of spheroids in cubic nanometers

  • m (npt.NDArray[np.float64]) – array of shape factors of spheroids (major axis / minor axis) of the same length as V. All must be either 0<m<1 or all m>1.

  • d (float) – the diameter of the pore in nanometers

  • L (float) – the length of the pore in nanometers

Returns:

Tuple of arrays of theoretical max and min blockage values for the given parameters, one per V,m pair

Return type:

Tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]

Raises:

ValueError – If m contains a mix of oblate (0<m<1) and prolate (m>1) form factors, or any negative form factor.

ProteinView._construct_all_points_histogram(event_generator: Iterator[Dict[str, Any]], plot_type: str, bins: Any = None, sizes: bool = False) DataFrame

Build a combined histogram across all event current values.

Parameters:
  • event_generator (Iterator[Dict[str, Any]]) – Generator yielding individual event data.

  • plot_type (str) – Type of histogram to create (raw or filtered).

  • bins (Any) – Number of bins (if sizes==False) or size of bins (if sizes==True) for use when binning. Arrives as a single-element list from the controls and is rebound to a scalar (or None, to fall back to an automatic estimate) in the body, hence the loose annotation.

  • sizes (bool) – whether bins represents a number of bins or a bin size.

Returns:

DataFrame with histogram values and corresponding current levels.

Return type:

pd.DataFrame

Raises:

ValueError – If bins is not a usable bin count/size specification.

ProteinView._construct_single_event_histogram(event: Dict[str, Any], plot_type: str, bins: Any = None, sizes: bool = False) DataFrame | None

Build a histogram of the current in a single event

Parameters:
  • event (Dict[str, Any]) – a dictionary of event metadata and the underlying timeseries

  • plot_type (str) – Type of histogram to create (raw or filtered).

  • bins (Any) – Number of bins (if sizes==False) or size of bins (if sizes==True) for use when binning. Arrives as a single-element list from the controls and is rebound to a scalar (or None, to fall back to an automatic estimate) in the body, hence the loose annotation.

  • sizes (bool) – whether bins represents a number or a binsize

Returns:

DataFrame with histogram values and corresponding current levels.

Return type:

Optional[pd.DataFrame]

Raises:

ValueError – If bins is not a usable bin count/size specification.

ProteinView._delete_all_selected_filters() None

Deletes multiple selected filters.

ProteinView._delete_filter(name: str) None

Internal method to remove a filter and update the UI.

Parameters:

name (str) – The name of the filter to remove.

ProteinView._delete_filter_by_name(name: str) None

Deletes a single filter by name.

Parameters:

name (str) – The name of the filter to delete.

ProteinView._double_gaussian(x: ndarray[tuple[int, ...], dtype[float64]], amp1: float, mean1: float, std1: float, amp2: float, mean2: float, std2: float) ndarray[tuple[int, ...], dtype[float64]]

return the value of a double gaussian with the specified paramters

Parameters:
  • x (npt.NDArray[np.float64]) – array of x values at which to calculate double gaussian

  • amp1 (float) – amplitude of the first gaussian

  • mean1 (float) – mean of the first gaussian

  • std1 (float) – standard deviation of the first gaussian

  • amp2 (float) – amplitude of the second gaussian

  • mean2 (float) – mean of the second gaussian

  • std2 (float) – standard deviation of the second gaussian

Returns:

array of gaussian values at the given x positions

Return type:

npt.NDArray[np.float64]

ProteinView._fetch_event_data(parameters: Dict[str, Any], action_label: str = 'events') list[dict]

Shared validation and targeted data fetching for event-based plots. Resolves the requested event_index list to database ids via a single query scoped to the current experiment/channel, then fetches exactly those rows. Always fetches fresh rather than caching event blobs in memory — event_id is only unique within an experiment/channel scope, and a per-event_id blob cache is an easy invariant to accidentally violate later; the targeted DB query is already O(events requested) rather than O(distance into the dataset), so the extra memoization isn’t worth the correctness risk.

Parameters:
  • parameters (Dict[str, Any]) – Dictionary containing db_loader, filter, channels, and event indices.

  • action_label (str) – Label used in error messages to identify the plot type.

Returns:

List of fetched event dictionaries, in the order requested, or empty list on failure.

Return type:

list[dict]

ProteinView._fit_and_plot_ensemble_geometry(plot_data: DataFrame, plot_type: str, d: float, L: float, N: int) bool

Fit a double Gaussian to the aggregated ensemble histogram, then Monte Carlo sample prolate/oblate V/m ensembles from that fit and plot them.

Called once by _update_distribution_ensemble after its single (experiment, channel, filter) combination has been plotted, using whatever plot_data that produced.

Parameters:
  • plot_data (pd.DataFrame) – the aggregated histogram DataFrame to fit against.

  • plot_type (str) – the plot type label to reuse when plotting the fit.

  • d (float) – the diameter of the pore in nanometers

  • L (float) – the length of the pore in nanometers

  • N (int) – target number of samples to draw for each of the prolate/oblate ensembles

Returns:

True if fitting and plotting succeeded, False if any failure occurred (already logged/displayed to the user).

Return type:

bool

ProteinView._fit_and_sanity_check_double_gaussian(bins: ndarray[tuple[int, ...], dtype[float64]], amplitude: ndarray[tuple[int, ...], dtype[float64]]) ndarray[tuple[int, ...], dtype[float64]] | None

Attempt to fit a double gaussian to data or None on failure.

Parameters:
  • bins (npt.NDArray[np.float64]) – numpy array of bin centers

  • amplitude (npt.NDArray[np.float64]) – numpy array of amplitude in bins

Returns:

fit parameters for a double gaussian (amplitude, mean, std, amplitude_2, mean_2, std_2)

Return type:

Optional[npt.NDArray[np.float64]]

ProteinView._fit_double_gaussian(bins: ndarray[tuple[int, ...], dtype[float64]], amplitude: ndarray[tuple[int, ...], dtype[float64]]) tuple

Attempt to fit a double gaussian to data or return None on failure.

Parameters:
  • bins (npt.NDArray[np.float64]) – numpy array of bin centers

  • amplitude (npt.NDArray[np.float64]) – numpy array of amplitude in bins

Returns:

Tuple of (best-fit parameters (amplitude, mean, std, amplitude_2, mean_2, std_2), parameter covariance matrix), or (None, None) if fitting fails.

Return type:

tuple

Raises:

ValueError – If curve fitting fails or peaks/split points cannot be determined; caught internally by nested fallback logic, so it never propagates to the caller.

ProteinView._generate_vm_ensemble(N_target: int, mean_max: float, std_max: float, mean_min: float, std_min: float, d: float, L: float, prolate: bool = True, cutoff_std: float = 4) Tuple[ndarray[tuple[int, ...], dtype[float64]], ndarray[tuple[int, ...], dtype[float64]]]

Uses Monte Carlo rejection sampling with dynamic bounds to find valid (V, m) pairs. Bails out after a maximum number of consecutive failed batches if the experimental data represents an unphysical geometry.

Parameters:
  • N_target (int) – number of value V,m pairs to generate, if possible

  • mean_max (float) – The mean value of the larger of the two blockage histograms

  • std_max (float) – The standard deviation value of the larger of the two blockage histograms

  • mean_min (float) – The mean value of the smaller of the two blockage histograms

  • std_min (float) – The standard deviation value of the smaller of the two blockage histograms

  • d (float) – the length of the pore in nanometers

  • L (float) – the length of the pore in nanometers

  • prolate (bool) – whether we are looking for prolate (m>1) solutions or oblate (0<m<1) solutions

  • cutoff_std (float) – the number of standard deviations outside the mean after which to cut off solutions

Returns:

Tuple of arrays of V,m pairs

Return type:

Tuple[npt.NDArray[np.float64], npt.NDArray[np.float64]]

ProteinView._handle_other_actions(action_name: str, parameters: Dict[str, Any]) None

Raise an error for actions not yet implemented.

Parameters:
  • action_name (str) – The name of the unhandled action.

  • parameters (Dict[str, Any]) – Parameters associated with the action.

Raises:

NotImplementedError – Always, since this action is not implemented.

ProteinView._handle_plot_events(parameters: dict) None

Handle loading and plotting of selected events based on provided parameters.

Resolves event_id + n_events into a concrete list of event_ids via the filtered_event_ids cache and bisect, then delegates to _fetch_event_data, which resolves those event_ids to database ids and fetches them directly.

Parameters:

parameters (dict) – Dictionary containing db_loader, filter, channels, event_id (int), and n_events (int).

ProteinView._handle_plot_histogram(parameters: dict) None

Handle loading and plotting of the ΔI/I histogram for selected events, each in its own subplot on the event canvas.

Resolves event_id + n_events into a concrete list of event_ids via the filtered_event_ids cache and bisect, then delegates to _fetch_event_data, which resolves those event_ids to database ids and fetches them directly.

Parameters:

parameters (dict) – Dictionary containing db_loader, filter, channels, event_id (int), n_events (int), bins, and sizes.

ProteinView._init() None

Initialize the ProteinView instance.

ProteinView._load_filter(parameters: Dict[str, Any]) None

Append filters from a JSON file, warn if duplicates are found, and apply all new filters only if none conflict with existing ones.

Parameters:

parameters (Dict[str, Any]) – Dictionary with ‘db_loader’.

ProteinView._plot_all_points_histogram(ax: Axes, data: DataFrame, cols: Sequence[str], units: Sequence[str | None], dataset_label: str = '', norm: bool = False) None

Plot a histogram of current values across all events (raw or filtered).

Parameters:
  • ax (Axes) – Matplotlib axes to draw the histogram on.

  • data (pd.DataFrame) – DataFrame containing time and current values.

  • cols (Sequence[str]) – Column names for x and y axes.

  • units (Sequence[Optional[str]]) – Units corresponding to the axes.

  • dataset_label (str) – Label for the plotted dataset.

  • norm (bool) – Whether to normalize the plotted y-values.

ProteinView._plot_scatterplot(ax: Axes, data: DataFrame, cols: Sequence[str], units: Sequence[str | None], logscales: Sequence[bool], dataset_label: str = '') None

Create a scatterplot of two metadata columns.

Parameters:
  • ax (Axes) – Matplotlib axes object.

  • data (pd.DataFrame) – DataFrame containing the columns to plot.

  • cols (Sequence[str]) – Sequence containing two column names for x and y axes.

  • units (Sequence[Optional[str]]) – Corresponding units for x and y axes.

  • logscales (Sequence[bool]) – Log-scaling flags for x and y axes.

  • dataset_label (str) – Label for the dataset.

ProteinView._plot_xyerr_scatterplot(ax: Axes, data: DataFrame, cols: Sequence[str], units: Sequence[str | None], logscales: Sequence[bool], dataset_label: str = '', err_cols: Sequence[str] | None = None) None

Create a scatterplot of two metadata columns with error bars.

Parameters:
  • ax (Axes) – Matplotlib axes object.

  • data (pd.DataFrame) – DataFrame containing the columns to plot.

  • cols (Sequence[str]) – Sequence containing two column names for x and y axes.

  • units (Sequence[Optional[str]]) – Corresponding units for x and y axes.

  • logscales (Sequence[bool]) – Log-scaling flags for x and y axes.

  • dataset_label (str) – Label for the dataset.

  • err_cols (Optional[Sequence[str]]) – Sequence containing two column names for x and y errors.

Raises:

ValueError – If err_cols is not a list of exactly two column names.

ProteinView._rebuild_event_id_cache(loader: str, sql_filter: str, exp: str | None, channel: int | None) bool

Fetch all event_ids matching the current filter in one DB query and store them sorted in self.filtered_event_ids.

Also updates current_sql_filter / current_experiment / current_channel so that staleness checks in _shift_range_and_update_plot and _handle_plot_events/_handle_plot_histogram can detect scope changes.

Emits a display-panel message with the total count and first/last event_id (mirrors MetadataView._rebuild_event_id_cache behaviour).

Goes through load_metadata rather than querying the events table directly, so that the filter is evaluated against the same joins the subset and scatter paths give it. A filter on a sublevels column - filtered = 5, meaning every event with at least one sublevel that matches - is only meaningful against events JOIN sublevels, and the hand-built SELECT event_id FROM events this replaces made every such filter fail as an unknown column and then report itself as an empty subset.

Parameters:
  • loader (str) – Name of the database loader.

  • sql_filter (str) – Raw filter expression without WHERE (used for label and staleness tracking).

  • exp (Optional[str]) – Experiment name.

  • channel (Optional[int]) – Channel identifier.

Returns:

True if the cache was populated, False if no events were found.

Return type:

bool

ProteinView._report_ensemble_fit() None

Report the double-Gaussian fit parameters and V/m sample summaries from the most recent ensemble distribution fit, alongside the binning configuration that produced them. Ensemble mode has no per-event id to write these back to the database against, so this is a display-only report rather than a database commit. Takes no arguments; reads entirely from self.ensemble_fit_* state set by _update_distribution_ensemble and cleared by _reset_actions.

Returns:

None

Return type:

None

ProteinView._reset_actions(axis_type: str = '2d') None

Clears the figure and reinitializes axes. This will also add a flag to the tab action history if @register_action is being used to keep track of actions. Only actions applied after the most recent call to this function will be recreated if the related file is loaded.

Also clears stored fit state for whichever analysis mode is currently active (self.fit_data for Individual, self.ensemble_fit_* for Ensemble), leaving the other mode’s fit untouched. This means switching modes and running Update Plot, or clicking Reset, only affects the fit belonging to the mode you’re currently in.

Parameters:

axis_type (str) – Either ‘2d’ or ‘3d’ to determine plot projection.

Returns:

None

Return type:

None

ProteinView._resolve_event_db_ids(loader: str, event_ids: Sequence[int], exp: str | None, channel: int | None) DataFrame | None

Resolve a list of event_id values, scoped to a specific experiment and channel, to their corresponding database primary keys (id) via a single direct query. event_id is only unique within an experiment/channel scope, not across the whole events table, so this scoping is required to avoid resolving to the wrong row when two channels share an event_id.

Parameters:
  • loader (str) – Name of the database loader.

  • event_ids (Sequence[int]) – List of event_id values to resolve.

  • exp (Optional[str]) – Experiment name, or None.

  • channel (Optional[int]) – Channel identifier, or None.

Returns:

DataFrame with columns id, event_id for the matching rows, or None on failure.

Return type:

Optional[pd.DataFrame]

ProteinView._save_filter() None

Save the current filters to a JSON file.

ProteinView._set_control_area(layout: QBoxLayout) None

Set up the control area layout by inserting metadata controls.

Parameters:

layout (QBoxLayout) – The layout to which the controls will be added.

ProteinView._set_custom_display_area(layout: QLayout) None

Initialize the display area with two independent sets of canvases — one for Individual mode, one for Ensemble mode — shown via a nested QStackedWidget, plus a separate full-canvas page for event plots. Each mode’s histogram/V-M plots persist independently; switching modes shows that mode’s last-drawn plot immediately, with no redraw needed.

ProteinView._set_display_mode(mode: str) None

Switch between distribution view (hist + V/M) and full event plot view.

ProteinView._shift_range_and_update_plot(parameters: dict, direction: str) None

Navigate filtered event_ids by n_events steps in the given direction with wrap-around at both ends, then trigger a plot update.

Parameters:
  • parameters (dict) – Action parameters from ProteinControls (must contain ‘db_loader’, ‘event_id’, ‘n_events’).

  • direction (str) – ‘left’ (backward) or ‘right’ (forward).

ProteinView._show_add_filter_dialog(parameters: dict) None

Displays the dialog for adding a new subset filter. Validates filter syntax before actually saving the filter.

Parameters:

parameters (dict) – Dictionary with ‘db_loader’.

ProteinView._show_filter_info_dialog(comboBox: MultiSelectComboBox, parameters: Dict[str, Any]) None

Called when clicking the edit button for filters with multiple selection.

Validates that exactly one filter is selected and delegates to the edit dialog.

Parameters:
  • comboBox (MultiSelectComboBox) – The combo box containing the list of selectable filters.

  • parameters (Dict[str, Any]) – Dictionary with ‘db_loader’.

ProteinView._summarize_vm(df: DataFrame) tuple

Build a one-line median +/- std summary of V, a, b, m for a sampled shape DataFrame. Falls back to a plain-value readout when there is only one sample (std is undefined for N=1), and reports explicitly when there are no samples at all.

Parameters:

df (pd.DataFrame) – DataFrame with columns “V”, “m”, “a”, “b” from Monte Carlo shape sampling.

Returns:

Tuple of (list of formatted “label = value” row strings, sample-count label string).

Return type:

tuple

ProteinView._update_distribution_ensemble(parameters: Dict[str, Any]) None

Compute and plot the ΔI/I histogram and V/M scatterplot aggregated across all events in Ensemble analysis mode.

Parameters:

parameters (Dict[str, Any]) – Dictionary of plotting parameters collected from the controls.

ProteinView._update_distribution_individual(parameters: Dict[str, Any]) None

Compute and plot the ΔI/I histogram and V/M scatterplot for a single selected event in Individual analysis mode.

Parameters:

parameters (Dict[str, Any]) – Dictionary of plotting parameters collected from the controls.

ProteinView._update_event_histogram(event_data: Sequence[Dict[str, Any]], bins: Any = None, sizes: bool = False, plot_type: str = 'Filtered Histogram') None

Update the event canvas with per-event ΔI/I histograms, one subplot per event.

Parameters:
  • event_data (Sequence[Dict[str, Any]]) – List of event dictionaries, each containing data and metadata for one event.

  • bins (Any) – Number of bins (if sizes==False) or size of bins (if sizes==True) for use when binning. Arrives as a single-element list from the controls and is rebound to a scalar (or None, to fall back to an automatic estimate) in the body, hence the loose annotation.

  • sizes (bool) – Whether bins represent bin sizes.

  • plot_type (str) – Type of histogram to construct.

Raises:

ValueError – If the double-Gaussian fit fails for an event; caught internally and skipped, so it never propagates to the caller.

ProteinView._update_event_plot(event_data: Sequence[Dict[str, Any]], use_raw: bool = False) None

Update the event plot with raw, filtered, and fitted traces for multiple events.

Each event is plotted in its own subplot with time on the x-axis and current on the y-axis. The method also updates internal cache with data for interactive use (e.g., tooltips or exports).

Parameters:
  • event_data (Sequence[Dict[str, Any]]) – List of dictionaries, each containing the data and metadata for one event. Each dictionary should have the keys: ‘experiment_id’, ‘channel_id’, ‘event_id’, ‘raw_data’, ‘filtered_data’, ‘fit_data’, and ‘samplerate’.

  • use_raw (bool) – Whether to overlay the unfiltered raw signal alongside filtered/fit traces.

Returns:

None

Return type:

None

Properties

ProteinView.ax_hist
ProteinView.ax_vm
ProteinView.canvas_hist
ProteinView.canvas_vm
ProteinView.fig_hist
ProteinView.fig_vm