如何在 nextflow 中执行 try catch?
我目前正在编写一个管道,其中我正在执行的 bash 命令可能在某些条件下以退出代码 1 退出。这使我的管道陷入停滞。我现在想使用 try catch 子句来定义一些替代行为,以防发生这种情况。
我尝试过以常规方式执行此操作,但似乎不起作用:
process align_kallisto {
publishDir "${params.outdir}/kallisto", mode: 'copy', saveAs:{ filename -> "${name}_abundance.tsv" }
input:
tuple val(name), file(fastq) from fq_kallisto.dump(tag: 'kallisto fq')
file(index) from kallisto_index.collect().dump(tag: 'kallisto index')
output:
file("output/abundance.tsv") into kallisto_quant
// this can throw an exit 1 status
try {
"""
kallisto quant -i ${index} --bias --single --fr-stranded -o output --plaintext \
--fragment-length ${params.frag_length} --sd ${params.frag_deviation} ${fastq}
"""
}
// if this happens catch and do something …
Run Code Online (Sandbox Code Playgroud)