MetaView

class MetaView()

Bases: QWidget

Abstract base class designed to provide a unified interface for different analysis tabs.

This class includes a blank plot canvas for visualizing data, a dedicated space for control elements, and an interface for dynamically updating the plot based on user interactions or analysis results.

Public Methods

Abstract Methods

These methods must be implemented by subclasses.

abstractmethod MetaView.notify_plugin_state_changed(metaclass: str, plugin_key: str, reason: str) None

Called by MainController whenever any plugin instance’s internal state changed elsewhere in the app (e.g. new columns committed to a loader’s table). Must be implemented by subclasses, even if the correct implementation is a no-op (pass).

Where the implementation is not a no-op, it must make a deliberate decision about whether the notification applies to this tab, filter accordingly, and determine what the specific reaction should be.

Currently known (metaclass, reason) combinations in use:

  • (“MetaDatabaseLoader”, <loader_key>, “columns”) — emitted after columns are added to a loader’s table (see ClusteringView._commit_clusters, ProteinView._commit_fits).

Parameters:
  • metaclass (str) – The metaclass of the plugin instance whose state changed (e.g. “MetaDatabaseLoader”).

  • plugin_key (str) – The unique key identifying the plugin instance that changed (e.g. “SQLiteDBLoader_0”).

  • reason (str) – A short string identifying what kind of change occurred (e.g. “columns”). Free-form; the emitter and every receiver must agree on the exact string used.

Returns:

None

Return type:

None

abstractmethod MetaView.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.

Concrete Methods

MetaView.handle_add_triggered(metaclass: str) None

Trigger addition of a new plugin by prompting for a subclass.

Parameters:

metaclass (str) – The type of plugin to add (e.g., ‘MetaReader’)

MetaView.handle_delete_triggered(metaclass: str, key: str) None

Emit a signal to trigger the delete process for a data plugin, passing the identifier.

Parameters:
  • metaclass (str) – The class type of the plugin

  • key (str) – the identifier of the plugin to be deleted

MetaView.handle_edit_triggered(metaclass: str, key: str) None

Emit a signal to trigger the saving process for a data plugin, passing the appropriate arguments to handle editing plugin settings.

Parameters:
  • metaclass (str) – The class type of the plugin

  • key (str) – the identifier of the plugin to be edited

MetaView.handle_kill_all() None

Handle the ‘Kill All’ button click event.

MetaView.handle_kill_button(identifier: str) None

Handle the kill button click event for individual workers.

MetaView.remove_progress_bar(identifier: str) None

Remove a specific progress bar and its components when a task is complete.

MetaView.set_available_subclasses(available_subclasses: Mapping[str, List[str]] | None) None
MetaView.set_column_exists(exists_in_table: str | None) None

Sets the status indicating if cluster columns already exist.

Parameters:

exists_in_table (Optional[str]) – Name of table where columns exist or None.

MetaView.update_actions_from_json(actions: Dict[str, Dict[str, Any]]) None
MetaView.update_plot_data(data: Any | None) None
MetaView.update_progressbar(value: float, identifier: str) None

Update a specific progress bar’s value or create it if it doesn’t exist.

Private Methods

Abstract Methods

These methods must be implemented by subclasses.

abstractmethod MetaView._init() None

Perform additional initialization specific to the algorithm being implemented. Must be implemented by subclasses.

This function is called at the end of the class constructor to perform additional initialization specific to the algorithm being implemented. kwargs provided to the base class constructor are available as class attributes.

abstractmethod MetaView._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.

Parameters:

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

abstractmethod MetaView._set_control_area(layout: QBoxLayout) None

Create and set up the control area for user interaction elements.

Parameters:

layout (QBoxLayout) – The main layout to which the control area will be added. A box layout specifically, since implementations nest a sub-layout with addLayout().

Concrete Methods

MetaView.__init__() None

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

MetaView._clear_cache() None
MetaView._commit_cache() None
MetaView._expand_event_indices(indices_str: str) list[int]

Expand ‘1,3-5’ → [1,3,4,5], exclude segments with negatives.

