Galaxy Utilities

26.0.0 · active · verified Fri Apr 17

The `galaxy-util` package provides common utility functions and helper classes used across the larger Galaxy bioinformatics platform. It is an integral part of the Galaxy ecosystem, supporting various functionalities within the main application. Currently at version 26.0.0, it follows the rapid release cadence of the main Galaxy project, often tied to its major releases. While available on PyPI, its primary use case is within the Galaxy project itself.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic usage of two common utility functions: `safe_path` for sanitizing path components and `sanitize_text` for removing potentially dangerous HTML/script tags from strings. These are representative of the type of general-purpose helpers found in `galaxy-util`.

from galaxy.util.path import safe_path
from galaxy.util.sanitize_text import sanitize_text

# Example 1: Safely resolve a path component
unsafe_path_component = '../etc/passwd'
safe_component = safe_path(unsafe_path_component)
print(f"Unsafe: {unsafe_path_component}, Safe: {safe_component}")

# Example 2: Sanitize text input
raw_text = '<script>alert("XSS")</script>Hello & World!'
sanitized_text = sanitize_text(raw_text)
print(f"Raw: {raw_text}\nSanitized: {sanitized_text}")

view raw JSON →