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)#

This indicates whether a process requires outgoing IPv4/IPv6 network access. Starting with CWL v1.1, programs are not granted network access by default, so you must include the requirement for network access in the specification of your tool.

cwlVersion: v1.2
class: CommandLineTool

requirements:
  NetworkAccess:
     networkAccess: true

备注

CWL v1.0 command-line tools that are upgraded to v1.1 or v1.2 or v1.2 will have networkAccess: true set automatically.