HTMLExporter#

class panorama.info.info.HTMLExporter(output_dir)#

Bases: object

A 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)#

Initialize the HTMLExporter.

Parameters:

output_dir (Path) – Directory where HTML files will be saved.

static _create_boolean_filters(source)#

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.

Return type:

List[RadioButtonGroup]

_create_column_visibility_control(source, columns, visible_indices)#

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.

Return type:

CheckboxGroup

_create_download_button(source, filename)#

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.

Return type:

Button

_create_filter_button(source, radio_buttons)#

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.

Return type:

Button

_create_range_sliders(source)#

Create range sliders for numeric column filtering.

Parameters:

source (ColumnDataSource) – Bokeh data source.

Returns:

List[RangeSlider] – List of configured range sliders.

Return type:

List[RangeSlider]

static _layout_content_components(table, checkbox_group, sliders, download_button)#

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.

Return type:

Column

_load_js_file(filename)#

Load JavaScript code from the file.

Parameters:

filename (str) – Name of the JavaScript file.

Returns:

str – JavaScript code content.

Return type:

str

static _rename_content_columns(df)#

Rename DataFrame columns for better readability.

Parameters:

df (DataFrame) – DataFrame with content information.

Returns:

pd.DataFrame – DataFrame with renamed columns.

Return type:

DataFrame

static _reorder_content_columns(df)#

Reorder DataFrame columns for logical grouping and presentation.

Parameters:

df (DataFrame) – DataFrame with content information.

Returns:

pd.DataFrame – DataFrame with reordered columns.

Return type:

DataFrame

_save_html(layout, filename, title)#

Save Bokeh layout to the HTML file.

Parameters:
  • layout (Column) – Bokeh layout to save.

  • filename (str) – Output filename.

  • title (str) – HTML page title.

Return type:

None

_setup_slider_callbacks(sliders, source)#

Set up JavaScript callbacks for slider interactions.

Parameters:
  • sliders (List[RangeSlider]) – List of range sliders.

  • source (ColumnDataSource) – Bokeh data source.

Return type:

None

static _unpack_content_dict(content_dict)#

Unpack nested dictionaries in the content dictionary for flat DataFrame creation.

Parameters:

content_dict (Dict[str, Dict[str, Union[int, float, Dict[str, Union[int, float]]]]]) – Dictionary with potentially nested content information.

Returns:

Dict[str, Dict[str, Any]] – Flattened dictionary suitable for DataFrame creation.

Return type:

Dict[str, Dict[str, Any]]

Note

This method flattens nested dictionaries using dot notation for keys and handles special cases for module counts and other metrics.

_validate_js_files()#

Validate that required JavaScript files exist.

Raises:

FileNotFoundError – If required JavaScript files are not found.

Return type:

None

export_content(content_dict)#

Export content information to an interactive HTML file.

Parameters:

content_dict (Dict[str, Dict[str, Union[int, float, Dict[str, Union[int, float]]]]]) – Dictionary containing content information for each pangenome, including statistics about gene families, modules, and other metrics.

Return type:

None

Note

Creates an HTML file with column visibility controls, range sliders for filtering, and download functionality.

export_status(status_dict)#

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.

Return type:

None

Note

Creates an HTML file with filtering capabilities for boolean columns and download functionality.