【问题标题】:How to specify a scratch output directory in Nextflow?如何在 Nextflow 中指定临时输出目录?
【发布时间】:2021-11-16 07:59:24
【问题描述】:

我已经开始阅读 Nexflow 的文档,found that 可以指定一个scratch 目录来执行。一旦任务完成,one can usestageOutMode 指令将输出文件从scratch 复制到storeDir

要复制的输出文件由output 指令指定。我的问题如下:是否可以将整个目录指定为输出,以便将它们从scratch 递归复制到storeDir?如果有,怎么做?

【问题讨论】:

    标签: nextflow


    【解决方案1】:

    默认情况下,path output qualifier 将递归捕获进程输出(文件、目录等)。您需要做的就是在输出声明中指定(顶级)目录,如下例所示:

    nextflow.enable.dsl=2
    
    process test {
    
        scratch '/tmp/my/path'
    
        stageOutMode 'copy'
    
        storeDir '/store/results'
    
        input:
        val myint
    
        output:
        path "outdir-${myint}"
    
        script:
        def outdir = "outdir-${myint}/foo/bar/baz"
    
        """
        mkdir -p "${outdir}" 
        touch "${outdir}/${myint}.txt"
        """
    }
    
    workflow {
    
        ch = Channel.of( 1..3 )
    
        test(ch)
    }
    

    设置stageOutMode 指令只会改变输出文件从临时目录转移到工作目录 的方式。 IE。此指令不会更改将流程结果暂存到 storeDir 目录的方式。

    storeDir 指令更改了输出声明中列出的文件的最终结果,以便将它们从工作目录移动到指定的 storeDir 目录。

    【讨论】:

    • 谢谢。请允许我再问一个问题:如果我定义 scratch '$tmppath',并在 SLURM 集群上执行脚本,$tmppath 会在运行时被替换吗?我的调度程序分配了一个临时目录,其名称中包含 JOBID,该目录仅在作业开始运行时分配。
    • @Botond 是的,只要变量像上面提到的那样单引号。我们的 PBS Pro 调度程序做同样的事情并设置一个名为 $TMPDIR 的变量,当作业开始时,它将指向类似 /scratch/pbs.36569355.hpcpbs01 的东西。该目录仅在作业开始时创建,并在作业完成时自动清理。 Nextflow 将尝试使用唯一 id 将所有输出写入子目录中,例如:/scratch/pbs.36569355.hpcpbs01/nxf.6S4nL9mY3p/outdir-1/foo/bar/baz/1.txt
    猜你喜欢
    • 2012-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-07
    • 2012-01-29
    相关资源
    最近更新 更多