问题我如何描述哪些参数必须和不能组合使用?目标学习如何使用记录来描述输入之间的关系。
有时,一个基础工具有几个必须一起提供的参数(它们是相互依赖的)或几个不能一起提供的参数(它们是互斥的)。您可以使用记录和类型联合将参数组合在一起来描述这两个条件。
record.cwl
#!/usr/bin/env cwl-runnercwlVersion: v1.0class: CommandLineToolinputs:dependent_parameters:type:type: recordname: dependent_parametersfields:itemA:type: stringinputBinding:prefix: -AitemB:type: stringinputBinding:prefix: -Bexclusive_parameters:type:- type: recordname: itemCfields:itemC:type: stringinputBinding:prefix: -C- type: recordname: itemDfields:itemD:type: stringinputBinding:prefix: -Doutputs:example_out:type: stdoutstdout: output.txtbaseCommand: echo
record-job1.yml
dependent_parameters:itemA: oneexclusive_parameters:itemC: three
输出为
$ cwl-runner record.cwl record-job1.ymlWorkflow error, try again with --debug for more information:Invalid job input record:record-job1.yml:1:1: the `dependent_parameters` field is not valid becausemissing required field `itemB`
在这个例子上,不能提供itemA就不能提供itemB。
record-job2.ymldependent_parameters:itemA: oneitemB: twoexclusive_parameters:itemC: threeitemD: four
输出为
$ cwl-runner record.cwl record-job2.ymlrecord-job2.yml:6:3: invalid field `itemD`, expected one of: 'itemC'[job record.cwl] /home/example$ echo \-A \one \-B \two \-C \three > /home/example/output.txt[job record.cwl] completed success{"example_out": {"location": "file:///home/example/11-records/output.txt","basename": "output.txt","class": "File","checksum": "sha1$329fe3b598fed0dfd40f511522eaf386edb2d077","size": 23,"path": "/home/example/output.txt"}}Final process status is success$ cat output.txt-A one -B two -C three
第二个例子中,itemC和itemD是独立的,因此只有itemC被调用,itemD被忽略。
record-job3.yml
dependent_parameters:itemA: oneitemB: twoexclusive_parameters:itemD: four
输出为
$ cwl-runner record.cwl record-job3.yml[job record.cwl] /home/example$ echo \-A \one \-B \two \-D \four > /home/example/output.txt[job record.cwl] completed success{"example_out": {"location": "file:///home/example/output.txt","basename": "output.txt","class": "File","checksum": "sha1$77f572b28e441240a5e30eb14f1d300bcc13a3b4","size": 22,"path": "/home/example/output.txt"}}Final process status is success$ cat output.txt-A one -B two -D four
第三个例子中,只有itemD是被调用的。
