Warning

This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

galaxy.tool_util.toolbox package

API for this module containing functionality related to the toolbox.

class galaxy.tool_util.toolbox.AbstractToolBox(config_filenames, tool_root_dir, app, view_sources=None, default_panel_view='default', save_integrated_tool_panel=True)[source]

Bases: ManagesIntegratedToolPanelMixin

Abstract container for managing a ToolPanel - containing tools and workflows optionally in labelled sections.

__init__(config_filenames, tool_root_dir, app, view_sources=None, default_panel_view='default', save_integrated_tool_panel=True)[source]

Create a toolbox from the config files named by config_filenames, using tool_root_dir as the base directory for finding individual tool config files.

create_tool(config_file, tool_cache_data_dir=None, **kwds)[source]
create_dynamic_tool(dynamic_tool)[source]
can_load_config_file(config_filename)[source]
tool_tag_manager()[source]

Build a tool tag manager according to app’s configuration and return it.

panel_views() List[ToolPanelViewModel][source]
panel_view_dicts() Dict[str, Dict][source]
panel_has_tool(tool, panel_view_id)[source]
load_dynamic_tool(dynamic_tool)[source]
load_item(item, tool_path, panel_dict=None, integrated_panel_dict=None, load_panel_dict=True, guid=None, index=None, tool_cache_data_dir=None)[source]
get_shed_config_dict_by_filename(filename) Dict[str, Any] | None[source]
update_shed_config(shed_conf)[source]

Update the in-memory descriptions of tools and write out the changes to integrated tool panel unless we are just deactivating a tool (since that doesn’t affect that file).

get_section(section_id, new_label=None, create_if_needed=False)[source]
create_section(section_dict)[source]
get_section_for_tool(tool)[source]
add_tool_to_tool_panel_view(tool, view_panel_component)[source]
get_tool(tool_id, tool_version=None, get_all_versions=False, exact=False, tool_uuid=None)[source]

Attempt to locate a tool in the tool box. Note that exact only refers to the tool_id, not the tool_version.

has_tool(tool_id: str, tool_version: str | None = None, exact: bool = False)[source]
is_missing_shed_tool(tool_id: str) bool[source]

Confirm that the tool ID does reference a shed tool and is not installed.

get_loaded_tools_by_lineage(tool_id: str) list[source]

Get all loaded tools associated by lineage to the tool whose id is tool_id.

tools()[source]
dynamic_confs(include_migrated_tool_conf=False) List[Dict[str, Any]][source]
default_shed_tool_conf_dict() Dict[str, Any][source]

If set, returns the first shed_tool_conf_dict corresponding to shed_tool_config_file, else the first dynamic conf.

dynamic_conf_filenames()[source]

Return list of dynamic tool configuration filenames (shed_tools). These must be used with various dynamic tool configuration update operations (e.g. with update_shed_config).

get_tool_repository_from_xml_item(elem, path)[source]
load_tool(config_file, guid=None, tool_shed_repository=None, use_cached=False, tool_cache_data_dir=None, **kwds)[source]

Load a single tool from the file named by config_file and return an instance of Tool.

watch_tool(tool)[source]
add_tool_to_cache(tool, config_file)[source]
load_tool_from_cache(config_file, recover_tool=False)[source]
load_hidden_lib_tool(path)[source]
load_hidden_tool(config_file, **kwds)[source]

Load a hidden tool (in this context meaning one that does not appear in the tool panel) and register it in _tools_by_id.

register_tool(tool)[source]
package_tool(trans, tool_id)[source]

Create a tarball with the tool’s xml, help images, and test data. :param trans: the web transaction :param tool_id: the tool ID from app.toolbox :returns: tuple of tarball filename, success True/False, message/None

reload_tool_by_id(tool_id: str) Tuple[str | Dict[str, str], str][source]

Attempt to reload the tool identified by ‘tool_id’, if successful replace the old tool.

remove_tool_by_id(tool_id, remove_from_panel=True)[source]

Attempt to remove the tool identified by ‘tool_id’. Ignores tool lineage - so to remove a tool with potentially multiple versions send remove_from_panel=False and handle the logic of promoting the next newest version of the tool into the panel if needed.

get_sections()[source]

Return section id and name pairs.

Only used by build_tool_panel_section_select_field in tool shed client code.

find_section_id(tool_panel_section_id)[source]

Find the section ID referenced by the key or return ‘’ indicating no such section id.

tool_panel_contents(trans, view=None, **kwds)[source]

Filter tool_panel contents for displaying for user.

get_tool_to_dict(trans, tool, tool_help=False)[source]

Return tool’s to_dict. Use cache if present, store to cache otherwise. Note: The cached tool’s to_dict is specific to the calls from toolbox.

to_dict(trans, in_panel=True, tool_help=False, view=None, **kwds)[source]

Create a dictionary representation of the toolbox. Uses primitive cache for toolbox-specific tool ‘to_dict’s.

to_panel_view(trans, view='default_panel_view', **kwds)[source]

Create a panel view representation of the toolbox. Uses the structure:

{section_id: { section but with .tools=List[all tool ids] }, …}}

class galaxy.tool_util.toolbox.AbstractToolTagManager[source]

Bases: object

abstract reset_tags()[source]

Starting to load tool panels, reset all tags.

abstract handle_tags(tool_id, tool_definition_source)[source]

Parse out tags and persist them.

class galaxy.tool_util.toolbox.panel_item_types(value)[source]

Bases: str, Enum

An enumeration.

TOOL = 'TOOL'
WORKFLOW = 'WORKFLOW'
SECTION = 'SECTION'
LABEL = 'LABEL'
class galaxy.tool_util.toolbox.ToolSection(item=None)[source]

Bases: UsesDictVisibleKeys, HasPanelItems

A group of tools with similar type/purpose that will be displayed as a group in the user interface.

dict_collection_visible_keys = ['id', 'name', 'version', 'description', 'links']
__init__(item=None)[source]

Build a ToolSection from an ElementTree element or a dictionary.

copy(merge_tools=False)[source]
to_dict(trans, link_details=False, tool_help=False, toolbox=None, only_ids=False)[source]

Return a dict that includes section’s attributes.

if only_ids is True, we store only the ids of the section’s tools in section.tools (also full ToolSectionLabel objects in section.tools if any are present)

if only_ids is False, we store the section’s full Tool (and any other) objects in section.elems

panel_items()[source]

Return an ordered dictionary-like object describing tool panel items (such as workflows, tools, labels, and sections).

class galaxy.tool_util.toolbox.ToolSectionLabel(item)[source]

Bases: UsesDictVisibleKeys

A label for a set of tools that can be displayed above groups of tools and sections in the user interface

dict_collection_visible_keys = ['id', 'text', 'version', 'description', 'links']
__init__(item)[source]

Build a ToolSectionLabel from an ElementTree element or a dictionary.

to_dict(**kwds)[source]

Subpackages

Submodules

galaxy.tool_util.toolbox.base module

class galaxy.tool_util.toolbox.base.ToolConfRepository(tool_shed, name, owner, installed_changeset_revision, changeset_revision, tool_dependencies_installed_or_in_error, repository_path, tool_path)[source]

Bases: _ToolConfRepository

get_tool_relative_path(*args, **kwargs)[source]
class galaxy.tool_util.toolbox.base.ToolBoxRegistryImpl(toolbox: AbstractToolBox)[source]

Bases: ToolBoxRegistry

View of ToolBox provided to ToolPanelView to reason about tools loaded.

__init__(toolbox: AbstractToolBox)[source]
has_tool(tool_id: str) bool[source]

Return bool indicating if tool with specified id is loaded.

get_tool(tool_id: str)[source]

Return tool with supplied tool id.

get_workflow(id: str)[source]

Return workflow from panel with supplied id.

add_tool_to_tool_panel_view(tool, tool_panel_component) None[source]

Add tool to the tool panel view component (root or section).

class galaxy.tool_util.toolbox.base.AbstractToolTagManager[source]

Bases: object

abstract reset_tags()[source]

Starting to load tool panels, reset all tags.

abstract handle_tags(tool_id, tool_definition_source)[source]

Parse out tags and persist them.

class galaxy.tool_util.toolbox.base.NullToolTagManager[source]

Bases: AbstractToolTagManager

reset_tags() None[source]

Starting to load tool panels, reset all tags.

handle_tags(tool_id, tool_definition_source) None[source]

Parse out tags and persist them.

class galaxy.tool_util.toolbox.base.AbstractToolBox(config_filenames, tool_root_dir, app, view_sources=None, default_panel_view='default', save_integrated_tool_panel=True)[source]

Bases: ManagesIntegratedToolPanelMixin

Abstract container for managing a ToolPanel - containing tools and workflows optionally in labelled sections.

__init__(config_filenames, tool_root_dir, app, view_sources=None, default_panel_view='default', save_integrated_tool_panel=True)[source]

Create a toolbox from the config files named by config_filenames, using tool_root_dir as the base directory for finding individual tool config files.

create_tool(config_file, tool_cache_data_dir=None, **kwds)[source]
create_dynamic_tool(dynamic_tool)[source]
can_load_config_file(config_filename)[source]
tool_tag_manager()[source]

Build a tool tag manager according to app’s configuration and return it.

