Question: Are CWL CommandLineTool arguments guaranteed to be contiguous?
0
gravatar for jh36
11 months ago by
jh360
jh360 wrote:

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 • 349 views
ADD COMMENTlink modified 11 months ago by drkennetz370 • written 11 months ago by jh360

-1 put a at the front?

ADD REPLYlink written 11 months ago by drkennetz370

I think it did, yes.

ADD REPLYlink written 11 months ago by jh360

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 REPLYlink written 11 months ago by drkennetz370
2
gravatar for drkennetz
11 months ago by
drkennetz370
drkennetz370 wrote:

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 COMMENTlink written 11 months ago by drkennetz370
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1456 users visited in the last hour