11process 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,40 @@ 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' )
58+
59+ autozyg_cmd = touchCmd(euploidy, autozyg)
60+ coverage_cmd = touchCmd(euploidy, coverage)
61+ exome_cmd = touchCmd(euploidy, exome)
62+ fracsnp_cmd = touchCmd(euploidy, fracsnp)
63+ ideogram_cmd = touchCmd(euploidy, ideogram)
64+ regions_cmd = touchCmd(euploidy, regions)
65+ sites_cmd = touchCmd(euploidy, sites)
7166
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- }
8767 """
88- mkdir ${ prefix}
68+ $autozyg_cmd
69+ $coverage_cmd
70+ $exome_cmd
71+ $fracsnp_cmd
72+ $ideogram_cmd
73+ $regions_cmd
74+ $sites_cmd
8975
9076 cat <<-END_VERSIONS > versions.yml
9177 "${ task.process} ":
92- chromograph: \$ (echo \$ (chromograph --version 2>&1 ) | sed 's/chromograph //' )
78+ chromograph: \$ (echo \$ (chromograph --version) | sed 's/.* //' )
9379 END_VERSIONS
9480 """
9581}
82+
83+ // Helper function to generate touch commands
84+ def touchCmd(euploidy, input_file) {
85+ def chrs = euploidy ? (1 .. 22 ) + [' X' ,' Y' ] : [1 ]
86+ input_file ? chrs. collect { chr -> " touch ${ input_file} _chr${ chr} .png" }. join(' \n ' ) : ' '
87+ }
0 commit comments