diff --git a/modules/fastp/main.nf b/modules/fastp/main.nf index 6d703615..acba864a 100644 --- a/modules/fastp/main.nf +++ b/modules/fastp/main.nf @@ -20,6 +20,7 @@ process FASTP { input: tuple val(meta), path(reads) + val save_trimmed_fail output: tuple val(meta), path('*.trim.fastq.gz'), emit: reads @@ -34,7 +35,7 @@ process FASTP { def software = getSoftwareName(task.process) def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}" if (meta.single_end) { - def fail_fastq = params.save_trimmed_fail ? "--failed_out ${prefix}.fail.fastq.gz" : '' + def fail_fastq = save_trimmed_fail ? "--failed_out ${prefix}.fail.fastq.gz" : '' """ [ ! -f ${prefix}.fastq.gz ] && ln -s $reads ${prefix}.fastq.gz fastp \\ @@ -49,7 +50,7 @@ process FASTP { echo \$(fastp --version 2>&1) | sed -e "s/fastp //g" > ${software}.version.txt """ } else { - def fail_fastq = params.save_trimmed_fail ? "--unpaired1 ${prefix}_1.fail.fastq.gz --unpaired2 ${prefix}_2.fail.fastq.gz" : '' + def fail_fastq = save_trimmed_fail ? "--unpaired1 ${prefix}_1.fail.fastq.gz --unpaired2 ${prefix}_2.fail.fastq.gz" : '' """ [ ! -f ${prefix}_1.fastq.gz ] && ln -s ${reads[0]} ${prefix}_1.fastq.gz [ ! -f ${prefix}_2.fastq.gz ] && ln -s ${reads[1]} ${prefix}_2.fastq.gz diff --git a/tests/modules/fastp/main.nf b/tests/modules/fastp/main.nf index 012f4c6c..f4129c09 100644 --- a/tests/modules/fastp/main.nf +++ b/tests/modules/fastp/main.nf @@ -11,8 +11,9 @@ workflow test_fastp_single_end { input = [ [ id:'test', single_end:true ], // meta map [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ] ] + save_trimmed_fail = false - FASTP ( input ) + FASTP ( input, save_trimmed_fail ) } // @@ -23,7 +24,32 @@ workflow test_fastp_paired_end { [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ] ] + save_trimmed_fail = false - FASTP ( input ) + FASTP ( input, save_trimmed_fail ) } +// +// Test with single-end data with saving trimming fails +// +workflow test_fastp_single_end_trim_fail { + input = [ [ id:'test', single_end:true ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) ] + ] + save_trimmed_fail = true + + FASTP ( input, save_trimmed_fail ) +} + +// +// Test with paired-end data with saving trimming fails +// +workflow test_fastp_paired_end_trim_fail { + input = [ [ id:'test', single_end:false ], // meta map + [ file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_2_fastq_gz'], checkIfExists: true) ] + ] + save_trimmed_fail = true + + FASTP ( input, save_trimmed_fail ) +} diff --git a/tests/modules/fastp/test.yml b/tests/modules/fastp/test.yml index eb9de964..a6e253af 100644 --- a/tests/modules/fastp/test.yml +++ b/tests/modules/fastp/test.yml @@ -36,3 +36,48 @@ md5sum: e2257263668dc8a75d95475099fb472d - path: output/fastp/test_2.trim.fastq.gz md5sum: 9eff7203596580cc5e42aceab4a469df + +- name: fastp test_fastp_single_end_trim_fail + command: nextflow run tests/modules/fastp -entry test_fastp_single_end_trim_fail -c tests/config/nextflow.config + tags: + - fastp + files: + - path: output/fastp/test.fastp.html + contains: + - "Q20 bases: