Skip to content

Commit c2e58b8

Browse files
LouisLeNezetLouisLeNezetSPPearce
authored
Migrate khmer/normalizebymedian to nf-test (#8357)
* Migrate to nf-test * Update script * Update meta * Update modules/nf-core/khmer/normalizebymedian/main.nf Co-authored-by: Simon Pearce <[email protected]> * Update modules/nf-core/khmer/normalizebymedian/main.nf Co-authored-by: Simon Pearce <[email protected]> --------- Co-authored-by: LouisLeNezet <[email protected]> Co-authored-by: Simon Pearce <[email protected]>
1 parent 712d3f4 commit c2e58b8

File tree

9 files changed

+337
-159
lines changed

9 files changed

+337
-159
lines changed
Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
process KHMER_NORMALIZEBYMEDIAN {
2-
tag "${name}"
2+
tag "${meta.id}"
33
label 'process_long'
44

55
conda "${moduleDir}/environment.yml"
@@ -8,34 +8,45 @@ process KHMER_NORMALIZEBYMEDIAN {
88
'biocontainers/khmer:3.0.0a3--py37haa7609a_2' }"
99

1010
input:
11-
path pe_reads
12-
path se_reads
13-
val name
11+
tuple val(meta), path(fastq_paired), path(fastq_unpaired)
1412

1513
output:
16-
path "${name}.fastq.gz", emit: reads
17-
path "versions.yml" , emit: versions
14+
tuple val(meta), path("*.fastq.gz"), emit: reads
15+
path "versions.yml" , emit: versions
1816

1917
when:
2018
task.ext.when == null || task.ext.when
2119

2220
script:
23-
def args = task.ext.args ?: ''
24-
pe_args = pe_reads ? "--paired" : ""
25-
se_args = se_reads ? "--unpaired-reads ${se_reads}" : ""
26-
files = pe_reads ? pe_reads : se_reads
21+
def args = task.ext.args ?: ''
22+
def prefix = task.ext.prefix ?: "${meta.id}_normalized"
23+
assert "${prefix}.fastq.gz" != fastq_paired.name : "KHMER_NORMALIZEBYMEDIAN: The output file name must be different from the input file name. Please set a different prefix."
24+
assert "${prefix}.fastq.gz" != fastq_unpaired.name : "KHMER_NORMALIZEBYMEDIAN: The output file name must be different from the input file name. Please set a different prefix."
25+
def paired = fastq_paired ? "--paired" : ""
26+
def unpaired = fastq_unpaired ? "--unpaired ${fastq_unpaired}" : ""
27+
def input_sequence_filename = fastq_paired ? fastq_paired : fastq_unpaired
2728
"""
2829
normalize-by-median.py \\
2930
-M ${task.memory.toGiga()}e9 \\
3031
--gzip $args \\
31-
-o ${name}.fastq.gz \\
32-
$pe_args \\
33-
$se_args \\
34-
$files
32+
-o ${prefix}.fastq.gz \\
33+
${paired} \\
34+
${unpaired} \\
35+
${input_sequence_filename}
3536
3637
cat <<-END_VERSIONS > versions.yml
3738
"${task.process}":
3839
khmer: \$( normalize-by-median.py --version 2>&1 | grep ^khmer | sed 's/^khmer //' )
3940
END_VERSIONS
4041
"""
42+
43+
stub:
44+
def prefix = task.ext.prefix ?: "${meta.id}_normalized"
45+
"""
46+
echo "" | gzip > ${prefix}.fastq.gz
47+
cat <<-END_VERSIONS > versions.yml
48+
"${task.process}":
49+
khmer: \$( normalize-by-median.py --version 2>&1 | grep ^khmer | sed 's/^khmer //' )
50+
END_VERSIONS
51+
"""
4152
}

modules/nf-core/khmer/normalizebymedian/meta.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,27 @@ tools:
1616
licence: ["BSD License"]
1717
identifier: biotools:khmer
1818
input:
19-
- - pe_reads:
19+
- - meta:
20+
type: map
21+
description: |
22+
Groovy Map containing sample information
23+
e.g. [ id:'test', single_end:false ]
24+
- fastq_paired:
2025
type: file
2126
description: Paired-end interleaved fastq files
2227
pattern: "*.{fq,fastq}.gz"
23-
- - se_reads:
28+
- fastq_unpaired:
2429
type: file
2530
description: Single-end fastq files
2631
pattern: "*.{fq,fastq}.gz"
27-
- - name:
28-
type: string
29-
description: filename for output file(s); ".fastq.gz" will be appended
3032
output:
3133
- reads:
32-
- ${name}.fastq.gz:
34+
- meta:
35+
type: map
36+
description: |
37+
Groovy Map containing sample information
38+
e.g. [ id:'test', single_end:false ]
39+
- "*.fastq.gz":
3340
type: file
3441
description: Interleaved fastq files
3542
pattern: "*.{fq,fastq}.gz"
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
nextflow_process {
2+
3+
name "Test Process KHMER_NORMALIZEBYMEDIAN"
4+
config "./nextflow.config"
5+
script "../main.nf"
6+
process "KHMER_NORMALIZEBYMEDIAN"
7+
8+
tag "modules"
9+
tag "modules_nfcore"
10+
tag "seqtk"
11+
tag "seqtk/mergepe"
12+
tag "khmer"
13+
tag "khmer/normalizebymedian"
14+
15+
test("sarscov2 - fastq - only_pe") {
16+
setup {
17+
run("SEQTK_MERGEPE") {
18+
script "../../../seqtk/mergepe/main.nf"
19+
20+
process {
21+
"""
22+
input[0] = [
23+
[id:'test', single_end:false],
24+
[
25+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true),
26+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists:true)
27+
]
28+
]
29+
"""
30+
}
31+
}
32+
}
33+
when {
34+
params {
35+
module_args = ''
36+
module_prefix = 'only_pe'
37+
}
38+
process {
39+
"""
40+
input[0] = SEQTK_MERGEPE.out.reads.combine(Channel.of([[]]))
41+
"""
42+
}
43+
}
44+
then {
45+
assertAll(
46+
{ assert process.success },
47+
{ assert snapshot(process.out).match() }
48+
)
49+
}
50+
}
51+
test("sarscov2 - fastq - only_se") {
52+
when {
53+
params {
54+
module_args = '-C 20 -k 32'
55+
module_prefix = 'only_se'
56+
}
57+
process {
58+
"""
59+
input[0] = [
60+
[id:'only_se'],
61+
[],
62+
[
63+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true)
64+
]
65+
]
66+
"""
67+
}
68+
}
69+
then {
70+
assertAll(
71+
{ assert process.success },
72+
{ assert snapshot(process.out).match() }
73+
)
74+
}
75+
}
76+
test("sarscov2 - fastq - mixed") {
77+
setup {
78+
run("SEQTK_MERGEPE") {
79+
script "../../../seqtk/mergepe/main.nf"
80+
81+
process {
82+
"""
83+
input[0] = [
84+
[id:'khmer_test0', single_end:false],
85+
[
86+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true),
87+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists:true)
88+
],
89+
[id:'khmer_test1', single_end:false],
90+
[
91+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true),
92+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_2.fastq.gz', checkIfExists:true)
93+
]
94+
]
95+
"""
96+
}
97+
}
98+
}
99+
when {
100+
params {
101+
module_args = ''
102+
module_prefix = 'mixed'
103+
}
104+
process {
105+
"""
106+
input[0] = SEQTK_MERGEPE.out.reads
107+
.combine([
108+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true)
109+
])
110+
"""
111+
}
112+
}
113+
then {
114+
assertAll(
115+
{ assert process.success },
116+
{ assert snapshot(process.out).match() }
117+
)
118+
}
119+
}
120+
121+
test("sarscov2 - fastq -- stub") {
122+
options '-stub'
123+
when {
124+
params {
125+
module_args = ''
126+
module_prefix = 'stub'
127+
}
128+
process {
129+
"""
130+
input[0] = [
131+
[id:'test'],
132+
[],
133+
[
134+
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/fastq/test_1.fastq.gz', checkIfExists:true)
135+
]
136+
]
137+
"""
138+
}
139+
}
140+
then {
141+
assertAll(
142+
{ assert process.success },
143+
{ assert snapshot(
144+
process.out,
145+
path(process.out.versions[0]).yaml
146+
).match() }
147+
)
148+
}
149+
}
150+
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
{
2+
"sarscov2 - fastq - mixed": {
3+
"content": [
4+
{
5+
"0": [
6+
[
7+
{
8+
"id": "khmer_test0",
9+
"single_end": false
10+
},
11+
"mixed.fastq.gz:md5,d05f6edff80d5cd8a891a4c3f4e1f9ff"
12+
]
13+
],
14+
"1": [
15+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
16+
],
17+
"reads": [
18+
[
19+
{
20+
"id": "khmer_test0",
21+
"single_end": false
22+
},
23+
"mixed.fastq.gz:md5,d05f6edff80d5cd8a891a4c3f4e1f9ff"
24+
]
25+
],
26+
"versions": [
27+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
28+
]
29+
}
30+
],
31+
"meta": {
32+
"nf-test": "0.9.2",
33+
"nextflow": "24.10.5"
34+
},
35+
"timestamp": "2025-04-24T10:29:39.888495732"
36+
},
37+
"sarscov2 - fastq - only_pe": {
38+
"content": [
39+
{
40+
"0": [
41+
[
42+
{
43+
"id": "test",
44+
"single_end": false
45+
},
46+
"only_pe.fastq.gz:md5,efe40fe3df38b5a1c469890e5ad19874"
47+
]
48+
],
49+
"1": [
50+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
51+
],
52+
"reads": [
53+
[
54+
{
55+
"id": "test",
56+
"single_end": false
57+
},
58+
"only_pe.fastq.gz:md5,efe40fe3df38b5a1c469890e5ad19874"
59+
]
60+
],
61+
"versions": [
62+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
63+
]
64+
}
65+
],
66+
"meta": {
67+
"nf-test": "0.9.2",
68+
"nextflow": "24.10.5"
69+
},
70+
"timestamp": "2025-04-24T10:29:23.184229887"
71+
},
72+
"sarscov2 - fastq - only_se": {
73+
"content": [
74+
{
75+
"0": [
76+
[
77+
{
78+
"id": "only_se"
79+
},
80+
"only_se.fastq.gz:md5,3ad9406595fafec8172368f9cd0b6a22"
81+
]
82+
],
83+
"1": [
84+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
85+
],
86+
"reads": [
87+
[
88+
{
89+
"id": "only_se"
90+
},
91+
"only_se.fastq.gz:md5,3ad9406595fafec8172368f9cd0b6a22"
92+
]
93+
],
94+
"versions": [
95+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
96+
]
97+
}
98+
],
99+
"meta": {
100+
"nf-test": "0.9.2",
101+
"nextflow": "24.10.5"
102+
},
103+
"timestamp": "2025-04-24T10:29:31.721379128"
104+
},
105+
"sarscov2 - fastq -- stub": {
106+
"content": [
107+
{
108+
"0": [
109+
[
110+
{
111+
"id": "test"
112+
},
113+
"stub.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
114+
]
115+
],
116+
"1": [
117+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
118+
],
119+
"reads": [
120+
[
121+
{
122+
"id": "test"
123+
},
124+
"stub.fastq.gz:md5,68b329da9893e34099c7d8ad5cb9c940"
125+
]
126+
],
127+
"versions": [
128+
"versions.yml:md5,d5a27634133040e2d93c1c54a30eb28e"
129+
]
130+
},
131+
{
132+
"KHMER_NORMALIZEBYMEDIAN": {
133+
"khmer": "3.0.0a3"
134+
}
135+
}
136+
],
137+
"meta": {
138+
"nf-test": "0.9.2",
139+
"nextflow": "24.10.5"
140+
},
141+
"timestamp": "2025-04-24T10:29:46.325233501"
142+
}
143+
}

0 commit comments

Comments
 (0)