nextflow:处理来自不同目录的所有文件对

问题描述 投票:0回答:1

我有这样的结构:

|-- combine.nf
|-- first
|   |-- a.txt
|   |-- b.txt
|   `-- c.txt
|-- second
|   |-- A.txt
|   `-- B.txt

并且

combine.nf

#!/usr/bin/env nextflow
process sayHello {
  input:
  path first
  path second

  output:
    stdout

  script:
    """
    echo 'Hello couple (${first}, ${second})' 
    """
}

workflow {
    def files_first = Channel.fromPath("first/*.txt")
    def files_second = Channel.fromPath("second/*.txt")
    sayHello(files_first, files_second) | view { it }
  }

仅对两对调用

sayHello
进程(实际上是最小目录的大小):

Hello couple (a.txt, A.txt)
Hello couple (b.txt, B.txt)

如何处理所有可能的对?预先感谢

PS:这个问题是通用的,在我的例子中,其中一个目录仅包含一个文件。

nextflow
1个回答
0
投票

消耗来自两个独立“队列”通道的元素的进程每次执行都会从每个通道中获取一个值。最后执行的一对由较短的通道决定。所以这正是您所得到的。

您需要做的是将两个通道

combine
合并为一个包含所有对的通道:

workflow {
    def files_first = Channel.fromPath("first/*.txt")
    def files_second = Channel.fromPath("second/*.txt")
    all_pairs = files_first.combine(files_second)
    sayHello(all_pairs) | view { it }
}

然后您需要修改流程以仅将组合通道作为输入

process sayHello {
  input:
    tuple path(first), path(second)
  
  ...
}
© www.soinside.com 2019 - 2024. All rights reserved.