ProteinController

class ProteinController(available_subclasses: Optional[Mapping[str, List[str]]] = None, **kwargs)

Bases: MetaController

Subclass of MetaController for managing protein view-model logic.

Relays queries, event data, and filter/column metadata between the database backend and ProteinView.

Public Methods

ProteinController.alter_database_status(status: bool) None

Inform the view whether database alteration was successful.

Parameters:

status (bool) – Result of the database alteration operation.

ProteinController.check_column_exists(table_name: str | None) None

Notify the view to check if a fit-data column exists in the given table.

Parameters:

table_name (Optional[str]) – Name of the table containing the queried column, or None if the loader could not resolve one.

ProteinController.get_experiment_names_for_tree(experiments: list[str], loader_name: str) None

Provide a list of experiment names to the view for the tree display.

Parameters:
  • experiments (list[str]) – List of experiment names fetched from the database.

  • loader_name (str) – Name of the data loader associated with the experiments.

ProteinController.get_experiment_structure_ready(structure: dict[str, list[int]], loader_name: str) None

Pass experiment-to-channel mappings to the view in display-ready format.

Parameters:
  • structure (dict[str, list[int]]) – Dictionary mapping experiment names to a list of channel IDs.

  • loader_name (str) – Name of the data loader providing the structure.

ProteinController.get_session_state() Dict[str, Any]

Include the view’s live subset filters in this tab’s session history entry.

Returns:

Extra state to serialize into this tab’s session history entry.

Return type:

Dict[str, Any]

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

Relay the result of raw filter validation to the view.

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

  • error_msg (str) – Error message if invalid.

ProteinController.relay_baseline_duration(duration: float | None) None

Relay the computed baseline duration to the view.

Parameters:

duration (Optional[float]) – Duration of the baseline in appropriate units, or None if it could not be resolved.

ProteinController.relay_event_data_generator(generator: Generator) None

Relay a generator for event data overlays to the view.

Parameters:

generator (Generator) – Generator yielding event data for overlay purposes.

ProteinController.relay_event_plot_data_generator(generator: Generator) None

Relay a generator for event plotting to the view.

Parameters:

generator (Generator) – Generator yielding event data for plotting.

ProteinController.relay_event_query(query: str, debug: str) None

Relay an event-level query to the view.

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

  • debug (str) – Debug message to display if query is empty.

ProteinController.relay_plot_data(data: Any) None

Relay processed data to the view for plotting.

Parameters:

data (Any) – Structured plot data.

ProteinController.relay_query(query: str, debug: str, table_name: str, *args: str) None

Relay a query and optional debug message to the view, handling optional filter intents.

Parameters:
  • query (str) – SQL query string to display or execute.

  • debug (str) – Debug message to display if query is empty.

  • table_name (str) – Name of the table associated with the query.

  • *args (str) – Optional intent string (e.g. ‘validate_new_filter’, ‘validate_edited_filter’).

ProteinController.relay_query_result(result: DataFrame | None) None

Relay a direct database query result to the view. Used by ProteinView._rebuild_event_id_cache to receive the list of filtered event_ids.

Parameters:

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

ProteinController.relay_table_by_column(table: str | None) None

Relay the name of the table a column lives in to the view.

Parameters:

table (Optional[str]) – Name of the table containing the queried column, or None if the loader could not resolve one.

ProteinController.relay_units(units: str | None) None

Provide a column unit label to the view.

Parameters:

units (Optional[str]) – Unit string for the queried column, or None if the loader could not resolve one.

ProteinController.restore_session_state(state: Dict[str, Any]) None

Restore subset filters captured by get_session_state() onto the view.

Parameters:

state (Dict[str, Any]) – This tab’s session history entry, as previously written by get_session_state().

ProteinController.set_channel_db_id(channel_db_id: int | None) None

Relay the channel database ID to the view.

Parameters:

channel_db_id (Optional[int]) – Integer database ID of the channel.

ProteinController.set_experiment_id(experiment_id: int | None) None

Relay the experiment ID to the view.

Parameters:

experiment_id (Optional[int]) – Integer ID of the experiment.

ProteinController.set_exported_event_count(written: int) None

Update the view with the number of events exported.

Parameters:

written (int) – Number of events successfully written to file.

ProteinController.update_column_names(column_names: list[str]) None

Update the view with new column names.

Parameters:

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

ProteinController.update_column_units(column_units: str | None, axis: str) None

Update the view with the unit label for a specific axis.

Parameters:
  • column_units (Optional[str]) – Unit string for the column plotted on this axis, or None if the loader could not resolve one.

  • axis (str) – Axis to apply the units to (e.g., ‘x’ or ‘y’).

Private Methods

ProteinController._init() None

Initialize the protein view and model.

ProteinController._setup_connections() None

Connect internal view signals to their corresponding controller slots.