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.parameters package

Classes encapsulating Galaxy tool parameters.

class galaxy.tools.parameters.DataCollectionToolParameter(tool, input_source, trans=None)[source]

Bases: galaxy.tools.parameters.basic.BaseDataToolParameter

__init__(tool, input_source, trans=None)[source]

Initialize self. See help(type(self)) for accurate signature.

property collection_types
match_collections(trans, history, dataset_collection_matcher)[source]
match_multirun_collections(trans, history, dataset_collection_matcher)[source]
from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.DataToolParameter(tool, input_source, trans=None)[source]

Bases: galaxy.tools.parameters.basic.BaseDataToolParameter

Parameter that takes on one (or many) or a specific set of values.

TODO: There should be an alternate display that allows single selects to be

displayed as radio buttons and multiple selects as a set of checkboxes

TODO: The following must be fixed to test correctly for the new security_check tag in the DataToolParameter (the last test below is broken) Nate’s next pass at the dataset security stuff will dramatically alter this anyway.

__init__(tool, input_source, trans=None)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

get_dependencies()[source]

Get the names of the other params this param depends on.

converter_safe(other_values, trans)[source]
get_options_filter_attribute(value)[source]
to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.SelectToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that takes on one (or many) or a specific set of values.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch(), workflow_building_mode=False)
>>> p = SelectToolParameter(None, XML(
... '''
... <param name="_name" type="select">
...     <option value="x">x_label</option>
...     <option value="y" selected="true">y_label</option>
...     <option value="z">z_label</option>
... </param>
... '''))
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', False), ('name', '_name'), ('optional', False), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', False)]), ('refresh_on_change', False), ('textable', False), ('type', 'select'), ('value', 'y')]
>>> p = SelectToolParameter(None, XML(
... '''
... <param name="_name" type="select" multiple="true">
...     <option value="x">x_label</option>
...     <option value="y" selected="true">y_label</option>
...     <option value="z" selected="true">z_label</option>
... </param>
... '''))
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', True), ('name', '_name'), ('optional', True), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', True)]), ('refresh_on_change', False), ('textable', False), ('type', 'select'), ('value', ['y', 'z'])]
>>> print(p.to_param_dict_string(["y", "z"]))
y,z
__init__(tool, input_source, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

get_options(trans, other_values)[source]

determine the set of values of legal options

determine a mapping from names to values for all legal options

from_json(value, trans, other_values=None, require_legal_value=True)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

get_dependencies()[source]

Get the names of the other params this param depends on.

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

validate(value, trans=None)[source]

Submodules

galaxy.tools.parameters.basic module

Basic tool parameters.

class galaxy.tools.parameters.basic.workflow_building_modes[source]

Bases: object

DISABLED = False
ENABLED = True
USE_HISTORY = 1
exception galaxy.tools.parameters.basic.ImplicitConversionRequired[source]

Bases: Exception

galaxy.tools.parameters.basic.contains_workflow_parameter(value, search=False)[source]
galaxy.tools.parameters.basic.is_runtime_value(value)[source]
galaxy.tools.parameters.basic.is_runtime_context(trans, other_values)[source]
galaxy.tools.parameters.basic.parse_dynamic_options(param, input_source)[source]
galaxy.tools.parameters.basic.assert_throws_param_value_error(message)[source]
exception galaxy.tools.parameters.basic.ParameterValueError(message_suffix, parameter_name, parameter_value=<object object>, is_dynamic=None)[source]

Bases: ValueError

__init__(message_suffix, parameter_name, parameter_value=<object object>, is_dynamic=None)[source]

Initialize self. See help(type(self)) for accurate signature.

to_dict()[source]
class galaxy.tools.parameters.basic.ToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.util.dictifiable.Dictifiable

Describes a parameter accepted by a tool. This is just a simple stub at the moment but in the future should encapsulate more complex parameters (lists of valid choices, validation logic, …)

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None)
>>> p = ToolParameter(None, XML('<param argument="--parameter-name" type="text" value="default" />'))
>>> assert p.name == 'parameter_name'
>>> assert sorted(p.to_dict(trans).items()) == [('argument', '--parameter-name'), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'ToolParameter'), ('name', 'parameter_name'), ('optional', False), ('refresh_on_change', False), ('type', 'text'), ('value', None)]
dict_collection_visible_keys = ['name', 'argument', 'type', 'label', 'help', 'refresh_on_change']
__init__(tool, input_source, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

property visible

Return true if the parameter should be rendered on the form

get_label()[source]

Return user friendly name for the parameter

from_json(value, trans=None, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

get_required_enctype()[source]

If this parameter needs the form to have a specific encoding return it, otherwise return None (indicating compatibility with any encoding)

get_dependencies()[source]

Return the names of any other parameters this parameter depends on

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

to_python(value, app)[source]

Convert a value created with to_json back to an object representation

value_to_basic(value, app, use_security=False)[source]
value_from_basic(value, app, ignore_errors=False)[source]
value_to_display_text(value)[source]
to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

validate(value, trans=None)[source]
to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

classmethod build(tool, input_source)[source]

Factory method to create parameter of correct type

static parse_name(input_source)[source]
class galaxy.tools.parameters.basic.SimpleTextToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

class galaxy.tools.parameters.basic.TextToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.SimpleTextToolParameter

Parameter that can take on any text value.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None)
>>> p = TextToolParameter(None, XML('<param name="_name" type="text" value="default" />'))
>>> print(p.name)
_name
>>> assert sorted(p.to_dict(trans).items()) == [('area', False), ('argument', None), ('datalist', []), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'TextToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'text'), ('value', u'default')]
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]
to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.IntegerToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.TextToolParameter

Parameter that takes an integer value.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch(), workflow_building_mode=True)
>>> p = IntegerToolParameter(None, XML('<param name="_name" type="integer" value="10" />'))
>>> print(p.name)
_name
>>> assert sorted(p.to_dict(trans).items()) == [('area', False), ('argument', None), ('datalist', []), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('max', None), ('min', None), ('model_class', 'IntegerToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'integer'), ('value', u'10')]
>>> assert type(p.from_json("10", trans)) == int
>>> with assert_throws_param_value_error("parameter '_name': an integer or workflow parameter is required"):
...     p.from_json("_string", trans)
dict_collection_visible_keys = ['name', 'argument', 'type', 'label', 'help', 'refresh_on_change', 'min', 'max']
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_python(value, app)[source]

Convert a value created with to_json back to an object representation

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

class galaxy.tools.parameters.basic.FloatToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.TextToolParameter

Parameter that takes a real number value.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch(), workflow_building_mode=True)
>>> p = FloatToolParameter(None, XML('<param name="_name" type="float" value="3.141592" />'))
>>> print(p.name)
_name
>>> assert sorted(p.to_dict(trans).items()) == [('area', False), ('argument', None), ('datalist', []), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('max', None), ('min', None), ('model_class', 'FloatToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'float'), ('value', u'3.141592')]
>>> assert type(p.from_json("36.1", trans)) == float
>>> with assert_throws_param_value_error("parameter '_name': an integer or workflow parameter is required"):
...     p.from_json("_string", trans)
dict_collection_visible_keys = ['name', 'argument', 'type', 'label', 'help', 'refresh_on_change', 'min', 'max']
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_python(value, app)[source]

Convert a value created with to_json back to an object representation

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

class galaxy.tools.parameters.basic.BooleanToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that takes one of two values.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch())
>>> p = BooleanToolParameter(None, XML('<param name="_name" type="boolean" checked="yes" truevalue="_truevalue" falsevalue="_falsevalue" />'))
>>> print(p.name)
_name
>>> assert sorted(p.to_dict(trans).items()) == [('argument', None), ('falsevalue', '_falsevalue'), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'BooleanToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('truevalue', '_truevalue'), ('type', 'boolean'), ('value', 'true')]
>>> print(p.from_json('true'))
True
>>> print(p.to_param_dict_string(True))
_truevalue
>>> print(p.from_json('false'))
False
>>> print(p.to_param_dict_string(False))
_falsevalue
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans=None, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_python(value, app=None)[source]

Convert a value created with to_json back to an object representation

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

property legal_values
class galaxy.tools.parameters.basic.FileToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that takes an uploaded file as a value.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch())
>>> p = FileToolParameter(None, XML('<param name="_name" type="file"/>'))
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'FileToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'file'), ('value', None)]
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans=None, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

get_required_enctype()[source]

File upload elements require the multipart/form-data encoding

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

to_python(value, app)[source]

Convert a value created with to_json back to an object representation

class galaxy.tools.parameters.basic.FTPFileToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that takes a file uploaded via FTP as a value.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch(), user=None)
>>> p = FTPFileToolParameter(None, XML('<param name="_name" type="ftpfile"/>'))
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'FTPFileToolParameter'), ('multiple', True), ('name', '_name'), ('optional', True), ('refresh_on_change', False), ('type', 'ftpfile'), ('value', None)]
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

