CWLのinフィールドの文字列操作
目的
inputsフィールドで受け取った値をinフィールドで、文字列加工することは可能か?値に接頭辞や接尾辞をつけたい
ポイント
inフィールドで文字列操作できた
sourceフィールドでselfの対象を指定し、valueFromフィールドで文字列操作できた
オプションで下記2つを指定することで動いた
StepInputExpressionRequirement: {}
InlineJavascriptRequirement: {} ※なしでもいける
Javascriptの書き方でない方式
code:yaml
# valueFrom: $("prefix_" + self + "_suffix")
valueFrom: prefix_$(self)_suffix
Javascriptの書き方でない方式でも動いた。InlineJavascriptRequirement: {}も不要
参考資料
code:txt
ワークフローのステップの実行前に各パラメータの加工が可能になります。"
つまり、inフィールドなどの文字列操作ができる
今回の文字列操作にJavascriptの記法を使っていた。その記法なしでもいけるが
方法
Workflow:example_workflow.cwl
code:yaml
cwlVersion: v1.2
class: Workflow
inputs:
original_input: string
steps:
example_step:
run: example_tool.cwl
in:
tool_input:
source: original_input
# valueFrom: $("prefix_" + self + "_suffix")
valueFrom: prefix_$(self)_suffix
out:
- output_text
outputs:
final_output:
type: File
outputSource: example_step/output_text
requirements:
StepInputExpressionRequirement: {}
# InlineJavascriptRequirement: {}
CommandLineTool:example_tool.cwl
code:yaml
cwlVersion: v1.2
class: CommandLineTool
inputs:
tool_input:
type: string
inputBinding:
position: 1
outputs:
output_text:
type: File
outputBinding:
glob: "output.txt"
stdout: "output.txt"
yaml: input.yaml
code:yaml
original_input: "sample_text"
ツールのバージョン
code:bash
$ node --version
v14.17.6
$ singularity --version
singularity version 3.8.7
$ cwltool --version
cwltool 3.1.20210816212154
実行コマンド
code:bash
cwltool example_workflow.cwl input.yaml
実行結果
code:output.txt
prefix_sample_text_suffix