From 9a88ef161fa266f3115536b39cab808fbf3f26f8 Mon Sep 17 00:00:00 2001 From: stamper Date: Sat, 27 Jul 2019 17:01:23 +0200 Subject: [PATCH 1/3] rough draft of Miscellaneous page --- _extras/miscellaneous.md | 130 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 _extras/miscellaneous.md diff --git a/_extras/miscellaneous.md b/_extras/miscellaneous.md new file mode 100644 index 00000000..859bfe0c --- /dev/null +++ b/_extras/miscellaneous.md @@ -0,0 +1,130 @@ +--- +layout: page +title: Miscellaneous +permalink: /misc/ +--- + +This is a collection of examples and short notes +about some operations that fall outside the scope of the User Guide +and/or have not yet been implemented in a clean way in the CWL specification. + +### Get output values of a specific type using `evalFrom` + +```yaml +cwlVersion: v1.0 # or v1.1 +class: CommandLineTool +requirements: + InlineJavascriptRequirement: {} + +baseCommand: [ echo, "42" ] + +inputs: [] + +stdout: my_number.txt + +outputs: + my_number: + type: int + outputBinding: + glob: my_number.txt + loadContents: True + outputEval: $(parselnt(self[0].contents)) + + my_number_as_string: + type: string + outputBinding: + glob: my_number.txt + loadContents: True + outputEval: $(self[0].contents) +``` + +### Rename an input file + +This example shows how you can change the name of an input file +as part of a tool description. +This could be useful when you are taking files produced from another +step in a workflow and don't want to work with the default names that these +files were given when they were created. + +```yaml +requirements: + InitialWorkDirRequirement: + listing: + - entry: $(inputs.src1) + entryName: newName + - entry: $(inputs.src2) + entryName: $(inputs.src1.basename)_custom_extension +``` + +### Rename an output file + +This example shows how you can change the name an output file +from the default name given to it by a tool: + +```yaml +cwlVersion: v1.0 # or v1.1 +class: CommandLineTool +requirements: + InlineJavascriptRequirement: {} + +baseCommand: [] + +inputs: [] + +outputs: + otu_table: + type: File + outputBinding: + glob: otu_table.txt + outputEval: ${self[0].basename=inputs.otu_table_name; return self;} +``` + +### Setting `self`-based input bindings for optional inputs + +Currently, `cwltool` can't cope with missing optional inputs if their +input binding makes use of `self`. +Below is an example workaround for this, +pending a more sophisticated fix. + +```yaml +#!/usr/bin/env cwl-runner +cwlVersion: v1.0 +class: CommandLineTool + +requirements: { InlineJavascriptRequirement: {} } + +inputs: + cfg: + type: File? + inputBinding: + prefix: -cfg + valueFrom: | + ${ if(self === null) { return null;} else { return self.basename; } } + +baseCommand: echo + +outputs: [] +``` + +### Model a "one-or-the-other" parameter + +Below is an example of how +you can specify different strings to be added to a command line +based on the value given to a Boolean parameter. + +```yaml +cwlVersion: v1.0 +class: CommandLineTool +requirements: + InlineJavascriptRequirement: {} +inputs: + fancy_bool: + type: boolean + default: false # or true + inputBinding: + valueFrom: ${if (self) { return "foo";} else { return "bar";}} + +baseCommand: echo + +outputs: [] +``` From 6171a38f65e31dc149d4f21860f6cc75d33e0f98 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> Date: Sat, 27 Jul 2019 17:12:21 +0200 Subject: [PATCH 2/3] standards --- _extras/miscellaneous.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_extras/miscellaneous.md b/_extras/miscellaneous.md index 859bfe0c..faacbb4d 100644 --- a/_extras/miscellaneous.md +++ b/_extras/miscellaneous.md @@ -6,7 +6,7 @@ permalink: /misc/ This is a collection of examples and short notes about some operations that fall outside the scope of the User Guide -and/or have not yet been implemented in a clean way in the CWL specification. +and/or have not yet been implemented in a clean way in the CWL standards. ### Get output values of a specific type using `evalFrom` From 88ea048239beafdc8960c6cc9cc51f74db586a29 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> Date: Sat, 27 Jul 2019 17:12:28 +0200 Subject: [PATCH 3/3] Update _extras/miscellaneous.md --- _extras/miscellaneous.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_extras/miscellaneous.md b/_extras/miscellaneous.md index faacbb4d..d2cb9062 100644 --- a/_extras/miscellaneous.md +++ b/_extras/miscellaneous.md @@ -8,7 +8,7 @@ This is a collection of examples and short notes about some operations that fall outside the scope of the User Guide and/or have not yet been implemented in a clean way in the CWL standards. -### Get output values of a specific type using `evalFrom` +### Non "`File`" types using `evalFrom` ```yaml cwlVersion: v1.0 # or v1.1