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.tool_shed.util package¶
Submodules¶
galaxy.tool_shed.util.basic_util module¶
- galaxy.tool_shed.util.basic_util.evaluate_template(text, install_environment)[source]¶
Substitute variables defined in XML blocks from dependencies file. The value of the received repository_install_dir is the root installation directory of the repository that contains the tool dependency. The value of the received install_dir is the root installation directory of the tool_dependency.
- galaxy.tool_shed.util.basic_util.get_env_var_values(install_environment)[source]¶
Return a dictionary of values, some of which enable substitution of reserved words for the values. The received install_enviroment object has 3 important attributes for reserved word substitution: install_environment.tool_shed_repository_install_dir is the root installation directory of the repository that contains the tool dependency being installed, install_environment.install_dir is the root installation directory of the tool dependency, and install_environment.tmp_work_dir is the temporary directory where the tool dependency compilation/installation is being processed.
- galaxy.tool_shed.util.basic_util.move_file(current_dir, source, destination, rename_to=None)[source]¶
- galaxy.tool_shed.util.basic_util.size_string(raw_text, size=32768)[source]¶
Return a subset of a string (up to MAX_DISPLAY_SIZE) translated to a safe string for display in a browser.
galaxy.tool_shed.util.container_util module¶
- galaxy.tool_shed.util.container_util.generate_repository_dependencies_key_for_repository(toolshed_base_url, repository_name, repository_owner, changeset_revision, prior_installation_required, only_if_compiling_contained_td)[source]¶
Assumes tool shed is current tool shed since repository dependencies across tool sheds is not yet supported.
galaxy.tool_shed.util.hg_util module¶
- galaxy.tool_shed.util.hg_util.clone_repository(repository_clone_url, repository_file_dir, ctx_rev=None)[source]¶
Clone the repository up to the specified changeset_revision. No subsequent revisions will be present in the cloned repository.
- galaxy.tool_shed.util.hg_util.copy_file_from_manifest(repo, changeset_revision, filename, dir)[source]¶
Copy the latest version of the file named filename from the repository manifest to the directory to which dir refers.
- galaxy.tool_shed.util.hg_util.get_changectx_for_changeset(repo, changeset_revision, **kwd)[source]¶
Retrieve a specified changectx from a repository.
- galaxy.tool_shed.util.hg_util.get_ctx_file_path_from_manifest(filename, repo, changeset_revision)[source]¶
Get the ctx file path for the latest revision of filename from the repository manifest up to the value of changeset_revision.
- galaxy.tool_shed.util.hg_util.get_file_context_from_ctx(ctx, filename)[source]¶
Return the mercurial file context for a specified file.
- galaxy.tool_shed.util.hg_util.pull_repository(repo_path, repository_clone_url, ctx_rev)[source]¶
Pull changes from a remote repository to a local one.
- galaxy.tool_shed.util.hg_util.reversed_lower_upper_bounded_changelog(repo, excluded_lower_bounds_changeset_revision, included_upper_bounds_changeset_revision)[source]¶
Return a reversed list of changesets in the repository changelog after the excluded_lower_bounds_changeset_revision, but up to and including the included_upper_bounds_changeset_revision. The value of excluded_lower_bounds_changeset_revision will be the value of INITIAL_CHANGELOG_HASH if no valid changesets exist before included_upper_bounds_changeset_revision.
- galaxy.tool_shed.util.hg_util.reversed_upper_bounded_changelog(repo, included_upper_bounds_changeset_revision)[source]¶
Return a reversed list of changesets in the repository changelog up to and including the included_upper_bounds_changeset_revision.
- galaxy.tool_shed.util.hg_util.update_repository(repo_path, ctx_rev=None)[source]¶
Update the cloned repository to changeset_revision. It is critical that the installed repository is updated to the desired changeset_revision before metadata is set because the process for setting metadata uses the repository files on disk.
galaxy.tool_shed.util.metadata_util module¶
galaxy.tool_shed.util.repository_util module¶
- galaxy.tool_shed.util.repository_util.check_or_update_tool_shed_status_for_installed_repository(app, repository)[source]¶
- galaxy.tool_shed.util.repository_util.create_or_update_tool_shed_repository(app, name, description, installed_changeset_revision, ctx_rev, repository_clone_url, status, metadata_dict=None, current_changeset_revision=None, owner='', dist_to_shed=False)[source]¶
Update a tool shed repository record in the Galaxy database with the new information received. If a record defined by the received tool shed, repository name and owner does not exist, create a new record with the received information.
- galaxy.tool_shed.util.repository_util.extract_components_from_tuple(repository_components_tuple)[source]¶
Extract the repository components from the provided tuple in a backward-compatible manner.
- galaxy.tool_shed.util.repository_util.generate_tool_shed_repository_install_dir(repository_clone_url, changeset_revision)[source]¶
Generate a repository installation directory that guarantees repositories with the same name will always be installed in different directories. The tool path will be of the form: <tool shed url>/repos/<repository owner>/<repository name>/<installed changeset revision>
- galaxy.tool_shed.util.repository_util.get_absolute_path_to_file_in_repository(repo_files_dir, file_name)[source]¶
Return the absolute path to a specified disk file contained in a repository.
- galaxy.tool_shed.util.repository_util.get_ids_of_tool_shed_repositories_being_installed(app, as_string=False)[source]¶
- galaxy.tool_shed.util.repository_util.get_installed_repository(app, tool_shed=None, name=None, owner=None, changeset_revision=None, installed_changeset_revision=None, repository_id=None, from_cache=False)[source]¶
Return a tool shed repository database record defined by the combination of a toolshed, repository name, repository owner and either current or originally installed changeset_revision.
- galaxy.tool_shed.util.repository_util.get_installed_tool_shed_repository(app, id)[source]¶
Get a tool shed repository record from the Galaxy database defined by the id.
- galaxy.tool_shed.util.repository_util.get_prior_import_or_install_required_dict(app, tsr_ids, repo_info_dicts)[source]¶
This method is used in the Tool Shed when exporting a repository and its dependencies, and in Galaxy when a repository and its dependencies are being installed. Return a dictionary whose keys are the received tsr_ids and whose values are a list of tsr_ids, each of which is contained in the received list of tsr_ids and whose associated repository must be imported or installed prior to the repository associated with the tsr_id key.
- galaxy.tool_shed.util.repository_util.get_repo_info_tuple_contents(repo_info_tuple)[source]¶
Take care in handling the repo_info_tuple as it evolves over time as new tool shed features are introduced.
- galaxy.tool_shed.util.repository_util.get_repository_admin_role_name(repository_name, repository_owner)[source]¶
- galaxy.tool_shed.util.repository_util.get_repository_and_repository_dependencies_from_repo_info_dict(app, repo_info_dict)[source]¶
Return a tool_shed_repository or repository record defined by the information in the received repo_info_dict.
- galaxy.tool_shed.util.repository_util.get_repository_by_id(app, id)[source]¶
Get a repository from the database via id.
- galaxy.tool_shed.util.repository_util.get_repository_by_name(app, name)[source]¶
Get a repository from the database via name.
- galaxy.tool_shed.util.repository_util.get_repository_by_name_and_owner(app, name, owner, eagerload_columns=None)[source]¶
Get a repository from the database via name and owner
- galaxy.tool_shed.util.repository_util.get_repository_dependency_types(repository_dependencies)[source]¶
Inspect the received list of repository_dependencies tuples and return boolean values for has_repository_dependencies and has_repository_dependencies_only_if_compiling_contained_td.
- galaxy.tool_shed.util.repository_util.get_repository_for_dependency_relationship(app, tool_shed, name, owner, changeset_revision)[source]¶
Return an installed tool_shed_repository database record that is defined by either the current changeset revision or the installed_changeset_revision.
- galaxy.tool_shed.util.repository_util.get_repository_ids_requiring_prior_import_or_install(app, tsr_ids, repository_dependencies)[source]¶
This method is used in the Tool Shed when exporting a repository and its dependencies, and in Galaxy when a repository and its dependencies are being installed. Inspect the received repository_dependencies and determine if the encoded id of each required repository is in the received tsr_ids. If so, then determine whether that required repository should be imported / installed prior to its dependent repository. Return a list of encoded repository ids, each of which is contained in the received list of tsr_ids, and whose associated repositories must be imported / installed prior to the dependent repository associated with the received repository_dependencies.
- galaxy.tool_shed.util.repository_util.get_repository_in_tool_shed(app, id, eagerload_columns=None)[source]¶
Get a repository on the tool shed side from the database via id.
- galaxy.tool_shed.util.repository_util.get_repository_owner(cleaned_repository_url)[source]¶
Gvien a “cleaned” repository clone URL, return the owner of the repository.
- galaxy.tool_shed.util.repository_util.get_repository_owner_from_clone_url(repository_clone_url)[source]¶
Given a repository clone URL, return the owner of the repository.
- galaxy.tool_shed.util.repository_util.get_role_by_id(app, role_id)[source]¶
Get a Role from the database by id.
- galaxy.tool_shed.util.repository_util.get_tool_shed_repository_by_id(app, repository_id)[source]¶
Return a tool shed repository database record defined by the id.
- galaxy.tool_shed.util.repository_util.get_tool_shed_status_for_installed_repository(app, repository)[source]¶
Send a request to the tool shed to retrieve information about newer installable repository revisions, current revision updates, whether the repository revision is the latest downloadable revision, and whether the repository has been deprecated in the tool shed. The received repository is a ToolShedRepository object from Galaxy.
- galaxy.tool_shed.util.repository_util.is_tool_shed_client(app)[source]¶
The tool shed and clients to the tool (i.e. Galaxy) require a lot of similar functionality in this file but with small differences. This method should determine if the app performing the action is the tool shed or a client of the tool shed.
- galaxy.tool_shed.util.repository_util.repository_was_previously_installed(app, tool_shed_url, repository_name, repo_info_tuple, from_tip=False)[source]¶
Find out if a repository is already installed into Galaxy - there are several scenarios where this is necessary. For example, this method will handle the case where the repository was previously installed using an older changeset_revsion, but later the repository was updated in the tool shed and now we’re trying to install the latest changeset revision of the same repository instead of updating the one that was previously installed. We’ll look in the database instead of on disk since the repository may be currently uninstalled.
galaxy.tool_shed.util.shed_util_common module¶
- galaxy.tool_shed.util.shed_util_common.can_eliminate_repository_dependency(metadata_dict, tool_shed_url, name, owner)[source]¶
Determine if the relationship between a repository_dependency record associated with a tool_shed_repository record on the Galaxy side can be eliminated.
- galaxy.tool_shed.util.shed_util_common.can_eliminate_tool_dependency(metadata_dict, name, dependency_type, version)[source]¶
Determine if the relationship between a tool_dependency record associated with a tool_shed_repository record on the Galaxy side can be eliminated.
- galaxy.tool_shed.util.shed_util_common.clean_dependency_relationships(trans, metadata_dict, tool_shed_repository, tool_shed_url)[source]¶
Repositories of type tool_dependency_definition allow for defining a package dependency at some point in the change log and then removing the dependency later in the change log. This function keeps the dependency relationships on the Galaxy side current by deleting database records that defined the now-broken relationships.
- galaxy.tool_shed.util.shed_util_common.generate_tool_guid(repository_clone_url, tool)[source]¶
Generate a guid for the installed tool. It is critical that this guid matches the guid for the tool in the Galaxy tool shed from which it is being installed. The form of the guid is <tool shed host>/repos/<repository owner>/<repository name>/<tool id>/<tool version>
- galaxy.tool_shed.util.shed_util_common.get_ctx_rev(app, tool_shed_url, name, owner, changeset_revision)[source]¶
Send a request to the tool shed to retrieve the ctx_rev for a repository defined by the combination of a name, owner and changeset revision.
- galaxy.tool_shed.util.shed_util_common.get_next_prior_import_or_install_required_dict_entry(prior_required_dict, processed_tsr_ids)[source]¶
This method is used in the Tool Shed when exporting a repository and its dependencies, and in Galaxy when a repository and its dependencies are being installed. The order in which the prior_required_dict is processed is critical in order to ensure that the ultimate repository import or installation order is correctly defined. This method determines the next key / value pair from the received prior_required_dict that should be processed.
- galaxy.tool_shed.util.shed_util_common.get_tool_panel_config_tool_path_install_dir(app, repository)[source]¶
Return shed-related tool panel config, the tool_path configured in it, and the relative path to the directory where the repository is installed. This method assumes all repository tools are defined in a single shed-related tool panel config.
- galaxy.tool_shed.util.shed_util_common.get_user(app, id)[source]¶
Get a user from the database by id.
- galaxy.tool_shed.util.shed_util_common.set_image_paths(app, text, encoded_repository_id=None, tool_shed_repository=None, tool_id=None, tool_version=None)[source]¶
Handle tool help image display for tools that are contained in repositories in the tool shed or installed into Galaxy as well as image display in repository README files. This method will determine the location of the image file and return the path to it that will enable the caller to open the file.
galaxy.tool_shed.util.tool_dependency_util module¶
- galaxy.tool_shed.util.tool_dependency_util.build_tool_dependencies_select_field(app, tool_shed_repository, name, multiple=True, display='checkboxes', uninstalled_only=False)[source]¶
Generate a SelectField consisting of the current list of tool dependency ids for an installed tool shed repository.
- galaxy.tool_shed.util.tool_dependency_util.create_or_update_tool_dependency(app, tool_shed_repository, name, version, type, status, set_status=True)[source]¶
Create or update a tool_dependency record in the Galaxy database.
- galaxy.tool_shed.util.tool_dependency_util.create_tool_dependency_objects(app, tool_shed_repository, relative_install_dir, set_status=True)[source]¶
Create or update a ToolDependency for each entry in tool_dependencies_config. This method is called when installing a new tool_shed_repository.
- galaxy.tool_shed.util.tool_dependency_util.get_download_url_for_platform(url_templates, platform_info_dict)[source]¶
Compare the dict returned by get_platform_info() with the values specified in the url_template element. Return true if and only if all defined attributes match the corresponding dict entries. If an entry is not defined in the url_template element, it is assumed to be irrelevant at this stage. For example, <url_template os=”darwin”>http://hgdownload.cse.ucsc.edu/admin/exe/macOSX.${architecture}/faToTwoBit</url_template> where the OS must be ‘darwin’, but the architecture is filled in later using string.Template.
- galaxy.tool_shed.util.tool_dependency_util.get_platform_info_dict()[source]¶
Return a dict with information about the current platform.
- galaxy.tool_shed.util.tool_dependency_util.get_tool_dependency(app, id)[source]¶
Get a tool_dependency from the database via id
- galaxy.tool_shed.util.tool_dependency_util.get_tool_dependency_by_name_type_repository(app, repository, name, type)[source]¶
- galaxy.tool_shed.util.tool_dependency_util.get_tool_dependency_by_name_version_type(app, name, version, type)[source]¶
- galaxy.tool_shed.util.tool_dependency_util.get_tool_dependency_by_name_version_type_repository(app, repository, name, version, type)[source]¶
- galaxy.tool_shed.util.tool_dependency_util.get_tool_dependency_install_dir(app, repository_name, repository_owner, repository_changeset_revision, tool_dependency_type, tool_dependency_name, tool_dependency_version)[source]¶
- galaxy.tool_shed.util.tool_dependency_util.parse_package_elem(package_elem, platform_info_dict=None, include_after_install_actions=True)[source]¶
Parse a <package> element within a tool dependency definition and return a list of action tuples. This method is called when setting metadata on a repository that includes a tool_dependencies.xml file or when installing a repository that includes a tool_dependencies.xml file. If installing, platform_info_dict must be a valid dictionary and include_after_install_actions must be True.
- galaxy.tool_shed.util.tool_dependency_util.remove_tool_dependency(app, tool_dependency)[source]¶
The received tool_dependency must be in an error state.
galaxy.tool_shed.util.tool_util module¶
- galaxy.tool_shed.util.tool_util.build_shed_tool_conf_select_field(app)[source]¶
Build a SelectField whose options are the keys in app.toolbox.shed_tool_confs.
- galaxy.tool_shed.util.tool_util.build_tool_panel_section_select_field(app)[source]¶
Build a SelectField whose options are the sections of the current in-memory toolbox.
- galaxy.tool_shed.util.tool_util.copy_sample_file(app, filename, dest_path=None)[source]¶
Copies a sample file at filename to the dest_path directory and strips the ‘.sample’ extensions from filename. Returns the path to the copied file (with the .sample extension).
- galaxy.tool_shed.util.tool_util.copy_sample_files(app, sample_files, tool_path=None, sample_files_copied=None, dest_path=None)[source]¶
Copy all appropriate files to dest_path in the local Galaxy environment that have not already been copied. Those that have been copied are contained in sample_files_copied. The default value for dest_path is ~/tool-data. We need to be careful to copy only appropriate files here because tool shed repositories can contain files ending in .sample that should not be copied to the ~/tool-data directory.
- galaxy.tool_shed.util.tool_util.generate_message_for_invalid_tools(app, invalid_file_tups, repository, metadata_dict, as_html=True, displaying_invalid_tool=False)[source]¶
- galaxy.tool_shed.util.tool_util.get_tool_path_install_dir(partial_install_dir, shed_tool_conf_dict, tool_dict, config_elems)[source]¶
- galaxy.tool_shed.util.tool_util.handle_missing_index_file(app, tool_path, sample_files, repository_tools_tups, sample_files_copied)[source]¶
Inspect each tool to see if it has any input parameters that are dynamically generated select lists that depend on a .loc file. This method is not called from the tool shed, but from Galaxy when a repository is being installed.
- galaxy.tool_shed.util.tool_util.is_data_index_sample_file(file_path)[source]¶
Attempt to determine if a .sample file is appropriate for copying to ~/tool-data when a tool shed repository is being installed into a Galaxy instance.