property visible

Return true if the parameter should be rendered on the form

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

from_json(value, trans=None, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

to_python(value, app, validate=False)[source]

Convert a value created with to_json back to an object representation

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.HiddenToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that takes one of two values.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch())
>>> p = HiddenToolParameter(None, XML('<param name="_name" type="hidden" value="_value"/>'))
>>> print(p.name)
_name
>>> assert sorted(p.to_dict(trans).items()) == [('argument', None), ('help', ''), ('hidden', True), ('is_dynamic', False), ('label', ''), ('model_class', 'HiddenToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'hidden'), ('value', u'_value')]
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

get_label()[source]

Return user friendly name for the parameter

class galaxy.tools.parameters.basic.ColorToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that stores a color.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch())
>>> p = ColorToolParameter(None, XML('<param name="_name" type="color" value="#ffffff"/>'))
>>> print(p.name)
_name
>>> print(p.to_param_dict_string("#ffffff"))
#ffffff
>>> assert sorted(p.to_dict(trans).items()) == [('argument', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'ColorToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'color'), ('value', u'#ffffff')]
>>> p = ColorToolParameter(None, XML('<param name="_name" type="color"/>'))
>>> print(p.get_initial_value(trans, {}))
#000000
>>> p = ColorToolParameter(None, XML('<param name="_name" type="color" value="#ffffff" rgb="True"/>'))
>>> print(p.to_param_dict_string("#ffffff"))
(255, 255, 255)
>>> with assert_throws_param_value_error("parameter '_name': Failed to convert 'None' to RGB."):
...      p.to_param_dict_string(None)
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

class galaxy.tools.parameters.basic.BaseURLToolParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.HiddenToolParameter

Returns a parameter that contains its value prepended by the current server base url. Used in all redirects.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch())
>>> p = BaseURLToolParameter(None, XML('<param name="_name" type="base_url" value="_value"/>'))
>>> print(p.name)
_name
>>> assert sorted(p.to_dict(trans).items()) == [('argument', None), ('help', ''), ('hidden', True), ('is_dynamic', False), ('label', ''), ('model_class', 'BaseURLToolParameter'), ('name', '_name'), ('optional', False), ('refresh_on_change', False), ('type', 'base_url'), ('value', u'_value')]
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

from_json(value=None, trans=None, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.SelectToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that takes on one (or many) or a specific set of values.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch(), workflow_building_mode=False)
>>> p = SelectToolParameter(None, XML(
... '''
... <param name="_name" type="select">
...     <option value="x">x_label</option>
...     <option value="y" selected="true">y_label</option>
...     <option value="z">z_label</option>
... </param>
... '''))
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', False), ('name', '_name'), ('optional', False), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', False)]), ('refresh_on_change', False), ('textable', False), ('type', 'select'), ('value', 'y')]
>>> p = SelectToolParameter(None, XML(
... '''
... <param name="_name" type="select" multiple="true">
...     <option value="x">x_label</option>
...     <option value="y" selected="true">y_label</option>
...     <option value="z" selected="true">z_label</option>
... </param>
... '''))
>>> print(p.name)
_name
>>> sorted(p.to_dict(trans).items())
[('argument', None), ('display', None), ('help', ''), ('hidden', False), ('is_dynamic', False), ('label', ''), ('model_class', 'SelectToolParameter'), ('multiple', True), ('name', '_name'), ('optional', True), ('options', [('x_label', 'x', False), ('y_label', 'y', True), ('z_label', 'z', True)]), ('refresh_on_change', False), ('textable', False), ('type', 'select'), ('value', ['y', 'z'])]
>>> print(p.to_param_dict_string(["y", "z"]))
y,z
__init__(tool, input_source, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

get_options(trans, other_values)[source]

determine the set of values of legal options

determine a mapping from names to values for all legal options

from_json(value, trans, other_values=None, require_legal_value=True)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

get_dependencies()[source]

Get the names of the other params this param depends on.

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

validate(value, trans=None)[source]
class galaxy.tools.parameters.basic.GenomeBuildParameter(*args, **kwds)[source]

Bases: galaxy.tools.parameters.basic.SelectToolParameter

Select list that sets the last used genome build for the current history as “selected”.

>>> # Create a mock transaction with 'hg17' as the current build
>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch(genome_build='hg17'), db_builds=dbkeys.read_dbnames(None))
>>> p = GenomeBuildParameter(None, XML('<param name="_name" type="genomebuild" value="hg17" />'))
>>> print(p.name)
_name
>>> d = p.to_dict(trans)
>>> o = d['options']
>>> [i for i in o if i[2] == True]
[('Human May 2004 (NCBI35/hg17) (hg17)', 'hg17', True)]
>>> [i for i in o if i[1] == 'hg18']
[('Human Mar. 2006 (NCBI36/hg18) (hg18)', 'hg18', False)]
>>> p.is_dynamic
True
__init__(*args, **kwds)[source]

Initialize self. See help(type(self)) for accurate signature.

get_options(trans, other_values)[source]

determine the set of values of legal options

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.SelectTagParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.SelectToolParameter

Select set that is composed of a set of tags available for an input.

__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

get_tag_list(other_values)[source]

Generate a select list containing the tags of the associated dataset (if found).

get_options(trans, other_values)[source]

Show tags

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

determine the set of values of legal options

get_dependencies()[source]

Get the names of the other params this param depends on.

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.ColumnListParameter(tool, input_source)[source]

Bases: galaxy.tools.parameters.basic.SelectToolParameter

Select list that consists of either the total number of columns or only those columns that contain numerical values in the associated DataToolParameter.

# TODO: we need better testing here, but not sure how to associate a DatatoolParameter with a ColumnListParameter # from a twill perspective…

>>> # Mock up a history (not connected to database)
>>> from galaxy.model import History, HistoryDatasetAssociation
>>> from galaxy.util.bunch import Bunch
>>> from galaxy.model.mapping import init
>>> sa_session = init("/tmp", "sqlite:///:memory:", create_tables=True).session
>>> hist = History()
>>> sa_session.add(hist)
>>> sa_session.flush()
>>> hda = hist.add_dataset(HistoryDatasetAssociation(id=1, extension='interval', create_dataset=True, sa_session=sa_session))
>>> dtp =  DataToolParameter(None, XML('<param name="blah" type="data" format="interval"/>'))
>>> print(dtp.name)
blah
>>> clp = ColumnListParameter(None, XML('<param name="numerical_column" type="data_column" data_ref="blah" numerical="true"/>'))
>>> print(clp.name)
numerical_column
__init__(tool, input_source)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans, other_values=None)[source]

