Mercurial > repos > kkonganti > cfsan_bettercallsal
comparison 0.6.1/workflows/bettercallsal_db.nf @ 11:749faef1caa9
"planemo upload"
author | kkonganti |
---|---|
date | Tue, 05 Sep 2023 11:51:40 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
10:1b9de878b04a | 11:749faef1caa9 |
---|---|
1 // Define any required imports for this specific workflow | |
2 import java.nio.file.Paths | |
3 import nextflow.file.FileHelper | |
4 | |
5 | |
6 // Include any necessary methods | |
7 include { \ | |
8 fastqEntryPointHelp; summaryOfParams; stopNow; sendMail; \ | |
9 addPadding; wrapUpHelp } from "${params.routines}" | |
10 include { wcompHelp } from "${params.toolshelp}${params.fs}wcomp" | |
11 include { wsnpHelp } from "${params.toolshelp}${params.fs}wsnp" | |
12 include { mashsketchHelp } from "${params.toolshelp}${params.fs}mashsketch" | |
13 | |
14 | |
15 // Exit if help requested before any subworkflows | |
16 if (params.help) { | |
17 log.info help() | |
18 exit 0 | |
19 } | |
20 | |
21 | |
22 // Include any necessary modules and subworkflows | |
23 include { DOWNLOAD_PDG_METADATA } from "${params.modules}${params.fs}download_pdg_metadata${params.fs}main" | |
24 include { FILTER_PDG_METADATA } from "${params.modules}${params.fs}filter_pdg_metadata${params.fs}main" | |
25 include { DB_PER_COMPUTED_SEROTYPE } from "${params.modules}${params.fs}db_per_computed_serotype${params.fs}main" | |
26 include { DB_PER_SNP_CLUSTER } from "${params.modules}${params.fs}db_per_snp_cluster${params.fs}main" | |
27 include { INDEX_METADATA } from "${params.modules}${params.fs}index_metadata${params.fs}main" | |
28 include { SCAFFOLD_GENOMES } from "${params.modules}${params.fs}scaffold_genomes${params.fs}main" | |
29 include { MASH_SKETCH } from "${params.modules}${params.fs}mash${params.fs}sketch${params.fs}main" | |
30 include { DUMP_SOFTWARE_VERSIONS } from "${params.modules}${params.fs}custom${params.fs}dump_software_versions${params.fs}main" | |
31 | |
32 /* | |
33 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
34 INPUTS AND ANY CHECKS FOR THE BETTERCALLSAL_DB WORKFLOW | |
35 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
36 */ | |
37 | |
38 if (!params.output) { | |
39 stopNow("Please mention the absolute UNIX path to store the DB flat files\n" + | |
40 "using the --output option.\n" + | |
41 "Ex: --output /path/to/bettercallsal/db_files") | |
42 } | |
43 | |
44 /* | |
45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
46 RUN THE BETTERCALLSAL_DB WORKFLOW | |
47 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
48 */ | |
49 | |
50 workflow BETTERCALLSAL_DB { | |
51 main: | |
52 log.info summaryOfParams() | |
53 | |
54 DOWNLOAD_PDG_METADATA ( params.pdg_release ?: null ) | |
55 | |
56 DOWNLOAD_PDG_METADATA | |
57 .out | |
58 .versions | |
59 .set { software_versions } | |
60 | |
61 FILTER_PDG_METADATA ( | |
62 DOWNLOAD_PDG_METADATA.out.accs | |
63 .splitText(by: params.genomes_chunk.toInteger() * 10, file: true) | |
64 ) | |
65 | |
66 DB_PER_COMPUTED_SEROTYPE ( | |
67 FILTER_PDG_METADATA.out.accs_chunk_tbl | |
68 .collectFile(name: 'per_comp_db_accs.txt'), | |
69 DOWNLOAD_PDG_METADATA.out.pdg_metadata | |
70 ) | |
71 | |
72 DB_PER_SNP_CLUSTER ( | |
73 FILTER_PDG_METADATA.out.accs_chunk_tbl | |
74 .collectFile(name: 'per_snp_db_accs.txt'), | |
75 DOWNLOAD_PDG_METADATA.out.pdg_metadata, | |
76 DOWNLOAD_PDG_METADATA.out.snp_cluster_metadata | |
77 ) | |
78 | |
79 DB_PER_COMPUTED_SEROTYPE.out.genome_paths | |
80 .map { query -> | |
81 kv = [:] | |
82 kv['id'] = 'comp' | |
83 [ kv, query ] | |
84 } | |
85 .concat( | |
86 DB_PER_SNP_CLUSTER.out.genome_paths | |
87 .map { query -> | |
88 kv = [:] | |
89 kv['id'] = 'snp' | |
90 [ kv, query ] | |
91 } | |
92 ) | |
93 .groupTuple(by: [0]) | |
94 .set { ch_mash_these_genomes } | |
95 | |
96 DB_PER_SNP_CLUSTER | |
97 .out | |
98 .asm_chunk_snp_tbl | |
99 .concat( DB_PER_COMPUTED_SEROTYPE.out.asm_chunk_comp_tbl ) | |
100 .map { acc -> [ acc.name.find(/\_comp|\_snp/), acc ] } | |
101 .set { ch_index_metadata } | |
102 | |
103 INDEX_METADATA ( ch_index_metadata ) | |
104 | |
105 DB_PER_COMPUTED_SEROTYPE.out.accs_comp | |
106 .concat( DB_PER_SNP_CLUSTER.out.accs_snp ) | |
107 .splitText() | |
108 .collect() | |
109 .flatten() | |
110 .unique() | |
111 .collectFile(name: 'accs_to_download.txt') | |
112 .splitText(by: params.genomes_chunk, file: true) | |
113 .set { ch_accs_to_download } | |
114 | |
115 SCAFFOLD_GENOMES ( ch_accs_to_download ) | |
116 | |
117 SCAFFOLD_GENOMES | |
118 .out | |
119 .genomes_dir | |
120 .toSortedList() | |
121 .flatten() | |
122 .unique() | |
123 .set { ch_genomes_dir } | |
124 | |
125 MASH_SKETCH ( | |
126 ch_mash_these_genomes.combine( ch_genomes_dir ) | |
127 ) | |
128 | |
129 DUMP_SOFTWARE_VERSIONS ( | |
130 software_versions | |
131 .mix ( | |
132 DOWNLOAD_PDG_METADATA.out.versions, | |
133 FILTER_PDG_METADATA.out.versions, | |
134 DB_PER_COMPUTED_SEROTYPE.out.versions, | |
135 DB_PER_SNP_CLUSTER.out.versions, | |
136 INDEX_METADATA.out.versions, | |
137 SCAFFOLD_GENOMES.out.versions, | |
138 MASH_SKETCH.out.versions, | |
139 ) | |
140 .unique() | |
141 .collectFile(name: 'collected_versions.yml') | |
142 ) | |
143 } | |
144 | |
145 /* | |
146 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
147 ON COMPLETE, SHOW GORY DETAILS OF ALL PARAMS WHICH WILL BE HELPFUL TO DEBUG | |
148 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
149 */ | |
150 | |
151 workflow.onComplete { | |
152 if (workflow.success) { | |
153 sendMail() | |
154 } | |
155 } | |
156 | |
157 workflow.onError { | |
158 sendMail() | |
159 } | |
160 | |
161 /* | |
162 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
163 HELP TEXT METHODS FOR BETTERCALLSAL_DB WORKFLOW | |
164 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
165 */ | |
166 | |
167 def help() { | |
168 | |
169 Map helptext = [:] | |
170 | |
171 helptext.putAll ( | |
172 fastqEntryPointHelp().findAll { | |
173 it.key =~ /Required|output|Other|Workflow|Author|Version/ | |
174 } + | |
175 wcompHelp(params).text + | |
176 wsnpHelp(params).text + | |
177 mashsketchHelp(params).text + | |
178 wrapUpHelp() | |
179 ) | |
180 | |
181 return addPadding(helptext) | |
182 } |