nextflow-io / nextflow-io/nextflow

splitFastq produces wrong number of outputs

Open
#3,216 13 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug lang/dataflow
Dominant language
Groovy
Stars
3.5k
Forks
811
Avg merge
2d 11h
Merged PRs (30d)
61

Description

Bug report

Expected behavior and actual behavior

Given a pair of fastq files from S3 with 171390646 reads, calling fastqChannel.splitFastq(by: params.chunkSize, pe: true, file: true) where chunkSize is 10000000, the operator does not create the correct number of output files.

Steps to reproduce the problem
#!/usr/bin/env nextflow 

nextflow.enable.dsl=2

process validate {
    input:
        path(fastqFiles)
    output:
        path("*.f*q*"), includeInputs: true, emit: fastqFiles
        stdout emit: logs
    shell:
    '''
    for f in !{fastqFiles}; do
        echo "${f}:"
        du -h $(realpath $f)
    done
    '''
}

workflow {
    fastqsChannel = Channel.fromPath(params.fastqFiles)
    validate(fastqsChannel)
    
    groupedFastqs = validate.out.fastqFiles
    .map {file -> 
        m = file =~ /.*\/([\w\d\-_]+)?[\-_]R?[1,2]/
        return tuple(m[0][1], file)
    }
    .groupTuple()
    .map { tuple(it[0], it[1][0], it[1][1]) }

    chunksChannel = groupedFastqs.splitFastq(by: params.chunkSize, pe: true, file: true)
    chunksChannel.subscribe { println "Created chunk ${it}"}
    chunksChannel.count().view { "Created ${it} chunks" }

}
Program output

Prints Created 1 chunks

Environment
  • Nextflow version: 22.09.3.edge build 5767
  • Java version:
  • Operating system: Linux
  • Bash version: (use the command $SHELL --version)
Additional context

I'm using AWS batch to test since the files are too big for me to test locally.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the splitFastq operator entry point and reproduce the paired-file case using the supplied DSL2 workflow; inspect how pe:true and file:true determine chunk output. Done means the channel emits the expected number of paired chunk files for 171390646 reads with chunkSize 10000000.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, groovy
Domain
cloud, data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.