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