panorama.info package#
Submodules#
panorama.info.info module#
Panorama Info Module - Pangenome Information Extraction and Visualization
This module provides functionality to extract, process, and export information from pangenome HDF5 files, generating interactive HTML reports for analysis.
- class panorama.info.info.HTMLExporter(output_dir: Path)#
Bases:
objectA class to export pangenome information as interactive HTML reports.
This class provides methods to create interactive HTML tables and visualizations for different types of pangenome information.
- __init__(output_dir: Path)#
Initialize the HTMLExporter.
- Parameters:
output_dir (Path) – Directory where HTML files will be saved.
- static _create_boolean_filters(source: ColumnDataSource) List[RadioButtonGroup]#
Create radio button groups for filtering boolean columns.
- Parameters:
source (ColumnDataSource) – Bokeh data source.
- Returns:
List[RadioButtonGroup] – List of radio button groups for boolean columns.
- _create_column_visibility_control(source: ColumnDataSource, columns: List[TableColumn], visible_indices: List[int]) CheckboxGroup#
Create a checkbox group for controlling column visibility.
- Parameters:
source (ColumnDataSource) – Bokeh data source.
columns (List[TableColumn]) – Table columns.
visible_indices (List[int]) – Indices of initially visible columns.
- Returns:
CheckboxGroup – Configured a checkbox group.
- _create_download_button(source: ColumnDataSource, filename: str) Button#
Create a download button with a JavaScript callback for data export.
- Parameters:
source (ColumnDataSource) – Bokeh data source.
filename (str) – Name of the file to download.
- Returns:
Button – Configured download button.
- _create_filter_button(source: ColumnDataSource, radio_buttons: List[RadioButtonGroup]) Button#
Create a filter button with a JavaScript callback for boolean filtering.
- Parameters:
source (ColumnDataSource) – Bokeh data source.
radio_buttons (List[RadioButtonGroup]) – Radio buttons for filtering.
- Returns:
Button – Configured filter button.
- _create_range_sliders(source: ColumnDataSource) List[RangeSlider]#
Create range sliders for numeric column filtering.
- Parameters:
source (ColumnDataSource) – Bokeh data source.
- Returns:
List[RangeSlider] – List of configured range sliders.
- static _layout_content_components(table: DataTable, checkbox_group: CheckboxGroup, sliders: List[RangeSlider], download_button: Button) Column#
Layout content export components in an organized manner.
- Parameters:
table (DataTable) – Main data table.
checkbox_group (CheckboxGroup) – Column visibility controls.
sliders (List[RangeSlider]) – Range sliders for filtering.
download_button (Button) – Download button.
- Returns:
column – Bokeh layout containing all components.
- _load_js_file(filename: str) str#
Load JavaScript code from the file.
- Parameters:
filename (str) – Name of the JavaScript file.
- Returns:
str – JavaScript code content.
- static _rename_content_columns(df: DataFrame) DataFrame#
Rename DataFrame columns for better readability.
- Parameters:
df (pd.DataFrame) – DataFrame with content information.
- Returns:
pd.DataFrame – DataFrame with renamed columns.
- static _reorder_content_columns(df: DataFrame) DataFrame#
Reorder DataFrame columns for logical grouping and presentation.
- Parameters:
df (pd.DataFrame) – DataFrame with content information.
- Returns:
pd.DataFrame – DataFrame with reordered columns.
- _save_html(layout: Column, filename: str, title: str) None#
Save Bokeh layout to the HTML file.
- Parameters:
layout (column) – Bokeh layout to save.
filename (str) – Output filename.
title (str) – HTML page title.
- _setup_slider_callbacks(sliders: List[RangeSlider], source: ColumnDataSource) None#
Set up JavaScript callbacks for slider interactions.
- Parameters:
sliders (List[RangeSlider]) – List of range sliders.
source (ColumnDataSource) – Bokeh data source.
- static _unpack_content_dict(content_dict: Dict[str, Dict[str, int | float | Dict[str, int | float]]]) Dict[str, Dict[str, Any]]#
Unpack nested dictionaries in the content dictionary for flat DataFrame creation.
- Parameters:
content_dict (ContentDict) – Dictionary with potentially nested content information.
- Returns:
Dict[str, Dict[str, Any]] – Flattened dictionary suitable for DataFrame creation.
Note
This method flattens nested dictionaries using dot notation for keys and handles special cases for module counts and other metrics.
- _validate_js_files() None#
Validate that required JavaScript files exist.
- Raises:
FileNotFoundError – If required JavaScript files are not found.
- export_content(content_dict: Dict[str, Dict[str, int | float | Dict[str, int | float]]]) None#
Export content information to an interactive HTML file.
- Parameters:
content_dict (ContentDict) – Dictionary containing content information for each pangenome, including statistics about gene families, modules, and other metrics.
Note
Creates an HTML file with column visibility controls, range sliders for filtering, and download functionality.
- export_status(status_dict: Dict[str, bool | str]) None#
Export status information to an interactive HTML file.
- Parameters:
status_dict (Dict[str, Union[bool, str]]) – Dictionary containing status information for each pangenome, where keys are pangenome names and values are status data.
Note
Creates an HTML file with filtering capabilities for boolean columns and download functionality.
- class panorama.info.info.PangenomeInfoExtractor(disable_bar: bool = False)#
Bases:
objectA class to extract and process information from pangenome HDF5 files.
This class handles the extraction of status, content, parameters, and metadata information from multiple pangenome files and provides methods to export this information as interactive HTML reports.
- __init__(disable_bar: bool = False)#
Initialize the PangenomeInfoExtractor.
- Parameters:
disable_bar (bool) – Whether to disable the progress bar during processing.
- static _extract_content(h5f: File) Dict[str, Any]#
Extract content information from an HDF5 file.
- Parameters:
h5f (tables.File) – Open HDF5 file handle.
- Returns:
Dict[str, Any] – Content information.
- static _extract_metadata(h5f: File) Dict[str, Any]#
Extract metadata information from an HDF5 file.
- Parameters:
h5f (tables.File) – Open HDF5 file handle.
- Returns:
Dict[str, Any] – Metadata information.
- static _extract_parameters(h5f: File) Dict[str, Any]#
Extract parameter information from an HDF5 file.
- Parameters:
h5f (tables.File) – Open HDF5 file handle.
- Returns:
Dict[str, Any] – Parameter information.
Note
This method currently prints parameters for debugging but doesn’t return them. Implementation needs to be completed.
- static _extract_status(h5f: File) Dict[str, bool | str]#
Extract status information from an HDF5 file.
- Parameters:
h5f (tables.File) – Open HDF5 file handle.
- Returns:
Dict[str, Union[bool, str]] – Status information.
- extract_info(pangenomes_path: Dict[str, Dict[str, str | int]], status: bool = False, content: bool = False, parameters: bool = False, metadata: bool = False) Dict[str, Dict[str, Any]]#
Extract information from multiple pangenome files.
- Parameters:
pangenomes_path (PangenomePaths) – Dictionary mapping pangenome names to their file paths.
status (bool, optional) – Whether to extract status information. Defaults to False.
content (bool, optional) – Whether to extract content information. Defaults to False.
parameters (bool, optional) – Whether to extract parameter information. Defaults to False.
metadata (bool, optional) – Whether to extract metadata information. Defaults to False.
- Returns:
InfoDict – Dictionary containing all extracted information organized by type.
Note
If no specific information type is requested, all types will be extracted.
- panorama.info.info.check_info_args(args: Namespace)#
Checks the validity of arguments for the info command.
- Parameters:
args (argparse.Namespace) – Parsed command-line arguments
- panorama.info.info.export_info(info_dict: Dict[str, Dict[str, Any]], output: Path) None#
Export extracted information to HTML files.
- Parameters:
info_dict (InfoDict) – Dictionary containing extracted pangenome information.
output (Path) – Output directory path where HTML files will be saved.
- Raises:
NotImplementedError – If parameter or metadata export is requested (not yet implemented).
KeyError – If an unrecognized information type is provided.
Note
Currently supports exporting status and content information. Parameter and metadata export functionality is planned for future implementation.
- panorama.info.info.launch(args: Namespace) None#
Main command launcher for the info extraction functionality.
- Parameters:
args (argparse.Namespace) – Parsed command-line arguments containing all user options.
Note
This function orchestrates the entire workflow: validates input files, extracts information, and exports results to HTML files.
- panorama.info.info.parser_info(parser: ArgumentParser) None#
Configure an argument parser with info command-specific options.
- Parameters:
parser (argparse.ArgumentParser) – Argument parser to configure.
Note
Sets up required arguments (input files, output directory) and optional arguments for controlling which information types to extract and export.
- panorama.info.info.subparser(sub_parser: _SubParsersAction) ArgumentParser#
Create the subparser for the info command.
- Parameters:
sub_parser (argparse._SubParsersAction) – Parent subparser to add the info command to.
- Returns:
argparse.ArgumentParser – Configured argument parser for the info command.