Skip to main content

Foundation library for parsing, profile-aware validation, and typed inspection of Galaxy tool XML

Project description

galaxy-tool-source

A Python library and small CLI for parsing, profile-aware validation, and typed inspection of Galaxy tool definition XML — the <tool> wrapper files that define Galaxy bioinformatics tools.

This package is the foundation for a separate, black-like program for Galaxy tool XML (conformance checking, autofixing, reformatting). It provides only the foundation — no rules, no formatter, no serializer:

  1. Parse tool XML into a mutable representation that faithfully preserves CDATA, comments, attribute data and order, and significant element text.
  2. A typed read-only view of a parsed tool — bound to the model for the tool's own schema profile — for convenient rule-checking.
  3. Profile-aware XSD validation, with configurable macro handling so validation is accurate on real-world tools that use Galaxy macros.
  4. Near-miss typo suggestions against the schema vocabulary (suggest only).

Install

From PyPI:

pip install galaxy-tool-source

For development, from the workspace root:

uv sync

Usage

from galaxy_tool_source.binding import load_tool, validate_tool

document = load_tool("my_tool.xml")
print(document.profile)

result = validate_tool("my_tool.xml")
if not result.valid:
    for error in result.errors:
        print(error)

From the command line:

uv run galaxy-tool-source validate my_tool.xml
uv run galaxy-tool-source suggest my_tool.xml
uv run galaxy-tool-source profiles

Public API

The downstream formatter project may rely on exactly these symbols. Everything else is private and may change without notice.

from galaxy_tool_source.binding import load_tool, parse_tool, validate_tool, newest_valid_profile, oldest_valid_profile
from galaxy_tool_source.binding import load_macros
from galaxy_tool_source.binding import ParseResult, ValidationResult, XmlError, ToolXmlSyntaxError
from galaxy_tool_source.document import ToolDocument, MacroDocument
from galaxy_tool_source.macros import MacroError, imported_macro_paths, token_definitions, TokenDefinition, expanded_detection_root, top_level_expand_tags
from galaxy_tool_source.corrections import suggest_corrections, Correction
from galaxy_tool_source.boolean_values import suggest_boolean_normalizations, normalize_boolean_token, BooleanNormalization
from galaxy_tool_source.cheetah_refs import tool_cheetah_references, CheetahRef
from galaxy_tool_source.command_conditionals import command_boolean_conditionals, BooleanConditional
from galaxy_tool_source.cheetah_rename import rename_param, rename_param_plan, RenameOutcome, RenameEdit, RenamePlan
from galaxy_tool_source.bundle import ToolBundle, load_bundle, rename_param_in_bundle, BundleRenameOutcome
from galaxy_tool_source.version_tokens import tokenization_skip_reason, expansion_equality_holds, adopt_suffix_skip_reason, adopt_suffix_equality_holds, GALAXY_SUFFIX_VERSION, package_requirements, retarget_version, append_version_tokens, build_version_macros_root, tokenize_tree, tokenize_version_plan, VersionTokenPlan, VersionEdit, NewMacroFile
from galaxy_tool_source.profiles import available_profiles, latest_profile, UnknownProfileError
from galaxy_tool_source.schema_content import text_bearing_tags
from galaxy_tool_source.models.registry import model_module, tool_class
from galaxy_tool_source.models.any_tool import AnyTool

Architecture

ToolDocument (document.py) wraps a mutable lxml tree — the source of truth, faithfully preserving CDATA, comments, and attribute order. binding.py parses and validates; profiles.py resolves the per-release vendored XSD; macros.py handles Galaxy macros (the sole galaxy-util adapter); corrections.py suggests near-miss typo fixes; boolean_values.py reports schema-boolean attribute value normalizations (Truetrue); cheetah_refs.py / cheetah_rename.py find and rename a parameter across a tool's Cheetah sections (the latter renders the rename either as a tree mutation, rename_param, or as minimal source offsets, rename_param_plan, for editor / LSP use); bundle.py extends the rename across a tool and its imported macro files (ToolBundle / load_bundle / rename_param_in_bundle); version_tokens.py factors a literal version into the @TOOL_VERSION@ / @VERSION_SUFFIX@ IUC tokens, owning the GTR094 decision, the expansion-equality gate, the tree mutation, and the offset planner tokenize_version_plan (the editor / LSP and CLI rendering, like rename_param_plan); rst.py / rst_markdown.py own the <help> reStructuredText subsystem — validity + surgical repair (the GTR089 partition seam) and the render-equivalence-gated RST → Markdown conversion (GTR092; needs the [markdown] extra); models/ holds an xsdata-generated read-only typed model for every vendored schema version, reached via ToolDocument.model().

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

galaxy_tool_source-0.3.4.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

galaxy_tool_source-0.3.4-py3-none-any.whl (3.6 MB view details)

Uploaded Python 3

File details

Details for the file galaxy_tool_source-0.3.4.tar.gz.

File metadata

  • Download URL: galaxy_tool_source-0.3.4.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for galaxy_tool_source-0.3.4.tar.gz
Algorithm Hash digest
SHA256 1114896548b41b7d5c264ae1b4124778740585f1a5e19d9aa9c314cbdb63b8ec
MD5 6ec5b54f689c607d9663ba835ee9b15d
BLAKE2b-256 42bc6311c0a2ef7b3faa142850802f68c3bfcc794a9c1efe51d2406411f545cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for galaxy_tool_source-0.3.4.tar.gz:

Publisher: release.yml on richard-burhans/galaxy-tool-refactor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file galaxy_tool_source-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for galaxy_tool_source-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 25a8004c840eac5fd31109e6b9221c724e23b8e573299f2ff2e8dda72b210a0a
MD5 976a076ed7b15c778d2f38f09d1a81fe
BLAKE2b-256 10a38b9e9fc7263bfdf869b11ebb486b0cc71c651e37df2d1b82f1b1e47df01e

See more details on using hashes here.

Provenance

The following attestation bundles were made for galaxy_tool_source-0.3.4-py3-none-any.whl:

Publisher: release.yml on richard-burhans/galaxy-tool-refactor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page