panel_views() List[ToolPanelViewModel][source]
panel_view_dicts() Dict[str, Dict][source]
panel_has_tool(tool, panel_view_id)[source]
load_dynamic_tool(dynamic_tool)[source]
load_item(item, tool_path, panel_dict=None, integrated_panel_dict=None, load_panel_dict=True, guid=None, index=None, tool_cache_data_dir=None)[source]
get_shed_config_dict_by_filename(filename) Dict[str, Any] | None[source]
update_shed_config(shed_conf)[source]

Update the in-memory descriptions of tools and write out the changes to integrated tool panel unless we are just deactivating a tool (since that doesn’t affect that file).

get_section(section_id, new_label=None, create_if_needed=False)[source]
create_section(section_dict)[source]
get_section_for_tool(tool)[source]
add_tool_to_tool_panel_view(tool, view_panel_component)[source]
get_tool(tool_id, tool_version=None, get_all_versions=False, exact=False, tool_uuid=None)[source]

Attempt to locate a tool in the tool box. Note that exact only refers to the tool_id, not the tool_version.

has_tool(tool_id: str, tool_version: str | None = None, exact: bool = False)[source]
is_missing_shed_tool(tool_id: str) bool[source]

Confirm that the tool ID does reference a shed tool and is not installed.

get_loaded_tools_by_lineage(tool_id: str) list[source]

Get all loaded tools associated by lineage to the tool whose id is tool_id.

tools()[source]
dynamic_confs(include_migrated_tool_conf=False) List[Dict[str, Any]][source]
default_shed_tool_conf_dict() Dict[str, Any][source]

If set, returns the first shed_tool_conf_dict corresponding to shed_tool_config_file, else the first dynamic conf.

dynamic_conf_filenames()[source]

Return list of dynamic tool configuration filenames (shed_tools). These must be used with various dynamic tool configuration update operations (e.g. with update_shed_config).

get_tool_repository_from_xml_item(elem, path)[source]
load_tool(config_file, guid=None, tool_shed_repository=None, use_cached=False, tool_cache_data_dir=None, **kwds)[source]

Load a single tool from the file named by config_file and return an instance of Tool.

watch_tool(tool)[source]
add_tool_to_cache(tool, config_file)[source]
load_tool_from_cache(config_file, recover_tool=False)[source]
load_hidden_lib_tool(path)[source]
load_hidden_tool(config_file, **kwds)[source]

Load a hidden tool (in this context meaning one that does not appear in the tool panel) and register it in _tools_by_id.

register_tool(tool)[source]
package_tool(trans, tool_id)[source]

Create a tarball with the tool’s xml, help images, and test data. :param trans: the web transaction :param tool_id: the tool ID from app.toolbox :returns: tuple of tarball filename, success True/False, message/None

reload_tool_by_id(tool_id: str) Tuple[str | Dict[str, str], str][source]

Attempt to reload the tool identified by ‘tool_id’, if successful replace the old tool.

remove_tool_by_id(tool_id, remove_from_panel=True)[source]

Attempt to remove the tool identified by ‘tool_id’. Ignores tool lineage - so to remove a tool with potentially multiple versions send remove_from_panel=False and handle the logic of promoting the next newest version of the tool into the panel if needed.

get_sections()[source]

Return section id and name pairs.

Only used by build_tool_panel_section_select_field in tool shed client code.

find_section_id(tool_panel_section_id)[source]

Find the section ID referenced by the key or return ‘’ indicating no such section id.

tool_panel_contents(trans, view=None, **kwds)[source]

Filter tool_panel contents for displaying for user.

get_tool_to_dict(trans, tool, tool_help=False)[source]

Return tool’s to_dict. Use cache if present, store to cache otherwise. Note: The cached tool’s to_dict is specific to the calls from toolbox.

to_dict(trans, in_panel=True, tool_help=False, view=None, **kwds)[source]

Create a dictionary representation of the toolbox. Uses primitive cache for toolbox-specific tool ‘to_dict’s.

to_panel_view(trans, view='default_panel_view', **kwds)[source]

Create a panel view representation of the toolbox. Uses the structure:

{section_id: { section but with .tools=List[all tool ids] }, …}}

galaxy.tool_util.toolbox.integrated_panel module

class galaxy.tool_util.toolbox.integrated_panel.ManagesIntegratedToolPanelMixin[source]

Bases: object

galaxy.tool_util.toolbox.panel module

class galaxy.tool_util.toolbox.panel.panel_item_types(value)[source]

Bases: str, Enum

An enumeration.

TOOL = 'TOOL'
WORKFLOW = 'WORKFLOW'
SECTION = 'SECTION'
LABEL = 'LABEL'
class galaxy.tool_util.toolbox.panel.HasPanelItems[source]

Bases: object

abstract panel_items()[source]

Return an ordered dictionary-like object describing tool panel items (such as workflows, tools, labels, and sections).

