Nextflow 如何枚举通道中的文件以使用“collectFile”`

Nextflow 如何枚举通道中的文件以使用“collectFile”`,nextflow,Nextflow,在使用collectFile之前,我试图枚举通道中的文件以重命名它们: files.flatten().merge(Channel.fromList([1, 2, 3, 4])).collectFile(storeDir: "$SCRATCH/intermediate") { item -> ["data${item[1]}.csv", item[0].text] } 但是文档中说,频道的merge操作符已被弃用,但没有指出应该使用的任何替

在使用
collectFile
之前,我试图枚举通道中的文件以重命名它们:

files.flatten().merge(Channel.fromList([1, 2, 3, 4])).collectFile(storeDir: "$SCRATCH/intermediate") {
    item -> ["data${item[1]}.csv", item[0].text]
}
但是文档中说,频道的
merge
操作符已被弃用,但没有指出应该使用的任何替代方法。我可以用什么来代替合并?

可以用。如果您的输入是列表,您可以执行以下操作:

def indexedChannel( items ) {
    return Channel.from( items.withIndex() ).map { item, idx -> tuple( idx, item ) }
}

ch1 = indexedChannel( [ 15, 20, 21 ] )
ch2 = indexedChannel( [ 'a', 'b', 'c' ] )
ch3 = indexedChannel( [ 1, 2, 3 ] )

ch1
    .join( ch2 )
    .join( ch3 )
    .view()
结果:

[0, 15, a, 1]
[1, 20, b, 2]
[2, 21, c, 3]
但是,两个通道的合并/连接不需要枚举。只需使用:


这是我最后的解决方案:```files.map{items->items.withIndex()}.flant().collate(2.map{item,idx->tuple(idx+1,item)}.collectFile(storeDir:$SCRATCH/intermediate”){item->[“data${item[0]}.csv”,item[1].text]}``谢谢您的帮助:)
def c = 1
Channel
    .fromPath( './data/*.txt' )
    .map { tuple( it, c++ ) }
    .collectFile(storeDir: "$SCRATCH/intermediate") { fn, count ->
        ["data${count}.csv", fn.text]
    }