Nextflow 将文件加入元组

问题描述

我在使用 nextflow 时遇到问题,我有一个包含 3 个元素(id、fastq_File、out_file)的元组,我需要将一个文件加入到每个元组元素中(所有元组元素都使用相同的文件)。

首先我有一个 fastq,我把它分成块,然后用它们的 id 映射,在我有一个进程(例子中的简单进程)之后,但是这个进程返回了其他文件的 id。

reads = Channel.fromPath( 'data/illumina.fastq' )
.splitFastq(by: 150_000,file:true)

 reads.map { it -> [it.name -  ~/\.fastq/,it] }
            .into{tuple_reads ; tuple_reads2}

process pr1 { /*is an example my real process is more complex*/
echo true

input:
tuple val(id),path(file) from tuple_reads

output:
tuple val(id),file("example${id}.out") into example_test

script:
"""
echo example${id} > example${id}.out
"""
}

readss = tuple_reads2.join(example_test)

我加入频道并获得如下内容

[illumina.1,/home/qs/work/../illumina.1.fastq,/home/qs/work/../exampleillumina.1.out]
[illumina.2,/home/qs/work/../illumina.2.fastq,/home/qs/work/../exampleillumina.2.out]
[illumina.3,/home/qs/work/../illumina.3.fastq,/home/qs/work/../exampleillumina.3.out]

现在,我有一个包含我的 id、fastq 文件和进程 pr1 的输出的通道,这对我来说是完美的,但这就是现在的问题,我需要创建其他进程来运行静态文件。 我需要每个 id 与 static_file 一起运行,但我不知道如何做到这一点。我需要一个像这样的新频道:

[illumina.1,/home/qs/work/../exampleillumina.1.out,/home/qs/work/../static_file.txt]
[illumina.2,/home/qs/work/../exampleillumina.2.out,/home/qs/work/../static_file.txt]
[illumina.3,/home/qs/work/../exampleillumina.3.out,/home/qs/work/../static_file.txt]

或者我需要一个在每次运行时重复静态文件的进程。 下面的代码仅使用元组中的第一个元素运行 :( (我尝试了每个元素,但都不起作用。

process pr2 {
echo true

input:
  tuple val(id),path(fastq_file),path(out_file) from example_test
  path(st_file) from static_file

script:
"""
echo ${id} ${st_file}
"""
}

谢谢!!

解决方法

您只需要确保您的第二个频道(即您的静态文件的频道)是 value channel。您没有展示 static_file 通道是如何创建的,但是如果它是常规队列通道,您将获得所看到的行为,请参见此处:Understand how multiple input channels work。要修复您的示例,您只需要:

static_file = file(params.static)

process pr2 {

    echo true

    input:
    tuple val(id),path(fastq_file),path(out_file) from example_test
    path(st_file) from static_file

    script:
    """
    echo ${id} ${st_file}
    """
}

与以下相同:

static_file = file(params.static)

process pr2 {

    echo true

    input:
    tuple val(id),path(out_file) from example_test
    path static_file

    script:
    """
    echo ${id} ${static_file}
    """
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...