Label convention prepends column number with a ‘c’, but tool uses the integer. This removes the ‘c’ when entered into a workflow.

get_column_list(trans, other_values)[source]

Generate a select list containing the columns of the associated dataset (if found).

get_options(trans, other_values)[source]

Show column labels rather than c1..cn if use_header_names=True

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

determine the set of values of legal options

is_file_empty(trans, other_values)[source]
get_dependencies()[source]

Get the names of the other params this param depends on.

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.DrillDownSelectToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.tools.parameters.basic.SelectToolParameter

Parameter that takes on one (or many) of a specific set of values. Creating a hierarchical select menu, which allows users to ‘drill down’ a tree-like set of options.

>>> from galaxy.util.bunch import Bunch
>>> trans = Bunch(app=None, history=Bunch(genome_build='hg17'), db_builds=dbkeys.read_dbnames(None))
>>> p = DrillDownSelectToolParameter(None, XML(
... '''
... <param name="_name" type="drill_down" display="checkbox" hierarchy="recurse" multiple="true">
...   <options>
...    <option name="Heading 1" value="heading1">
...        <option name="Option 1" value="option1"/>
...        <option name="Option 2" value="option2"/>
...        <option name="Heading 2" value="heading2">
...          <option name="Option 3" value="option3"/>
...          <option name="Option 4" value="option4"/>
...        </option>
...    </option>
...    <option name="Option 5" value="option5"/>
...   </options>
... </param>
... '''))
>>> print(p.name)
_name
>>> d = p.to_dict(trans)
>>> assert d['multiple'] == True
>>> assert d['display'] == 'checkbox'
>>> assert d['options'][0]['name'] == 'Heading 1'
>>> assert d['options'][0]['value'] == 'heading1'
>>> assert d['options'][0]['options'][0]['name'] == 'Option 1'
>>> assert d['options'][0]['options'][0]['value'] == 'option1'
>>> assert d['options'][0]['options'][1]['name'] == 'Option 2'
>>> assert d['options'][0]['options'][1]['value'] == 'option2'
>>> assert d['options'][0]['options'][2]['name'] == 'Heading 2'
>>> assert d['options'][0]['options'][2]['value'] == 'heading2'
>>> assert d['options'][0]['options'][2]['options'][0]['name'] == 'Option 3'
>>> assert d['options'][0]['options'][2]['options'][0]['value'] == 'option3'
>>> assert d['options'][0]['options'][2]['options'][1]['name'] == 'Option 4'
>>> assert d['options'][0]['options'][2]['options'][1]['value'] == 'option4'
>>> assert d['options'][1]['name'] == 'Option 5'
>>> assert d['options'][1]['value'] == 'option5'
__init__(tool, input_source, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

get_options(trans=None, value=None, other_values=None)[source]

determine the set of values of legal options

from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

get_dependencies()[source]

Get the names of the other params this param depends on.

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.BaseDataToolParameter(tool, input_source, trans)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

__init__(tool, input_source, trans)[source]

Initialize self. See help(type(self)) for accurate signature.

get_initial_value(trans, other_values)[source]

Return the starting value of the parameter

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

to_python(value, app)[source]

Convert a value created with to_json back to an object representation

validate(value, trans=None)[source]
class galaxy.tools.parameters.basic.DataToolParameter(tool, input_source, trans=None)[source]

Bases: galaxy.tools.parameters.basic.BaseDataToolParameter

Parameter that takes on one (or many) or a specific set of values.

TODO: There should be an alternate display that allows single selects to be

displayed as radio buttons and multiple selects as a set of checkboxes

TODO: The following must be fixed to test correctly for the new security_check tag in the DataToolParameter (the last test below is broken) Nate’s next pass at the dataset security stuff will dramatically alter this anyway.

__init__(tool, input_source, trans=None)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

get_dependencies()[source]

Get the names of the other params this param depends on.

converter_safe(other_values, trans)[source]
get_options_filter_attribute(value)[source]
to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.DataCollectionToolParameter(tool, input_source, trans=None)[source]

Bases: galaxy.tools.parameters.basic.BaseDataToolParameter

__init__(tool, input_source, trans=None)[source]

Initialize self. See help(type(self)) for accurate signature.

property collection_types
match_collections(trans, history, dataset_collection_matcher)[source]
match_multirun_collections(trans, history, dataset_collection_matcher)[source]
from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.HiddenDataToolParameter(tool, elem)[source]

Bases: galaxy.tools.parameters.basic.HiddenToolParameter, galaxy.tools.parameters.basic.DataToolParameter

Hidden parameter that behaves as a DataToolParameter. As with all hidden parameters, this is a HACK.

__init__(tool, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

class galaxy.tools.parameters.basic.LibraryDatasetToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Parameter that lets users select a LDDA from a modal window, then use it within the wrapper.

__init__(tool, input_source, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

from_json(value, trans, other_values=None)[source]

Convert a value from an HTML POST into the parameters preferred value format.

to_param_dict_string(value, other_values=None)[source]

Called via __str__ when used in the Cheetah template

to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

to_python(value, app, other_values=None, validate=False)[source]

Convert a value created with to_json back to an object representation

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

class galaxy.tools.parameters.basic.BaseJsonToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.tools.parameters.basic.ToolParameter

Class of parameter that tries to keep values as close to JSON as possible. In particular value_to_basic is overloaded to prevent params_to_strings from double encoding JSON and to_python using loads to produce values.

value_to_basic(value, app, use_security=False)[source]
to_json(value, app, use_security)[source]

Convert a value to a string representation suitable for persisting

to_python(value, app)[source]

Convert a value created with to_json back to an object representation

class galaxy.tools.parameters.basic.DirectoryUriToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.tools.parameters.basic.SimpleTextToolParameter

galaxy.files URIs for directories.

__init__(tool, input_source, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]
class galaxy.tools.parameters.basic.RulesListToolParameter(tool, input_source, context=None)[source]

Bases: galaxy.tools.parameters.basic.BaseJsonToolParameter

Parameter that allows for the creation of a list of rules using the Galaxy rules DSL.

__init__(tool, input_source, context=None)[source]

Initialize self. See help(type(self)) for accurate signature.

to_dict(trans, other_values=None)[source]

to_dict tool parameter. This can be overridden by subclasses.

validate(value, trans=None)[source]
to_text(value)[source]

Convert a value to a text representation suitable for displaying to the user >>> p = ToolParameter(None, XML(‘<param name=”_name” />’)) >>> print(p.to_text(None)) Not available. >>> print(p.to_text(‘’)) Empty. >>> print(p.to_text(‘text’)) text >>> print(p.to_text(True)) True >>> print(p.to_text(False)) False >>> print(p.to_text(0)) 0

galaxy.tools.parameters.basic.runtime_to_json(runtime_value)[source]
galaxy.tools.parameters.basic.runtime_to_object(runtime_value)[source]
class galaxy.tools.parameters.basic.RuntimeValue[source]

Bases: object

Wrapper to note a value that is not yet set, but will be required at runtime.

class galaxy.tools.parameters.basic.ConnectedValue[source]

Bases: galaxy.tools.parameters.basic.RuntimeValue

Wrapper to note a value that is not yet set, but will be inferred from a connection.

galaxy.tools.parameters.dataset_matcher module

galaxy.tools.parameters.dataset_matcher.get_dataset_matcher_factory(trans)[source]
galaxy.tools.parameters.dataset_matcher.set_dataset_matcher_factory(trans, tool)[source]
galaxy.tools.parameters.dataset_matcher.unset_dataset_matcher_factory(trans)[source]

galaxy.tools.parameters.dynamic_options module

Support for generating the options for a SelectToolParameter dynamically (based on the values of other parameters or other aspects of the current state)

class galaxy.tools.parameters.dynamic_options.Filter(d_option, elem)[source]

Bases: object

A filter takes the current options list and modifies it.

classmethod from_element(d_option, elem)[source]

Loads the proper filter by the type attribute of elem

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

get_dependency_name()[source]

Returns the name of any dependencies, otherwise None

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.StaticValueFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Filters a list of options on a column by a static value.

Type: static_value

Required Attributes:

value: static value to compare to column: column in options to compare with

Optional Attributes:
keep: Keep columns matching value (True)

Discard columns matching value (False)

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.RegexpFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Filters a list of options on a column by a regular expression.

Type: regexp

Required Attributes:

value: regular expression to compare to column: column in options to compare with

Optional Attributes:
keep: Keep columns matching the regexp (True)

Discard columns matching the regexp (False)

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.DataMetaFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Filters a list of options on a column by a dataset metadata value.

Type: data_meta

When no ‘from’ source has been specified in the <options> tag, this will populate the options list with (meta_value, meta_value, False). Otherwise, options which do not match the metadata value in the column are discarded.

Required Attributes:

  • ref: Name of input dataset

  • key: Metadata key to use for comparison

  • column: column in options to compare with (not required when not associated with input options)

Optional Attributes:

  • multiple: Option values are multiple, split column by separator (True)

  • separator: When multiple split by this (,)

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

get_dependency_name()[source]

Returns the name of any dependencies, otherwise None

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.ParamValueFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Filters a list of options on a column by the value of another input.

Type: param_value

Required Attributes:

  • ref: Name of input value

  • column: column in options to compare with

Optional Attributes:

  • keep: Keep columns matching value (True)

    Discard columns matching value (False)

  • ref_attribute: Period (.) separated attribute chain of input (ref) to use as value for filter

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

get_dependency_name()[source]

Returns the name of any dependencies, otherwise None

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.UniqueValueFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Filters a list of options to be unique by a column value.

Type: unique_value

Required Attributes:

column: column in options to compare with

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

get_dependency_name()[source]

Returns the name of any dependencies, otherwise None

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.MultipleSplitterFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Turns a single line of options into multiple lines, by splitting a column and creating a line for each item.

Type: multiple_splitter

Required Attributes:

column: column in options to compare with

Optional Attributes:

separator: Split column by this (,)

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.AttributeValueSplitterFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Filters a list of attribute-value pairs to be unique attribute names.

DEPRECATED: just replace with 2 rounds of MultipleSplitterFilter

Type: attribute_value_splitter

Required Attributes:

column: column in options to compare with

Optional Attributes:

pair_separator: Split column by this (,) name_val_separator: Split name-value pair by this ( whitespace )

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.AdditionalValueFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Adds a single static value to an options list.

Type: add_value

Required Attributes:

value: value to appear in select list

Optional Attributes:

name: Display name to appear in select list (value) index: Index of option list to add value (APPEND)

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.RemoveValueFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Removes a value from an options list.

Type: remove_value

Required Attributes:

value: value to remove from select list
    or
ref: param to refer to
    or
meta_ref: dataset to refer to
key: metadata key to compare to
__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.SortByColumnFilter(d_option, elem)[source]

Bases: galaxy.tools.parameters.dynamic_options.Filter

Sorts an options list by a column

Type: sort_by

Required Attributes:

column: column to sort by

__init__(d_option, elem)[source]

Initialize self. See help(type(self)) for accurate signature.

filter_options(options, trans, other_values)[source]

Returns a list of options after the filter is applied

class galaxy.tools.parameters.dynamic_options.DynamicOptions(elem, tool_param)[source]

Bases: object

Handles dynamically generated SelectToolParameter options

__init__(elem, tool_param)[source]

Initialize self. See help(type(self)) for accurate signature.

property tool_data_table
property missing_tool_data_table_name
parse_column_definitions(elem)[source]
parse_file_fields(reader)[source]
get_dependency_names()[source]

Return the names of parameters these options depend on – both data and other param types.

get_fields(trans, other_values)[source]
get_fields_by_value(value, trans, other_values)[source]

Return a list of fields with column ‘value’ matching provided value.

get_field_by_name_for_value(field_name, value, trans, other_values)[source]

Get contents of field by name for specified value.

get_options(trans, other_values)[source]
column_spec_to_index(column_spec)[source]

Convert a column specification (as read from the config file), to an index. A column specification can just be a number, a column name, or a column alias.

galaxy.tools.parameters.grouping module

Constructs for grouping tool parameters

class galaxy.tools.parameters.grouping.Group[source]

Bases: galaxy.util.dictifiable.Dictifiable

dict_collection_visible_keys = ['name', 'type']
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

property visible
value_to_basic(value, app, use_security=False)[source]

Convert value to a (possibly nested) representation using only basic types (dict, list, tuple, string_types, int, long, float, bool, None)

value_from_basic(value, app, ignore_errors=False)[source]

Convert a basic representation as produced by value_to_basic back into the preferred value form.

get_initial_value(trans, context)[source]

Return the initial state/value for this group

to_dict(trans)[source]

Return item dictionary.

class galaxy.tools.parameters.grouping.Repeat[source]

Bases: galaxy.tools.parameters.grouping.Group

dict_collection_visible_keys = ['name', 'type', 'title', 'help', 'default', 'min', 'max']
type = 'repeat'
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

property title
property title_plural
label()[source]
value_to_basic(value, app, use_security=False)[source]

Convert value to a (possibly nested) representation using only basic types (dict, list, tuple, string_types, int, long, float, bool, None)

value_from_basic(value, app, ignore_errors=False)[source]

Convert a basic representation as produced by value_to_basic back into the preferred value form.

get_initial_value(trans, context)[source]

Return the initial state/value for this group

to_dict(trans)[source]

Return item dictionary.

class galaxy.tools.parameters.grouping.Section[source]

Bases: galaxy.tools.parameters.grouping.Group

dict_collection_visible_keys = ['name', 'type', 'title', 'help', 'expanded']
type = 'section'
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

property title_plural
label()[source]
value_to_basic(value, app, use_security=False)[source]

Convert value to a (possibly nested) representation using only basic types (dict, list, tuple, string_types, int, long, float, bool, None)

value_from_basic(value, app, ignore_errors=False)[source]

Convert a basic representation as produced by value_to_basic back into the preferred value form.

get_initial_value(trans, context)[source]

Return the initial state/value for this group

to_dict(trans)[source]

Return item dictionary.

class galaxy.tools.parameters.grouping.UploadDataset[source]

Bases: galaxy.tools.parameters.grouping.Group

type = 'upload_dataset'
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

get_composite_dataset_name(context)[source]
get_file_base_name(context)[source]
get_file_type(context, parent_context=None)[source]
get_dbkey(context, parent_context=None)[source]
get_datatype_ext(trans, context, parent_context=None)[source]
get_datatype(trans, context, parent_context=None)[source]
property title_plural
group_title(context)[source]
title_by_index(trans, index, context)[source]
value_to_basic(value, app, use_security=False)[source]

Convert value to a (possibly nested) representation using only basic types (dict, list, tuple, string_types, int, long, float, bool, None)

value_from_basic(value, app, ignore_errors=False)[source]

Convert a basic representation as produced by value_to_basic back into the preferred value form.

get_file_count(trans, context)[source]
get_initial_value(trans, context)[source]

Return the initial state/value for this group

get_uploaded_datasets(trans, context, override_name=None, override_info=None)[source]
class galaxy.tools.parameters.grouping.Conditional[source]

Bases: galaxy.tools.parameters.grouping.Group

type = 'conditional'
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

property label
get_current_case(value)[source]
value_to_basic(value, app, use_security=False)[source]

Convert value to a (possibly nested) representation using only basic types (dict, list, tuple, string_types, int, long, float, bool, None)

value_from_basic(value, app, ignore_errors=False)[source]

Convert a basic representation as produced by value_to_basic back into the preferred value form.

get_initial_value(trans, context)[source]

Return the initial state/value for this group

to_dict(trans)[source]

Return item dictionary.

class galaxy.tools.parameters.grouping.ConditionalWhen[source]

Bases: galaxy.util.dictifiable.Dictifiable

dict_collection_visible_keys = ['value']
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

to_dict(trans)[source]

Return item dictionary.

galaxy.tools.parameters.history_query module

class galaxy.tools.parameters.history_query.HistoryQuery(**kwargs)[source]

Bases: object

An object for describing the collections to pull out of a history, used by DataCollectionToolParameter.

__init__(**kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

static from_collection_type(collection_type, collection_type_descriptions)[source]
static from_collection_types(collection_types, collection_type_descriptions)[source]
static from_parameter(param, collection_type_descriptions)[source]

Take in a tool parameter element.

direct_match(hdca)[source]
can_map_over(hdca)[source]

galaxy.tools.parameters.input_translation module

Tool Input Translation.

class galaxy.tools.parameters.input_translation.ToolInputTranslator[source]

Bases: object

Handles Tool input translation. This is used for data source tools

>>> from galaxy.util import Params, XML
>>> translator = ToolInputTranslator.from_element(XML(
... '''
... <request_param_translation>
...  <request_param galaxy_name="URL_method" remote_name="URL_method" missing="post" />
...  <request_param galaxy_name="URL" remote_name="URL" missing="" >
...     <append_param separator="&amp;" first_separator="?" join="=">
...         <value name="_export" missing="1" />
...         <value name="GALAXY_URL" missing="0" />
...     </append_param>
...  </request_param>
...  <request_param galaxy_name="dbkey" remote_name="db" missing="?" />
...  <request_param galaxy_name="organism" remote_name="org" missing="unknown species" />
...  <request_param galaxy_name="table" remote_name="hgta_table" missing="unknown table" />
...  <request_param galaxy_name="description" remote_name="hgta_regionType" missing="no description" />
...  <request_param galaxy_name="data_type" remote_name="hgta_outputType" missing="tabular" >
...   <value_translation>
...    <value galaxy_value="tabular" remote_value="primaryTable" />
...    <value galaxy_value="tabular" remote_value="selectedFields" />
...    <value galaxy_value="wig" remote_value="wigData" />
...    <value galaxy_value="interval" remote_value="tab" />
...    <value galaxy_value="html" remote_value="hyperlinks" />
...    <value galaxy_value="fasta" remote_value="sequence" />
...   </value_translation>
...  </request_param>
... </request_param_translation>
... '''))
>>> params = Params({'db':'hg17', 'URL':'URL_value', 'org':'Human', 'hgta_outputType':'primaryTable'})
>>> translator.translate(params)
>>> print(sorted(params.__dict__.keys()))
['URL', 'URL_method', 'data_type', 'db', 'dbkey', 'description', 'hgta_outputType', 'org', 'organism', 'table']
>>> params.get('URL', None) in ['URL_value?GALAXY_URL=0&_export=1', 'URL_value?_export=1&GALAXY_URL=0']
True
classmethod from_element(elem)[source]

Loads the proper filter by the type attribute of elem

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

translate(params)[source]

update params in-place

galaxy.tools.parameters.meta module

class galaxy.tools.parameters.meta.WorkflowParameterExpansion(param_combinations, param_keys, input_combinations)

Bases: tuple

property input_combinations

Alias for field number 2

property param_combinations

Alias for field number 0

property param_keys

Alias for field number 1

class galaxy.tools.parameters.meta.ParamKey(step_id, key)[source]

Bases: object

__init__(step_id, key)[source]

Initialize self. See help(type(self)) for accurate signature.

class galaxy.tools.parameters.meta.InputKey(input_id)[source]

Bases: object

__init__(input_id)[source]

Initialize self. See help(type(self)) for accurate signature.

galaxy.tools.parameters.meta.expand_workflow_inputs(param_inputs, inputs=None)[source]

Expands incoming encoded multiple payloads, into the set of all individual payload combinations >>> expansion = expand_workflow_inputs({‘1’: {‘input’: {‘batch’: True, ‘product’: True, ‘values’: [{‘hid’: ‘1’}, {‘hid’: ‘2’}] }}}) >>> print([“%s” % (p[‘1’][‘input’][‘hid’]) for p in expansion.param_combinations]) [‘1’, ‘2’] >>> expansion = expand_workflow_inputs({‘1’: {‘input’: {‘batch’: True, ‘values’: [{‘hid’: ‘1’}, {‘hid’: ‘2’}] }}}) >>> print([“%s” % (p[‘1’][‘input’][‘hid’]) for p in expansion.param_combinations]) [‘1’, ‘2’] >>> expansion = expand_workflow_inputs({‘1’: {‘input’: {‘batch’: True, ‘values’: [{‘hid’: ‘1’}, {‘hid’: ‘2’}] }}, ‘2’: {‘input’: {‘batch’: True, ‘values’: [{‘hid’: ‘3’}, {‘hid’: ‘4’}] }}}) >>> print([“%s%s” % (p[‘1’][‘input’][‘hid’], p[‘2’][‘input’][‘hid’]) for p in expansion.param_combinations]) [‘13’, ‘24’] >>> expansion = expand_workflow_inputs({‘1’: {‘input’: {‘batch’: True, ‘product’: True, ‘values’: [{‘hid’: ‘1’}, {‘hid’: ‘2’}] }}, ‘2’: {‘input’: {‘batch’: True, ‘values’: [{‘hid’: ‘3’}, {‘hid’: ‘4’}, {‘hid’: ‘5’}] }}}) >>> print([“%s%s” % (p[‘1’][‘input’][‘hid’], p[‘2’][‘input’][‘hid’]) for p in expansion.param_combinations]) [‘13’, ‘23’, ‘14’, ‘24’, ‘15’, ‘25’] >>> expansion = expand_workflow_inputs({‘1’: {‘input’: {‘batch’: True, ‘product’: True, ‘values’: [{‘hid’: ‘1’}, {‘hid’: ‘2’}] }}, ‘2’: {‘input’: {‘batch’: True, ‘product’: True, ‘values’: [{‘hid’: ‘3’}, {‘hid’: ‘4’}, {‘hid’: ‘5’}] }}, ‘3’: {‘input’: {‘batch’: True, ‘product’: True, ‘values’: [{‘hid’: ‘6’}, {‘hid’: ‘7’}, {‘hid’: ‘8’}] }}}) >>> print([“%s%s%s” % (p[‘1’][‘input’][‘hid’], p[‘2’][‘input’][‘hid’], p[‘3’][‘input’][‘hid’]) for p in expansion.param_combinations]) [‘136’, ‘137’, ‘138’, ‘146’, ‘147’, ‘148’, ‘156’, ‘157’, ‘158’, ‘236’, ‘237’, ‘238’, ‘246’, ‘247’, ‘248’, ‘256’, ‘257’, ‘258’] >>> expansion = expand_workflow_inputs(None, inputs={‘myinput’: {‘batch’: True, ‘product’: True, ‘values’: [{‘hid’: ‘1’}, {‘hid’: ‘2’}] }}) >>> print([“%s” % (p[‘myinput’][‘hid’]) for p in expansion.input_combinations]) [‘1’, ‘2’]

galaxy.tools.parameters.meta.process_key(incoming_key, incoming_value, d)[source]
galaxy.tools.parameters.meta.expand_meta_parameters(trans, tool, incoming)[source]

Take in a dictionary of raw incoming parameters and expand to a list of expanded incoming parameters (one set of parameters per tool execution).

galaxy.tools.parameters.sanitize module

Tool Parameter specific sanitizing.

class galaxy.tools.parameters.sanitize.ToolParameterSanitizer[source]

Bases: object

Handles tool parameter specific sanitizing.

>>> from galaxy.util import XML
>>> sanitizer = ToolParameterSanitizer.from_element(XML(
... '''
... <sanitizer invalid_char="">
...   <valid initial="string.ascii_letters"/>
... </sanitizer>
... '''))
>>> sanitizer.sanitize_param(''.join(sorted(c for c in string.printable))) == ''.join(sorted(c for c in string.ascii_letters))
True
>>> slash = chr(92)
>>> sanitizer = ToolParameterSanitizer.from_element(XML(
... '''
... <sanitizer>
...   <valid initial="none">
...    <add preset="string.printable"/>
...    <remove value="&quot;"/>
...    <remove value="%s"/>
...   </valid>
...   <mapping initial="none">
...     <add source="&quot;" target="%s&quot;"/>
...     <add source="%s" target="%s%s"/>
...   </mapping>
... </sanitizer>
... ''' % (slash, slash, slash, slash, slash)))
>>> text = '%s"$rm&#!' % slash
>>> [c for c in sanitizer.sanitize_param(text)] == [slash, slash, slash, '"', '$', 'r', 'm', '&', '#', '!']
True
VALID_PRESET = {'default': 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -=_.()/+*^,:?!', 'none': ''}
MAPPING_PRESET = {'default': {'\t': '__tc__', '\n': '__cn__', '\r': '__cr__', '"': '__dq__', '#': '__pd__', "'": '__sq__', '<': '__lt__', '>': '__gt__', '@': '__at__', '[': '__ob__', ']': '__cb__', '{': '__oc__', '}': '__cc__'}, 'none': {}}
DEFAULT_INVALID_CHAR = 'X'
classmethod from_element(elem)[source]

Loads the proper filter by the type attribute of elem

classmethod get_valid_by_name(name)[source]
classmethod get_mapping_by_name(name)[source]
__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

restore_text(text)[source]

Restores sanitized text

sanitize_text(text)[source]

Restricts the characters that are allowed in a text

sanitize_param(value)[source]

Clean incoming parameters (strings or lists)

galaxy.tools.parameters.validation module

Classes related to parameter validation.

galaxy.tools.parameters.validation.get_test_fname(fname)[source]

Returns test data filename

class galaxy.tools.parameters.validation.Validator(message, negate=False)[source]

Bases: abc.ABC

A validator checks that a value meets some conditions OR raises ValueError

requires_dataset_metadata = False
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(message, negate=False)[source]

Initialize self. See help(type(self)) for accurate signature.

abstract validate(value, trans=None, message=None, value_to_show=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.RegexValidator(message, expression, negate)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that evaluates a regular expression

>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="10">
...     <validator type="regex">[Ff]oo</validator>
... </param>
... '''))
>>> t = p.validate("Foo")
>>> t = p.validate("foo")
>>> t = p.validate("Fop")
Traceback (most recent call last):
    ...
ValueError: Value 'Fop' does not match regular expression '[Ff]oo'
>>> t = p.validate(["Foo", "foo"])
>>> t = p.validate(["Foo", "Fop"])
Traceback (most recent call last):
    ...
ValueError: Value 'Fop' does not match regular expression '[Ff]oo'
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="10">
...     <validator type="regex" negate="true">[Ff]oo</validator>
... </param>
... '''))
>>> t = p.validate("Foo")
Traceback (most recent call last):
    ...
ValueError: Value 'Foo' does match regular expression '[Ff]oo'
>>> t = p.validate("foo")
Traceback (most recent call last):
    ...
ValueError: Value 'foo' does match regular expression '[Ff]oo'
>>> t = p.validate("Fop")
>>> t = p.validate(["Fop", "foo"])
Traceback (most recent call last):
    ...
ValueError: Value 'foo' does match regular expression '[Ff]oo'
>>> t = p.validate(["Fop", "Fop"])
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(message, expression, negate)[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.ExpressionValidator(message, expression, negate)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that evaluates a python expression using the value

>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="10">
...     <validator type="expression" message="Not gonna happen">value.lower() == "foo"</validator>
... </param>
... '''))
>>> t = p.validate("Foo")
>>> t = p.validate("foo")
>>> t = p.validate("Fop")
Traceback (most recent call last):
    ...
ValueError: Not gonna happen
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="10">
...     <validator type="expression" message="Not gonna happen" negate="true">value.lower() == "foo"</validator>
... </param>
... '''))
>>> t = p.validate("Foo")
Traceback (most recent call last):
    ...
ValueError: Not gonna happen
>>> t = p.validate("foo")
Traceback (most recent call last):
    ...
ValueError: Not gonna happen
>>> t = p.validate("Fop")
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="10">
...     <validator type="expression" message="Not gonna happen">value</validator>
... </param>
... '''))
>>> p.validate("Foo")
>>> p.validate("")
Traceback (most recent call last):
    ...
ValueError: Not gonna happen
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(message, expression, negate)[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.InRangeValidator(message, range_min, range_max, exclude_min=False, exclude_max=False, negate=False)[source]

Bases: galaxy.tools.parameters.validation.ExpressionValidator

Validator that ensures a number is in a specified range

>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="integer" value="10">
...     <validator type="in_range" message="Doh!! %s not in range" min="10" exclude_min="true" max="20"/>
... </param>
... '''))
>>> t = p.validate(10)
Traceback (most recent call last):
    ...
ValueError: Doh!! 10 not in range
>>> t = p.validate(15)
>>> t = p.validate(20)
>>> t = p.validate(21)
Traceback (most recent call last):
    ...
ValueError: Doh!! 21 not in range
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="integer" value="10">
...     <validator type="in_range" min="10" exclude_min="true" max="20" negate="true"/>
... </param>
... '''))
>>> t = p.validate(10)
>>> t = p.validate(15)
Traceback (most recent call last):
    ...
ValueError: Value ('15') must not fulfill float('10') < value <= float('20')
>>> t = p.validate(20)
Traceback (most recent call last):
    ...
ValueError: Value ('20') must not fulfill float('10') < value <= float('20')
>>> t = p.validate(21)
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(message, range_min, range_max, exclude_min=False, exclude_max=False, negate=False)[source]

When the optional exclude_min and exclude_max attributes are set to true, the range excludes the end points (i.e., min < value < max), while if set to False (the default), then range includes the end points (1.e., min <= value <= max). Combinations of exclude_min and exclude_max values are allowed.

class galaxy.tools.parameters.validation.LengthValidator(message, length_min, length_max, negate)[source]

Bases: galaxy.tools.parameters.validation.InRangeValidator

Validator that ensures the length of the provided string (value) is in a specific range

>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="foobar">
...     <validator type="length" min="2" max="8"/>
... </param>
... '''))
>>> t = p.validate("foo")
>>> t = p.validate("bar")
>>> t = p.validate("f")
Traceback (most recent call last):
    ...
ValueError: Must have length of at least 2 and at most 8
>>> t = p.validate("foobarbaz")
Traceback (most recent call last):
    ...
ValueError: Must have length of at least 2 and at most 8
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="foobar">
...     <validator type="length" min="2" max="8" negate="true"/>
... </param>
... '''))
>>> t = p.validate("foo")
Traceback (most recent call last):
    ...
ValueError: Must not have length of at least 2 and at most 8
>>> t = p.validate("bar")
Traceback (most recent call last):
    ...
ValueError: Must not have length of at least 2 and at most 8
>>> t = p.validate("f")
>>> t = p.validate("foobarbaz")
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(message, length_min, length_max, negate)[source]

When the optional exclude_min and exclude_max attributes are set to true, the range excludes the end points (i.e., min < value < max), while if set to False (the default), then range includes the end points (1.e., min <= value <= max). Combinations of exclude_min and exclude_max values are allowed.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.DatasetOkValidator(message, negate=False)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks if a dataset is in an ‘ok’ state

>>> from galaxy.datatypes.registry import example_datatype_registry_for_sample
>>> from galaxy.model import History, HistoryDatasetAssociation, set_datatypes_registry
>>> from galaxy.model.mapping import init
>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>>
>>> sa_session = init("/tmp", "sqlite:///:memory:", create_tables=True).session
>>> hist = History()
>>> sa_session.add(hist)
>>> sa_session.flush()
>>> set_datatypes_registry(example_datatype_registry_for_sample())
>>> ok_hda = hist.add_dataset(HistoryDatasetAssociation(id=1, extension='interval', create_dataset=True, sa_session=sa_session))
>>> ok_hda.set_dataset_state(model.Dataset.states.OK)
>>> notok_hda = hist.add_dataset(HistoryDatasetAssociation(id=2, extension='interval', create_dataset=True, sa_session=sa_session))
>>> notok_hda.set_dataset_state(model.Dataset.states.EMPTY)
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="dataset_ok_validator"/>
... </param>
... '''))
>>> t = p.validate(ok_hda)
>>> t = p.validate(notok_hda)
Traceback (most recent call last):
    ...
ValueError: The selected dataset is still being generated, select another dataset or wait until it is completed
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="dataset_ok_validator" negate="true"/>
... </param>
... '''))
>>> t = p.validate(ok_hda)
Traceback (most recent call last):
    ...
ValueError: The selected dataset must not be in state OK
>>> t = p.validate(notok_hda)
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.DatasetEmptyValidator(message, negate=False)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks if a dataset has a positive file size.

>>> from galaxy.datatypes.registry import example_datatype_registry_for_sample
>>> from galaxy.model import Dataset, History, HistoryDatasetAssociation, set_datatypes_registry
>>> from galaxy.model.mapping import init
>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>>
>>> sa_session = init("/tmp", "sqlite:///:memory:", create_tables=True).session
>>> hist = History()
>>> sa_session.add(hist)
>>> sa_session.flush()
>>> set_datatypes_registry(example_datatype_registry_for_sample())
>>> empty_dataset = Dataset(external_filename=get_test_fname("empty.txt"))
>>> empty_hda = hist.add_dataset(HistoryDatasetAssociation(id=1, extension='interval', dataset=empty_dataset, sa_session=sa_session))
>>> full_dataset = Dataset(external_filename=get_test_fname("1.tabular"))
>>> full_hda = hist.add_dataset(HistoryDatasetAssociation(id=2, extension='interval', dataset=full_dataset, sa_session=sa_session))
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="empty_dataset"/>
... </param>
... '''))
>>> t = p.validate(full_hda)
>>> t = p.validate(empty_hda)
Traceback (most recent call last):
    ...
