Entering edit mode
5.3 years ago
Azat Badretdin
•
0
I need to default to /dev/null
when calling an application depending on whether input File?
is Null
I need to default to /dev/null
when calling an application depending on whether input File?
is Null
Hello Azat Badretdin,
You'll need to use a CWL Javascript Expression
Here is an example:
cwlVersion: v1.0
class: CommandLineTool
requirements:
InlineJavascriptRequirement: {}
inputs:
optional_file: File?
baseCommand: echo
arguments:
- valueFrom: |
${
if (inputs.optional_file) {
return inputs.optional_file.path;
} else {
return "/dev/null"; }
}
outputs: []
And how it works in practice:
$ cwltool --quiet 396625.cwl
/dev/null
{}
$ cwltool --quiet 396625.cwl --optional_file README.md
/tmp/tmpcpymo708/stg188757bd-0ef9-45b2-a965-0884b73de8b6/README.md
{}
Another solution, using an empty file:
cwlVersion: v1.0
class: CommandLineTool
inputs:
optional_file:
type: File
default:
class: File
size: 0
basename: empty
contents: ""
inputBinding: {}
baseCommand: [ls, -sH]
outputs: []
And the output
$ cwltool --quiet 396625-3.cwl --optional_file README.md
4 /tmp/tmp7fc9dlpp/stg63bc390d-1944-4a54-9d30-c52210af50d8/README.md
{}
$ cwltool --quiet 396625-3.cwl
0 /tmp/tmp9mvxth8m/stg3a4b5a05-f856-411c-ba91-f0d912f85a39/empty
{}
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
This question is better suited for Stack Overflow.
Fyi, Biostars is an official support platform for CWL.