LoginSignup
2
0

More than 3 years have passed since last update.

Conformance test #1 について (前振り編)

Last updated at Posted at 2018-12-14

全体の構成

  • 前振り編 (いまここ)
    • #1 でテストされる入力ファイルおよび期待される出力の説明
  • 実行コマンド生成編
    • #1 で実行されるコマンドを CWL ファイルから生成する方法の解説
  • Docker & 出力パラメータ編
    • 実行コマンド生成編では取り扱わなかった、Docker 上でコマンドを動かす場合の解説および、出力パラメータの補足方法の解説

また、ダイジェスト版の説明スライド(英語)もあります。

注意!

この記事は CWL に対応したワークフローエンジンを実装する人向けの記事です!
CWL を書いて利用する一般の方は、お茶でも飲みながら軽い気持ちで読んでいただければ幸いです。

はじめに

昨日の記事では「僕の考えた最強のワークフローエンジン」の準拠度を確認する conformance test の実行方法を解説しました。

本日は、エンジン実装者の最初の(そして初見殺しの)壁である conformance test #1 の突破に必要な言語仕様について解説する…前に、#1 がどんなテストなのかを簡単に示します。

Conformance test #1 って?

雑に説明すると、指定された Python のスクリプトを動かして、出力ファイルを取得する(ように見える)単体のコマンドラインツールのテストです。

以下が CWL ファイルと入力パラメータです。

v1.0/bwa-mem-tool.cwl
#!/usr/bin/env cwl-runner
cwlVersion: v1.0
class: CommandLineTool

hints:
  - class: ResourceRequirement
    coresMin: 2
  - class: DockerRequirement
    dockerPull: python:2-slim

inputs:
  - id: reference
    type: File
    inputBinding: { position: 2 }

  - id: reads
    type:
      type: array
      items: File
    inputBinding: { position: 3 }

  - id: minimum_seed_length
    type: int
    inputBinding: { position: 1, prefix: -m }

  - id: min_std_max_min
    type: { type: array, items: int }
    inputBinding:
      position: 1
      prefix: -I
      itemSeparator: ","

  - id: args.py
    type: File
    default:
      class: File
      location: args.py
    inputBinding:
      position: -1

outputs:
  - id: sam
    type: ["null", File]
    outputBinding: { glob: output.sam }
  - id: args
    type:
      type: array
      items: string

baseCommand: python

arguments:
  - bwa
  - mem
  - valueFrom: $(runtime.cores)
    position: 1
    prefix: -t

stdout: output.sam
v1.0/bwa-mem-job.json
{
    "reference": {
        "class": "File",
        "location": "chr20.fa",
        "size": 123,
        "checksum": "sha1$hash"
    },
    "reads": [
        {
            "class": "File",
            "location": "example_human_Illumina.pe_1.fastq"
        },
        {
            "class": "File",
            "location": "example_human_Illumina.pe_2.fastq"
        }
    ],
    "min_std_max_min": [
        1,
        2,
        3,
        4
    ],
    "minimum_seed_length": 3
}
v1.0/args.py
#!/usr/bin/env python
import sys
import json
import os
args = [os.path.basename(a) for a in sys.argv[1:]]
with open("cwl.output.json", "w") as f:
    json.dump({"args": args}, f)

以下が cwltool による実行例です。

$ git clone git@github.com:common-workflow-language/common-workflow-language.git
$ cd common-workflow-language/v1.0
$ cwltool --quiet v1.0/bwa-mem-tool.cwl v1.0/bwa-mem-job.json
{
    "args": [
        "bwa",
        "mem",
        "-t",
        "2",
        "-I",
        "1,2,3,4",
        "-m",
        "3",
        "chr20.fa",
        "example_human_Illumina.pe_1.fastq",
        "example_human_Illumina.pe_2.fastq"
    ]
}

解説の前に

ぱっと見ただけで、全力でエンジン実装者の心を折る気なのがわかりますね。
次回は、このテストの突破に必要な仕様の解説を行います。

2
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
2
0