panel_items_iter()[source]

Iterate through panel items each represented as a tuple of (panel_key, panel_type, panel_content).

class galaxy.tool_util.toolbox.panel.ToolSection(item=None)[source]

Bases: UsesDictVisibleKeys, HasPanelItems

A group of tools with similar type/purpose that will be displayed as a group in the user interface.

dict_collection_visible_keys = ['id', 'name', 'version', 'description', 'links']
__init__(item=None)[source]

Build a ToolSection from an ElementTree element or a dictionary.

copy(merge_tools=False)[source]
to_dict(trans, link_details=False, tool_help=False, toolbox=None, only_ids=False)[source]

Return a dict that includes section’s attributes.

if only_ids is True, we store only the ids of the section’s tools in section.tools (also full ToolSectionLabel objects in section.tools if any are present)

if only_ids is False, we store the section’s full Tool (and any other) objects in section.elems

panel_items()[source]

Return an ordered dictionary-like object describing tool panel items (such as workflows, tools, labels, and sections).

class galaxy.tool_util.toolbox.panel.ToolSectionLabel(item)[source]

Bases: UsesDictVisibleKeys

A label for a set of tools that can be displayed above groups of tools and sections in the user interface

dict_collection_visible_keys = ['id', 'text', 'version', 'description', 'links']
__init__(item)[source]

Build a ToolSectionLabel from an ElementTree element or a dictionary.

to_dict(**kwds)[source]
class galaxy.tool_util.toolbox.panel.ToolPanelElements(dict=None)[source]

Bases: odict, HasPanelItems

Represents an ordered dictionary of tool entries - abstraction used both by tool panel itself (normal and integrated) and its sections.

record_section_for_tool_id(tool_id: str, key: str, val: str)[source]
get_section_for_tool_id(tool_id: str) Tuple[str | None, str | None][source]
replace_tool_for_id(tool_id: str, new_tool) None[source]
get_or_create_section(sec_id: str, sec_nm: str, description: str | None = None, links: Dict[str, str] | None = None) ToolSection[source]
remove_tool(tool_id: str) None[source]
update_or_append(index: int, key: str, value) None[source]
get_label(label: str) ToolSection | None[source]
has_tool_with_id(tool_id: str) bool[source]
replace_tool(previous_tool_id: str, new_tool_id: str, tool) None[source]
index_of_tool_id(tool_id: str) int | None[source]
insert_tool(index: int, tool) None[source]
get_tool_with_id(tool_id: str)[source]
append_tool(tool) None[source]
stub_tool(key: str) None[source]
stub_workflow(key: str) None[source]
stub_label(key: str) None[source]
append_section(key: str, section: ToolSection) None[source]
panel_items()[source]

Return an ordered dictionary-like object describing tool panel items (such as workflows, tools, labels, and sections).

walk_sections()[source]
closest_section(target_section_id: str | None, target_section_name: str | None)[source]
apply_filter(f)[source]
copy() ToolPanelElements[source]
has_item_recursive(item)[source]

Check panel and section elements for supplied item.

galaxy.tool_util.toolbox.parser module

This module is used to parse tool_conf files.

These files define tool lists, sections, labels, etc… the elements of the Galaxy tool panel.

galaxy.tool_util.toolbox.parser.get_toolbox_parser(config_filename: str | PathLike)[source]
galaxy.tool_util.toolbox.parser.ensure_tool_conf_item(xml_or_item)[source]

galaxy.tool_util.toolbox.tags module

galaxy.tool_util.toolbox.watcher module

galaxy.tool_util.toolbox.watcher.get_tool_conf_watcher(reload_callback, tool_cache=None)[source]
galaxy.tool_util.toolbox.watcher.get_tool_watcher(toolbox, config)[source]
class galaxy.tool_util.toolbox.watcher.ToolFileEventHandler(tool_watcher)[source]

Bases: FileSystemEventHandler

__init__(tool_watcher)[source]
on_any_event(event)[source]

Catch-all event handler.

Parameters:

event (FileSystemEvent) – The event object representing the file system event.

class galaxy.tool_util.toolbox.watcher.ToolConfWatcher(reload_callback, tool_cache=None)[source]

Bases: object

__init__(reload_callback, tool_cache=None)[source]
start()[source]
shutdown()[source]
check()[source]

Check for changes in self.paths or self.cache and call the event handler.

monitor(path)[source]
watch_file(tool_conf_file)[source]
class galaxy.tool_util.toolbox.watcher.ToolWatcher(observer_class, event_handler_class, toolbox)[source]

Bases: BaseWatcher

__init__(observer_class, event_handler_class, toolbox)[source]
watch_file(tool_file, tool_id)[source]
watch_directory(tool_dir, callback)[source]