Warning

This document is for an old release 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.tools package

Classes encapsulating galaxy tools and tool configuration.

class galaxy.tools.safe_update(min_version, current_version)[source]

Bases: tuple

property min_version

Alias for field number 0

property current_version

Alias for field number 1

exception galaxy.tools.ToolNotFoundException[source]

Bases: Exception

galaxy.tools.create_tool_from_source(app, tool_source, config_file=None, **kwds)[source]
class galaxy.tools.ToolBox(config_filenames, tool_root_dir, app, save_integrated_tool_panel=True)[source]

Bases: galaxy.tool_util.toolbox.base.BaseGalaxyToolBox

A derivative of AbstractToolBox with knowledge about Tool internals - how to construct them, action types, dependency management, etc….

__init__(config_filenames, tool_root_dir, app, 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.

persist_cache(register_postfork=False)[source]

Persists any modified tool cache files to disk.

Set register_postfork to stop database thread queue, close database connection and register re-open function that re-opens the database after forking.

can_load_config_file(config_filename)[source]
has_reloaded(other_toolbox)[source]
property all_requirements
property tools_by_id
get_cache_region(tool_cache_data_dir)[source]
create_tool(config_file, tool_cache_data_dir=None, **kwds)[source]
get_expanded_tool_source(config_file, **kwargs)[source]
create_dynamic_tool(dynamic_tool, **kwds)[source]
get_tool_components(tool_id, tool_version=None, get_loaded_tools_by_lineage=False, set_selected=False)[source]

Retrieve all loaded versions of a tool from the toolbox and return a select list enabling selection of a different version, the list of the tool’s loaded versions, and the specified tool.

class galaxy.tools.DefaultToolState[source]

Bases: object

Keeps track of the state of a users interaction with a tool between requests.

__init__()[source]
initialize(trans, tool)[source]

Create a new DefaultToolState for this tool. It will be initialized with default values for inputs. Grouping elements are filled in recursively.

encode(tool, app, nested=False)[source]

Convert the data to a string

decode(values, tool, app)[source]

Restore the state from a string

copy()[source]

Shallow copy of the state

class galaxy.tools.Tool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.util.dictifiable.Dictifiable

Represents a computational tool that can be executed through Galaxy.

tool_type = 'default'
requires_setting_metadata = True
produces_entry_points = False
default_tool_action

alias of galaxy.tools.actions.DefaultToolAction

tool_action: galaxy.tools.actions.ToolAction
tool_type_local = False
dict_collection_visible_keys = ['id', 'name', 'version', 'description', 'labels']
version: str
__init__(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Load a tool from the config named by config_file

assert_finalized(raise_if_invalid=False)[source]
remove_from_cache()[source]
property history_manager
property version_object
property sa_session

Returns a SQLAlchemy session

property lineage

Return ToolLineage for this tool.

property tool_versions
property is_latest_version
property latest_version
property is_datatype_converter
property tool_shed_repository
property produces_collections_with_unknown_structure
property valid_input_states
property requires_galaxy_python_environment

Indicates this tool’s runtime requires Galaxy’s Python environment.

get_configured_job_handler(job_params=None)[source]

Get the configured job handler for this Tool given the provided job_params.

Unlike the former get_job_handler() method, this does not perform “preassignment” (random selection of a configured handler ID from a tag).

Parameters

job_params (dict or None) – Any params specific to this job (e.g. the job source)

Returns

str or None – The configured handler for a job run of this Tool

get_job_destination(job_params=None)[source]
Returns

galaxy.jobs.JobDestination – The destination definition and runner parameters.

get_panel_section()[source]
allow_user_access(user, attempting_access=True)[source]
Returns

bool – Whether the user is allowed to access the tool.

parse(tool_source, guid=None, dynamic=False)[source]

Read tool configuration from the element root and fill in self.

property tests
test_data_path(filename)[source]
tool_provided_metadata(job_wrapper)[source]
parse_command(tool_source)[source]
parse_environment_variables(tool_source)[source]
parse_inputs(tool_source)[source]

Parse the “<inputs>” element and create appropriate ToolParameter s. This implementation supports multiple pages and grouping constructs.

parse_help(tool_source)[source]

Parse the help text for the tool. Formatted in reStructuredText, but stored as Mako to allow for dynamic image paths. This implementation supports multiple pages.

parse_outputs(tool_source)[source]

Parse <outputs> elements and fill in self.outputs (keyed by name)

parse_stdio(tool_source)[source]

Parse <stdio> element(s) and fill in self.return_codes, self.stderr_rules, and self.stdout_rules. Return codes have a range and an error type (fault or warning). Stderr and stdout rules have a regular expression and an error level (fault or warning).

parse_input_elem(page_source, enctypes, context=None)[source]

Parse a parent element whose children are inputs – these could be groups (repeat, conditional) or param elements. Groups will be parsed recursively.

parse_param_elem(input_source, enctypes, context)[source]

Parse a single “<param>” element and return a ToolParameter instance. Also, if the parameter has a ‘required_enctype’ add it to the set enctypes.

populate_resource_parameters(tool_source)[source]
populate_tool_shed_info(tool_shed_repository)[source]
property legacy_biotools_external_reference: Optional[str]

Return a bio.tools ID if any of tool’s IDs are BIOTOOLS_MAPPING.

property biotools_reference: Optional[str]

Return a bio.tools ID if external reference to it is found.

If multiple bio.tools references are found, return just the first one.

property help
property help_by_page
property raw_help
find_output_def(name)[source]
property is_workflow_compatible
check_workflow_compatible(tool_source)[source]

Determine if a tool can be used in workflows. External tools and the upload tool are currently not supported by workflows.

new_state(trans)[source]

Create a new DefaultToolState for this tool. It will be initialized with default values for inputs. Grouping elements are filled in recursively.

get_param(key)[source]

Returns the parameter named key or None if there is no such parameter.

get_hook(name)[source]

Returns an object from the code file referenced by code_namespace (this will normally be a callable object)

visit_inputs(values, callback)[source]

Call the function callback on each parameter of this tool. Visits grouping parameters recursively and constructs unique prefixes for each nested set of The callback method is then called as:

callback( level_prefix, parameter, parameter_value )

expand_incoming(trans, incoming, request_context, input_format='legacy')[source]
handle_input(trans, incoming, history=None, use_cached_job=False, input_format='legacy')[source]

Process incoming parameters for this tool from the dict incoming, update the tool state (or create if none existed), and either return to the form or execute the tool (only if ‘execute’ was clicked and there were no errors).

handle_single_execution(trans, rerun_remap_job_id, execution_slice, history, execution_cache=None, completed_job=None, collection_info=None, job_callback=None, flush_job=True)[source]

Return a pair with whether execution is successful as well as either resulting output data or an error message indicating the problem.

find_fieldstorage(x)[source]
property params_with_missing_data_table_entry

Return all parameters that are dynamically generated select lists whose options require an entry not currently in the tool_data_table_conf.xml file.

property params_with_missing_index_file

Return all parameters that are dynamically generated select lists whose options refer to a missing .loc file.

get_static_param_values(trans)[source]

Returns a map of parameter names and values if the tool does not require any user input. Will raise an exception if any parameter does require input.

execute(trans, incoming=None, set_output_hid=True, history=None, **kwargs)[source]

Execute the tool using parameter values in incoming. This just dispatches to the ToolAction instance specified by self.tool_action. In general this will create a Job that when run will build the tool’s outputs, e.g. DefaultToolAction.

params_to_strings(params, app, nested=False)[source]
params_from_strings(params, app, ignore_errors=False)[source]
check_and_update_param_values(values, trans, update_values=True, workflow_building_mode=False)[source]

Check that all parameters have values, and fill in with default values where necessary. This could be called after loading values from a database in case new parameters have been added.

build_dependency_cache(**kwds)[source]
build_dependency_shell_commands(job_directory=None, metadata=False)[source]

Return a list of commands to be run to populate the current environment to include this tools requirements.

property installed_tool_dependencies
property tool_requirements

Return all requiremens of type package

property tool_requirements_status

Return a list of dictionaries for all tool dependencies with their associated status

property output_discover_patterns
build_redirect_url_params(param_dict)[source]

Substitute parameter values into self.redirect_url_params

parse_redirect_url(data, param_dict)[source]

Parse the REDIRECT_URL tool param. Tools that send data to an external application via a redirect must include the following 3 tool params:

  1. REDIRECT_URL - the url to which the data is being sent

  2. DATA_URL - the url to which the receiving application will send an http post to retrieve the Galaxy data

  3. GALAXY_URL - the url to which the external application may post data as a response

call_hook(hook_name, *args, **kwargs)[source]

Call the custom code hook function identified by ‘hook_name’ if any, and return the results

exec_before_job(app, inp_data, out_data, param_dict=None)[source]
exec_after_process(app, inp_data, out_data, param_dict, job=None, **kwds)[source]
job_failed(job_wrapper, message, exception=False)[source]

Called when a job has failed

discover_outputs(out_data, out_collections, tool_provided_metadata, tool_working_directory, job, input_ext, input_dbkey, inp_data=None, final_job_state='ok')[source]

Find any additional datasets generated by a tool and attach (for cases where number of outputs is not known in advance).

to_archive()[source]
to_dict(trans, link_details=False, io_details=False, tool_help=False)[source]

Returns dict of tool.

to_json(trans, kwd=None, job=None, workflow_building_mode=False, history=None)[source]

Recursively creates a tool dictionary containing repeats, dynamic options and updated states.

populate_model(request_context, inputs, state_inputs, group_inputs, other_values=None)[source]

Populates the tool model consumed by the client form builder.

get_default_history_by_trans(trans, create=False)[source]
classmethod get_externally_referenced_paths(path)[source]

Return relative paths to externally referenced files by the tool described by file at path. External components should not assume things about the structure of tool xml files (this is the tool’s responsibility).

class galaxy.tools.OutputParameterJSONTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.Tool

Alternate implementation of Tool that provides parameters and other values JSONified within the contents of an output dataset

tool_type = 'output_parameter_json'
exec_before_job(app, inp_data, out_data, param_dict=None)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.ExpressionTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.Tool

requires_js_runtime = True
tool_type = 'expression'
tool_type_local = True
EXPRESSION_INPUTS_NAME = '_expression_inputs_.json'
parse_command(tool_source)[source]
parse_outputs(tool_source)[source]

Parse <outputs> elements and fill in self.outputs (keyed by name)

exec_before_job(app, inp_data, out_data, param_dict=None)[source]
exec_after_process(app, inp_data, out_data, param_dict, job=None, **kwds)[source]
parse_environment_variables(tool_source)[source]

Setup environment variable for inputs file.

tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.DataSourceTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.OutputParameterJSONTool

Alternate implementation of Tool for data_source tools – those that allow the user to query and extract data from another web site.

tool_type = 'data_source'
default_tool_action

alias of galaxy.tools.actions.data_source.DataSourceToolAction

parse_inputs(tool_source)[source]

Parse the “<inputs>” element and create appropriate ToolParameter s. This implementation supports multiple pages and grouping constructs.

exec_before_job(app, inp_data, out_data, param_dict=None)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.AsyncDataSourceTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DataSourceTool

tool_type = 'data_source_async'
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.DataDestinationTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.Tool

tool_type = 'data_destination'
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.SetMetadataTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.Tool

Tool implementation for special tool that sets metadata on an existing dataset.

tool_type = 'set_metadata'
requires_setting_metadata = False
tool_action: SetMetadataToolAction
regenerate_imported_metadata_if_needed(hda, history, job)[source]
exec_after_process(app, inp_data, out_data, param_dict, job=None, **kwds)[source]
job_failed(job_wrapper, message, exception=False)[source]

Called when a job has failed

class galaxy.tools.ExportHistoryTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.Tool

tool_type = 'export_history'
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.ImportHistoryTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.Tool

tool_type = 'import_history'
exec_after_process(app, inp_data, out_data, param_dict, job, final_job_state=None, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.InteractiveTool(config_file, tool_source, app, **kwd)[source]

Bases: galaxy.tools.Tool

tool_type = 'interactive'
produces_entry_points = True
__init__(config_file, tool_source, app, **kwd)[source]

Load a tool from the config named by config_file

exec_after_process(app, inp_data, out_data, param_dict, job=None, **kwds)[source]
job_failed(job_wrapper, message, exception=False)[source]

Called when a job has failed

tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.DataManagerTool(config_file, root, app, guid=None, data_manager_id=None, **kwds)[source]

Bases: galaxy.tools.OutputParameterJSONTool

tool_type = 'manage_data'
default_tool_action

alias of galaxy.tools.actions.data_manager.DataManagerToolAction

__init__(config_file, root, app, guid=None, data_manager_id=None, **kwds)[source]

Load a tool from the config named by config_file

exec_after_process(app, inp_data, out_data, param_dict, job=None, final_job_state=None, **kwds)[source]
get_default_history_by_trans(trans, create=False)[source]
allow_user_access(user, attempting_access=True) bool[source]

Check user access to this tool.

Parameters
  • user (galaxy.model.User) – model object representing user.

  • attempting_access (bool) – is the user attempting to do something with the the tool (set false for incidental checks like toolbox listing)

Returns

Whether the user is allowed to access the tool. Data Manager tools are only accessible to admins.

tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.DatabaseOperationTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.Tool

default_tool_action

alias of galaxy.tools.actions.model_operations.ModelOperationToolAction

require_dataset_ok = True
tool_type_local = True
property valid_input_states
property allow_errored_inputs
check_inputs_ready(input_datasets, input_dataset_collections)[source]
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.UnzipCollectionTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'unzip_collection'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.ZipCollectionTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'zip_collection'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.BuildListCollectionTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'build_list'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.ExtractDatasetCollectionTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'extract_dataset'
produce_outputs(trans, out_data, output_collections, incoming, history, tags=None, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.MergeCollectionTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'merge_collection'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.FilterDatasetsTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.FilterFailedDatasetsTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.FilterDatasetsTool

tool_type = 'filter_failed_datasets_collection'
require_dataset_ok = False
element_is_valid(element)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.FilterEmptyDatasetsTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.FilterDatasetsTool

tool_type = 'filter_empty_datasets_collection'
require_dataset_ok = False
element_is_valid(element)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.FlattenTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'flatten_collection'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.SortTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'sort_collection'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.RelabelFromFileTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'relabel_from_file'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.ApplyRulesTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'apply_rules'
produce_outputs(trans, out_data, output_collections, incoming, history, tag_handler, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.TagFromFileTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'tag_from_file'
produce_outputs(trans, out_data, output_collections, incoming, history, tag_handler, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.FilterFromFileTool(config_file, tool_source, app, guid=None, repository_id=None, tool_shed_repository=None, allow_code_files=True, dynamic=False, tool_dir=None)[source]

Bases: galaxy.tools.DatabaseOperationTool

tool_type = 'filter_from_file'
produce_outputs(trans, out_data, output_collections, incoming, history, **kwds)[source]
tool_action: galaxy.tools.actions.ToolAction
version: str
action: Union[str, Tuple[str, str]]
class galaxy.tools.TracksterConfig(actions)[source]

Bases: object

Trackster configuration encapsulation.

__init__(actions)[source]
static parse(root)[source]
class galaxy.tools.SetParamAction(name, output_name)[source]

Bases: object

Set parameter action.

__init__(name, output_name)[source]
static parse(elt)[source]

Parse action from element.

class galaxy.tools.BadValue(value)[source]

Bases: object

__init__(value)[source]
galaxy.tools.tool_class

alias of galaxy.tools.DataDestinationTool

exception galaxy.tools.InterruptedUpload[source]

Bases: Exception

Subpackages

Submodules

galaxy.tools.biotools module

Adapt Galaxy-agnostic abstraction galaxy.tool_util.biotools to Galaxy config and dependencies.

galaxy.tools.biotools.get_galaxy_biotools_metadata_source(config) galaxy.tool_util.biotools.source.BiotoolsMetadataSource[source]

Build a BiotoolsMetadataSource from a Galaxy configuration object.

galaxy.tools.cache module

galaxy.tools.cache.encoder(obj)[source]
galaxy.tools.cache.decoder(obj)[source]
class galaxy.tools.cache.ToolDocumentCache(cache_dir)[source]

Bases: object

__init__(cache_dir)[source]
close()[source]
property cache_file_is_writeable
reopen_ro()[source]
get(config_file)[source]
persist()[source]
set(config_file, tool_source)[source]
delete(config_file)[source]
class galaxy.tools.cache.ToolCache[source]

Bases: object

Cache tool definitions to allow quickly reloading the whole toolbox.

__init__()[source]
assert_hashes_initialized()[source]
cleanup()[source]

Remove uninstalled tools from tool cache if they are not on disk anymore or if their content has changed.

Returns list of tool_ids that have been removed.

get_tool(config_filename)[source]

Get the tool at config_filename from the cache if the tool is up to date.

get_removed_tool(config_filename)[source]
get_tool_by_id(tool_id)[source]

Get the tool with the id tool_id from the cache if the tool is up to date.

expire_tool(tool_id)[source]
cache_tool(config_filename, tool)[source]
reset_status()[source]

Reset tracking of new and newly disabled tools.

class galaxy.tools.cache.ToolHash(path, modtime=None, lazy_hash=False)[source]

Bases: object

__init__(path, modtime=None, lazy_hash=False)[source]
property hash
class galaxy.tools.cache.ToolShedRepositoryCache(session: galaxy.model.scoped_session.install_model_scoped_session)[source]

Bases: object

Cache installed ToolShedRepository objects.

__init__(session: galaxy.model.scoped_session.install_model_scoped_session)[source]
local_repositories: List[galaxy.tool_util.toolbox.base.ToolConfRepository]
repositories: List[galaxy.model.tool_shed_install.ToolShedRepository]
repos_by_tuple: Dict[Tuple[str, str, str], List[galaxy.tool_util.toolbox.base.ToolConfRepository]]
add_local_repository(repository)[source]
get_installed_repository(tool_shed=None, name=None, owner=None, installed_changeset_revision=None, changeset_revision=None, repository_id=None)[source]

galaxy.tools.data_fetch module

galaxy.tools.data_fetch.main(argv=None)[source]
galaxy.tools.data_fetch.elements_tree_map(f, items)[source]
galaxy.tools.data_fetch.get_file_sources(working_directory)[source]
class galaxy.tools.data_fetch.UploadConfig(request, registry, working_directory, allow_failed_collections)[source]

Bases: object

__init__(request, registry, working_directory, allow_failed_collections)[source]
get_option(item, key)[source]

Return item[key] if specified otherwise use default from UploadConfig.

This default represents the default for the whole request instead item which is the option for individual files.

ensure_in_working_directory(path, purge_source, in_place)[source]

galaxy.tools.errors module

Functionality for dealing with tool errors.

class galaxy.tools.errors.ErrorReporter(hda, app)[source]

Bases: object

__init__(hda, app)[source]
create_report(user, email='', message='', redact_user_details_in_bugreport=False, **kwd)[source]
send_report(user, email=None, message=None, **kwd)[source]
class galaxy.tools.errors.EmailErrorReporter(hda, app)[source]

Bases: galaxy.tools.errors.ErrorReporter

galaxy.tools.evaluation module

class galaxy.tools.evaluation.ToolErrorLog[source]

Bases: object

__init__()[source]
add_error(file, phase, exception)[source]
galaxy.tools.evaluation.global_tool_logs(func, config_file, action_str)[source]
class galaxy.tools.evaluation.ToolEvaluator(app, tool, job, local_working_directory)[source]

Bases: object

An abstraction linking together a tool and a job runtime to evaluate tool inputs in an isolated, testable manner.

__init__(app, tool, job, local_working_directory)[source]
set_compute_environment(compute_environment: galaxy.job_execution.compute_environment.ComputeEnvironment, get_special: Optional[Callable] = None)[source]

Setup the compute environment and established the outline of the param_dict for evaluating command and config cheetah templates.

execute_tool_hooks(inp_data, out_data, incoming)[source]
build_param_dict(incoming, input_datasets, output_datasets, output_collections)[source]

Build the dictionary of parameters for substituting into the command line. Each value is wrapped in a InputValueWrapper, which allows all the attributes of the value to be used in the template, but when the __str__ method is called it actually calls the to_param_dict_string method of the associated input.

populate_interactivetools()[source]

Populate InteractiveTools templated values.

build()[source]

Build runtime description of job to execute, evaluate command and config templates corresponding to this tool with these inputs on this compute environment.

class galaxy.tools.evaluation.PartialToolEvaluator(app, tool, job, local_working_directory)[source]

Bases: galaxy.tools.evaluation.ToolEvaluator

ToolEvaluator that only builds Environment Variables.

build()[source]

Build runtime description of job to execute, evaluate command and config templates corresponding to this tool with these inputs on this compute environment.

class galaxy.tools.evaluation.RemoteToolEvaluator(app, tool, job, local_working_directory)[source]

Bases: galaxy.tools.evaluation.ToolEvaluator

ToolEvaluator that skips unnecessary steps already executed during job setup.

execute_tool_hooks(inp_data, out_data, incoming)[source]
build()[source]

Build runtime description of job to execute, evaluate command and config templates corresponding to this tool with these inputs on this compute environment.

galaxy.tools.exception_handling module

class galaxy.tools.exception_handling.UCSCOutWrapper(other)[source]

Bases: object

File-like object that throws an exception if it encounters the UCSC limit error lines

__init__(other)[source]
next()[source]
readline()[source]
exception galaxy.tools.exception_handling.UCSCLimitException[source]

Bases: Exception

galaxy.tools.execute module

Once state information has been calculated, handle actually executing tools from various states, tracking results, and building implicit dataset collections from matched collections.

galaxy.tools.execute.execute(trans, tool, mapping_params, history, rerun_remap_job_id=None, collection_info=None, workflow_invocation_uuid=None, invocation_step=None, max_num_jobs=None, job_callback=None, completed_jobs=None, workflow_resource_parameters=None, validate_outputs=False)[source]

Execute a tool and return object containing summary (output data, number of failures, etc…).

galaxy.tools.recommendations module

Compute tool recommendations

class galaxy.tools.recommendations.ToolRecommendations[source]

Bases: object

__init__()[source]
get_predictions(trans, tool_sequence, remote_model_url)[source]

Compute tool predictions

galaxy.tools.remote_tool_eval module

class galaxy.tools.remote_tool_eval.ToolAppConfig(name, tool_data_path, galaxy_data_manager_data_path, nginx_upload_path, len_file_path, builds_file_path, root, is_admin_user, admin_users)[source]

Bases: tuple

property name

Alias for field number 0

property tool_data_path

Alias for field number 1

property galaxy_data_manager_data_path

Alias for field number 2

property nginx_upload_path

Alias for field number 3

property len_file_path

Alias for field number 4

property builds_file_path

Alias for field number 5

property root

Alias for field number 6

property is_admin_user

Alias for field number 7

property admin_users

Alias for field number 8

class galaxy.tools.remote_tool_eval.ToolApp(sa_session: galaxy.model.store.SessionlessContext, tool_app_config: galaxy.tools.remote_tool_eval.ToolAppConfig, datatypes_registry: galaxy.datatypes.registry.Registry, object_store: galaxy.objectstore.ObjectStore, tool_data_table_manager: galaxy.tools.data.ToolDataTableManager, file_sources: galaxy.files.ConfiguredFileSources)[source]

Bases: galaxy.structured_app.MinimalToolApp

Dummy App that allows loading tools

name: str = 'tool_app'
__init__(sa_session: galaxy.model.store.SessionlessContext, tool_app_config: galaxy.tools.remote_tool_eval.ToolAppConfig, datatypes_registry: galaxy.datatypes.registry.Registry, object_store: galaxy.objectstore.ObjectStore, tool_data_table_manager: galaxy.tools.data.ToolDataTableManager, file_sources: galaxy.files.ConfiguredFileSources)[source]
Parameters

container – Optional container if provided the existing definitions will be copied

:param log_undefined_deps indicates if a log message should be emmited when an undefined dep is loaded

config: Any
datatypes_registry: galaxy.datatypes.registry.Registry
object_store: galaxy.objectstore.ObjectStore
file_sources: galaxy.files.ConfiguredFileSources
sa_session: Union[galaxy.model.scoped_session.galaxy_scoped_session, galaxy.model.store.SessionlessContext]
tool_data_table_manager: ToolDataTableManager
galaxy.tools.remote_tool_eval.main(TMPDIR, WORKING_DIRECTORY, IMPORT_STORE_DIRECTORY)[source]

galaxy.tools.repositories module

Provides a subset of app for verifying tools.

class galaxy.tools.repositories.ValidationContext(app_name, security, model, tool_data_path, shed_tool_data_path, tool_data_tables=None, registry=None, hgweb_config_manager=None, biotools_metadata_source=None)[source]

Bases: object

Minimal App object for tool validation.

__init__(app_name, security, model, tool_data_path, shed_tool_data_path, tool_data_tables=None, registry=None, hgweb_config_manager=None, biotools_metadata_source=None)[source]
static from_app(app, work_dir=None)[source]

galaxy.tools.special_tools module

galaxy.tools.special_tools.load_lib_tools(toolbox)[source]

galaxy.tools.test module

galaxy.tools.test.parse_tests(tool, tests_source)[source]

Build ToolTestDescription objects for each “<test>” elements and return default interactor (if any).

galaxy.tools.test.description_from_tool_object(tool, test_index, raw_test_dict)[source]
galaxy.tools.test.require_file(name, value, extra, required_files)[source]
class galaxy.tools.test.ParamContext(name, index=None, parent_context=None)[source]

Bases: object

__init__(name, index=None, parent_context=None)[source]
for_state()[source]
param_names()[source]
extract_value(raw_inputs)[source]
class galaxy.tools.test.RootParamContext[source]

Bases: object

__init__()[source]
for_state()[source]
param_names()[source]
get_index()[source]

galaxy.tools.wrappers module

class galaxy.tools.wrappers.ToolParameterValueWrapper[source]

Bases: object

Base class for object that Wraps a Tool Parameter and Value.

value: Union[str, List[str]]
input: ToolParameter
get_display_text(quote: bool = True) str[source]

Returns a string containing the value that would be displayed to the user in the tool interface. When quote is True (default), the string is escaped for e.g. command-line usage.

class galaxy.tools.wrappers.RawObjectWrapper(obj: Any)[source]

Bases: galaxy.tools.wrappers.ToolParameterValueWrapper

Wraps an object so that __str__ returns module_name:class_name.

__init__(obj: Any)[source]
value: Union[str, List[str]]
input: ToolParameter
class galaxy.tools.wrappers.InputValueWrapper(input: ToolParameter, value: str, other_values: Optional[Dict[str, str]] = None)[source]

Bases: galaxy.tools.wrappers.ToolParameterValueWrapper

Wraps an input so that __str__ gives the “param_dict” representation.

__init__(input: ToolParameter, value: str, other_values: Optional[Dict[str, str]] = None) None[source]
input: ToolParameter
value: Union[str, List[str]]
class galaxy.tools.wrappers.SelectToolParameterWrapper(input: SelectToolParameter, value: Union[str, List[str]], other_values: Optional[Dict[str, str]] = None, compute_environment: Optional[ComputeEnvironment] = None)[source]

Bases: galaxy.tools.wrappers.ToolParameterValueWrapper

Wraps a SelectTooParameter so that __str__ returns the selected value, but all other attributes are accessible.

class SelectToolParameterFieldWrapper(input: SelectToolParameter, value: Union[str, List[str]], other_values: Optional[Dict[str, str]], compute_environment: Optional[ComputeEnvironment])[source]

Bases: object

Provide access to any field by name or index for this particular value. Only applicable for dynamic_options selects, which have more than simple ‘options’ defined (name, value, selected).

__init__(input: SelectToolParameter, value: Union[str, List[str]], other_values: Optional[Dict[str, str]], compute_environment: Optional[ComputeEnvironment]) None[source]
__init__(input: SelectToolParameter, value: Union[str, List[str]], other_values: Optional[Dict[str, str]] = None, compute_environment: Optional[ComputeEnvironment] = None)[source]
input: SelectToolParameter
class galaxy.tools.wrappers.DatasetFilenameWrapper(dataset: Optional[galaxy.model.DatasetInstance], datatypes_registry: Optional[Registry] = None, tool: Optional[Tool] = None, name: Optional[str] = None, compute_environment: Optional[ComputeEnvironment] = None, identifier: Optional[str] = None, io_type: str = 'input', formats: Optional[List[str]] = None)[source]

Bases: galaxy.tools.wrappers.ToolParameterValueWrapper

Wraps a dataset so that __str__ returns the filename, but all other attributes are accessible.

class MetadataWrapper(dataset: galaxy.model.DatasetInstance, compute_environment: Optional[ComputeEnvironment] = None)[source]

Bases: object

Wraps a Metadata Collection to return MetadataParameters wrapped according to the metadata spec. Methods implemented to match behavior of a Metadata Collection.

__init__(dataset: galaxy.model.DatasetInstance, compute_environment: Optional[ComputeEnvironment] = None) None[source]
element_is_set(name: str) bool[source]
get(key: str, default: Optional[Any] = None) Any[source]
items() Iterator[Tuple[str, Any]][source]
__init__(dataset: Optional[galaxy.model.DatasetInstance], datatypes_registry: Optional[Registry] = None, tool: Optional[Tool] = None, name: Optional[str] = None, compute_environment: Optional[ComputeEnvironment] = None, identifier: Optional[str] = None, io_type: str = 'input', formats: Optional[List[str]] = None) None[source]
false_path: Optional[str]
property element_identifier: str
property file_ext: str
property name_and_ext: str
get_staging_path(invalid_chars: Sequence[str] = ('/',)) str[source]

Strip leading dots, unicode null chars, replace / with _, truncate at 255 characters.

Not safe for commandline use, would need additional sanitization.

property all_metadata_files: List[Tuple[str, str]]
serialize(invalid_chars: Sequence[str] = ('/',)) Dict[str, Any][source]
property is_collection: bool
is_of_type(*exts: str) bool[source]
class galaxy.tools.wrappers.HasDatasets[source]

Bases: object

job_working_directory: Optional[str]
paths_as_file(sep: str = '\n') str[source]
class galaxy.tools.wrappers.DatasetListWrapper(job_working_directory: Optional[str], datasets: Union[Sequence[Union[None, galaxy.model.DatasetInstance, galaxy.model.DatasetCollectionInstance, galaxy.model.DatasetCollectionElement]], galaxy.model.DatasetInstance], **kwargs: Any)[source]

Bases: List[galaxy.tools.wrappers.DatasetFilenameWrapper], galaxy.tools.wrappers.ToolParameterValueWrapper, galaxy.tools.wrappers.HasDatasets

__init__(job_working_directory: Optional[str], datasets: Union[Sequence[Union[None, galaxy.model.DatasetInstance, galaxy.model.DatasetCollectionInstance, galaxy.model.DatasetCollectionElement]], galaxy.model.DatasetInstance], **kwargs: Any) None[source]
static to_dataset_instances(dataset_instance_sources: Any) List[Union[None, galaxy.model.DatasetInstance]][source]
get_datasets_for_group(group: str) List[galaxy.tools.wrappers.DatasetFilenameWrapper][source]
serialize(invalid_chars: Sequence[str] = ('/',)) List[Dict[str, Any]][source]
value: Union[str, List[str]]
input: ToolParameter
class galaxy.tools.wrappers.DatasetCollectionWrapper(job_working_directory: Optional[str], has_collection: Union[None, galaxy.model.DatasetCollectionElement, galaxy.model.HistoryDatasetCollectionAssociation], datatypes_registry: Registry, **kwargs: Any)[source]

Bases: galaxy.tools.wrappers.ToolParameterValueWrapper, galaxy.tools.wrappers.HasDatasets

__init__(job_working_directory: Optional[str], has_collection: Union[None, galaxy.model.DatasetCollectionElement, galaxy.model.HistoryDatasetCollectionAssociation], datatypes_registry: Registry, **kwargs: Any) None[source]
name: Optional[str]
collection: galaxy.model.DatasetCollection
get_datasets_for_group(group: str) List[galaxy.tools.wrappers.DatasetFilenameWrapper][source]
keys() Union[List[str], KeysView[Any]][source]
property is_collection: bool
property element_identifier: Optional[str]
property all_paths: List[str]
property all_metadata_files: List[List[str]]
property element_identifiers_extensions_paths_and_metadata_files: List[List[Any]]
get_all_staging_paths(invalid_chars: Sequence[str] = ('/',), include_collection_name: bool = False) List[str][source]
serialize(invalid_chars: Sequence[str] = ('/',), include_collection_name: bool = False) List[Dict[str, Any]][source]
property is_input_supplied: bool
class galaxy.tools.wrappers.ElementIdentifierMapper(input_datasets: Optional[Dict[str, Any]] = None)[source]

Bases: object

Track mapping of dataset collection elements datasets to element identifiers.

__init__(input_datasets: Optional[Dict[str, Any]] = None) None[source]
identifier(dataset_value: str, input_values: Dict[str, str]) Optional[str][source]