Array Outputs

Overview

Teaching: 10 min
Exercises: 0 min
Questions
  • How do I specify tool outputs as arrays?

Objectives
  • Learn how to create arrays of output files.

You can also capture multiple output files into an array of files using glob.

array-outputs.cwl

#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool
baseCommand: touch
inputs:
  touchfiles:
    type:
      type: array
      items: string
    inputBinding:
      position: 1
outputs:
  output:
    type:
      type: array
      items: File
    outputBinding:
      glob: "*.txt"

array-outputs-job.yml

touchfiles:
  - foo.txt
  - bar.dat
  - baz.txt

Now invoke cwl-runner providing the tool wrapper and the input object on the command line:

$ cwl-runner array-outputs.cwl array-outputs-job.yml
[job 140190876078160] /home/example$ touch foo.txt bar.dat baz.txt
Final process status is success
{
  "output": [
    {
      "size": 0,
      "location": "/home/peter/work/common-workflow-language/draft-3/examples/foo.txt",
      "checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
      "class": "File"
    },
    {
      "size": 0,
      "location": "/home/peter/work/common-workflow-language/draft-3/examples/baz.txt",
      "checksum": "sha1$da39a3ee5e6b4b0d3255bfef95601890afd80709",
      "class": "File"
    }
  ]
}

The array of expected outputs is specified in array-outputs-job.yml with each entry marked by a leading -. This format can also be used in CWL descriptions to mark entries in arrays, as demonstrated in several of the upcoming sections.

Key Points

  • You can capture multiple output files into an array of files using glob.

  • Use wildcards and filenames to specify the output files that will be returned after tool execution.