1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CWL User Guide 13: JavaScript Expressions をやってみた

Last updated at Posted at 2017-12-14

CWL User Guide 13: JavaScript Expressions

Common Workflow Language User Guide: JavaScript Expressions

今回は、JavaScript で、入力パラメータを、操作(manipulate)することができるということ、について書かれています

このあたり、JavaScriptで、どのあたりまでできるのか?
JavaScript あれば解決できるなということがこのあたりに合致するかを確認してみると良いと思います。

Key Points から

  • InlineJavascriptRequirement が指定された場合、 JavaScript は、 CWL runner により解釈される
  • expression 形式が使えるフィールドは限られている。
  • expression は、他に解決策がないときのみ使われるべき

この回にでてくる主なキーワード

  • InlineJavascriptRequirement
  • valueFrom

CWLファイル、expression.cwl

expression.cwl
#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool
baseCommand: echo

requirements:
  - class: InlineJavascriptRequirement

inputs: []
outputs: []
arguments:
  - prefix: -A
    valueFrom: $(1+1)
  - prefix: -B
    valueFrom: $("/foo/bar/baz".split('/').slice(-1)[0])
  - prefix: -C
    valueFrom: |
      ${
        var r = [];
        for (var i = 10; i >= 1; i--) {
          r.push(i);
        }
        return r;
      }

パラメータファイル

empty.yml
{}

実行

実行方法

cwltool expression.cwl empty.yml

実行結果

$ cwltool expression.cwl empty.yml
/usr/local/bin/cwltool 1.0.20171107133715
Resolved 'expression.cwl' to 'file:///home/vagrant/cwl_user_guide_work/13-expressions/expression.cwl'
[job expression.cwl] /tmp/tmpMRy2L5$ echo \
    -A \
    2 \
    -B \
    baz \
    -C \
    10 \
    9 \
    8 \
    7 \
    6 \
    5 \
    4 \
    3 \
    2 \
    1
-A 2 -B baz -C 10 9 8 7 6 5 4 3 2 1
[job expression.cwl] completed success
{}
Final process status is success

今回使ったファイル

cwl_user_guide_work/13-expressions at master · manabuishii/cwl_user_guide_work

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?