How do i accept multiple file paths/globs in my channel?

hi, i want to accept multiple file paths in my channel. How do i do that?
This is my Samplesheet -

sample02,ord_02,sample02/*.fastq.gz,,s3://prod/fastq_sample02/sub01/*fastq.gz s3://prod/fastq_sample02/sub02/*fastq.gz

and this is my channel:

    .splitCsv(header: true)
    .map { row ->
        def sample = row.sample
        def orderid = row.orderid
        def fastqFiles = file(row.fastq_dir).collect()
        def frumFastqFiles = []
        if (row.frum_fastq_dir) {
            frumFastqFiles = files(row.frum_fastq_dir)
        tuple(sample, orderid, fastqFiles, frumFastqFiles)

When i run this, I am able to get the file paths for frum_fastq_dir in row1 but not in row2, instead it shows up as an empty list. How do i capture multiple globs/file patterns as shown in my example?

Hey, @bhanu_gandham. The trick here is to use channel operators to make it explicit the format you want for the multi-element field in your samplesheet. Let’s take a simpler version of the samplesheet you brought above, but with a third row with three files, to show how generic the solution is. What’s missing from your code is basically a split call (and making it clear they’re files).

sample02,ord_02,/Users/mribeirodantas/a.txt /Users/mribeirodantas/b.txt
sample03,ord_03,/Users/mribeirodantas/a.txt /Users/mribeirodantas/b.txt /Users/mribeirodantas/c.txt
process FOO {
  debug true

  tuple val(sample), val(orderid), path(my_files)


  cat ${my_files}

workflow {
    .splitCsv ( header: true, sep: ',')
    .map { it -> [sample:it['sample'], orderid:it['orderid'], frum_fastq_dir:it['frum_fastq_dir'].split(' ').collect { file(it) }] }
    | FOO

I have the strings first, second and third within the files a, b and c, respectively. You can view the output of the script below:

You can also inspect your work directory to see files being staged in the task directories.

awesome! thank you @mribeirodantas !!

1 Like