Skip to content

Commit

Permalink
Update WIPERTOOLS (#7300)
Browse files Browse the repository at this point in the history
* Refactor fastq and report variable names for consistency across wipertools modules

* Refactor variable names for consistency in fastq and report processing modules

* Update test assertions to reflect changes in output variable names in fastqwiper module

* Update test assertions to match changes in report output structure in fastqwiper tests
  • Loading branch information
mazzalab authored Jan 14, 2025
1 parent fb1f03c commit c9e9241
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 71 deletions.
14 changes: 7 additions & 7 deletions modules/nf-core/wipertools/fastqgather/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ process WIPERTOOLS_FASTQGATHER {
'biocontainers/wipertools:1.1.3--pyhdfd78af_0' }"

input:
tuple val(meta), path(fastq_in)
tuple val(meta), path(fastq)

output:
tuple val(meta), path("${prefix}.fastq.gz"), emit: fastq_out
tuple val(meta), path("${prefix}.fastq.gz"), emit: gathered_fastq
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}_gather"
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}_gather"

// Check if the output file name is in the list of input files
if (fastq_in.any { it.name == "${prefix}.fastq.gz" }) {
if (fastq.any { it.name == "${prefix}.fastq.gz" }) {
error 'Output file name "${prefix}.fastq.gz}" matches one of the input files. Use \"task.ext.prefix\" to disambiguate!.'
}

"""
wipertools \\
fastqgather \\
-i $fastq_in \\
-i $fastq \\
-o ${prefix}.fastq.gz \\
${args}
Expand All @@ -43,7 +43,7 @@ process WIPERTOOLS_FASTQGATHER {
prefix = task.ext.prefix ?: "${meta.id}_gather"

// Check if the output file name is in the list of input files
if (fastq_in.any { it.name == "${prefix}.fastq.gz" }) {
if (fastq.any { it.name == "${prefix}.fastq.gz" }) {
error 'Output file name "${prefix}.fastq.gz}" matches one of the input files. Use \"task.ext.prefix\" to disambiguate!.'
}
"""
Expand Down
7 changes: 3 additions & 4 deletions modules/nf-core/wipertools/fastqgather/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ keywords:
- union
tools:
- "fastqgather":
description:
"A tool of the wipertools suite that merges FASTQ chunks produced\
description: "A tool of the wipertools suite that merges FASTQ chunks produced\
\ by wipertools_fastqscatter."
homepage: "https://github.com/mazzalab/fastqwiper"
documentation: "https://github.com/mazzalab/fastqwiper"
Expand All @@ -24,15 +23,15 @@ input:
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- fastq_in:
- fastq:
type: file
description: List of FASTQ chunk files to be merged
pattern: "*.{fastq,fastq.gz}"
ontologies:
- edam: "http://edamontology.org/format_1930"
- edam: "http://edamontology.org/format_3989"
output:
- fastq_out:
- gathered_fastq:
- meta:
type: map
description: |
Expand Down
4 changes: 2 additions & 2 deletions modules/nf-core/wipertools/fastqgather/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ nextflow_process {
}
process {
"""
input[0] = WIPERTOOLS_FASTQSCATTER.out.chunks
input[0] = WIPERTOOLS_FASTQSCATTER.out.fastq_chunks
"""
}
}
Expand All @@ -56,7 +56,7 @@ nextflow_process {
}
process {
"""
input[0] = WIPERTOOLS_FASTQSCATTER.out.chunks
input[0] = WIPERTOOLS_FASTQSCATTER.out.fastq_chunks
"""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"1": [
"versions.yml:md5,291a2e6d58146bfcf57b4d9ef850cbd9"
],
"fastq_out": [
"gathered_fastq": [
[
{
"id": "fastq_chunks"
Expand All @@ -30,7 +30,7 @@
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-17T20:28:22.882325"
"timestamp": "2025-01-13T18:49:15.441781"
},
"merge two gzipped fastq - fastq.gz": {
"content": [
Expand All @@ -46,7 +46,7 @@
"1": [
"versions.yml:md5,291a2e6d58146bfcf57b4d9ef850cbd9"
],
"fastq_out": [
"gathered_fastq": [
[
{
"id": "fastq_chunks"
Expand All @@ -63,6 +63,6 @@
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-17T20:28:12.396668"
"timestamp": "2025-01-13T18:49:02.891972"
}
}
8 changes: 7 additions & 1 deletion modules/nf-core/wipertools/fastqscatter/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ process WIPERTOOLS_FASTQSCATTER {
val(num_splits)

output:
tuple val(meta), path("${out_folder}/*") , emit: chunks
tuple val(meta), path("${out_folder}/*") , emit: fastq_chunks
path "versions.yml" , emit: versions

when:
Expand All @@ -24,6 +24,9 @@ process WIPERTOOLS_FASTQSCATTER {
def args_list = args.tokenize()
out_folder = (args_list.contains('--out_folder') ? args_list[args_list.indexOf('--out_folder')+1] :
(args_list.contains('-o') ? args_list[args_list.indexOf('-o')+1] : 'chunks'))
if(!args.contains('-o') && !args.contains('--out_folder')) {
args += " -o ${out_folder}"
}
"""
wipertools \\
fastqscatter \\
Expand All @@ -44,6 +47,9 @@ process WIPERTOOLS_FASTQSCATTER {
def args_list = args.tokenize()
out_folder = (args_list.contains('--out_folder') ? args_list[args_list.indexOf('--out_folder')+1] :
(args_list.contains('-o') ? args_list[args_list.indexOf('-o')+1] : 'chunks'))
if(!args.contains('-o') && !args.contains('--out_folder')) {
args += " -o ${out_folder}"
}
"""
mkdir ${out_folder}
for i in {1..${num_splits}}
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/wipertools/fastqscatter/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ input:
pattern: "[1-9][0-9]*"

output:
- chunks:
- fastq_chunks:
- meta:
type: map
description: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"1": [
"versions.yml:md5,c8e701c1048cc9ab79752d1bf631ad4b"
],
"chunks": [
"fastq_chunks": [
[
{
"id": "test"
Expand All @@ -36,7 +36,7 @@
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-17T20:28:32.330894"
"timestamp": "2025-01-13T18:41:58.317846"
},
"3 reads, one truncated - fastq - stub": {
"content": [
Expand All @@ -55,7 +55,7 @@
"1": [
"versions.yml:md5,c8e701c1048cc9ab79752d1bf631ad4b"
],
"chunks": [
"fastq_chunks": [
[
{
"id": "test"
Expand All @@ -75,6 +75,6 @@
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-17T20:28:41.304878"
"timestamp": "2025-01-13T18:42:09.268891"
}
}
12 changes: 6 additions & 6 deletions modules/nf-core/wipertools/fastqwiper/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ process WIPERTOOLS_FASTQWIPER {
'biocontainers/wipertools:1.1.3--pyhdfd78af_0' }"

input:
tuple val(meta), path(fastq_in)
tuple val(meta), path(fastq)

output:
tuple val(meta), path("${prefix}.fastq.gz"), emit: fastq_out
path("*.report") , emit: report
tuple val(meta), path("${prefix}.fastq.gz"), emit: wiped_fastq
tuple val(meta), path("*.report") , emit: report
path "versions.yml" , emit: versions

when:
Expand All @@ -21,11 +21,11 @@ process WIPERTOOLS_FASTQWIPER {
script:
def args = task.ext.args ?: ''
prefix = task.ext.prefix ?: "${meta.id}_wiped"
if ("${fastq_in}" == "${prefix}.fastq.gz") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!."
if ("${fastq}" == "${prefix}.fastq.gz") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!."
"""
wipertools \\
fastqwiper \\
-i ${fastq_in} \\
-i ${fastq} \\
-o ${prefix}.fastq.gz \\
-r ${prefix}.report \\
${args}
Expand All @@ -38,7 +38,7 @@ process WIPERTOOLS_FASTQWIPER {

stub:
prefix = task.ext.prefix ?: "${meta.id}_wiped"
if ("${fastq_in}" == "${prefix}.fastq.gz") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!."
if ("${fastq}" == "${prefix}.fastq.gz") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!."
"""
echo "" | gzip > ${prefix}.fastq.gz
touch ${prefix}.report
Expand Down
9 changes: 7 additions & 2 deletions modules/nf-core/wipertools/fastqwiper/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ input:
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- fastq_in:
- fastq:
type: file
description: FASTQ file to be cleaned
pattern: "*.{fastq,fastq.gz}"
ontologies:
- edam: "http://edamontology.org/format_1930"
- edam: "http://edamontology.org/format_3989"
output:
- fastq_out:
- wiped_fastq:
- meta:
type: map
description: |
Expand All @@ -45,6 +45,11 @@ output:
- edam: "http://edamontology.org/format_1930"
- edam: "http://edamontology.org/format_3989"
- report:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test' ]
- "*.report":
type: file
description: Summary of the cleaning task
Expand Down
10 changes: 5 additions & 5 deletions modules/nf-core/wipertools/fastqwiper/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert path(process.out.fastq_out.get(0).get(1)).linesGzip.size() == 8},
{ assert path(process.out.wiped_fastq.get(0).get(1)).linesGzip.size() == 8},
{
def read_final_qual = path(process.out.fastq_out.get(0).get(1)).linesGzip[7]
def read_final_qual = path(process.out.wiped_fastq.get(0).get(1)).linesGzip[7]
assert read_final_qual.equals('CCCCCGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG')
},
{ assert path(process.out.report.get(0)).readLines().size() == 11},
{ assert path(process.out.report.get(0).get(1)).readLines().size() == 11},
{
def report_header = path(process.out.report.get(0)).readLines()[0]
def report_header = path(process.out.report.get(0).get(1)).readLines()[0]
assert report_header.equals('FASTQWIPER REPORT:')
},
{
def qual_check = path(process.out.report.get(0)).readLines()[9]
def qual_check = path(process.out.report.get(0).get(1)).readLines()[9]
assert qual_check.equals('Reads discarded because len(SEQ) neq len(QUAL): 1')
},
{ assert snapshot(process.out).match() }
Expand Down
48 changes: 34 additions & 14 deletions modules/nf-core/wipertools/fastqwiper/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,42 @@
]
],
"1": [
"test_wiped.report:md5,d41d8cd98f00b204e9800998ecf8427e"
[
{
"id": "test"
},
"test_wiped.report:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"2": [
"versions.yml:md5,0a814cc53368590314bd01d1b433b6fd"
],
"fastq_out": [
"report": [
[
{
"id": "test"
},
"test_wiped.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
"test_wiped.report:md5,d41d8cd98f00b204e9800998ecf8427e"
]
],
"report": [
"test_wiped.report:md5,d41d8cd98f00b204e9800998ecf8427e"
],
"versions": [
"versions.yml:md5,0a814cc53368590314bd01d1b433b6fd"
],
"wiped_fastq": [
[
{
"id": "test"
},
"test_wiped.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
]
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-17T20:29:03.969824"
"timestamp": "2025-01-13T18:52:39.908974"
},
"Quality mismatch - fastq": {
"content": [
Expand All @@ -50,31 +60,41 @@
]
],
"1": [
"test_wiped.report:md5,d6fe1f0066f538993bb8f6b90150c8d5"
[
{
"id": "test"
},
"test_wiped.report:md5,d6fe1f0066f538993bb8f6b90150c8d5"
]
],
"2": [
"versions.yml:md5,0a814cc53368590314bd01d1b433b6fd"
],
"fastq_out": [
"report": [
[
{
"id": "test"
},
"test_wiped.fastq.gz:md5,81b1d99cf5c1615123a8c31760858a10"
"test_wiped.report:md5,d6fe1f0066f538993bb8f6b90150c8d5"
]
],
"report": [
"test_wiped.report:md5,d6fe1f0066f538993bb8f6b90150c8d5"
],
"versions": [
"versions.yml:md5,0a814cc53368590314bd01d1b433b6fd"
],
"wiped_fastq": [
[
{
"id": "test"
},
"test_wiped.fastq.gz:md5,81b1d99cf5c1615123a8c31760858a10"
]
]
}
],
"meta": {
"nf-test": "0.9.2",
"nextflow": "24.10.3"
},
"timestamp": "2024-12-17T20:28:53.747935"
"timestamp": "2025-01-13T18:52:27.962146"
}
}
Loading

0 comments on commit c9e9241

Please sign in to comment.