diff --git a/src/faq.md b/src/faq.md index 50843d6a..6aa65b54 100644 --- a/src/faq.md +++ b/src/faq.md @@ -447,6 +447,77 @@ The reference runner and several other CWL implementations support running those Docker format containers using the Singularity engine. Directly specifying a Singularity format container is not part of the CWL standards. +## How does glob work when describing output values? +The field outputBinding describes how to set the value of each output parameter. The 'glob' field specifies a pattern to find files/directories relative to the output directory. The pattern used for glob' must be either relative to the output directory, an absolute path to the output directory, or an absolute path to an input file. + +CWL uses the POSIX glob(3) pathname matching. Wildcards are allowed in the glob field and are useful when If you don’t know the exact name of a file or directory in advance. The wildcard characters can either be an asterisk `*`, a question mark matching pathnames in directories. `?` or a range `[]`. + +If an array used in the glob field, any files that match any pattern in the array are returned. + +In the example below, the glob field using the `*` wildcard is used to return all outputs from the tool. + +``` +cwlVersion: v1.0 +class: CommandLineTool +inputs: + in1: + type: File + default: + class: File + path: /path/to/my/file + inputBinding: + position: 1 + +baseCommand: cat + +outputs: + my_output: + type: + type: array + items: [Directory, File] + outputBinding: + glob: "*" +``` + +Below is an example where the input file is used as the output file using `glob` +``` +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 +class: CommandLineTool + +doc: | + Merge multiple BAM files. + +hints: + ResourceRequirement: + coresMin: 1 + ramMin: 20000 + DockerRequirement: + dockerPull: quay.io/biocontainers/samtools:1.14--hb421002_0 + +baseCommand: ["samtools", "merge"] + +inputs: + - id: output_name + doc: name of merged bam file + type: string + inputBinding: + position: 1 + - id: bams + doc: bam files to be merged + type: + type: array + items: File + inputBinding: + position: 2 + +outputs: + - id: bam_merged + type: File + outputBinding: + glob: $(inputs.output_name) +``` + ## Debug JavaScript Expressions You can use the --js-console option of cwltool, or you can try