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:12.922000 K (92.984097%)" + - "single end (151 cycles)" + - path: output/fastp/test.fastp.log + contains: + - "Q20 bases: 12922(92.9841%)" + - "reads passed filter: 99" + - path: output/fastp/test.trim.fastq.gz + md5sum: e2257263668dc8a75d95475099fb472d + - path: output/fastp/test.fastp.json + md5sum: ee65a46d6e59fa556f112727b8a902ce + - path: output/fastp/test.fail.fastq.gz + md5sum: de315d397c994d8e66bafc7a8dc11070 + +- name: fastp test_fastp_paired_end_trim_fail + command: nextflow run tests/modules/fastp -entry test_fastp_paired_end_trim_fail -c tests/config/nextflow.config + tags: + - fastp + files: + - path: output/fastp/test.fastp.html + contains: + - "Q20 bases:25.719000 K (93.033098%)" + - "The input has little adapter percentage (~0.000000%), probably it's trimmed before." + - path: output/fastp/test.fastp.log + contains: + - "No adapter detected for read1" + - "Q30 bases: 12281(88.3716%)" + - path: output/fastp/test.fastp.json + contains: + - '"passed_filter_reads": 198' + - path: output/fastp/test_1.trim.fastq.gz + md5sum: e2257263668dc8a75d95475099fb472d + - path: output/fastp/test_2.trim.fastq.gz + md5sum: 9eff7203596580cc5e42aceab4a469df + - path: output/fastp/test_1.fail.fastq.gz + md5sum: e62ff0123a74adfc6903d59a449cbdb0 + - path: output/fastp/test_2.fail.fastq.gz + md5sum: f52309b35a7c15cbd56a9c3906ef98a5