Create channel of FASTQ file paths by parsing a CSV file

1,158 views
Skip to first unread message

James Ashmore

unread,
May 24, 2016, 1:03:46 PM5/24/16
to Nextflow
I want to read a column from a text file which contains the paths to all of my FASTQ files. I then want to run each of these files through the various processes in my pipeline. I think I've successfully created the channel, but I am getting an error when I try and run the check process:

Script:

#!/usr/bin/env nextflow

designFile
= file("design.tsv")
fastqChannel
= Channel
                   
.from(designFile)
                   
.splitCsv(header: true)
                   
.subscribe { row ->
                       println
"${row.fastq}"
                   
}

process check
{
    input
:
    file reads_fastq
from fastqChannel

    output
:
    file fastqc_html

    shell
:
   
"""
    fastqc ${reads_fastq}
    """

}

Output:

$ ./main.nf check
N E X T F L O W  
~  version 0.19.1
Launching ./main.nf
A
.fastq
B
.fastq
C
.fastq
[warm up] executor > local
ERROR
~ Channel `reads_fastq` has been used twice as an input by process `check` and another operator

 
-- Check script 'main.nf' at line: 11 or see '.nextflow.log' file for more details

Any help greatly appreciated,
James

Paolo Di Tommaso

unread,
May 24, 2016, 1:34:26 PM5/24/16
to nextflow
Hi, 

The problem in your example is that both the `subscribe` operator and the `check` process consume the same channel. 

To fix your example you can use the view operator in place of the subscribe. The main difference is that it implicitly creates a new channel that will be assigned to `fastqChannel`. For example: 


designFile = file("design.tsv")
fastqChannel = Channel
                   .from(designFile)
                   .splitCsv(header: true)
                   .view { row -> "${row.fastq}" }

process check {
    input:
    file reads_fastq from fastqChannel

    output:
    file fastqc_html

    shell:
    """
    fastqc ${reads_fastq}
    """
}


Hope it helps 

Paolo



--
You received this message because you are subscribed to the Google Groups "Nextflow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nextflow+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/nextflow.
For more options, visit https://groups.google.com/d/optout.

James Ashmore

unread,
May 26, 2016, 11:53:54 AM5/26/16
to Nextflow
Works fine now, thank you
Reply all
Reply to author
Forward
0 new messages