Are CWL CommandLineTool arguments guaranteed to be contiguous?
1
0
Entering edit mode
5.7 years ago
jh36 • 0

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?

cwl • 1.6k views
ADD COMMENT
0
Entering edit mode

-1 put a at the front?

ADD REPLY
0
Entering edit mode

I think it did, yes.

ADD REPLY
0
Entering edit mode

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: position you guarantee their order.

ADD REPLY
2
Entering edit mode
5.7 years ago
drkennetz ▴ 560

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:

  1. baseCommand
  2. argument
  3. argument
  4. input
  5. 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.

ADD COMMENT

Login before adding your answer.

Traffic: 2723 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6