gxformat2 package

Submodules

gxformat2.abstract module

Module for exporting Galaxy workflows to CWL abstract interface.

gxformat2.abstract.main(argv=None)[source]

Entry point for script to export abstract interface.

gxformat2.abstract.from_dict(workflow_dict: dict, subworkflow=False)[source]

Convert dictified Galaxy workflow into abstract CWL representation.

gxformat2.converter module

Functionality for converting a Format 2 workflow into a standard Galaxy workflow.

gxformat2.converter.main(argv=None)[source]

Entry point for script to conversion from Format 2 interface.

gxformat2.converter.python_to_workflow(as_python, galaxy_interface, workflow_directory=None, import_options=None)[source]

Convert a Format 2 workflow into standard Galaxy format from supplied dictionary.

gxformat2.converter.yaml_to_workflow(has_yaml, galaxy_interface, workflow_directory, import_options=None)[source]

Convert a Format 2 workflow into standard Galaxy format from supplied stream.

gxformat2.cytoscape module

Build standalone visualization for Galaxy workflows.

gxformat2.cytoscape.main(argv=None)[source]

Entry point for building Cytoscape visualizations of Galaxy workflows.

gxformat2.cytoscape.to_cytoscape(workflow_path: str, output_path=None)[source]

Produce cytoscape output for supplied workflow path.

gxformat2.export module

Functionality for converting a standard Galaxy workflow into a format 2 workflow.

gxformat2.export.from_galaxy_native(native_workflow_dict, tool_interface=None, json_wrapper=False)[source]

Convert native .ga workflow definition to a format2 workflow.

This is highly experimental and currently broken.

gxformat2.export.main(argv=None)[source]

Entry point for script to convert native workflows to Format 2.

gxformat2.interface module

This module contains an interface and implementation describing Galaxy interactions used by gxformat2.

The interface is ImporterGalaxyInterface and the default implementation based on BioBlend is BioBlendImporterGalaxyInterface.

class gxformat2.interface.BioBlendImporterGalaxyInterface(**kwds)[source]

Bases: object

Implementation of ImporterGalaxyInterface using bioblend.

import_tool(tool_representation)[source]

Import Galaxy tool using instance bioblend.GalaxyInstance object.

import_workflow(workflow, **kwds)[source]

Import Galaxy workflow using instance bioblend.GalaxyInstance object.

class gxformat2.interface.ImporterGalaxyInterface[source]

Bases: object

An abstract interface describing Galaxy operations used by gxformat2.

Specifically containing definitions of operations required to load workflows into Galaxy.

import_tool(tool)[source]

Import a new dynamically defined tool.

Not yet implemented in vanilla Galaxy - used only in the cwl branch of Galaxy.

import_workflow(workflow, **kwds)[source]

Import a workflow via POST /api/workflows or comparable interface into Galaxy.

gxformat2.lint module

Workflow linting entry point - main script.

gxformat2.lint.main(argv=None)[source]

Script entry point for linting workflows.

gxformat2.lint.lint_format2(lint_context, workflow_dict, path=None)[source]

Lint a Format 2 Galaxy workflow and populate the corresponding LintContext.

gxformat2.lint.lint_ga(lint_context, workflow_dict, path=None)[source]

Lint a native/legacy style Galaxy workflow and populate the corresponding LintContext.

gxformat2.linting module

Generic utilities for linting.

Largely derived in large part from galaxy.tool_util.lint.

class gxformat2.linting.LintContext(level='warn', training_topic=None)[source]

Bases: object

Track running status (state) of linting.

error(message, *args, **kwds)[source]

Track a linting error - a serious problem with the artifact preventing execution.

print_messages()[source]

Print error messages and update state at the end of linting.

warn(message, *args, **kwds)[source]

Track a linting warning - a deviation from best practices.

gxformat2.main module

Module containing convert_and_import_workflow().

gxformat2.main.convert_and_import_workflow(has_workflow, **kwds)[source]

Conversion and import Format 2 workflows into a target Galaxy instance.

gxformat2.markdown_parse module

Utilities for parsing “Galaxy Flavored Markdown”.

See markdown_util.py for loading objects and interacting with the rest of Galaxy. This file is meant to be relatively self contained and just used to “parse” and validate Galaxy Markdown. Keeping things isolated to allow re-use of these utilities in other projects (e.g. gxformat2).

gxformat2.markdown_parse.validate_galaxy_markdown(galaxy_markdown, internal=True)[source]

Validate the supplied markdown and throw an ValueError with reason if invalid.

gxformat2.model module

Abstractions for dealing with Format2 data.

gxformat2.model.convert_dict_to_id_list_if_needed(dict_or_list: Union[Dict[KT, VT], List[T]], add_label: bool = False, mutate: bool = False) → list[source]

