2.17. ファイルフォーマット#
ToolsやWorkflowsは、File
型を入力として受け取り、出力として生成できます。また、File
タイプのフォーマットを示すことをお勧めします。これにより、ツールの使用方法を他の人に示すことができ、パラメータファイルを作成する際に簡単な型チェックを行うことができるようになります。
ファイルフォーマットについては、既存のオントロジーを参照すること(例ではEDAM)、所属機関のローカルオントロジーを参照すること、またはツールを他者と共有する前に迅速に開発するために最初はファイルフォーマットを追加しないことを推奨しています。既存のIANAファイルフォーマット一覧とEDAMファイルフォーマット一覧は、それぞれのウェブサイトで参照できます。
次のチュートリアルで、$namespaces
と$schemas
の部分をより詳しく説明しますので、今は気にしないでください。
なお、さらなる利点としてcwltool
は、ファイル形式に基づく基本的な推論を行い、明らかな不一致があるようであれば警告を発します。
metadata_example.cwl
##!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: CommandLineTool
label: An example tool demonstrating metadata.
inputs:
aligned_sequences:
type: File
label: Aligned sequences in BAM format
format: edam:format_2572
inputBinding:
position: 1
baseCommand: [ wc, -l ]
stdout: output.txt
outputs:
report:
type: stdout
format: edam:format_1964
label: A text file that contains a line count
$namespaces:
edam: http://edamontology.org/
$schemas:
- http://edamontology.org/EDAM_1.18.owl
このCWL定義に相当するものをコマンドライン形式にすると:
$ wc -l /path/to/aligned_sequences.ext > output.txt
2.17.1. サンプルパラメーターファイル#
以下は、上記の例のパラメータファイルの例です。あなたのツールのパラメータファイルの実例をチェックすることをお勧めします。これにより、他の人が「既知の良い」パラメータ化から始めて、あなたのツールで素早く作業できます。
sample.yml
#aligned_sequences:
class: File
format: http://edamontology.org/format_2572
path: file-formats.bam
注: 以下の例に実行するには、例の入力ファイル、file-formats.bam をダウンロードする必要があります。このファイルはcommon-workflow-language/user_guide から入手可能で、wget
などでダウンロードできます:
$ wget https://github.com/common-workflow-language/user_guide/raw/main/src/_includes/cwl/file-formats/file-formats.bam
ここで、コマンドラインにツール定義と入力オブジェクトを指定して、cwltool
を起動します:
$ cwltool metadata_example.cwl sample.yml
INFO /opt/hostedtoolcache/Python/3.9.19/x64/bin/cwltool 3.1.20240508115724
INFO Resolved 'metadata_example.cwl' to 'file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/file-formats/metadata_example.cwl'
INFO [job metadata_example.cwl] /tmp/dnlt7lfj$ wc \
-l \
/tmp/ulie7rv9/stgad7ee7ec-5f40-40b4-9bcc-b77f51c04274/file-formats.bam > /tmp/dnlt7lfj/output.txt
INFO [job metadata_example.cwl] completed success
{
"report": {
"location": "file:///home/runner/work/user_guide/user_guide/src/_includes/cwl/file-formats/output.txt",
"basename": "output.txt",
"class": "File",
"checksum": "sha1$835f7bf2c539c75934dc1c8f29c40341acba442e",
"size": 77,
"format": "http://edamontology.org/format_1964",
"path": "/home/runner/work/user_guide/user_guide/src/_includes/cwl/file-formats/output.txt"
}
}INFO Final process status is success