在 Nextflow 中获取两个输出文件的问题

Problems getting two output files in Nextflow

大家好!

我正在尝试编写一个小型的 Nextflow 管道,运行s vcftools 命令在 300 个 vcf 中。管道有四个输入:vcf、pop1、pop2 和一个 .txt 文件,并且必须生成两个输出:一个 .log.weir.fst 和一个 .log.log 文件。当我 运行 管道时,它只提供 .log.weir.fst 文件而不提供 .log 文件。

这是我的流程定义:

process fst_calculation {

publishDir "${results_dir}/fst_results_pop1_pop2/", mode:"copy"

    input:
    file vcf
    file pop_1
    file pop_2
    file mart

    output:
    path "*.log.*"

    """
    while read linea
            do
                echo "[DEBUG] working in line: $linea"
                inicio=$(echo "$linea" | cut -f3)
                final=$(echo "$linea" | cut -f4)
                cromosoma=$(echo "$linea" | cut -f1)
                segmento=$(echo "$linea" | cut -f5)
                vcftools --vcf ${vcf} \
                     --weir-fst-pop ${pop_1} \
                     --weir-fst-pop ${pop_2} \
                     --out $inicio.log --chr $cromosoma \
                     --from-bp $inicio --to-bp $final
            done < ${mart}
    """
}

这是我的流程

/* Load files  into channel*/
pop_1 = Channel.fromPath("${params.fst_path}/pop_1")
pop_2 = Channel.fromPath("${params.fst_path}/pop_2")
vcf = Channel.fromPath("${params.fst_path}/*.vcf")
mart = Channel.fromPath("${params.fst_path}/*.txt")

/* Import modules
*/
 include {
   fst_calculation } from './nf_modules/modules.nf'

 /*
  * main pipeline logic
  */

 workflow  {
     p1 = fst_calculation(vcf, pop_1, pop_2, mart)
     p1.view()
 }

当我检查管道的工作目录时,我可以看到管道只生成.log.weir.fst。为了验证我的代码是否错误,我在工作目录中输入 运行 "bash .command.sh" ,这实际上生成了两个输出文件。那么,当我 运行 管道时,是否有没有得到两个输出文件的原因?

感谢任何帮助。

请注意 bash .command.shbash .command.run 做不同的事情。后者基本上是前者的包装器,它设置环境并暂存声明的输入文件等。如果 运行 后者产生异常行为,您需要更深入地挖掘。

我不太清楚这里的问题是什么。我的猜测是 vcftools 在 运行 非交互时可能表现不同,这样它会将它的日志记录发送到 STDERR。如果是这种情况,日志记录将被捕获到一个名为 .command.err 的文件中。要将其发送到文件,您可以按照通常的方式重定向 STDERR,未经测试:

while IFS=$'\t' read -r cromosoma null inicio final segmento ; do
    >&2 echo "[DEBUG] Working with: ${cromosoma}, ${inicio}, ${final}, ${segmento}"
    vcftools \
         --vcf "${vcf}" \
         --weir-fst-pop "${pop_1}" \
         --weir-fst-pop "${pop_2}" \
         --out "${inicio}.log" \
         --chr "${cromosoma}" \
         --from-bp "${inicio}" \
         --to-bp "${final}" \
         2> "${cromosoma}.${inicio}.${final}.log.log"
done < "${mart}"