Convert a list or dict to a list with keys embedded.

If add_label is True, embed dict keys as ‘label’ attribute else ‘id’.

gxformat2.model.ensure_step_position(step: dict, order_index: int)[source]

Ensure step contains a position definition.

Modifies the input step dictionary.

gxformat2.model.inputs_as_native_steps(workflow_dict: dict)[source]

Return workflow inputs to a steps in array - like in native Galaxy.

Convert Format2 types into native ones. workflow_dict is a Format 2 representation of a workflow. This method does not modify workflow_dict.

gxformat2.model.inputs_as_normalized_steps(workflow_dict)[source]

Return workflow inputs to a steps in array.

Normalize Format2 inputs. workflow_dict is a Format 2 representation of a workflow. This method does not modify workflow_dict.

gxformat2.model.native_input_to_format2_type(step: dict, tool_state: dict) → str[source]

Return a Format2 input type (‘type’) from a native input step dictionary.

gxformat2.model.outputs_as_list(as_python: dict) → list[source]

Extract outputs from Format2 rep as list.

gxformat2.model.prune_position(step)[source]

Keep only left and top keys in step position.

gxformat2.model.with_step_ids(steps: list, inputs_offset: int = 0)[source]

Walk over a list of steps and ensure the steps have a numeric id if otherwise missing.

gxformat2.normalize module

Abstractions for uniform across formats.

class gxformat2.normalize.Inputs(workflow_dict)[source]

Bases: object

An abstraction around a Galaxy workflow’s inputs.

count

Return the number of declared inputs for the workflow.

is_an_input(target_label)[source]

Return true if step label/id is a input.

This does assume all labels that are numeric strings refer to the Galaxy ‘id’ (i.e. order_index). We should make sure Galaxy doesn’t allow purely numeric labels so this doesn’t get confusing and we can ensure correctness.

class gxformat2.normalize.NormalizedWorkflow(input_workflow: dict)[source]

Bases: object

Present a view of a Format2 workflow that has been normalized.

In a normalized view: - Steps are a list and ids/labels have been populated - references to anonymous outputs have been relaced with the correct anonymous label

TODO: - input: <type> has been converted to input: {type: <type>} - step inputs have been replaced with input declarations - normalize out declarations to dicts?

gxformat2.normalize.inputs_normalized(**kwd)[source]

Call steps_normalized and retain just the input steps normalized.

gxformat2.normalize.outputs_normalized(**kwd)[source]

Ensure Format2 and return outputs.

Probably should go farther and normalize source -> outputSource, but doesn’t yet do this.

gxformat2.normalize.steps_normalized(workflow_dict=None, workflow_path=None)[source]

Walk over a normalized step rep. across workflow formats.

gxformat2.normalize.walk_id_list_or_dict(dict_or_list: Union[dict, list])[source]

Walk over idmap regardless of list or dict representation.

gxformat2.yaml module

YAML loading utilities for gxformat2.

gxformat2.yaml.ordered_dump(data, stream=None, Dumper=<class 'yaml.dumper.SafeDumper'>, **kwds)[source]

Safe and ordered dump of YAML to stream.

gxformat2.yaml.ordered_dump_to_path(as_dict: dict, path: str)[source]

Safe and ordered dump of YAML to path.

gxformat2.yaml.ordered_load(stream, Loader=<class 'yaml.loader.SafeLoader'>, **kwds)[source]

Safe and ordered load of YAML from stream.

gxformat2.yaml.ordered_load_path(path: str, **kwds)[source]

Safe and ordered load of YAML from specified path.

Module contents

The public interface or entry point for the Format 2 workflow code.

gxformat2.convert_and_import_workflow(has_workflow, **kwds)[source]

Conversion and import Format 2 workflows into a target Galaxy instance.

gxformat2.from_galaxy_native(native_workflow_dict, tool_interface=None, json_wrapper=False)[source]

Convert native .ga workflow definition to a format2 workflow.

This is highly experimental and currently broken.

class gxformat2.ImporterGalaxyInterface[source]

Bases: object

An abstract interface describing Galaxy operations used by gxformat2.

Specifically containing definitions of operations required to load workflows into Galaxy.

import_tool(tool)[source]

Import a new dynamically defined tool.

Not yet implemented in vanilla Galaxy - used only in the cwl branch of Galaxy.

import_workflow(workflow, **kwds)[source]

Import a workflow via POST /api/workflows or comparable interface into Galaxy.

class gxformat2.ImportOptions[source]

Bases: object

gxformat2.python_to_workflow(as_python, galaxy_interface, workflow_directory=None, import_options=None)[source]

Convert a Format 2 workflow into standard Galaxy format from supplied dictionary.