Skip to content

Commit f8e7eff

Browse files
committed
Set chunk prepare channel as function
1 parent 9368068 commit f8e7eff

File tree

6 files changed

+67
-164
lines changed

6 files changed

+67
-164
lines changed

subworkflows/local/chunk_prepare_channel/tests/main.nf.test.snap

Lines changed: 0 additions & 112 deletions
This file was deleted.

subworkflows/local/chunk_prepare_channel/tests/tags.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
workflow CHUNK_PREPARE_CHANNEL {
2-
3-
take:
4-
ch_chunks // channel: [ [id, chr], txt ]
5-
tool
6-
7-
main:
8-
1+
def chunkPrepareChannel(ch_chunks, tool) {
92
if(tool == "glimpse"){
103
ch_chunks = ch_chunks.map { chr, txt -> [chr, file(txt)]}
114
.splitCsv(header: ['ID', 'Chr', 'RegionIn', 'RegionOut', 'Size1', 'Size2'], sep: "\t", skip: 0)
@@ -20,8 +13,5 @@ workflow CHUNK_PREPARE_CHANNEL {
2013
} else {
2114
error "Only 'glimpse' and 'quilt' output format are supported. Got ${tool}"
2215
}
23-
24-
emit:
25-
chunks = ch_chunks // channel: [ [meta], regionstart, regionend ]
26-
16+
return ch_chunks // channel: [ [meta], regionstart, regionend ]
2717
}

workflows/phaseimpute/main.nf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ include { GAWK as FILTER_CHR_DWN } from '../../modules/nf-co
3232
include { VCF_NORMALIZE_BCFTOOLS } from '../../subworkflows/local/vcf_normalize_bcftools'
3333
include { VCF_SITES_EXTRACT_BCFTOOLS } from '../../subworkflows/local/vcf_sites_extract_bcftools'
3434
include { VCF_PHASE_SHAPEIT5 } from '../../subworkflows/local/vcf_phase_shapeit5'
35-
include { CHUNK_PREPARE_CHANNEL } from '../../subworkflows/local/chunk_prepare_channel'
3635
include { VCF_CONCATENATE_BCFTOOLS as CONCAT_PANEL } from '../../subworkflows/local/vcf_concatenate_bcftools'
3736
include { BCFTOOLS_STATS as BCFTOOLS_STATS_PANEL } from '../../modules/nf-core/bcftools/stats'
37+
include { chunkPrepareChannel } from './function.nf'
3838

3939
// Imputation
4040
include { LISTTOFILE } from '../../modules/local/listtofile'
@@ -291,8 +291,7 @@ workflow PHASEIMPUTE {
291291

292292
// Use chunks from parameters if provided or use previous chunks from panelprep
293293
if (params.chunks) {
294-
CHUNK_PREPARE_CHANNEL(ch_chunks, "glimpse")
295-
ch_chunks_glimpse1 = CHUNK_PREPARE_CHANNEL.out.chunks
294+
ch_chunks_glimpse1 = chunkPrepareChannel(ch_chunks, "glimpse")
296295
}
297296

298297
// Glimpse1 subworkflow
@@ -330,8 +329,7 @@ workflow PHASEIMPUTE {
330329
log.info("Impute with GLIMPSE2")
331330

332331
if (params.chunks) {
333-
CHUNK_PREPARE_CHANNEL(ch_chunks, "glimpse")
334-
ch_chunks_glimpse2 = CHUNK_PREPARE_CHANNEL.out.chunks
332+
ch_chunks_glimpse2 = chunkPrepareChannel(ch_chunks, "glimpse")
335333
}
336334

337335
// Run imputation
@@ -378,8 +376,7 @@ workflow PHASEIMPUTE {
378376

379377
// Use provided chunks if --chunks
380378
if (params.chunks) {
381-
CHUNK_PREPARE_CHANNEL(ch_chunks, "quilt")
382-
ch_chunks_quilt = CHUNK_PREPARE_CHANNEL.out.chunks
379+
ch_chunks_quilt = chunkPrepareChannel(ch_chunks, "quilt")
383380
}
384381

385382
// Impute BAMs with QUILT

subworkflows/local/chunk_prepare_channel/tests/main.nf.test renamed to workflows/phaseimpute/tests/function.nf.test

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
nextflow_workflow {
1+
nextflow_function {
2+
/*
3+
The following tests are for the functions in the main.nf script
4+
They are tested using the --verbose argument
5+
*/
26

3-
name "Test Subworkflow CHUNK_PREPARE_CHANNEL"
4-
script "../main.nf"
5-
6-
workflow "CHUNK_PREPARE_CHANNEL"
7-
8-
tag "subworkflows"
9-
tag "subworkflows_local"
10-
tag "subworkflows/chunk_prepare_channel"
11-
tag "chunk_prepare_channel"
7+
name "Test function phaseimpute"
8+
script "../function.nf"
9+
tag "function"
1210

1311
test("Prepare chunks channel Glimpse") {
12+
function "chunkPrepareChannel"
13+
tag "chunkPrepareChannel"
1414
when {
15-
params {
16-
max_cpus = 2
17-
max_memory = '2.GB'
18-
}
19-
workflow {
15+
function {
2016
"""
2117
input[0] = Channel.of([
2218
[id: "1000GP", chr: "chr21"],
@@ -29,19 +25,16 @@ nextflow_workflow {
2925

3026
then {
3127
assertAll(
32-
{ assert workflow.success },
33-
{ assert snapshot(workflow.out).match() },
28+
{ assert function.success }
3429
)
3530
}
3631
}
3732

3833
test("Prepare chunks channel Quilt") {
34+
function "chunkPrepareChannel"
35+
tag "chunkPrepareChannel"
3936
when {
40-
params {
41-
max_cpus = 2
42-
max_memory = '2.GB'
43-
}
44-
workflow {
37+
function {
4538
"""
4639
input[0] = Channel.of([
4740
[id: "1000GP", chr: "chr21"],
@@ -54,19 +47,16 @@ nextflow_workflow {
5447

5548
then {
5649
assertAll(
57-
{ assert workflow.success },
58-
{ assert snapshot(workflow.out).match() },
50+
{ assert function.success }
5951
)
6052
}
6153
}
6254

6355
test("Prepare chunks channel error tool") {
56+
function "chunkPrepareChannel"
57+
tag "chunkPrepareChannel"
6458
when {
65-
params {
66-
max_cpus = 2
67-
max_memory = '2.GB'
68-
}
69-
workflow {
59+
function {
7060
"""
7161
input[0] = Channel.of([
7262
[id: "1000GP", chr: "chr21"],
@@ -79,8 +69,8 @@ nextflow_workflow {
7969

8070
then {
8171
assertAll(
82-
{ assert workflow.failed },
83-
{ assert snapshot(workflow.stdout).match() }
72+
{ assert function.failed },
73+
{ assert function.stdout.contains("Only 'glimpse' and 'quilt' output format are supported. Got glimpse2") }
8474
)
8575
}
8676
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"Prepare chunks channel Quilt": {
3+
"content": [
4+
{
5+
6+
}
7+
],
8+
"meta": {
9+
"nf-test": "0.9.1",
10+
"nextflow": "24.10.4"
11+
},
12+
"timestamp": "2025-03-03T16:53:24.615848886"
13+
},
14+
"Prepare chunks channel error tool": {
15+
"content": [
16+
[
17+
"N E X T F L O W ~ version 24.10.4",
18+
"Launching `/home/llenezet/repositories/phaseimpute/.nf-test-dd0d5421ca2fe0df9ae90be137523768.nf` [scruffy_fermat] DSL2 - revision: d78e86493b",
19+
"Only 'glimpse' and 'quilt' output format are supported. Got glimpse2"
20+
]
21+
],
22+
"meta": {
23+
"nf-test": "0.9.1",
24+
"nextflow": "24.10.4"
25+
},
26+
"timestamp": "2025-03-03T16:59:53.809041216"
27+
},
28+
"Prepare chunks channel Glimpse": {
29+
"content": [
30+
{
31+
32+
}
33+
],
34+
"meta": {
35+
"nf-test": "0.9.1",
36+
"nextflow": "24.10.4"
37+
},
38+
"timestamp": "2025-03-03T16:53:17.567651555"
39+
}
40+
}

0 commit comments

Comments
 (0)