【9.1】生信分析流程框架概述

概况

1. 工作流管理系统
	Scripts
	Make
	nextflow

2. 工作流引擎
	Cromwell
	Argo

3. 工作流语言
	Common Workflow Language (CWL)
	WDL
4. YAML格式

A pipeline is a set of data processing elements connected in series, where the output of one element is the input of the next one. The elements of a pipeline are often executed in parallel or in time-sliced fashion; in that case, some amount of buffer storage is often inserted between elements.

1. 工作流管理系统

Scripts: 使用脚本语言把处理数据的脚本或软件串成。 Make:

nextflow:

例1. 官网示例

#!/usr/bin/env nextflow

params.in = "$baseDir/data/sample.fa"
sequences = file(params.in)

// split a fasta file in multiple files
process splitSeq{
    input:
    file 'input.fa' from sequences
    
    output:
    file 'seq_*' into records

    """
    awk '/^>/{f="seq_"++d}{print > f}' < input.fa
    """
}

// simple reverse the sequences
process reverse{
    input:
    file x from records

    output:
    stdout result

    """
    cat $x | rev
    """    
}

//print the channel content
result.subscribe{printIn it}

2. 工作流引擎

  • Cromwell
  • Argo
  • 云原生的工作流。

3. 工作流语言

无论 Snakemake,还是 Nextflow 都需要用户按照工具本身定义的语法来创建流程。这给流程在不同平台间的迁移带来了不便。 工作流语言旨在提供一套语法标准,以解决可移植性差的问题。生信领域最常见的工作流语言有 CWL 和 WDL。下文对他们的用法做一个简单介绍。

3.1 Common Workflow Language (CWL)

1.定义

CWL 是一种描述命令行工具并将它们连接在一起以创建工作流的规范。

2.使用方法

CWL文件使用YAML或JSON格式编写。调用形式一般为

cwl-runner [tool-or-workflow-description] [input-job-settings]

,上述命令将工作流描述和输入文件作为参数提供给CWL运行器。

例1. cwl-runner echo.cwl echo_input.yaml

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

cwlVersion: v1.0        # CWL版本
class: CommandLineTool  # 命令行工具
baseCommand: echo       # 运行的程序名
inputs:                 # 工具的输入
  message:                # 参数ID
    type: string            # 参数类型
    inputBinding:           # 参数如何出现在命令行
      position: 1             #  参数出现在命令行的位置
output: []

# input: echo_input.yaml
message: Hello world!

inputs 是一个输入参数的列表。每个参数又有多个字段组成,如参数名称 id,参数值类型 type(string, int, long, float, double, null, array, record, File, Directory, Any)等。

3.2 WDL

相较CWL,WDL 抽离了很多在需要通过文件解析的部分,因而可用性较好。 基本单元由 workflow,task,command,output,call 构成。

call task

4. YAML格式

  • 键值对 key: value
  • 注释 #
  • 数据结构: Maps & Arrays
  • JSON 风格

参考资料

药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn