
Workflow Description Language (WDL) đang được cộng đồng bioinformatics quan tâm nhiều hơn như một lựa chọn thay thế Nextflow cho các pipeline tính toán tái lập được. Nếu bạn đã làm việc với Nextflow và muốn tìm hiểu WDL, nhiều khái niệm sẽ quen thuộc, và một số khác biệt về cú pháp cũng như mô hình thực thi đáng để lưu ý. Hướng dẫn này đi qua việc thiết lập WDL với miniWDL và Sprocket — hai executor WDL hiện đại — đồng thời so sánh với Nextflow.
Khác biệt chính giữa WDL và Nextflow không chỉ nằm ở cú pháp — mà còn ở cách workflow được thực thi. Sự khác biệt này quan trọng khi chọn công cụ.
Nextflow vừa là ngôn ngữ vừa là runtime executor. Bạn viết bằng Nextflow DSL2 và thực thi trực tiếp bằng CLI nextflow, vốn trừu tượng hóa khác biệt hạ tầng:
nextflow run workflow.nf -profile slurm # HPC with SLURMnextflow run workflow.nf -profile aws # AWS Batchnextflow run workflow.nf -profile k8s # Kubernetesnextflow run workflow.nf -profile azure # AzureWDL chỉ là ngôn ngữ — bạn cần một executor riêng để chạy. Các executor phổ biến gồm Cromwell, miniWDL và Sprocket, mỗi cái có cấu hình và khả năng riêng:
miniwdl run workflow.wdl -i inputs.json # Local/Simplesprocket run workflow.wdl inputs.json # Modern CLIjava -jar cromwell.jar run workflow.wdl # Enterprise| Khía cạnh | WDL | Nextflow |
|---|---|---|
| Ngôn ngữ vs Runtime | Chỉ ngôn ngữ (cần executor riêng) | Ngôn ngữ + runtime tích hợp (CLI nextflow) |
| Mô hình thực thi | Task khai báo + tổ hợp workflow | Kênh dựa trên dataflow |
| Hệ thống kiểu | Kiểu mạnh, xác thực lúc biên dịch | Kiểu yếu, linh hoạt lúc chạy |
| Nguồn gốc & cộng đồng | Broad Institute (Mỹ), cộng đồng đang lớn dần | Nguồn gốc châu Âu, hiện được dùng rộng rãi |
| Hỗ trợ cloud | Cromwell/Sprocket trên AWS, GCP, Azure (đang lên) | Hỗ trợ trưởng thành trên các cloud lớn |
| Hỗ trợ HPC | Cromwell/miniWDL trên SLURM, PBS, v.v. | Hỗ trợ sẵn cho SLURM, PBS, SGE |
| Kubernetes | Hỗ trợ hạn chế | Hỗ trợ K8s trưởng thành |
| Triển khai production | Cấp doanh nghiệp trên Cromwell/Terra | Được dùng rộng rãi trong production |
| Workflow cộng đồng | ~500+ (GATK, WILDS) | Hơn 10.000 workflow công khai |
| Đường cong học tập | Dốc hơn (cấu trúc chặt hơn) | Thoải hơn (trực quan hơn) |
| Linh hoạt hạ tầng | Cách tiếp cận đa executor (kém thống nhất) | Một CLI với trừu tượng profile (rất linh hoạt) |
Chọn WDL khi:
Chọn Nextflow khi:
-profile)miniWDL là một executor WDL nhẹ, hướng đến phát triển và kiểm thử cục bộ:
# Using pip (Python 3.8+)pip install miniwdl
# Verify installationminiwdl --version
# Or using condaconda install -c bioconda miniwdlSprocket là một executor WDL hiện đại với giao diện CLI:
# Install using curlcurl -L https://releases.sprocket.bio/sprocket/latest/sprocket-linux-x86_64 -o sprocketchmod +x sprocketmv sprocket /usr/local/bin/
# Or download from: https://sprocket.bio/
# Verify installationsprocket --versionWorkflow WDL dựa trên môi trường container. Chọn một trong hai:
# Docker (recommended for local development)curl -fsSL https://get.docker.com -o get-docker.shsudo sh get-docker.sh
# Or Apptainer (HPC environments)sudo apt-get install apptainerMột workflow "Hello World" đơn giản minh họa cấu trúc cơ bản:
version 1.0
task greet { input { String name }
command <<< echo "Hello, ~{name}!" >>>
output { String greeting = read_string(stdout()) }
runtime { docker: "ubuntu:22.04" memory: "512 MB" cpu: 1 }}
workflow hello_world { input { String person_name = "World" }
call greet { input: name = person_name }
output { String message = greet.greeting }}version 1.0: phiên bản đặc tả WDL (giống manifest của Nextflow)task: tương đương process của Nextflow, định nghĩa một đơn vị tính toánworkflow: điều phối các task và luồng dữ liệu (giống workflow block của Nextflow)input: tham số đầu vào có kiểu tường minh (kiểu mạnh, khác Nextflow)command: lệnh shell (giống block script: của Nextflow)runtime: đặc tả container và tài nguyên (giống container và resources của Nextflow)output: output khai báo tường minh kèm kiểuTạo hello_inputs.json:
{ "hello_world.person_name": "WDL User"}Chú ý cú pháp: workflow_name.input_parameter.
# Run the workflowminiwdl run hello_world.wdl -i hello_inputs.json
# Check outputs in the generated directorycd hello_world_*/cat outputs.json# Run with Sprocketsprocket run hello_world.wdl hello_inputs.json
# Sprocket provides a summarysprocket run hello_world.wdl hello_inputs.json --watchMột ví dụ thực tế là pipeline ww-sra-salmon từ WILDS WDL Library, tải dữ liệu RNA-seq từ Sequence Read Archive của NCBI và định lượng mức phong phú transcript bằng Salmon.
sra_salmon workflow:├── Download FASTQ from SRA (scattered across samples)├── Detect paired-end vs single-end├── Build Salmon index (once)├── Quantify transcripts (scattered quantification)└── Merge results into expression matricesversion 1.0
import "https://raw.githubusercontent.com/getwilds/wilds-wdl-library/refs/heads/main/modules/ww-sra/ww-sra.wdl" as sra_tasksimport "https://raw.githubusercontent.com/getwilds/wilds-wdl-library/refs/heads/main/modules/ww-salmon/ww-salmon.wdl" as salmon_tasks
workflow sra_salmon { meta { author: "Taylor Firman" description: "Download RNA-seq from SRA and quantify with Salmon" }
input { Array[String] sra_id_list File transcriptome_fasta Int ncpu = 8 Int memory_gb = 16 Int? max_reads }
# Build Salmon index (single task, not scattered) call salmon_tasks.build_index { input: transcriptome_fasta = transcriptome_fasta, cpu_cores = ncpu, memory_gb = memory_gb }
# Process each SRA sample in parallel (scatter) scatter ( id in sra_id_list ){ call sra_tasks.fastqdump { input: sra_id = id, ncpu = ncpu, max_reads = max_reads }
# Conditional: paired-end vs single-end handling if (fastqdump.is_paired_end) { call salmon_tasks.quantify as quantify_paired { input: salmon_index_dir = build_index.salmon_index, sample_name = id, fastq_r1 = fastqdump.r1_end, fastq_r2 = fastqdump.r2_end, cpu_cores = ncpu, memory_gb = memory_gb } }
if (!fastqdump.is_paired_end) { call salmon_tasks.quantify as quantify_single { input: salmon_index_dir = build_index.salmon_index, sample_name = id, fastq_r1 = fastqdump.r1_end, cpu_cores = ncpu, memory_gb = memory_gb } }
# Select output from appropriate branch File quant_dir = select_first([quantify_paired.salmon_quant_dir, quantify_single.salmon_quant_dir]) }
# Merge quantification across all samples call salmon_tasks.merge_results { input: salmon_quant_dirs = quant_dir }
output { Array[File] salmon_quant_dirs = quant_dir File tpm_matrix = merge_results.tpm_matrix File counts_matrix = merge_results.counts_matrix }}Cùng logic đó trong Nextflow DSL2:
// Nextflow equivalent (simplified)workflow sra_salmon { input_ch = Channel.fromList(params.sra_id_list)
build_index(file(params.transcriptome_fasta))
input_ch | fastqdump | quantify | collect | merge_results}Khác biệt chính:
scatter của WDL tường minh và giới hạn phạm vi; kênh của Nextflow động hơnif của WDL cho điều kiện tường minh; Nextflow dùng when và phân nhánhimport của WDL kéo task từ xa trực tiếp; Nextflow dùng include và đường dẫn cục bộ{ "sra_salmon.sra_id_list": ["SRR3589956", "SRR3589957"], "sra_salmon.transcriptome_fasta": "/path/to/gencode.v43.transcripts.fa", "sra_salmon.ncpu": 8, "sra_salmon.memory_gb": 16}# Using miniWDLminiwdl run ww-sra-salmon.wdl -i inputs.json
# Using Sprocketsprocket run ww-sra-salmon.wdl inputs.json
# Watch execution progress (Sprocket)sprocket run ww-sra-salmon.wdl inputs.json --watchscatter của WDL tường minh và an toàn về kiểu:
scatter (sample in sample_list) { call process_sample { input: sample_name = sample }}# Output is automatically collected into an ArrayArray[File] results = process_sample.output_fileSo với Nextflow:
sample_ch = Channel.fromList(sample_list)sample_ch | process_sampleif (fastqdump.is_paired_end) { call quantify_paired { ... }}
# Select output safelyFile result = select_first([quantify_paired.output, quantify_single.output])WDL áp đặt kiểu nghiêm ngặt:
# These won't compileInt my_int = "string" # ERRORFile f = my_int # ERROR
# CorrectInt number = 42File input_file = "/path/to/file.txt"Array[File] files = ["/file1.txt", "/file2.txt"]# Import tasks from GitHubimport "https://raw.githubusercontent.com/getwilds/wilds-wdl-library/refs/heads/main/modules/ww-salmon/ww-salmon.wdl" as salmon_tasks
# Use imported tasks with namespacecall salmon_tasks.build_index { ... }Phần này trình bày một khác biệt kiến trúc dễ bị bỏ qua.
Nextflow: một CLI, nhiều backend
Với Nextflow, bạn chuyển giữa các backend hạ tầng bằng profile — cùng mã, môi trường thực thi khác:
# Define once, run anywherenextflow run workflow.nf -profile slurm # Local HPCnextflow run workflow.nf -profile aws # AWS Batch + S3nextflow run workflow.nf -profile azure # Azure Batchnextflow run workflow.nf -profile gcp # Google Cloudnextflow run workflow.nf -profile k8s # KubernetesWDL: ngôn ngữ cộng executor riêng
WDL tách biệt các mối quan tâm: viết workflow bằng WDL, rồi chọn executor hỗ trợ hạ tầng của bạn:
Mỗi executor cần cấu hình riêng.
Phù hợp nhất với: phát triển cục bộ, lặp nhanh, học tập
Ưu điểm:
--empty-secondaries)Hạn chế:
Sử dụng:
miniwdl run workflow.wdl -i inputs.json -d output_dirminiwdl check workflow.wdl # Syntax validationPhù hợp nhất với: triển khai doanh nghiệp, cụm HPC, genomics quy mô lớn
Ưu điểm:
Hạn chế:
Sử dụng:
java -jar cromwell.jar run workflow.wdl --inputs inputs.jsonVí dụ cấu hình backend (Cromwell):
backend { default = "slurm"
providers { slurm { actor-factory = "cromwell.backend.impl.sfs.config.ConfigBackendLifecycleActorFactory" config { runtime_attributes = """ Int cpu = 1 Int? memory_gb String? docker """ } } }}Phù hợp nhất với: triển khai cloud hiện đại, phát triển tương tác
Ưu điểm:
Hạn chế:
Sử dụng:
sprocket run workflow.wdl inputs.json --watchsprocket validate workflow.wdl # Type checking| Tính năng | miniWDL | Cromwell | Sprocket | Nextflow |
|---|---|---|---|---|
| Local Dev | ✓ Excellent | ○ Works | ✓ Good | ✓ Excellent |
| HPC (SLURM) | ✗ No | ✓ Yes | ○ Limited | ✓ Native |
| AWS Batch | ✗ No | ✓ Yes | ✓ Yes | ✓ Native |
| Google Cloud | ✗ No | ✓ Yes | ✓ Yes | ✓ Native |
| Azure | ✗ No | ✓ Yes | ✓ Yes | ✓ Native |
| Kubernetes | ✗ No | ○ Limited | ✓ Yes | ✓ Native |
| Installation | ✓ Simple (pip) | ○ Requires Java | ✓ Simple | ✓ Simple |
| Configuration | ○ JSON | ✗ Complex | ✓ Simple | ✓ Config files |
| Learning Curve | ✓ Gentle | ○ Steep | ✓ Gentle | ✓ Gentlest |
Điểm mấu chốt: Nextflow xử lý trừu tượng hóa executor ở một chỗ — bạn định nghĩa môi trường thực thi trong tệp config, không phải trong executor. WDL yêu cầu chọn executor khớp với nhu cầu hạ tầng.
# Good: Reusable, single responsibilitytask align_reads { input { File reads File reference Int threads } # ... implementation}
# Bad: Too many responsibilitiestask process_and_qc_and_align { # ...}struct Sample { String name File r1_fastq File r2_fastq}
workflow my_workflow { input { Array[Sample] samples }
scatter (sample in samples) { call process_sample { input: sample_data = sample } }}# Compile-time validation catches errors earlyFile my_file = "/path/to/file.txt" # Clear intentInt threads = 8 # Not a stringtask my_task { meta { description: "What this task does" author: "Your Name" email: "your@email.com" }
parameter_meta { input_file: "Description of input" output_name: "Description of output" }
input { ... } command { ... } output { ... }}Quyết định giữa WDL và Nextflow thường phụ thuộc vào hạ tầng, nhóm và nhu cầu cộng đồng hơn là chỉ riêng tính năng ngôn ngữ.
-profile hơn là thiết lập riêng cho từng executorDoes your organization use Cromwell/Terra? ├─ YES → Consider WDL + Cromwell └─ NO → Consider Nextflow
Do you need to run on multiple infrastructure types from same code? ├─ YES → Nextflow (built-in abstraction) └─ NO → Either works, consider other factors
Do you want community workflows? ├─ YES → Nextflow (10,000+ available) └─ NO → WDL or Nextflow
Is infrastructure compatibility your main challenge? ├─ YES → Nextflow (cleaner abstraction) └─ NO → Choose based on other factorsWDL và Nextflow đại diện cho hai cách tiếp cận khác nhau với tự động hóa workflow:
Điểm kiến trúc mấu chốt: trừu tượng hóa executor của Nextflow giúp triển khai đa nền tảng đơn giản hơn — chỉ cần đổi profile. WDL yêu cầu chọn executor khớp với nhu cầu hạ tầng. Với các tổ chức chạy trên nhiều nền tảng, CLI thống nhất của Nextflow là một lợi thế; với các nhóm gắn với Broad Institute, cấu trúc chính thức và tích hợp Terra của WDL có thể là lý do hợp lý để chấp nhận độ phức tạp của executor.
Khuyến nghị thực tế:
WILDS WDL Library cung cấp các module sẵn sàng cho production giúp tăng tốc phát triển WDL, trong khi dự án nf-core cung cấp hơn 100 pipeline Nextflow đã qua peer review. Dù chọn cách nào, bối cảnh hạ tầng workflow hiện có những công cụ trưởng thành cho genomics tái lập được và có thể mở rộng.



