【问题标题】:specifying stdout by modifying an input string with cwl通过使用 cwl 修改输入字符串来指定标准输出
【发布时间】:2016-05-07 16:38:52
【问题描述】:

我想使用 cwl(通用工作流语言)编写一个简单的命令包装器。例如,我想执行以下操作:

wc input.txt > input.txt.wc
wc some_folder/some_other_input > some_folder/some_other_input.wc

所以,基本上我希望代码将 .wc 放在输入文件名之后并将其用作输出文件名。我写了下面的代码,但它没有用。 (见下面的错误信息)。有人知道如何解决吗?

wc2.cwl

cwlVersion: cwl:draft-3
class: CommandLineTool
baseCommand: wc
inputs:
  - id: inputfile
    type: File
    inputBinding:
      position: 1
  - id: outfilename
    type: string
      inputBinding:
        valueFrom: ${ $(inputs.inputfile.path) + '.wc' }
outputs:
  - id: outputfile
    type: File
    outputBinding:
      glob: $(inputs.outfilename)
stdout: $(inputs.outfilename)

wc2-job1.yml

inputfile:
  class: File
  path: input.txt

运行

$ cwl-runner wc2.cwl wc2-job1.yml
/home/ec2-user/venv/cwl/bin/cwl-runner 1.0.20160504183010
I'm sorry, I couldn't load this CWL file, try again with --debug for more information.
mapping values are not allowed here
  in "file:///home/ec2-user/cwl.examples/hello.workflow2/wc2.cwl", line 11, column 19

【问题讨论】:

    标签: amazon-web-services workflow yaml


    【解决方案1】:

    CWL 输入中,您必须定义将出现在创建的命令行中的参数。 wc 流到标准输出,则无需在输入中指定 outfilename。勾选man wc,显示所有wc参数。

    这是您可以使用的解决方案,但我认为不是完美的解决方案!

    wc2.cwl

    #!/usr/bin/env cwl-runner
    cwlVersion: cwl:draft-3
    class: CommandLineTool
    baseCommand: wc
    requirements:
      - class: InlineJavascriptRequirement
    
    stdout: $(inputs.inputfile.path.replace(/^.*[\\\/]/, '').replace(/\.[^/.]+$/, '') + '.wc')
    inputs:
      - id: inputfile
        type: File
        inputBinding:
          position: 1
    outputs:
      - id: outputfile
        type: File
        outputBinding:
          glob: $(inputs.inputfile.path.replace(/^.*[\\\/]/, '').replace(/\.[^/.]+$/, '') + '.wc')
    

    【讨论】:

      【解决方案2】:

      标准输出:$(inputs.outfilename) 成为, 标准输出:$(inputs['outfilename'])

      【讨论】:

      • 请在您的回答中添加解释。
      【解决方案3】:

      根据Common Workflow Language User Guide: Capturing Standard Output 以及https://www.commonwl.org/v1.0/CommandLineTool.html#stdout 中列出的示例, 要指定捕获标准输出的文件名,请定义stdout: filenameoutputs: type: stdout

      wc2.cwl

      cwlVersion: cwl:v1.0
      class: CommandLineTool
      baseCommand: wc
      inputs:
        - id: inputfile
          type: File
          inputBinding:
            position: 1
      outputs:
        - id: outputfile
          type: stdout
      stdout: $(inputs.inputfile.basename).wc
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-05-25
        • 1970-01-01
        • 1970-01-01
        • 2019-02-19
        • 2010-10-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多