问题我如何为一个参数提供多个值?目标学习如何提供参数数组作为工具的输入。了解如何在命令行上控制数组参数的组织。
向命令行添加表示输入参数的数组很容易。有两种方法可以指定数组参数。首先是使用type: array和定义可能出现在数组中的有效数据类型的项来提供type字段。或者,可以在类型名之后添加方括号[],以表明输入参数是该类型的数组。
array-inputs.cwl
#!/usr/bin/env cwl-runnercwlVersion: v1.0class: CommandLineToolinputs:filesA:type: string[]inputBinding:prefix: -Aposition: 1filesB:type:type: arrayitems: stringinputBinding:prefix: -B=separate: falseinputBinding:position: 2filesC:type: string[]inputBinding:prefix: -C=itemSeparator: ","separate: falseposition: 4outputs:example_out:type: stdoutstdout: output.txtbaseCommand: echo
array-inputs-job.yml
filesA: [one, two, three]filesB: [four, five, six]filesC: [seven, eight, nine]
现在调用cwl-runner
$ cwl-runner array-inputs.cwl array-inputs-job.yml[job array-inputs.cwl] /home/examples$ echo \-A \one \two \three \-B=four \-B=five \-B=six \-C=seven,eight,nine > /home/examples/output.txt[job array-inputs.cwl] completed success{"example_out": {"location": "file:///home/examples/output.txt","basename": "output.txt","class": "File","checksum": "sha1$91038e29452bc77dcd21edef90a15075f3071540","size": 60,"path": "/home/examples/output.txt"}}Final process status is success$ cat output.txt-A one two three -B=four -B=five -B=six -C=seven,eight,nine
inputBinding既可以出现在外部数组参数定义中,也可以出现在内部数组元素定义中,它们在构造命令行时产生不同的行为,如上所示。此外,如果提供了itemSeparator字段,则指定数组值应该连接到由项目分隔符字符串分隔的单个参数中。
注意,在array-inputs-job.yml中,输入数组是在方括号[]中指定的。数组也可以在多行中表示,其中没有使用关联键定义的数组值用前导符号-标记。这将在下一课中演示,并在YAML指南中进行更详细的讨论。您可以指定数组的数组、记录的数组和其他复杂类型。