ValueError: The selected dataset is empty, this tool expects non-empty files.
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="empty_dataset" negate="true"/>
... </param>
... '''))
>>> t = p.validate(full_hda)
Traceback (most recent call last):
    ...
ValueError: The selected dataset is non-empty, this tool expects empty files.
>>> t = p.validate(empty_hda)
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.DatasetExtraFilesPathEmptyValidator(message, negate=False)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks if a dataset’s extra_files_path exists and is not empty.

>>> from galaxy.datatypes.registry import example_datatype_registry_for_sample
>>> from galaxy.model import History, HistoryDatasetAssociation, set_datatypes_registry
>>> from galaxy.model.mapping import init
>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>>
>>> sa_session = init("/tmp", "sqlite:///:memory:", create_tables=True).session
>>> hist = History()
>>> sa_session.add(hist)
>>> sa_session.flush()
>>> set_datatypes_registry(example_datatype_registry_for_sample())
>>> has_extra_hda = hist.add_dataset(HistoryDatasetAssociation(id=1, extension='interval', create_dataset=True, sa_session=sa_session))
>>> has_extra_hda.dataset.file_size = 10
>>> has_extra_hda.dataset.total_size = 15
>>> has_no_extra_hda = hist.add_dataset(HistoryDatasetAssociation(id=2, extension='interval', create_dataset=True, sa_session=sa_session))
>>> has_no_extra_hda.dataset.file_size = 10
>>> has_no_extra_hda.dataset.total_size = 10
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="empty_extra_files_path"/>
... </param>
... '''))
>>> t = p.validate(has_extra_hda)
>>> t = p.validate(has_no_extra_hda)
Traceback (most recent call last):
    ...
