Mercurial > repos > kkonganti > cfsan_bettercallsal
comparison 0.5.0/workflows/bettercallsal_db.nf @ 1:365849f031fd
"planemo upload"
author | kkonganti |
---|---|
date | Mon, 05 Jun 2023 18:48:51 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:a4b1ee4b68b1 | 1:365849f031fd |
---|---|
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 ( DOWNLOAD_PDG_METADATA.out.accs ) | |
62 | |
63 DB_PER_COMPUTED_SEROTYPE ( | |
64 FILTER_PDG_METADATA.out.accs_chunk_tbl, | |
65 DOWNLOAD_PDG_METADATA.out.pdg_metadata | |
66 ) | |
67 | |
68 DB_PER_SNP_CLUSTER ( | |
69 FILTER_PDG_METADATA.out.accs_chunk_tbl, | |
70 DOWNLOAD_PDG_METADATA.out.pdg_metadata, | |
71 DOWNLOAD_PDG_METADATA.out.snp_cluster_metadata | |
72 ) | |
73 | |
74 DB_PER_COMPUTED_SEROTYPE.out.genome_paths | |
75 .map { query -> | |
76 kv = [:] | |
77 kv['id'] = 'comp' | |
78 [ kv, query ] | |
79 } | |
80 .concat( | |
81 DB_PER_SNP_CLUSTER.out.genome_paths | |
82 .map { query -> | |
83 kv = [:] | |
84 kv['id'] = 'snp' | |
85 [ kv, query ] | |
86 } | |
87 ) | |
88 .groupTuple(by: [0]) | |
89 .set { ch_mash_these_genomes } | |
90 | |
91 DB_PER_SNP_CLUSTER | |
92 .out | |
93 .asm_chunk_snp_tbl | |
94 .concat( DB_PER_COMPUTED_SEROTYPE.out.asm_chunk_comp_tbl ) | |
95 .map { acc -> | |
96 [ acc.name.find(/\_comp|\_snp/), acc ] | |
97 } | |
98 .set { ch_index_metadata } | |
99 | |
100 INDEX_METADATA ( ch_index_metadata ) | |
101 | |
102 DB_PER_COMPUTED_SEROTYPE.out.accs_comp | |
103 .concat( DB_PER_SNP_CLUSTER.out.accs_snp ) | |
104 .collectFile(name: 'accs_to_download.txt') | |
105 .splitText(by: params.genomes_chunk, file: true) | |
106 .set { ch_accs_to_download } | |
107 | |
108 SCAFFOLD_GENOMES ( ch_accs_to_download ) | |
109 | |
110 SCAFFOLD_GENOMES | |
111 .out | |
112 .genomes_dir | |
113 .toSortedList() | |
114 .flatten() | |
115 .unique() | |
116 .set { ch_genomes_dir } | |
117 | |
118 MASH_SKETCH ( | |
119 ch_mash_these_genomes.combine( ch_genomes_dir ) | |
120 ) | |
121 | |
122 DUMP_SOFTWARE_VERSIONS ( | |
123 software_versions | |
124 .mix ( | |
125 DOWNLOAD_PDG_METADATA.out.versions, | |
126 FILTER_PDG_METADATA.out.versions, | |
127 DB_PER_COMPUTED_SEROTYPE.out.versions, | |
128 DB_PER_SNP_CLUSTER.out.versions, | |
129 INDEX_METADATA.out.versions, | |
130 SCAFFOLD_GENOMES.out.versions, | |
131 MASH_SKETCH.out.versions, | |
132 ) | |
133 .unique() | |
134 .collectFile(name: 'collected_versions.yml') | |
135 ) | |
136 } | |
137 | |
138 /* | |
139 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
140 ON COMPLETE, SHOW GORY DETAILS OF ALL PARAMS WHICH WILL BE HELPFUL TO DEBUG | |
141 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
142 */ | |
143 | |
144 workflow.onComplete { | |
145 if (workflow.success) { | |
146 sendMail() | |
147 } | |
148 } | |
149 | |
150 workflow.onError { | |
151 sendMail() | |
152 } | |
153 | |
154 /* | |
155 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
156 HELP TEXT METHODS FOR BETTERCALLSAL_DB WORKFLOW | |
157 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
158 */ | |
159 | |
160 def help() { | |
161 | |
162 Map helptext = [:] | |
163 | |
164 helptext.putAll ( | |
165 fastqEntryPointHelp().findAll { | |
166 it.key =~ /Required|output|Other|Workflow|Author|Version/ | |
167 } + | |
168 wcompHelp(params).text + | |
169 wsnpHelp(params).text + | |
170 mashsketchHelp(params).text + | |
171 wrapUpHelp() | |
172 ) | |
173 | |
174 return addPadding(helptext) | |
175 } |