Skip to content

Commit fc5accb

Browse files
committed
Fix chromograph module
1 parent 0a8c6d8 commit fc5accb

File tree

5 files changed

+477
-65
lines changed

5 files changed

+477
-65
lines changed
Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
process CHROMOGRAPH {
2-
tag "$meta.id"
2+
// $meta.id can be [] because autozyg is not required, so use all ids
3+
tag "${[meta, meta2, meta3, meta4, meta5, meta6, meta7].collect { meta_map -> meta_map.id }.findAll { id -> id }.join('_') ?: 'chromograph'}"
34
label 'process_single'
45

56
conda "${moduleDir}/environment.yml"
@@ -17,37 +18,22 @@ process CHROMOGRAPH {
1718
tuple val(meta7), path(sites)
1819

1920
output:
20-
tuple val(meta), path("*"), emit: plots
21-
path "versions.yml" , emit: versions
21+
tuple val(meta), path("*.png"), emit: plots
22+
path "versions.yml" , emit: versions
2223

2324
when:
2425
task.ext.when == null || task.ext.when
2526

2627
script:
27-
def args = task.ext.args ?: ''
28-
def autozyg_param = autozyg ? "--autozyg ${autozyg}" : ''
29-
def coverage_param = coverage ? "--coverage ${coverage}" : ''
30-
def exome_param = exome ? "--exom ${exome}" : ''
31-
def fracsnp_param = fracsnp ? "--fracsnp ${fracsnp}" : ''
32-
def ideogram_param = ideogram ? "--ideogram ${ideogram}" : ''
33-
def regions_param = regions ? "--regions ${regions}" : ''
34-
def sites_param = sites ? "--sites ${sites}" : ''
28+
def args = task.ext.args ?: ''
29+
def autozyg_param = autozyg ? "--autozyg ${autozyg}" : ''
30+
def coverage_param = coverage ? "--coverage ${coverage}" : ''
31+
def exome_param = exome ? "--exom ${exome}" : ''
32+
def fracsnp_param = fracsnp ? "--fracsnp ${fracsnp}" : ''
33+
def ideogram_param = ideogram ? "--ideogram ${ideogram}" : ''
34+
def regions_param = regions ? "--regions ${regions}" : ''
35+
def sites_param = sites ? "--sites ${sites}" : ''
3536

36-
if (autozyg) {
37-
prefix = task.ext.prefix ?: "${meta.id}"
38-
} else if (coverage) {
39-
prefix = task.ext.prefix ?: "${meta2.id}"
40-
} else if (exome) {
41-
prefix = task.ext.prefix ?: "${meta3.id}"
42-
} else if (fracsnp) {
43-
prefix = task.ext.prefix ?: "${meta4.id}"
44-
} else if (ideogram) {
45-
prefix = task.ext.prefix ?: "${meta5.id}"
46-
} else if (regions) {
47-
prefix = task.ext.prefix ?: "${meta6.id}"
48-
} else {
49-
prefix = task.ext.prefix ?: "${meta7.id}"
50-
}
5137
"""
5238
chromograph \\
5339
$args \\
@@ -62,34 +48,32 @@ process CHROMOGRAPH {
6248
6349
cat <<-END_VERSIONS > versions.yml
6450
"${task.process}":
65-
chromograph: \$(echo \$(chromograph --version 2>&1) | sed 's/chromograph //' )
51+
chromograph: \$(echo \$(chromograph --version) | sed 's/.* //' )
6652
END_VERSIONS
6753
"""
6854

6955
stub:
70-
def args = task.ext.args ?: ''
56+
def args = task.ext.args ?: ''
57+
euploidy = args.contains('-e') || args.contains('--euploid')
7158

72-
if (autozyg) {
73-
prefix = task.ext.prefix ?: "${meta.id}"
74-
} else if (coverage) {
75-
prefix = task.ext.prefix ?: "${meta2.id}"
76-
} else if (exome) {
77-
prefix = task.ext.prefix ?: "${meta3.id}"
78-
} else if (fracsnp) {
79-
prefix = task.ext.prefix ?: "${meta4.id}"
80-
} else if (ideogram) {
81-
prefix = task.ext.prefix ?: "${meta5.id}"
82-
} else if (regions) {
83-
prefix = task.ext.prefix ?: "${meta6.id}"
84-
} else {
85-
prefix = task.ext.prefix ?: "${meta7.id}"
86-
}
8759
"""
88-
mkdir ${prefix}
60+
${touchCmd(euploidy, autozyg)}
61+
${touchCmd(euploidy, coverage)}
62+
${touchCmd(euploidy, exome)}
63+
${touchCmd(euploidy, fracsnp)}
64+
${touchCmd(euploidy, ideogram)}
65+
${touchCmd(euploidy, regions)}
66+
${touchCmd(euploidy, sites)}
8967
9068
cat <<-END_VERSIONS > versions.yml
9169
"${task.process}":
92-
chromograph: \$(echo \$(chromograph --version 2>&1) | sed 's/chromograph //' )
70+
chromograph: \$(echo \$(chromograph --version) | sed 's/.* //' )
9371
END_VERSIONS
9472
"""
9573
}
74+
75+
// Helper function to generate touch commands
76+
def touchCmd(euploidy, input_file) {
77+
def chrs = euploidy ? (1..22) + ['X','Y'] : [1]
78+
input_file ? chrs.collect { chr -> "touch ${input_file}_chr${chr}.png" }.join('\n') : ''
79+
}

modules/nf-core/chromograph/meta.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ output:
8888
description: |
8989
Groovy Map containing sample information
9090
e.g. [ id:'test', single_end:false ]
91-
- ${prefix}:
91+
- "*.png":
9292
type: file
93-
description: Directory containing the plots in png format
94-
pattern: "*.png"
93+
description: Plot(s) in PNG format
9594
ontologies: []
9695
versions:
9796
- versions.yml:

modules/nf-core/chromograph/tests/main.nf.test

Lines changed: 126 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,100 @@ nextflow_process {
66
tag "modules"
77
tag "modules_nfcore"
88
tag "chromograph"
9+
config "./nextflow.config"
910

10-
test("test_chromograph_sites") {
11+
test("test_chromograph_sites_wig") {
12+
when {
13+
params {
14+
module_args = ''
15+
}
16+
process {
17+
"""
18+
input[0] = [[],[]]
19+
input[1] = Channel.of(
20+
'fixedStep chrom=chr3 start=400601 step=100',
21+
'11',
22+
'22',
23+
'33')
24+
.collectFile(name: 'wig_input.wig', newLine: true)
25+
.map { file -> [ [ id: file.name ], file ] }
26+
input[2] = [[],[]]
27+
input[3] = [[],[]]
28+
input[4] = [[],[]]
29+
input[5] = [[],[]]
30+
input[6] = [
31+
[ id:'test', single_end:false ], // meta map
32+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
33+
]
34+
"""
35+
}
36+
}
37+
38+
then {
39+
assertAll(
40+
{ assert process.success },
41+
{ assert snapshot(process.out).match() }
42+
)
43+
}
44+
}
1145

46+
test("test_chromograph_sites_wig_euploid") {
1247
when {
48+
params {
49+
module_args = '--euploid'
50+
}
1351
process {
1452
"""
15-
input[0] = [[:],[]]
16-
input[1] = [[:],[]]
17-
input[2] = [[:],[]]
18-
input[3] = [[:],[]]
19-
input[4] = [[:],[]]
20-
input[5] = [[:],[]]
53+
input[0] = [[],[]]
54+
input[1] = Channel.of(
55+
'fixedStep chrom=chr3 start=400601 step=100',
56+
'11',
57+
'22',
58+
'33')
59+
.collectFile(name: 'wig_input.wig', newLine: true)
60+
.map { file -> [ [ id: file.name ], file ] }
61+
input[2] = [[],[]]
62+
input[3] = [[],[]]
63+
input[4] = [[],[]]
64+
input[5] = [[],[]]
65+
input[6] = [
66+
[ id:'test', single_end:false ], // meta map
67+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
68+
]
69+
"""
70+
}
71+
}
72+
73+
then {
74+
assertAll(
75+
{ assert process.success },
76+
{ assert snapshot(process.out).match() }
77+
)
78+
}
79+
}
80+
81+
test("test_chromograph_sites_wig_stub") {
82+
83+
options "-stub"
84+
85+
when {
86+
params {
87+
module_args = ''
88+
}
89+
process {
90+
"""
91+
input[0] = [[],[]]
92+
input[1] = Channel.of(
93+
'fixedStep chrom=chr3 start=400601 step=100',
94+
'11',
95+
'22',
96+
'33')
97+
.collectFile(name: 'wig_input.wig', newLine: true)
98+
.map { file -> [ [ id: file.name ], file ] }
99+
input[2] = [[],[]]
100+
input[3] = [[],[]]
101+
input[4] = [[],[]]
102+
input[5] = [[],[]]
21103
input[6] = [
22104
[ id:'test', single_end:false ], // meta map
23105
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
@@ -35,4 +117,41 @@ nextflow_process {
35117

36118
}
37119

120+
test("test_chromograph_sites_wig_euploid_stub") {
121+
122+
options "-stub"
123+
124+
when {
125+
params {
126+
module_args = '--euploid'
127+
}
128+
process {
129+
"""
130+
input[0] = [[],[]]
131+
input[1] = Channel.of(
132+
'fixedStep chrom=chr3 start=400601 step=100',
133+
'11',
134+
'22',
135+
'33')
136+
.collectFile(name: 'wig_input.wig', newLine: true)
137+
.map { file -> [ [ id: file.name ], file ] }
138+
input[2] = [[],[]]
139+
input[3] = [[],[]]
140+
input[4] = [[],[]]
141+
input[5] = [[],[]]
142+
input[6] = [
143+
[ id:'test', single_end:false ], // meta map
144+
file(params.modules_testdata_base_path + 'genomics/homo_sapiens/genome/updsites.bed', checkIfExists: true)
145+
]
146+
"""
147+
}
148+
}
149+
150+
then {
151+
assertAll(
152+
{ assert process.success },
153+
{ assert snapshot(process.out).match() }
154+
)
155+
}
156+
}
38157
}

0 commit comments

Comments
 (0)