MetaView._factors(n: int) Tuple[int, int]

Find the closest pair of factors for a given number to approximate a square layout.

Parameters:

n (int) – Number to factor.

Returns:

Tuple of two factors.

Return type:

Tuple[int, int]

MetaView._format_ranges(ranges: Sequence[tuple[float, float]]) str

Format list of tuples into ‘8-11,13’

MetaView._load_actions_from_json() None
MetaView._logscale_and_filter_dataframe(df: DataFrame, log_columns: List[str] | None = None) DataFrame

Filters a DataFrame for NaN values and applies logarithmic scaling to specified columns, returning a new DataFrame; the input is not modified.

This function:

  • Removes rows with NaN values in any column.

  • Applies log10 scaling to specified columns after rectifying based on average sign.

  • Sequentially removes rows with non-positive values in log columns.

Args:

df (pd.DataFrame): Input DataFrame with numerical data. Not modified; a copy is filtered and transformed internally. log_columns (list of str, optional): List of column names to apply log scaling. If None, no log scaling is applied.

Returns:

pd.DataFrame: A new, filtered and transformed DataFrame.

MetaView._logscale_and_filter_multiple_columns(*data: ndarray[tuple[int, ...], dtype[Any]], log_flags: Sequence[bool] | None = None) Tuple[ndarray[tuple[int, ...], dtype[Any]], ...]

Filters multiple data columns for NaN values and applies logarithmic scaling.

This function takes an arbitrary number of 1D NumPy arrays as input. It first removes any data points (rows) where any of the input arrays contain a NaN value. Then, it optionally applies a base-10 logarithmic scale to specified columns. When applying log scale, it handles potentially negative data by ‘rectifying’ it based on its average sign and filters out any non-positive values after rectification. This filtering is applied sequentially, meaning filtering based on one column affects all others.

Parameters:
  • *data (npt.NDArray[Any]) – A variable number of 1D NumPy arrays representing the data columns.

  • log_flags (Optional[Sequence[bool]]) – A sequence of booleans, one for each data array. If True, the corresponding array will be log-scaled. If None, no log scaling is applied. Defaults to None.

Raises:

ValueError – If log_flags is provided but is not a list or tuple with the same length as the number of data arguments.

Returns:

A tuple containing the processed 1D NumPy arrays. The number of arrays returned matches the number of input arrays.

Return type:

Tuple[npt.NDArray[Any], …]

MetaView._merge_ranges(ranges: Sequence[tuple[float, float]]) list[tuple[float, float]]

Merge overlapping or contiguous ranges.

MetaView._parse_event_indices(indices: str, allow_floats: bool) list[tuple[float, float]]

Parse ‘7-10,12’ → [(7,10), (12,12)] If allow_floats=True, accepts ‘1.5-4.5,6’ → [(1.5, 4.5), (6.0, 6.0)]; otherwise every bound is parsed with int().

MetaView._save_actions_to_json() None
MetaView._set_custom_display_area(layout: QLayout) None
MetaView._set_display_area_base(layout: QLayout) None

Create and set up the display area for the plot canvas.

Parameters:

layout (QLayout) – The main layout to which the display area will be added.

MetaView._set_progress_area(layout: QLayout) None

Initialize the area for progress bars within the control area.

MetaView._setup_canvas(num_channels: int = 1) None

Set up the canvas with a given number of subplots corresponding to the number of channels.

MetaView._setup_ui() None

Set up the user interface with a main layout containing a display area for the plot canvas and a control area for user interaction elements.

MetaView._shift_ranges(ranges: Sequence[tuple[float, float]], direction: str, offset: float) list[tuple[float, float]]

Shift each tuple range left or right.

MetaView._update_cache(*data_label_pairs: Sequence[Any]) None

Update the cache with an arbitrary number of (data, label) pairs.

Parameters:

*data_label_pairs (Sequence[Any]) – Tuple(s) of (data, label)

Raises:

ValueError – If any argument is not a tuple or list of 1 or 2 elements.