LoginSignup
0
0

CWLのinフィールドの文字列操作

Last updated at Posted at 2023-09-26

目的

  • inputsフィールドで受け取った値をinフィールドで、文字列加工したい。値に接頭辞や接尾辞をつけたい。

ポイント

  • inフィールドで文字列操作したい
  • sourceフィールドでselfの対象を指定し、valueFromフィールドで文字列操作
  • 変数selfの前後に接頭辞と接尾辞をつける操作
  • オプションでStepInputExpressionRequirementを指定することで動いた
    • requirementsフィールド
      StepInputExpressionRequirement: {}
      
    • inフィールド
      in:
        tool_input:
          source: original_input
          valueFrom: prefix_$(self)_suffix
      

参考資料

方法

  • 検証に使ったテストコード
  • echoするだけのワークフロー。yamlで渡した変数に対して、文字列操作してecho。結果をoutput.txtに出力。
    • Workflow:example_workflow.cwl

      cwlVersion: v1.2
      class: Workflow
      
      requirements:
        StepInputExpressionRequirement: {}
      inputs:
        original_input: string
      
      steps:
        example_step:
          run: example_tool.cwl
          in:
            tool_input:
              source: original_input
              valueFrom: prefix_$(self)_suffix
          out:
            - output_text
      
      outputs:
        final_output:
          type: File
          outputSource: example_step/output_text
      
    • CommandLineTool:example_tool.cwl

      cwlVersion: v1.2
      class: CommandLineTool
      
      baseCommand: ["echo"]
      
      inputs:
        tool_input:
          type: string
          inputBinding:
            position: 1
      
      outputs:
        output_text:
          type: File
          outputBinding:
            glob: "output.txt"
      
      stdout: "output.txt"
      
    • yaml: input.yaml

      original_input: "sample_text"
      
    • ツールのバージョン

      $ node --version
      v14.17.6
      $ singularity --version
      singularity version 3.8.7
      $ cwltool --version
      cwltool 3.1.20210816212154
      
  • 実行コマンド
    $ cwltool example_workflow.cwl input.yaml
    
  • 実行結果(output.txt)
    prefix_sample_text_suffix
    
  • 「sample_text」という文字列の前後に、接頭辞と接尾辞をつけることができた。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0