@@ -9,6 +9,7 @@ include { UNTAR } from '../../modules/nf-core/untar/main'
99include { CAT_CAT } from ' ../../modules/nf-core/cat/cat/main'
1010include { SAMTOOLS_FLAGSTAT } from ' ../../modules/nf-core/samtools/flagstat/main'
1111include { GENERATE_CONFIG } from ' ../../modules/local/generate_config'
12+ include { JSONIFY_TAXDUMP } from ' ../../modules/local/jsonify_taxdump'
1213
1314workflow INPUT_CHECK {
1415 take :
@@ -159,6 +160,32 @@ workflow INPUT_CHECK {
159160 | first
160161 | set { ch_busco_db }
161162
163+
164+ //
165+ // Convert the taxdump to a JSON file if there isn't one yet
166+ //
167+ ch_databases. taxdump
168+ | filter { meta, db_path -> ! db_path. isFile() }
169+ | map { meta, db_path -> [meta, db_path, db_path. listFiles(). find { it. getName(). endsWith(' .json' ) }] }
170+ | branch { meta, db_path, json_path ->
171+ json : json_path
172+ return [meta, json_path]
173+ dir : true
174+ return [meta, db_path]
175+ }
176+ | set { taxdump_dirs }
177+
178+ JSONIFY_TAXDUMP ( taxdump_dirs. dir )
179+ ch_versions = ch_versions. mix(JSONIFY_TAXDUMP . out. versions. first())
180+
181+ ch_databases. taxdump
182+ | filter { meta, db_path -> db_path. isFile() }
183+ | mix ( taxdump_dirs. json )
184+ | mix( JSONIFY_TAXDUMP . out. json )
185+ | map { _, db_path -> db_path }
186+ | set { ch_taxdump }
187+
188+
162189 emit :
163190 reads // channel: [ val(meta), path(datafile) ]
164191 config = GENERATE_CONFIG . out. yaml // channel: [ val(meta), path(yaml) ]
@@ -170,7 +197,7 @@ workflow INPUT_CHECK {
170197 blastp = ch_databases. blastp. first() // channel: [ val(meta), path(blastp_db) ]
171198 blastx = ch_databases. blastx. first() // channel: [ val(meta), path(blastx_db) ]
172199 busco_db = ch_busco_db // channel: [ path(busco_db) ]
173- taxdump = ch_databases . taxdump . map { _, db_path -> db_path } // channel: [ path(taxdump) ]
200+ taxdump = ch_taxdump . first() // channel: [ path(taxdump) ]
174201 versions = ch_versions // channel: [ versions.yml ]
175202}
176203
0 commit comments