diff --git a/modules/nf-core/trimmomatic/main.nf b/modules/nf-core/trimmomatic/main.nf index 31f7ffdd422..13fe8b6ee7a 100644 --- a/modules/nf-core/trimmomatic/main.nf +++ b/modules/nf-core/trimmomatic/main.nf @@ -12,8 +12,9 @@ process TRIMMOMATIC { output: tuple val(meta), path("*.paired.trim*.fastq.gz") , emit: trimmed_reads - tuple val(meta), path("*.unpaired.trim_*.fastq.gz"), optional:true, emit: unpaired_reads - tuple val(meta), path("*.log") , emit: log + tuple val(meta), path("*.unpaired.trim_*.fastq.gz"), emit: unpaired_reads, optional:true + tuple val(meta), path("*_trim.log") , emit: trim_log + tuple val(meta), path("*_out.log") , emit: out_log tuple val(meta), path("*.summary") , emit: summary path "versions.yml" , emit: versions @@ -27,22 +28,46 @@ process TRIMMOMATIC { def output = meta.single_end ? "${prefix}.SE.paired.trim.fastq.gz" // HACK to avoid unpaired and paired in the trimmed_reads output : "${prefix}.paired.trim_1.fastq.gz ${prefix}.unpaired.trim_1.fastq.gz ${prefix}.paired.trim_2.fastq.gz ${prefix}.unpaired.trim_2.fastq.gz" - // TODO Give better error output def qual_trim = task.ext.args2 ?: '' """ trimmomatic \\ $trimmed \\ -threads $task.cpus \\ - -trimlog ${prefix}.log \\ + -trimlog ${prefix}_trim.log \\ -summary ${prefix}.summary \\ $reads \\ $output \\ $qual_trim \\ - $args + $args 2> >(tee ${prefix}_out.log >&2) cat <<-END_VERSIONS > versions.yml "${task.process}": trimmomatic: \$(trimmomatic -version) END_VERSIONS """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + + if (meta.single_end) { + output_command = "echo '' | gzip > ${prefix}.SE.paired.trim.fastq.gz" + } else { + output_command = "echo '' | gzip > ${prefix}.paired.trim_1.fastq.gz" + output_command = "echo '' | gzip > ${prefix}.paired.trim_2.fastq.gz" + output_command += "echo '' | gzip > ${prefix}.unpaired.trim_1.fastq.gz" + output_command += "echo '' | gzip > ${prefix}.unpaired.trim_2.fastq.gz" + } + + """ + $output_command + touch ${prefix}.summary + touch ${prefix}_trim.log + touch ${prefix}_out.log + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + trimmomatic: \$(trimmomatic -version) + END_VERSIONS + """ + } diff --git a/modules/nf-core/trimmomatic/meta.yml b/modules/nf-core/trimmomatic/meta.yml index 0486e9f5756..2d38bf50f39 100644 --- a/modules/nf-core/trimmomatic/meta.yml +++ b/modules/nf-core/trimmomatic/meta.yml @@ -10,7 +10,7 @@ tools: homepage: "http://www.usadellab.org/cms/?page=trimmomatic" documentation: "https://github.com/usadellab/Trimmomatic" doi: "10.1093/bioinformatics/btu170" - licence: "['GPL v3']" + licence: ["GPL v3"] input: - meta: type: map @@ -36,9 +36,13 @@ output: type: file description: The trimmed/modified unpaired end fastq reads pattern: "*.unpaired.trim_*.fastq.gz" - - log: + - trim_log: type: file - description: trimmomatic log file + description: trimmomatic log file, from the trim_log parameter + pattern: "*.log" + - out_log: + type: file + description: log of output from the standard out pattern: "*.log" - summary: type: file diff --git a/modules/nf-core/trimmomatic/tests/main.nf.test b/modules/nf-core/trimmomatic/tests/main.nf.test index fd855f25a65..d835c4c48b9 100644 --- a/modules/nf-core/trimmomatic/tests/main.nf.test +++ b/modules/nf-core/trimmomatic/tests/main.nf.test @@ -10,9 +10,6 @@ nextflow_process { test("Single-Read") { config "./nextflow_SE.config" when { - params { - outdir = "$outputDir" - } process { """ input[0] = [ @@ -30,8 +27,12 @@ nextflow_process { { assert process.success }, { assert process.out.trimmed_reads != null }, { assert process.out.trimmed_reads.get(0).get(1) ==~ ".*.SE.paired.trim.fastq.gz" }, - { assert snapshot(process.out.versions).match("versions") }, - { assert snapshot(process.out).match() } + { assert process.out.out_log.get(0).get(1) ==~ ".*.log" }, + { assert snapshot(process.out.trimmed_reads, + process.out.trim_log, + process.out.summary, + process.out.versions + ).match() } ) } } @@ -39,9 +40,6 @@ nextflow_process { test("Paired-Reads") { config "./nextflow_PE.config" when { - params { - outdir = "$outputDir" - } process { """ input[0] = [ @@ -61,8 +59,12 @@ nextflow_process { { assert process.out.trimmed_reads != null }, { assert process.out.trimmed_reads.get(0).get(1).get(0) ==~ ".*.paired.trim_1.fastq.gz" }, { assert process.out.trimmed_reads.get(0).get(1).get(1) ==~ ".*.paired.trim_2.fastq.gz" }, - { assert snapshot(process.out).match() }, - { assert snapshot(process.out.versions).match("versions") }, + { assert process.out.out_log.get(0).get(1) ==~ ".*.log" }, + { assert snapshot(process.out.trimmed_reads, + process.out.trim_log, + process.out.summary, + process.out.versions + ).match() } ) } } @@ -70,9 +72,6 @@ nextflow_process { test("No Adaptors") { when { - params { - outdir = "$outputDir" - } process { """ input[0] = [ @@ -92,4 +91,28 @@ nextflow_process { ) } } + + test("Single-Read - stub") { + options "-stub" + when { + process { + """ + input[0] = [ + [ id: 'test', single_end:true ], + [ + file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true) + ] + ] + """ + } + } + + then { + assertAll ( + { assert process.success }, + { assert snapshot(process.out).match() } + ) + } + } + } \ No newline at end of file diff --git a/modules/nf-core/trimmomatic/tests/main.nf.test.snap b/modules/nf-core/trimmomatic/tests/main.nf.test.snap index f1519f0cdfb..5e9ec050b9e 100644 --- a/modules/nf-core/trimmomatic/tests/main.nf.test.snap +++ b/modules/nf-core/trimmomatic/tests/main.nf.test.snap @@ -1,13 +1,5 @@ { - "versions": { - "content": [ - [ - "versions.yml:md5,14413a048f088a147fb04f3d59c6c604" - ] - ], - "timestamp": "2023-10-18T12:15:39.464478" - }, - "Single-Read": { + "Single-Read - stub": { "content": [ { "0": [ @@ -16,7 +8,7 @@ "id": "test", "single_end": true }, - "test.SE.paired.trim.fastq.gz:md5,089a57f61d7197566b8a3ce71df79113" + "test.SE.paired.trim.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" ] ], "1": [ @@ -28,7 +20,7 @@ "id": "test", "single_end": true }, - "test.log:md5,e4c3f619e9b0e26847f8f3e3d9af319b" + "test_trim.log:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "3": [ @@ -37,144 +29,150 @@ "id": "test", "single_end": true }, - "test.summary:md5,24c973237557a1439c775ca19a5deaa5" + "test_out.log:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "4": [ - "versions.yml:md5,14413a048f088a147fb04f3d59c6c604" - ], - "log": [ - [ - { - "id": "test", - "single_end": true - }, - "test.log:md5,e4c3f619e9b0e26847f8f3e3d9af319b" - ] - ], - "summary": [ - [ - { - "id": "test", - "single_end": true - }, - "test.summary:md5,24c973237557a1439c775ca19a5deaa5" - ] - ], - "trimmed_reads": [ [ { "id": "test", "single_end": true }, - "test.SE.paired.trim.fastq.gz:md5,089a57f61d7197566b8a3ce71df79113" + "test.summary:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], - "unpaired_reads": [ - - ], - "versions": [ + "5": [ "versions.yml:md5,14413a048f088a147fb04f3d59c6c604" - ] - } - ], - "timestamp": "2023-10-18T12:15:39.471788" - }, - "Paired-Reads": { - "content": [ - { - "0": [ - [ - { - "id": "test", - "single_end": false - }, - [ - "test.paired.trim_1.fastq.gz:md5,575355b98cb5ef9071fad8014c702f4a", - "test.paired.trim_2.fastq.gz:md5,73fb54874d01b2854640266d12cc534a" - ] - ] - ], - "1": [ - [ - { - "id": "test", - "single_end": false - }, - [ - "test.unpaired.trim_1.fastq.gz:md5,2f7b5a15cc4e73a6fb4af1fa01f575cd", - "test.unpaired.trim_2.fastq.gz:md5,096ad7f876b6b704ef7f9f2c5af3cf74" - ] - ] - ], - "2": [ - [ - { - "id": "test", - "single_end": false - }, - "test.log:md5,9629761761a34576b3484bf4174f681f" - ] ], - "3": [ + "out_log": [ [ { "id": "test", - "single_end": false + "single_end": true }, - "test.summary:md5,9698e5e5c060bbe64588998fe35f8d71" + "test_out.log:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], - "4": [ - "versions.yml:md5,14413a048f088a147fb04f3d59c6c604" - ], - "log": [ + "summary": [ [ { "id": "test", - "single_end": false + "single_end": true }, - "test.log:md5,9629761761a34576b3484bf4174f681f" + "test.summary:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], - "summary": [ + "trim_log": [ [ { "id": "test", - "single_end": false + "single_end": true }, - "test.summary:md5,9698e5e5c060bbe64588998fe35f8d71" + "test_trim.log:md5,d41d8cd98f00b204e9800998ecf8427e" ] ], "trimmed_reads": [ [ { "id": "test", - "single_end": false + "single_end": true }, - [ - "test.paired.trim_1.fastq.gz:md5,575355b98cb5ef9071fad8014c702f4a", - "test.paired.trim_2.fastq.gz:md5,73fb54874d01b2854640266d12cc534a" - ] + "test.SE.paired.trim.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940" ] ], "unpaired_reads": [ - [ - { - "id": "test", - "single_end": false - }, - [ - "test.unpaired.trim_1.fastq.gz:md5,2f7b5a15cc4e73a6fb4af1fa01f575cd", - "test.unpaired.trim_2.fastq.gz:md5,096ad7f876b6b704ef7f9f2c5af3cf74" - ] - ] + ], "versions": [ "versions.yml:md5,14413a048f088a147fb04f3d59c6c604" ] } ], - "timestamp": "2023-10-18T12:15:44.677305" + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.2" + }, + "timestamp": "2024-06-26T21:50:12.135007267" + }, + "Single-Read": { + "content": [ + [ + [ + { + "id": "test", + "single_end": true + }, + "test.SE.paired.trim.fastq.gz:md5,e68abbd3b88f7ec12940a4f5c2b8bfb9" + ] + ], + [ + [ + { + "id": "test", + "single_end": true + }, + "test_trim.log:md5,e4c3f619e9b0e26847f8f3e3d9af319b" + ] + ], + [ + [ + { + "id": "test", + "single_end": true + }, + "test.summary:md5,24c973237557a1439c775ca19a5deaa5" + ] + ], + [ + "versions.yml:md5,14413a048f088a147fb04f3d59c6c604" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.2" + }, + "timestamp": "2024-06-26T21:56:07.085100348" + }, + "Paired-Reads": { + "content": [ + [ + [ + { + "id": "test", + "single_end": false + }, + [ + "test.paired.trim_1.fastq.gz:md5,a866e64f451745f176316d0df7d52b30", + "test.paired.trim_2.fastq.gz:md5,725d4ab909b39291ab56b090cab32075" + ] + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test_trim.log:md5,9629761761a34576b3484bf4174f681f" + ] + ], + [ + [ + { + "id": "test", + "single_end": false + }, + "test.summary:md5,9698e5e5c060bbe64588998fe35f8d71" + ] + ], + [ + "versions.yml:md5,14413a048f088a147fb04f3d59c6c604" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.2" + }, + "timestamp": "2024-06-26T21:56:18.779303181" } } \ No newline at end of file