ValueError: The selected dataset's extra_files_path directory is empty or does not exist, this tool expects non-empty extra_files_path directories associated with the selected input.
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="empty_extra_files_path" negate="true"/>
... </param>
... '''))
>>> t = p.validate(has_extra_hda)
Traceback (most recent call last):
    ...
ValueError: The selected dataset's extra_files_path directory is non-empty or does exist, this tool expects empty extra_files_path directories associated with the selected input.
>>> t = p.validate(has_no_extra_hda)
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.MetadataValidator(message=None, check='', skip='', negate='false')[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks for missing metadata

>>> from galaxy.datatypes.registry import example_datatype_registry_for_sample
>>> from galaxy.model import History, HistoryDatasetAssociation, set_datatypes_registry
>>> from galaxy.model.mapping import init
>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>>
>>> sa_session = init("/tmp", "sqlite:///:memory:", create_tables=True).session
>>> hist = History()
>>> sa_session.add(hist)
>>> sa_session.flush()
>>> set_datatypes_registry(example_datatype_registry_for_sample())
>>> hda = hist.add_dataset(HistoryDatasetAssociation(id=1, extension='interval', create_dataset=True, sa_session=sa_session))
>>> hda.set_dataset_state(model.Dataset.states.OK)
>>> # TODO I did not find a way to remove a metadata from the hda, therefore I used two parameters, ideas?
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="metadata" check="dbkey" skip="absent_metadata"/>
... </param>
... '''))
>>> p2 = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="metadata" check="absent_metadata" skip="dbkey"/>
... </param>
... '''))
>>> t = p.validate(hda)
>>> t = p2.validate(hda)
Traceback (most recent call last):
    ...
ValueError: Metadata missing, click the pencil icon in the history item to edit / save the metadata attributes
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="metadata" check="dbkey" skip="absent_metadata" negate="true"/>
... </param>
... '''))
>>> p2 = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="metadata" check="absent_metadata" skip="dbkey" negate="true"/>
... </param>
... '''))
>>> t = p.validate(hda)
Traceback (most recent call last):
    ...
ValueError: Metadata missing, click the pencil icon in the history item to edit / save the metadata attributes
>>> t = p2.validate(hda)
requires_dataset_metadata = True
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(message=None, check='', skip='', negate='false')[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.UnspecifiedBuildValidator(message, negate=False)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks for dbkey not equal to ‘?’

>>> from galaxy.datatypes.registry import example_datatype_registry_for_sample
>>> from galaxy.model import History, HistoryDatasetAssociation, set_datatypes_registry
>>> from galaxy.model.mapping import init
>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>>
>>> sa_session = init("/tmp", "sqlite:///:memory:", create_tables=True).session
>>> hist = History()
>>> sa_session.add(hist)
>>> sa_session.flush()
>>> set_datatypes_registry(example_datatype_registry_for_sample())
>>> has_dbkey_hda = hist.add_dataset(HistoryDatasetAssociation(id=1, extension='interval', create_dataset=True, sa_session=sa_session))
>>> has_dbkey_hda.set_dataset_state(model.Dataset.states.OK)
>>> has_dbkey_hda.metadata.dbkey = 'hg19'
>>> has_no_dbkey_hda = hist.add_dataset(HistoryDatasetAssociation(id=2, extension='interval', create_dataset=True, sa_session=sa_session))
>>> has_no_dbkey_hda.set_dataset_state(model.Dataset.states.OK)
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="unspecified_build"/>
... </param>
... '''))
>>> t = p.validate(has_dbkey_hda)
>>> t = p.validate(has_no_dbkey_hda)
Traceback (most recent call last):
    ...
ValueError: Unspecified genome build, click the pencil icon in the history item to set the genome build
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="data">
...     <validator type="unspecified_build" negate="true"/>
... </param>
... '''))
>>> t = p.validate(has_dbkey_hda)
Traceback (most recent call last):
    ...
ValueError: Specified genome build, click the pencil icon in the history item to remove the genome build
>>> t = p.validate(has_no_dbkey_hda)
requires_dataset_metadata = True
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.NoOptionsValidator(message, negate=False)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks for empty select list

>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>> p = ToolParameter.build(None, XML('''
... <param name="index" type="select" label="Select reference genome">
...     <validator type="no_options" message="No options available for selection"/>
... </param>
... '''))
>>> t = p.validate('foo')
>>> t = p.validate(None)
Traceback (most recent call last):
    ...
ValueError: No options available for selection
>>>
>>> p = ToolParameter.build(None, XML('''
... <param name="index" type="select" label="Select reference genome">
...     <options from_data_table="bowtie2_indexes"/>
...     <validator type="no_options" negate="true"/>
... </param>
... '''))
>>> t = p.validate('foo')
Traceback (most recent call last):
    ...
ValueError: Options available for selection
>>> t = p.validate(None)
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.EmptyTextfieldValidator(message, negate=False)[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks for empty text field

>>> from galaxy.util import XML
>>> from galaxy.tools.parameters.basic import ToolParameter
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="">
...     <validator type="empty_field"/>
... </param>
... '''))
>>> t = p.validate("")
Traceback (most recent call last):
    ...
ValueError: Field requires a value
>>> p = ToolParameter.build(None, XML('''
... <param name="blah" type="text" value="">
...     <validator type="empty_field" negate="true"/>
... </param>
... '''))
>>> t = p.validate("foo")
Traceback (most recent call last):
    ...
ValueError: Field must not set a value
>>> t = p.validate("")
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.MetadataInFileColumnValidator(filename, metadata_name, metadata_column, message='Value for metadata not found.', line_startswith=None, split='\t', negate='false')[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks if the value for a dataset’s metadata item exists in a file.

Deprecated: DataTables are now the preferred way.

note: this is covered in a framework test (validation_dataset_metadata_in_file)

requires_dataset_metadata = True
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(filename, metadata_name, metadata_column, message='Value for metadata not found.', line_startswith=None, split='\t', negate='false')[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.ValueInDataTableColumnValidator(tool_data_table, column, message='Value not found.', negate='false')[source]

Bases: galaxy.tools.parameters.validation.Validator

Validator that checks if a value is in a tool data table column.

note: this is covered in a framework test (validation_value_in_datatable)

classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(tool_data_table, column, message='Value not found.', negate='false')[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.ValueNotInDataTableColumnValidator(tool_data_table, metadata_column, message='Value already present.', negate='false')[source]

Bases: galaxy.tools.parameters.validation.ValueInDataTableColumnValidator

Validator that checks if a value is NOT in a tool data table column. Equivalent to ValueInDataTableColumnValidator with negate=”true”.

note: this is covered in a framework test (validation_value_in_datatable)

__init__(tool_data_table, metadata_column, message='Value already present.', negate='false')[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.MetadataInDataTableColumnValidator(tool_data_table, metadata_name, metadata_column, message='Value for metadata not found.', negate='false')[source]

Bases: galaxy.tools.parameters.validation.ValueInDataTableColumnValidator

Validator that checks if the value for a dataset’s metadata item exists in a file.

note: this is covered in a framework test (validation_metadata_in_datatable)

requires_dataset_metadata = True
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(tool_data_table, metadata_name, metadata_column, message='Value for metadata not found.', negate='false')[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.MetadataNotInDataTableColumnValidator(tool_data_table, metadata_name, metadata_column, message='Value for metadata not found.', negate='false')[source]

Bases: galaxy.tools.parameters.validation.MetadataInDataTableColumnValidator

Validator that checks if the value for a dataset’s metadata item doesn’t exists in a file. Equivalent to MetadataInDataTableColumnValidator with negate=”true”.

note: this is covered in a framework test (validation_metadata_in_datatable)

requires_dataset_metadata = True
__init__(tool_data_table, metadata_name, metadata_column, message='Value for metadata not found.', negate='false')[source]

Initialize self. See help(type(self)) for accurate signature.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

class galaxy.tools.parameters.validation.MetadataInRangeValidator(metadata_name, message, range_min, range_max, exclude_min, exclude_max, negate)[source]

Bases: galaxy.tools.parameters.validation.InRangeValidator

validator that ensures metadata is in a specified range

note: this is covered in a framework test (validation_metadata_in_range)

requires_dataset_metadata = True
classmethod from_element(param, elem)[source]

Initialize the appropiate Validator class

example call validation.Validator.from_element(ToolParameter_object, Validator_object)

needs to be implemented in the subclasses and should return the corresponding Validator object by a call to cls( … ) which calls the __init__ method of the corresponding validator

param cls the Validator class param param the element to be evaluated (which contains the validator) param elem the validator element return an object of a Validator subclass that corresponds to the type attribute of the validator element

__init__(metadata_name, message, range_min, range_max, exclude_min, exclude_max, negate)[source]

When the optional exclude_min and exclude_max attributes are set to true, the range excludes the end points (i.e., min < value < max), while if set to False (the default), then range includes the end points (1.e., min <= value <= max). Combinations of exclude_min and exclude_max values are allowed.

validate(value, trans=None)[source]

validate a value

needs to be implemented in classes derived from validator. the implementation needs to call super().validate() giving result as a bool (which should be true if the validation is positive and false otherwise) and the value that is validated.

the Validator.validate function will then negate the value depending on self.negate and return None if - value is True and negate is False - value is False and negate is True and raise a ValueError otherwise.

return None if positive validation, otherwise a ValueError is raised

galaxy.tools.parameters.validation.get_suite()[source]

Get unittest suite for this module

galaxy.tools.parameters.wrapped module

class galaxy.tools.parameters.wrapped.WrappedParameters(trans, tool, incoming, input_datasets=None)[source]

Bases: object

__init__(trans, tool, incoming, input_datasets=None)[source]

Initialize self. See help(type(self)) for accurate signature.

property params
wrap_values(inputs, input_values, skip_missing_values=False)[source]
galaxy.tools.parameters.wrapped.make_dict_copy(from_dict)[source]

Makes a copy of input dictionary from_dict such that all values that are dictionaries result in creation of a new dictionary ( a sort of deepcopy ). We may need to handle other complex types ( e.g., lists, etc ), but not sure… Yes, we need to handle lists (and now are)…

galaxy.tools.parameters.wrapped_json module

galaxy.tools.parameters.wrapped_json.json_wrap(inputs, input_values, profile, as_dict=None, handle_files='skip')[source]