Skip to content

Commit

Permalink
Adding input value-channel for controlling spring-decompress cmd and …
Browse files Browse the repository at this point in the history
…output (#5850)

* Enable single fastq.gz-output from spring/decompress by setting meta.single_end or meta.one_strand

* Controlling output with value-channel write_one_fastq_gz

* Update modules/nf-core/spring/decompress/meta.yml

Co-authored-by: Maxime U Garcia <[email protected]>

* nf-test for spring/decompress

* Trying to please linter

* Trying to please linter

---------

Co-authored-by: Simon Pearce <[email protected]>
Co-authored-by: Maxime U Garcia <[email protected]>
  • Loading branch information
3 people authored Jun 23, 2024
1 parent db35d26 commit 0a92fa8
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 6 deletions.
3 changes: 2 additions & 1 deletion modules/nf-core/spring/decompress/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ process SPRING_DECOMPRESS {

input:
tuple val(meta), path(spring)
val(write_one_fastq_gz)

output:
tuple val(meta), path("*.fastq.gz"), emit: fastq
Expand All @@ -21,7 +22,7 @@ process SPRING_DECOMPRESS {
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def VERSION = '1.1.1' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
def output = meta.single_end ? "-o ${prefix}.fastq.gz" : "-o ${prefix}_R1.fastq.gz ${prefix}_R2.fastq.gz"
def output = write_one_fastq_gz ? "-o ${prefix}.fastq.gz" : "-o ${prefix}_R1.fastq.gz ${prefix}_R2.fastq.gz"

"""
spring \\
Expand Down
7 changes: 6 additions & 1 deletion modules/nf-core/spring/decompress/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ tools:
documentation: "https://github.com/shubhamchandak94/Spring/blob/master/README.md"
tool_dev_url: "https://github.com/shubhamchandak94/Spring"
doi: "10.1093/bioinformatics/bty1015"
licence: "['Free for non-commercial use']"
licence: ["Free for non-commercial use"]
input:
- meta:
type: map
Expand All @@ -22,6 +22,11 @@ input:
type: file
description: Spring file to decompress.
pattern: "*.{spring}"
- write_one_fastq_gz:
type: boolean
description: |
Controls whether spring should write one fastq.gz file with reads from both directions or two fastq.gz files with reads from distinct directions
pattern: "true or false"
output:
- meta:
type: map
Expand Down
78 changes: 78 additions & 0 deletions modules/nf-core/spring/decompress/test/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
nextflow_process {

name "Test Process SPRING_DECOMPRESS"
tag "modules_nfcore"
tag "modules"
tag "spring"
tag "spring/decompress"
script "../main.nf"
process "SPRING_DECOMPRESS"

test("Write-One-File") {

setup {
run("SPRING_COMPRESS") {
script "../../compress/main.nf"
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.modules_testdata_base_path + '/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
[]
]
"""
}
}
}

when {
process {
"""
input[0] = SPRING_COMPRESS.out.spring
input[1] = true // write_one_fastq_gz
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}

test("Write-Two-Files") {

setup {
run("SPRING_COMPRESS") {
script "../../compress/main.nf"
process {
"""
input[0] = [
[ id:'test2' ], // meta map
file(params.modules_testdata_base_path + '/genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists: true),
file(params.modules_testdata_base_path + '/genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists: true),
]
"""
}
}
}

when {
process {
"""
input[0] = SPRING_COMPRESS.out.spring
input[1] = false // write_one_fastq_gz
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
74 changes: 74 additions & 0 deletions modules/nf-core/spring/decompress/test/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"Write-Two-Files": {
"content": [
{
"0": [
[
{
"id": "test2"
},
[
"test2_R1.fastq.gz:md5,4161df271f9bfcd25d5845a1e220dbec",
"test2_R2.fastq.gz:md5,2ebae722295ea66d84075a3b042e2b42"
]
]
],
"1": [
"versions.yml:md5,4711df5941f1464e3693d24dd29c705b"
],
"fastq": [
[
{
"id": "test2"
},
[
"test2_R1.fastq.gz:md5,4161df271f9bfcd25d5845a1e220dbec",
"test2_R2.fastq.gz:md5,2ebae722295ea66d84075a3b042e2b42"
]
]
],
"versions": [
"versions.yml:md5,4711df5941f1464e3693d24dd29c705b"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-21T13:41:46.090761471"
},
"Write-One-File": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.fastq.gz:md5,4161df271f9bfcd25d5845a1e220dbec"
]
],
"1": [
"versions.yml:md5,4711df5941f1464e3693d24dd29c705b"
],
"fastq": [
[
{
"id": "test"
},
"test.fastq.gz:md5,4161df271f9bfcd25d5845a1e220dbec"
]
],
"versions": [
"versions.yml:md5,4711df5941f1464e3693d24dd29c705b"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.2"
},
"timestamp": "2024-06-21T13:02:07.466039653"
}
}
5 changes: 5 additions & 0 deletions modules/nf-core/spring/decompress/test/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

}
3 changes: 3 additions & 0 deletions modules/nf-core/spring/decompress/test/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
spring/decompress:
- modules/nf-core/spring/compress/**
- modules/nf-core/spring/decompress/**
8 changes: 4 additions & 4 deletions tests/modules/nf-core/spring/decompress/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ include { SPRING_DECOMPRESS } from '../../../../../modules/nf-core/spring/decomp
workflow test_spring_decompress_single_end {

input = [
[ id:'test', single_end:true ], // meta map
[ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_1_fastq_gz'], checkIfExists: true),
[]
]

SPRING_COMPRESS ( input )
SPRING_DECOMPRESS ( SPRING_COMPRESS.out.spring )
SPRING_DECOMPRESS ( SPRING_COMPRESS.out.spring, true )
}

workflow test_spring_decompress_paired_end {

input = [
[ id:'test', single_end:false ], // meta map
[ id:'test' ], // 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)
]

SPRING_COMPRESS ( input )
SPRING_DECOMPRESS ( SPRING_COMPRESS.out.spring )
SPRING_DECOMPRESS ( SPRING_COMPRESS.out.spring, false )
}

0 comments on commit 0a92fa8

Please sign in to comment.