Define a test-suite from a History

This example shows how to wft4galaxy wizard tool for automatically generate a workflow test suite from a Galaxy history (see also Wizard Tool).

Suppose you have the Galaxy history shown in Figure 1 obtained by running the Fluxomics Stationary workflow (you can find it in examples/fluxomics_stationary). The first five datasets are inputs, while the remaining are obtained by running the workflow.

wf-history

Figure 1. History: “_WorkflowTestHistory_21b96e0a-130b-11e7-8958-a45e60c4fc6b”

If you are somehow confident that the outputs above are exactly what you should obtain running the workflow running the workflow on the first five inputs, then you can use them as expected output for defining a workflow test case.

That described above is exactly the scenario where the wft4galaxy-wizard tool can help you from automatically generate a test case. Knowing that the history name is *_WorkflowTestHistory_21b96e0a-130b-11e7-8958-a45e60c4fc6b* you can obtain such a test case by simply typing:

In [1]:
wft4galaxy-wizard -o MyTestSuite generate-test _WorkflowTestHistory_21b96e0a-130b-11e7-8958-a45e60c4fc6b
2017-03-30 04:10:01,139 [wft4galaxy] [ INFO]  Loading Galaxy history info ...
2017-03-30 04:10:05,962 [wft4galaxy] [ INFO]  Selected history: _WorkflowTestHistory_21b96e0a-130b-11e7-8958-a45e60c4fc6b (id: u'0a248a1f62a0cc04')
2017-03-30 04:10:05,962 [wft4galaxy] [ INFO]  Loading history 0a248a1f62a0cc04 info
2017-03-30 04:10:06,285 [wft4galaxy] [ INFO]  Processing history info...
2017-03-30 04:10:07,719 [wft4galaxy] [ INFO]  Processing dataset 2fdbd5c5858e78fb ...
2017-03-30 04:10:07,836 [wft4galaxy] [ INFO]  Process dataset 2fdbd5c5858e78fb: done
2017-03-30 04:10:07,836 [wft4galaxy] [ INFO]  Processing dataset c385e49b9fe1853c ...
2017-03-30 04:10:08,025 [wft4galaxy] [ INFO]  Process dataset c385e49b9fe1853c: done
2017-03-30 04:10:08,025 [wft4galaxy] [ INFO]  Processing dataset f7bb1edd6b95db62 ...
2017-03-30 04:10:08,141 [wft4galaxy] [ INFO]  Process dataset f7bb1edd6b95db62: done
2017-03-30 04:10:08,141 [wft4galaxy] [ INFO]  Processing dataset 52e496b945151ee8 ...
2017-03-30 04:10:08,257 [wft4galaxy] [ INFO]  Process dataset 52e496b945151ee8: done
2017-03-30 04:10:08,257 [wft4galaxy] [ INFO]  Processing dataset b887d74393f85b6d ...
2017-03-30 04:10:08,444 [wft4galaxy] [ INFO]  Process dataset b887d74393f85b6d: done
2017-03-30 04:10:08,444 [wft4galaxy] [ INFO]  Processing dataset f0f309c56aff0025 ...
2017-03-30 04:10:08,561 [wft4galaxy] [ INFO]  Process dataset f0f309c56aff0025: done
2017-03-30 04:10:08,561 [wft4galaxy] [ INFO]  Processing dataset 36ddb788a0f14eb3 ...
2017-03-30 04:10:08,679 [wft4galaxy] [ INFO]  Process dataset 36ddb788a0f14eb3: done
2017-03-30 04:10:08,679 [wft4galaxy] [ INFO]  Processing dataset 72ad249754f05d26 ...
2017-03-30 04:10:08,806 [wft4galaxy] [ INFO]  Process dataset 72ad249754f05d26: done
2017-03-30 04:10:08,806 [wft4galaxy] [ INFO]  Processing dataset eafb646da3b7aac5 ...
2017-03-30 04:10:08,806 [wft4galaxy] [ INFO]  Process dataset eafb646da3b7aac5: done
2017-03-30 04:10:08,807 [wft4galaxy] [ INFO]  Processing dataset 42a2c611109e5ed3 ...
2017-03-30 04:10:08,807 [wft4galaxy] [ INFO]  Process dataset 42a2c611109e5ed3: done
2017-03-30 04:10:08,807 [wft4galaxy] [ INFO]  Processing extra info...
2017-03-30 04:10:08,914 [wft4galaxy] [ INFO]  Processing extra info: done
2017-03-30 04:10:08,914 [wft4galaxy] [ INFO]  History info processing: done
2017-03-30 04:10:08,914 [wft4galaxy] [ INFO]  Extracting Workflow from history...
2017-03-30 04:10:08,940 [wft4galaxy] [ INFO]  Saving workflow to file...
2017-03-30 04:10:08,943 [wft4galaxy] [ INFO]  Saving workflow to file: done
2017-03-30 04:10:08,943 [wft4galaxy] [ INFO]  Extracting Workflow from history: done
2017-03-30 04:10:08,944 [wft4galaxy] [ INFO]  Downloading input datasets...
2017-03-30 04:10:09,729 [wft4galaxy] [ INFO]  Downloading input datasets: done
2017-03-30 04:10:09,729 [wft4galaxy] [ INFO]  Downloading output datasets...
2017-03-30 04:10:09,850 [wft4galaxy] [ INFO]  Downloading output datasets: done
2017-03-30 04:10:09,852 [wft4galaxy] [ INFO]  Saving workflow test definition ...
2017-03-30 04:10:09,888 [wft4galaxy] [ INFO]  Saving workflow test definition: done

