如何将 "print" 与进程相关联?

How can I associate a "print" with a process?

我制作了我的管道,我想在每个过程之前打印一个关于所执行内容的简短描述。

我基本上尝试在脚本中的每个进程之前添加一个 "print"。当我 运行 管道时,它只是先打印出所有描述,然后进程开始执行。

我做了什么:

// Trimming
println 'Trimming reads with AlienTrimmer'
process Trimming {
    ...
}


// Convert to fasta
println 'Convert files from fastq to fasta'
process Fastq2Fasta {
    ...
}


// Concatenate files
println 'Combine all fasta files'
reads_fasta.collectFile()


// Dereplication
if (params.prefixdrep) println 'Dereplication using prefixes'
else println 'Dereplication using full reads lentgh'
process Dereplication {
    ...
}

我得到的:

* Trimming reads with AlienTrimmer
* Convert files from fastq to fasta
* Combine all fasta files
* Dereplication using full reads lentgh
[74/ee63b8] Cached process > Trimming (MOBIO2-16S)
[d7/9b16c3] Cached process > Trimming (IHMS1-16S)
[e8/821f96] Cached process > Trimming (IHMS2-16S)
[2d/bfe805] Cached process > Trimming (MOBIO1-16S)
[a0/6702b3] Cached process > Fastq2Fasta (IHMS1-16S)
[c0/044dcd] Cached process > Fastq2Fasta (MOBIO2-16S)
[84/344d52] Cached process > Fastq2Fasta (MOBIO1-16S)
[7f/20caee] Cached process > Fastq2Fasta (IHMS2-16S)
[aa/ea78e8] Cached process > Dereplication (mycobiote_16S)

我想要什么:

* Trimming reads with AlienTrimmer
[74/ee63b8] Cached process > Trimming (MOBIO2-16S)
[d7/9b16c3] Cached process > Trimming (IHMS1-16S)
[e8/821f96] Cached process > Trimming (IHMS2-16S)
[2d/bfe805] Cached process > Trimming (MOBIO1-16S)
* Convert files from fastq to fasta
[a0/6702b3] Cached process > Fastq2Fasta (IHMS1-16S)
[c0/044dcd] Cached process > Fastq2Fasta (MOBIO2-16S)
[84/344d52] Cached process > Fastq2Fasta (MOBIO1-16S)
[7f/20caee] Cached process > Fastq2Fasta (IHMS2-16S)
* Combine all fasta files   
* Dereplication using full reads lentgh
[aa/ea78e8] Cached process > Dereplication (mycobiote_16S)

快速回答不可能开箱即用。如果你真的需要,你可以在脚本部分使用 print 例如:

process foo {
  script:
  println 'Hello'
  """
  your_command_here
  """
}

但是,您还需要编写代码以仅在第一次写入该消息。