Nextflow:如何将输出(多个文件)从 publishdir 传递到下一个进程?

Nextflow: how do you pass an output (multiple files) from the publishdir to the next process?

我有一个进程生成两个我感兴趣的文件,hitsort.cls 和 contigs.fasta。 我使用 publishdir:

输出这些
process RUN_RE {
    publishDir "$baseDir/RE_output", mode: 'copy'
  
    input:
    file 'interleaved.fq'

    output:
    file "${params.RE_run}/seqclust/clustering/hitsort.cls"
    file "${params.RE_run}/contigs.fasta"

    script:
    """
    some_code

    """

  }

现在,我需要这两个文件作为另一个进程的输入,但我不知道该怎么做。

我试过用

调用这个进程
NEXT_PROCESS(params.hitsort, params.contigs)

同时将输入指定为:

process NEXT_PROCESS {
  
    input:
    path hitsort
    path contigs

但它不起作用,因为只使用了基本名称而不是完整路径。基本上我想要的是等待RUN_RE完成,然后将它输出的两个文件用于下一个过程。

最好避免访问 publishDir 中的文件,因为:

Files are copied into the specified directory in an asynchronous manner, thus they may not be immediately available in the published directory at the end of the process execution. For this reason files published by a process must not be accessed by other downstream processes.

因此,建议确保您的进程仅访问工作目录中的文件(即 ./work)。这意味着:最好避免在输入和输出声明中使用绝对路径之类的东西。这也将有助于确保您的工作流程是可移植的。

nextflow.enable.dsl=2

params.interleaved_fq = './path/to/interleaved.fq'
params.publish_dir = './results'
process RUN_RE {

    publishDir "${params.publish_dir}/RE_output", mode: 'copy'

    input:
    path interleaved

    output:
    path "./seqclust/clustering/hitsort.cls", emit: hitsort_cls
    path "./contigs.fasta", emit: contigs_fasta

    """
    # do something with ${interleaved}...
    ls -l "${interleaved}"

    # create some outputs...
    mkdir -p ./seqclust/clustering
    touch ./seqclust/clustering/hitsort.cls
    touch ./contigs.fasta
    """
}
process NEXT_PROCESS {

    input:
    path hitsort
    path contigs

    """
    ls -l
    """
}
workflow {

    interleaved_fq = file( params.interleaved_fq )

    NEXT_PROCESS( RUN_RE( interleaved_fq ) )
}

以上工作流程块实际上与:

workflow {

    interleaved_fq = file( params.interleaved_fq )

    RUN_RE( interleaved_fq )

    NEXT_PROCESS( RUN_RE.out.hitsort_cls, RUN_RE.out.contigs_fasta )
}