I'm looking at automatically generating some CWL, and I'm trying to work out if the arguments of a CommandLineTool will always be contiguous, i.e. if you have a file like this:
cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo
inputs:
- id: foo
type: string
inputBinding:
position: 0
- id: bar
type: string
inputBinding:
position: 0
- id: a
type: string
inputBinding:
position: -1
outputs: []
arguments:
- arg1
- arg2
whether arg1 and arg2 will always be immediately adjacent to each other, whether or not there are arguments to either side of them.
As far as I can tell, this is indeed the case – in this example, the command line generated by cwltool is echo a arg1 arg2 bar foo, but I can't work out from the CWL spec whether this is guaranteed behaviour. Will all spec-compliant CWL runners generate a command line for this example with arg1 and arg2 adjacent?
1 answer
This can be solved by giving everything an inputBinding: position:. Doing this will ensure the behavior you are looking for. For example, if you want your arguments to appear first and your inputs to appear second you can do the following:
cwlVersion: v1.0
class: CommandLineTool
requirements:
- class: InlineJavascriptRequirement
baseCommand: echo
inputs:
foo:
type: string
inputBinding:
position: 3
bar:
type: string
inputBinding:
position: 4
a:
type: string
inputBinding:
position: -1
outputs: []
arguments:
- valueFrom: arg1
position: 1
- valueFrom: arg2
position: 2
This will guarantee the following command line:
$ echo arg1 arg2 foo bar a
If the positions are not specified, I believe the following behavior order is:
- baseCommand
- argument
- argument
- input
- input
Where arguments will come before inputs, and inputs and arguments by section will be ordered in alphanumeric order, so for your case I believe your command-line would look like:
$ echo arg1 arg2 bar foo a
a would be last because you assigned the position as -1, but the rest would fall in order. I hope this makes sense. If I am wrong about the ordering, you can still guarantee the order you want to see by assigning a position.
Log in to answer this question.
-1 put a at the front?
I think it did, yes.
Okay, that sounds weird to me since -1 implies the last element in a list (and the command line is a list of arguments/inputs). Either way see below, by forcing the position using
inputBinding: positionyou guarantee their order.