@@ -70,7 +70,7 @@ workflow BUSCO_DIAMOND {
7070 meta,
7171 [
7272 batch_summary : file(" ${ busco_dir} /short_summary.txt" ),
73- short_summaries_txt : file( " ${ busco_dir } /short_summary.txt " ) ,
73+ short_summaries_txt : [] ,
7474 short_summaries_json : file(" ${ busco_dir} /short_summary.json" ),
7575 full_table : file(" ${ busco_dir} /full_table.tsv" ),
7676 missing_busco_list : file(" ${ busco_dir} /missing_busco_list.tsv" ),
@@ -81,6 +81,7 @@ workflow BUSCO_DIAMOND {
8181 ]
8282 ]
8383 }
84+
8485 ch_formatted_precomputed. view()
8586
8687 //
@@ -127,77 +128,82 @@ workflow BUSCO_DIAMOND {
127128 // Tidy up the BUSCO output directories before publication
128129 //
129130 RESTRUCTUREBUSCODIR (
130- ch_formatted_precomputed
131+ ch_all_busco_outputs
131132 .map { meta , outputs ->
132133 [
133134 meta,
134135 meta. lineage_name,
135136 outputs. batch_summary,
136- outputs. short_summaries_txt,
137- outputs. short_summaries_json,
138- outputs. busco_dir
137+ outputs. short_summaries_txt ?: [],
138+ outputs. short_summaries_json ?: [],
139+ outputs. full_table ?: [],
140+ outputs. missing_busco_list ?: [],
141+ outputs. seq_dir ? " ${ outputs.seq_dir} /single_copy_busco_sequences" : [],
142+ outputs. seq_dir ? " ${ outputs.seq_dir} /multi_copy_busco_sequences" : [],
143+ outputs. seq_dir ? " ${ outputs.seq_dir} /fragmented_busco_sequences" : [],
144+ outputs. busco_dir ? " ${ outputs.busco_dir} /hmmer_output" : []
139145 ]
140146 }
141147 )
142- ch_versions = ch_versions. mix(RESTRUCTUREBUSCODIR . out. versions. first())
143-
144-
145- // //
146- // // Select input for BLOBTOOLKIT_EXTRACTBUSCOS
147- // //
148- // ch_formatted_precomputed.seq_dir
149- // | filter { meta, seq -> basal_lineages.contains(meta.lineage_name) }
150- // | map { meta, seq -> seq }
151- // | collect
152- // | set { ch_basal_buscos }
153-
154-
155- // // Extract BUSCO genes from the basal lineages
156- // BLOBTOOLKIT_EXTRACTBUSCOS ( fasta, ch_basal_buscos )
157- // ch_versions = ch_versions.mix ( BLOBTOOLKIT_EXTRACTBUSCOS.out.versions.first() )
158-
159-
160- // //
161- // // Align BUSCO genes against the BLASTp database
162- // //
163- // BLOBTOOLKIT_EXTRACTBUSCOS.out.genes
164- // | filter { it[1].size() > 140 }
165- // | set { ch_busco_genes }
166-
167- // // Hardcoded to match the format expected by blobtools
168- // def outext = 'txt'
169- // def cols = 'qseqid staxids bitscore qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore'
170- // DIAMOND_BLASTP ( ch_busco_genes, blastp, outext, cols, taxon_id )
171- // ch_versions = ch_versions.mix ( DIAMOND_BLASTP.out.versions.first() )
172-
173-
174- // // Order BUSCO results according to the lineage index
175- // ch_formatted_precomputed.full_table
176- // // 1. Restore the original meta map, and pull the index as an extra tuple element
177- // | map { meta, table -> [meta.findAll { it.key != "lineage_name" && it.key != "lineage_index" }, [table, meta.lineage_index]] }
178- // // 2. Turn to a single-element channel that has the (one and only) meta map, and all the pairs (table, lineage index) concatenated as a list
179- // | groupTuple()
180- // // 3. Sort the pairs and discard the index
181- // | map { meta, table_positions -> [ meta, table_positions.sort { a, b -> a[1] <=> b[1] } . collect { table, lineage_index -> table } ] }
182- // | set { ch_indexed_buscos }
183148
149+ //
150+ // Select input for BLOBTOOLKIT_EXTRACTBUSCOS
151+ //
152+ ch_all_busco_outputs
153+ .filter { meta, outputs -> basal_lineages. contains(meta. lineage_name) }
154+ .map { meta, outputs -> [meta, outputs. seq_dir] }
155+ .collect { it[1 ] }
156+ .set { ch_basal_buscos }
184157
185- // // Select BUSCO results for taxonomically closest database
186- // ch_indexed_buscos
187- // | map { meta, tables -> [meta, tables[0]] }
188- // | set { ch_first_table }
158+ // Extract BUSCO genes from the basal lineages
159+ BLOBTOOLKIT_EXTRACTBUSCOS ( fasta, ch_basal_buscos )
160+ ch_versions = ch_versions. mix ( BLOBTOOLKIT_EXTRACTBUSCOS . out. versions. first() )
189161
162+ //
163+ // Align BUSCO genes against the BLASTp database
164+ //
165+ BLOBTOOLKIT_EXTRACTBUSCOS . out. genes
166+ .filter { it[1 ]. size() > 140 }
167+ .set { ch_busco_genes }
168+
169+ // Hardcoded to match the format expected by blobtools
170+ def outext = ' txt'
171+ def cols = ' qseqid staxids bitscore qseqid sseqid pident length mismatch gapopen qstart qend sstart send evalue bitscore'
172+ DIAMOND_BLASTP ( ch_busco_genes, blastp, outext, cols, taxon_id )
173+ ch_versions = ch_versions. mix ( DIAMOND_BLASTP . out. versions. first() )
174+
175+ // Order BUSCO results according to the lineage index
176+ ch_all_busco_outputs
177+ .map { meta, outputs ->
178+ [
179+ meta. findAll { it. key != " lineage_name" && it. key != " lineage_index" },
180+ [outputs. full_table, meta. lineage_index]
181+ ]
182+ }
183+ .groupTuple()
184+ .map { meta, table_positions ->
185+ [
186+ meta,
187+ table_positions. sort { a , b -> a[1 ] <=> b[1 ] }. collect { table , lineage_index -> table }
188+ ]
189+ }
190+ .set { ch_indexed_buscos }
190191
191- // // BUSCO results for MULTIQC
192- // ch_formatted_precomputed.short_summaries_txt
193- // | ifEmpty ( [ [], [] ] )
194- // | set { multiqc }
192+ // Select BUSCO results for taxonomically closest database
193+ ch_indexed_buscos
194+ .map { meta, tables -> [meta, tables[ 0 ]] }
195+ . set { ch_first_table }
195196
197+ // BUSCO results for MULTIQC
198+ ch_all_busco_outputs
199+ .map { meta, outputs -> outputs. batch_summary }
200+ .ifEmpty ( [ [], [] ] )
201+ .set { multiqc }
196202
197203 emit :
198- // first_table = ch_first_table // channel: [ val(meta), path(full_table) ]
199- // all_tables = ch_indexed_buscos // channel: [ val(meta), path(full_tables) ]
200- // blastp_txt = DIAMOND_BLASTP.out.txt // channel: [ val(meta), path(txt) ]
201- // multiqc // channel: [ meta, summary ]
204+ first_table = ch_first_table // channel: [ val(meta), path(full_table) ]
205+ all_tables = ch_indexed_buscos // channel: [ val(meta), path(full_tables) ]
206+ blastp_txt = DIAMOND_BLASTP . out. txt // channel: [ val(meta), path(txt) ]
207+ multiqc // channel: [ meta, summary ]
202208 versions = ch_versions // channel: [ versions.yml ]
203209}
0 commit comments