The wizard tool collects all history info which are useful to generate a test case. In particular, it extracts the workflow executed to generate the history and produces its definition file, i.e., the .ga definition file. Then, it downloads all history datasets to generate the test case and creates a new folder called MyTestSuite with the following structure:

\ MyTestSuite
| -- workflow-test-suite.yml
| -- workflow.ga
+ -- inputs
|      | constraints.csv
|      | exchanged_file.csv
|      | sbml_model.csv
|      | tracing_model.csv
|      | wd.zip
+ -- expected
|      | best_fit_fluxes.csv
|      | best_fit_label.csv
|      | constrained_sbml_model.xml
In [2]:
ls MyTestSuite
expected                workflow-test-suite.yml
inputs                  workflow.ga

As you can see in the workflow-test-suite.yml file, datasets uploaded by users are mapped to test case inputs, while datasets generated by the workflow execution are mapped to test case expected-outputs.

In [3]:
cat MyTestSuite/workflow-test-suite.yml
##########################################################################################
#  Global settings
##########################################################################################
galaxy_url:     "http://192.168.8.105:30700"             # default is GALAXY_URL
galaxy_api_key: "a4725a45123fd949d24878143801cd82"       # default is GALAXY_API_KEY
enable_debug:   "False"                                  # enable debug level
output_folder:  "results"                                # path folder for outputs

##########################################################################################
#  Workflow tests
##########################################################################################
workflows:

  ########################################################################################
  # workflow test case: "workflow_test_case_1"
  ########################################################################################
  workflow_test_case_1:

    # worflow definition file (i.e., `.ga`file)
    file: "workflow.ga"

    # input section
    #######################################################################################
    inputs:

      # extended form
      zipped_data:
        file: "inputs/wd.zip"
        type: "zip"

      # extended form
      tracing_model:
        file: "inputs/tracing_model.csv"
        type: "csv"

      # extended form
      sbml_model:
        file: "inputs/sbml_model.sbml"
        type: "xml"

      # extended form
      inputExchange:
        file: "inputs/exchanged_file.csv"
        type: "csv"

      # extended form
      constraints:
        file: "inputs/constraints.csv"
        type: "csv"

    # expected outputs
    #######################################################################################
    expected:

      # extended form
      constrained_sbml_model:
        file: "expected/constrained_sbml_model.xml"
        comparator: "filecmp.cmp"

      # extended form
      best_fit_fluxes:
        file: "expected/best_fit_fluxes.csv"
        comparator: "filecmp.cmp"

      # extended form
      best_fit_label:
        file: "expected/best_fit_label.csv"
        comparator: "filecmp.cmp"