【问题标题】:Merge multiple output chunks to one file in nextflow在 nextflow 中将多个输出块合并到一个文件中
【发布时间】:2022-11-02 04:04:10
【问题描述】:

我有一个输出多个文件的 nextflow 流程,如下所示:

[chr1,/path/to/chr1_chunk1.TC.linear]
[chr1,/path/to/chr1_chunk1.HDL.linear]
[chr1,/path/to/chr1_chunk2.TC.linear]
[chr1,/path/to/chr1_chunk2.HDL.linear]
.....

上面的例子是我使用transpose() 运算符后得到的。

现在,我想将所有块和所有染色体连接在一起,按块和染色体编号排序,这样我得到一个 TC 文件和另一个 HDL 文件。我在很多块中有多个特征,所以这个链接没有帮助。 output files (chromosomal chunks) merging in nextflow 有什么帮助吗?

【问题讨论】:

    标签: nextflow


    【解决方案1】:

    您可以使用branchcollectFile 运算符的组合。请看下面的目录结构(其中 .linear 文件以它们的名称作为内容):

    ➜  sandbox tree .
    .
    ├── ex1.HDL.linear
    ├── ex1.TC.linear
    ├── ex2.HDL.linear
    ├── ex2.TC.linear
    ├── ex3.HDL.linear
    ├── ex3.TC.linear
    └── example.nf
    

    我写了以下最小的可重现示例:

    workflow {
      files = Channel.fromPath('**.linear', checkIfExists: true)
      files
        .branch {
          TC: it.toString().contains('TC')
          HDL: it.toString().contains('HDL')
        }
        .set { result }
      result
        .TC
        .collectFile(name: 'TC.txt', storeDir: '/Users/mribeirodantas/sandbox')
      result
        .HDL
        .collectFile(name: 'HDL.txt', storeDir: '/Users/mribeirodantas/sandbox')
    }
    

    使用nextflow run example.nf 运行此管道后,我将在/Users/mribeirodantas/sandbox 文件夹中获得两个新文件:TC.txtHDL.txt。例如TC.txt的内容为:

    ex2.TC.linear
    ex3.TC.linear
    ex1.TC.linear
    

    【讨论】:

      猜你喜欢
      • 2021-06-03
      • 2021-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多