2.2. 命令行工具#

命令行工具是可以单独运行或作为工作流步骤运行的一类流程 (process) 对象。它是诸如 lsechotar 等命令的包装器,由相应的 CWL 文件中 baseCommand 这一属性定义。

CWL 命令行工具还必具有 inputs(输入)和 outputs(输出)。以下是一个 CWL 命令行工具的极简示例,用 Linux 下的 echo 命令演示输入和输出。

digraph G { compound=true; rankdir="LR"; fontname="Verdana"; fontsize="10"; graph [splines=ortho]; node [fontname="Verdana", fontsize="10", shape=box]; edge [fontname="Verdana", fontsize="10"]; subgraph cluster_0 { command[style="filled" label=<<FONT FACE='sans-serif;'>echo</FONT>>]; label="baseCommand"; fill=gray; } inputs -> command [lhead=cluster_0]; command -> outputs [ltail=cluster_0]; }

CWL 命令行工具。#

echo.cwl#
cwlVersion: v1.2
class: CommandLineTool

baseCommand: echo

stdout: output.txt

inputs:
  message:
    type: string
    inputBinding: {}
outputs:
  out:
    type: string
    outputBinding:
      glob: output.txt
      loadContents: true
      outputEval: $(self[0].contents)

备注

上例以简化的形式定义了输入和输出。在《输入》《输出》 章节中,您将进一步学习。

2.2.1. 网络访问 (Network Access)#

这用来指明某个进程是否需要对外 IPv4/IPv6 网络连接。从 CWL v1.1 版本起,程序不再默认有权访问网络,因此您需要在工具描述中加入网络访问需求。

cwlVersion: v1.2
class: CommandLineTool

requirements:
  NetworkAccess:
     networkAccess: true

备注

从 CWL v1.0 版本升级到 1.1 或 1.2 版的命令行工具将自动加入 networkAccess: true 设置。