Skip to content

Commit

Permalink
add dedicated output channel for trimmomatic stderr log (needed for m…
Browse files Browse the repository at this point in the history
…ultiqc) (#5501)

* created new output channel capturing stderr of trimmomatic

* updated output channel for trimmomatic

* Add stub test and update snapshots

* Add stub and update tests

* Fix linting and add tee

---------

Co-authored-by: John Palmer <john.palmer@bccdc.ca>
Co-authored-by: Simon Pearce <24893913+SPPearce@users.noreply.github.com>
Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
  • Loading branch information
4 people authored Jun 27, 2024
1 parent a7231cb commit 87b5dee
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 127 deletions.
35 changes: 30 additions & 5 deletions modules/nf-core/trimmomatic/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
"""

}
10 changes: 7 additions & 3 deletions modules/nf-core/trimmomatic/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
49 changes: 36 additions & 13 deletions modules/nf-core/trimmomatic/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ nextflow_process {
test("Single-Read") {
config "./nextflow_SE.config"
when {
params {
outdir = "$outputDir"
}
process {
"""
input[0] = [
Expand All @@ -30,18 +27,19 @@ 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() }
)
}
}

test("Paired-Reads") {
config "./nextflow_PE.config"
when {
params {
outdir = "$outputDir"
}
process {
"""
input[0] = [
Expand All @@ -61,18 +59,19 @@ 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() }
)
}
}

test("No Adaptors") {

when {
params {
outdir = "$outputDir"
}
process {
"""
input[0] = [
Expand All @@ -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() }
)
}
}

}
Loading

0 comments on commit 87b5dee

Please sign in to comment.