wft4galaxy
— WorkflowTester for Galaxy API¶
Core Classes¶
WorkflowTestCase¶
-
class
wft4galaxy.core.
WorkflowTestCase
(name=None, base_path='.', workflow_filename='workflow.ga', inputs=None, params=None, expected_outputs=None, output_folder=None, disable_cleanup=False, disable_assertions=False, enable_logger=False, enable_debug=False)[source]¶ A representation of the configuration of a workflow test.
Parameters: - base_path (str) – base path for workflow and dataset files (the current working path is assumed as default)
- workflow_filename (str) – the path (relative to
base_path
) of the file containing the workflow definition (i.e., the.ga
file which can be downloaded from a Galaxy server) - name (str) – a name for the workflow test
- inputs (dict) –
a dictionary which defines the mapping between a workflow input and a test dataset.
Example: {“DataMatrix”: “dataMatrix.tsv”} where DataMatrix is the name of a workflow input and dataMatrix.tsv is the file containing the dataset to be used as input for the workflow test. - params (dict) –
a dictionary which defines the mapping between steps and the set of parameters which has to be used to configure the corresponding tools of each step.
Example: params = { 3: { "orthoI": "NA" "predI": "1" "respC": "gender" "testL": "FALSE" } }
- expected_outputs (dict) –
a dictionary to configure the expected output, i.e., the output which has to be compared to the actual one produced by a workflow execution. Each output of a workflow step is eligible to be compared with an expected output. It is also possible to specify the python function which has to be used to perform the actual comparison. Such a function takes two parameters, i.e.,
actual_output_filename
andexpected_output_filename
, and returnsTrue
whether the comparison between the two files succeeds andFalse
otherwise.Example: Skeleton of a user-defined comparator: def compare_outputs(actual_output_filename, expected_output_filename): .... return True | False
Example: The example below shows an expected_outputs
dictionary that configures the expected output datasets for the two actual workflow outputsoutput1
andoutput2
. A user defined ‘comparator’ is also given to compare the expected to the actualoutput2
.{ 'output1': 'change_case/expected_output_1', 'output2': { 'comparator': 'filecmp.cmp', 'file': 'change_case_2/expected_output_2' } }
- output_folder (str) – path (relative to
base_path
) of the folder where workflow outputs are written. By default, it is the folderresults/<name>
within thebase_path
(wherename
is the name of the workflow test). - disable_cleanup (bool) –
True
to avoid the clean up of the workflow and history created on the Galaxy server;False
(default) otherwise. - disable_assertions (bool) –
True
to disable assertions during the execution of the workflow test;False
(default) otherwise.
-
base_path
¶ The base path of the workflow file definition and the input and output datasets.
-
set_base_path
(base_path)[source]¶ Set the base path of the workflow file definition and the input and output datasets.
Parameters: base_path (str) – a path within the local file system
-
filename
¶ The filename (relative to
base_paht
) of the workflow definition.
-
set_filename
(filename)[source]¶ Set the filename (relative to
base_path
) containing the workflow definition.Parameters: filename (str) – the path (relative to the base_path
) to the.ga
file
-
inputs
¶ Return the dictionary which defines the mapping between workflow inputs and test datasets.
-
set_inputs
(inputs)[source]¶ Update the mapping between workflow inputs and test datasets.
Parameters: inputs – dict Returns: a dictionary of mappings (see WorkflowTestCase
)
-
add_input
(name, path, type_=None)[source]¶ Add a new input mapping.
Parameters: - name (str) – the Galaxy label of an input
- path (str) – the path (relative to the
base_path
) of the file containing an input dataset - type (str) – the type of the input dataset
-
remove_input
(name)[source]¶ Remove an input mapping.
Parameters: name (str) – the Galaxy label of an input
-
get_input
(name)[source]¶ Return the input mapping for the input labeled as
name
.Parameters: name (str) – the Galaxy label of the input Return type: dict Returns: input configuration as dict (e.g., {‘name’: ‘Input Dataset’, ‘file’: “input.txt”})
-
params
¶ Return the dictionary containing the configured parameters (see
WorkflowTestCase
)Return type: dict Returns: a dictionary of configured parameters
-
set_params
(params)[source]¶ Add a new set of parameters.
Parameters: params (dict) – dictionary of parameters indexed by step id (see WorkflowTestCase
)
-
add_param
(step_id, name, value)[source]¶ Add a new parameter to the step identified by
step_id
.Parameters: - step_id (int) – step index
- name (str) – parameter name
- value (str) – parameter value
-
remove_param
(step_id, name)[source]¶ Remove the parameter labeled
name
from the step identified bystep_id
.Parameters: - step_id (int) – step index
- name (str) – name of the parameter to be removed
-
get_params
(step_id)[source]¶ Return the dictionary of parameters related to the step identified by ‘step_id’.
Parameters: step_id (int) – the step index Return type: dict Returns: the dictionary of parameters related to the step identified by ‘step_id’
-
get_param
(step_id, name)[source]¶ Return the value of a specific step parameter.
Parameters: - step_id (int) – the index of the step which the parameter is related to
- name (str) – the name of the parameter to be returned
Returns: the value of the requested parameter
-
expected_outputs
¶ A dictionary to configure the expected output, i.e., the output which has to be compared to the actual one produced by a workflow execution (see
WorkflowTestCase
).
-
set_expected_outputs
(expected_outputs)[source]¶ Add a new set of expected outputs (see
WorkflowTestCase
).Parameters: expected_outputs (dict) – a dictionary structured as specified in WorkflowTestCase
-
add_expected_output
(name, filename, comparator='filecmp.cmp')[source]¶ Add a new expected output to the workflow test configuration.
Parameters: - name (str) – the Galaxy name of the output which the expected dataset has to be mapped.
- filename (str) – the path (relative to the
base_path
) of the file containing the expected output dataset - comparator (str) – a fully qualified name of a comparator`function (see :class:`WorkflowTestCase)
-
remove_expected_output
(name)[source]¶ Remove an expected output from the workflow test configuration.
Parameters: name (str) – the Galaxy name of the output which the expected output has to be mapped
-
get_expected_output
(name)[source]¶ Return the configuration of an expected output.
Parameters: name (str) – the Galaxy name of the output which the expected output has to be mapped. Return type: dict Returns: a dictionary containing the configuration of the expected output as specified in WorkflowTestCase
-
to_dict
()[source]¶ Return a dictionary representation of the current class instance.
Return type: dict Returns:
-
save
(filename=None, file_format='YAML')[source]¶ Serialize this workflow test configuration to a file (YAML or JSON).
Parameters: - filename (str) – absolute path of the file
- file_format (str) –
YAML
orJSON
-
static
load
(filename='workflow-test-suite.yml', workflow_test_name='workflow_test_case', output_folder=None)[source]¶ Load the configuration of a workflow test suite or a single workflow test from a YAML or JSON configuration file.
Parameters: - filename (str) – the path of the file containing the suite definition
- workflow_test_name (str) – the optional name of a workflow test (default is “workflow-test-case”)
- output_folder (str) – the path of the output folder
Return type: Returns: the
WorkflowTestCase
instance which matches the name provided by the argument workflow_test_name_
-
static
dump
(filename, worflow_tests_config, file_format='YAML')[source]¶ Write the configuration of a workflow test suite to a YAML or JSON file.
Parameters: - filename (str) – the absolute path of the YAML or JSON configuration file
- worflow_tests_config (dict or list) – a dictionary which maps a workflow test name
to the corresponding configuration (
WorkflowTestCase
) or a list ofWorkflowTestCase
instances - file_format (str) –
YAML
orJSON
WorkflowTestSuite¶
-
class
wft4galaxy.core.
WorkflowTestSuite
(galaxy_url=None, galaxy_api_key=None, output_folder='results', enable_logger=True, enable_debug=False, disable_cleanup=False, disable_assertions=False, max_retries=None, retry_delay=None, polling_interval=None)[source]¶ Represent a test suite.
-
workflow_tests
¶ Return the configuration of workflow tests associated to this test suite.
Return type: dict Returns: a dictionary which maps a workflow test name to the WorkflowTestCase
instance representing its configuration
-
add_workflow_test
(workflow_test_configuration)[source]¶ Add a new workflow test to this suite.
Parameters: workflow_test_configuration (:class:"WorkflowTestCase") – the WorkflowTestCase
instance representing the workflow test configuration
-
remove_workflow_test
(workflow_test)[source]¶ Remove a workflow test from this suite.
Parameters: workflow_test (str or :class:"WorkflowTestCase") – the name of the workflow test to be removed or the WorkflowTestCase
instance representing the workflow test configuration
-
Bioblend Wrappers¶
Workflow¶
-
class
wft4galaxy.wrapper.
Workflow
(definition, inputs, params, outputs)[source]¶ Display workflow information which are relevant to configure a workflow test.
-
show_params
(stream=<open file '<stdout>', mode 'w'>)[source]¶ Print parameters needed by workflow tools to file.
-
show_outputs
(stream=<open file '<stdout>', mode 'w'>)[source]¶ Print workflow outputs (indexed by workflow step) to file.
-
static
load
(filename, galaxy_url=None, galaxy_api_key=None, tools_folder='.tools')[source]¶ Return the
Workflow
instance related to the workflow defined infilename
Parameters: - filename (str) – the path of the
.ga
workflow definition - galaxy_url (str) – url of your Galaxy server instance.
- galaxy_api_key (str) – an API key from your Galaxy server instance.
- tools_folder (str) – optional temp folder where tool definitions are downloaded (
.tools
by default)
Return type: Returns: the
Workflow
instance related to the workflow defined infilename
- filename (str) – the path of the
-