diff --git a/CHANGELOG.md b/CHANGELOG.md index c53ed896f..8368e07ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Changed` +- [#932](https://github.com/nf-core/mag/pull/932) - Replaced usages of deprecated `Channel()` with `channel()` and fix other LSP warnings (by @dialvarezs) + ### `Fixed` - [#894](https://github.com/nf-core/mag/pull/894) - Fix read order in metaSPAdes to allow co-assembly of paired-end data of multiple samples (reported by @maartenciers, fix by @jfy133 with contributions from @prototaxites, @d4straub and @dialvarezs) diff --git a/subworkflows/local/ancient_dna/main.nf b/subworkflows/local/ancient_dna/main.nf index c9996f5e7..d399e56ae 100644 --- a/subworkflows/local/ancient_dna/main.nf +++ b/subworkflows/local/ancient_dna/main.nf @@ -8,10 +8,10 @@ include { SAMTOOLS_FAIDX as FAIDX } from '../../../modules/nf-core workflow ANCIENT_DNA_ASSEMBLY_VALIDATION { take: - ch_input //channel: [val(meta), path(contigs), path(bam), path(bam_index)] + ch_input // [val(meta), path(contigs), path(bam), path(bam_index)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() PYDAMAGE_ANALYZE( ch_input.map { meta, _contigs, bam, bai -> @@ -28,7 +28,7 @@ workflow ANCIENT_DNA_ASSEMBLY_VALIDATION { ch_versions = ch_versions.mix(PYDAMAGE_FILTER.out.versions) if (params.skip_ancient_damagecorrection) { - ch_corrected_contigs = Channel.empty() + ch_corrected_contigs = channel.empty() } if (!params.skip_ancient_damagecorrection) { diff --git a/subworkflows/local/assembly/main.nf b/subworkflows/local/assembly/main.nf index 2fb53b7e8..fdf051d78 100644 --- a/subworkflows/local/assembly/main.nf +++ b/subworkflows/local/assembly/main.nf @@ -11,12 +11,12 @@ include { GUNZIP as GUNZIP_LONGREAD_ASSEMBLIES } from '../../../modules/nf-core workflow ASSEMBLY { take: - ch_short_reads // [ [meta] , fastq1, fastq2] (mandatory) - ch_long_reads // [ [meta] , fastq] (mandatory) + ch_short_reads // [val(meta), path(fastq1), path(fastq2)] (mandatory) + ch_long_reads // [val(meta), path(fastq)] (mandatory) main: - ch_versions = Channel.empty() + ch_versions = channel.empty() /* ================================================================================ @@ -39,7 +39,7 @@ workflow ASSEMBLY { sr_platform: metas.sr_platform[0] ] if (assemble_as_single) { - [meta, reads.collect { file -> file }, []] + [meta, reads.sort { files -> files[0].getName() }, []] } else { [meta] + reads.sort { files -> files[0].getName() }.transpose() @@ -63,23 +63,28 @@ workflow ASSEMBLY { meta.id = "group-${group}" meta.group = group meta.lr_platform = metas.lr_platform[0] - [meta, reads.collect { it }] + [meta, reads] } } else { - ch_short_reads_grouped = ch_short_reads - .filter { it[0].single_end } - .map { meta, reads -> [meta, [reads], []] } - .mix( - ch_short_reads.filter { !it[0].single_end }.map { meta, reads -> [meta, [reads[0]], [reads[1]]] } - ) + ch_short_reads_grouped = ch_short_reads.map { meta, reads -> + if (meta.single_end) { + [meta, [reads], []] + } + else { + [meta, [reads[0]], [reads[1]]] + } + } + ch_long_reads_grouped = ch_long_reads } if (!params.skip_spades || !params.skip_spadeshybrid) { if (params.coassemble_group) { if (params.bbnorm) { - ch_short_reads_spades = ch_short_reads_grouped.map { [it[0], it[1]] } + // When doing co-assembly and using bbnorm, all sample reads get pooled in a single file + // That's why we can drop R2 here (it's empty) + ch_short_reads_spades = ch_short_reads_grouped.map { meta, r1, _r2 -> [meta, r1] } } else { POOL_SHORT_READS(ch_short_reads_grouped_for_pooling) @@ -95,8 +100,8 @@ workflow ASSEMBLY { ch_long_reads_grouped_for_pool = ch_long_reads_grouped .map { meta, reads -> [meta.id, meta, reads] } - .combine(ch_short_reads_grouped.map { meta, _reads1, _reads2 -> [meta.id, meta] }, by: 0) - .map { [it[1], it[2]] } + .combine(ch_short_reads_grouped.map { meta, _reads1, _reads2 -> [meta.id] }, by: 0) + .map { _id, lr_meta, lr_reads -> [lr_meta, lr_reads] } //make sure no long reads are pooled for spades if there are no short reads POOL_LONG_READS(ch_long_reads_grouped_for_pool) @@ -104,12 +109,12 @@ workflow ASSEMBLY { ch_long_reads_spades = POOL_LONG_READS.out.reads } else { - ch_long_reads_spades = Channel.empty() + ch_long_reads_spades = channel.empty() } } else { - ch_short_reads_spades = Channel.empty() - ch_long_reads_spades = Channel.empty() + ch_short_reads_spades = channel.empty() + ch_long_reads_spades = channel.empty() } /* @@ -118,8 +123,8 @@ workflow ASSEMBLY { ================================================================================ */ - ch_shortread_assembled_contigs = Channel.empty() - ch_longread_assembled_contigs = Channel.empty() + ch_shortread_assembled_contigs = channel.empty() + ch_longread_assembled_contigs = channel.empty() // SHORTREAD ASSEMBLY SHORTREAD_ASSEMBLY( diff --git a/subworkflows/local/assembly_hybrid/main.nf b/subworkflows/local/assembly_hybrid/main.nf index 8fa0f90fe..b2f551d06 100644 --- a/subworkflows/local/assembly_hybrid/main.nf +++ b/subworkflows/local/assembly_hybrid/main.nf @@ -3,13 +3,13 @@ include { SPADES as METASPADESHYBRID } from '../../../modules/nf-core/spades/mai workflow HYBRID_ASSEMBLY { take: - ch_short_reads_spades // [ [meta] , fastq1, fastq2] (mandatory) - ch_long_reads_spades // [ [meta] , fastq] (mandatory) + ch_short_reads_spades // [val(meta), path(fastq1), path(fastq2)] (mandatory) + ch_long_reads_spades // [val(meta), path(fastq)] (mandatory) main: - ch_versions = Channel.empty() - ch_assembled_contigs = Channel.empty() + ch_versions = channel.empty() + ch_assembled_contigs = channel.empty() if (!params.single_end && !params.skip_spadeshybrid) { ch_short_reads_spades_tmp = ch_short_reads_spades.map { meta, reads -> [meta.id, meta, reads] } diff --git a/subworkflows/local/assembly_longread/main.nf b/subworkflows/local/assembly_longread/main.nf index 2b3cab32c..dac82f7c8 100644 --- a/subworkflows/local/assembly_longread/main.nf +++ b/subworkflows/local/assembly_longread/main.nf @@ -7,11 +7,11 @@ include { METAMDBG_ASM } from '../../../modules/nf-core/metamdbg/asm/main' workflow LONGREAD_ASSEMBLY { take: - ch_long_reads // [ [meta] , fastq] (mandatory) + ch_long_reads // [val(meta), path(fastq)] (mandatory) main: - ch_assembled_contigs = Channel.empty() - ch_versions = Channel.empty() + ch_assembled_contigs = channel.empty() + ch_versions = channel.empty() if (!params.skip_flye) { diff --git a/subworkflows/local/assembly_shortread/main.nf b/subworkflows/local/assembly_shortread/main.nf index 91e22978a..3268fc649 100644 --- a/subworkflows/local/assembly_shortread/main.nf +++ b/subworkflows/local/assembly_shortread/main.nf @@ -4,12 +4,12 @@ include { SPADES as METASPADES } from '../../../modules/nf-core/spades/main' workflow SHORTREAD_ASSEMBLY { take: - ch_short_reads_grouped // [ [meta] , fastq1, fastq2] (mandatory) - ch_short_reads_spades + ch_short_reads_grouped // [val(meta), path(fastq1), path(fastq2)] (mandatory) + ch_short_reads_spades // [val(meta), path(fastq1)] (mandatory) main: - ch_versions = Channel.empty() - ch_assembled_contigs = Channel.empty() + ch_versions = channel.empty() + ch_assembled_contigs = channel.empty() if (!params.single_end && !params.skip_spades) { METASPADES(ch_short_reads_spades.map { meta, reads -> [meta, reads, [], []] }, [], []) diff --git a/subworkflows/local/bin_qc/main.nf b/subworkflows/local/bin_qc/main.nf index 71456274b..74438ea40 100644 --- a/subworkflows/local/bin_qc/main.nf +++ b/subworkflows/local/bin_qc/main.nf @@ -19,16 +19,16 @@ include { UNTAR as CHECKM_UNTAR } from '../../../modules/nf-core/un workflow BIN_QC { take: - ch_bins // [ [ meta] , fasta ], input bins (mandatory) + ch_bins // [val(meta), path(fasta)], input bins (mandatory) main: - ch_qc_summaries = Channel.empty() + ch_qc_summaries = channel.empty() ch_input_bins_for_qc = ch_bins.transpose() - ch_versions = Channel.empty() - ch_multiqc_files = Channel.empty() - ch_busco_final_summaries = Channel.empty() - ch_checkm_final_summaries = Channel.empty() - ch_checkm2_final_summaries = Channel.empty() + ch_versions = channel.empty() + ch_multiqc_files = channel.empty() + ch_busco_final_summaries = channel.empty() + ch_checkm_final_summaries = channel.empty() + ch_checkm2_final_summaries = channel.empty() /* @@ -53,7 +53,7 @@ workflow BIN_QC { CHECKM_UNTAR(ch_checkm_db) ch_versions = ch_versions.mix(CHECKM_UNTAR.out.versions) - ch_checkm_db = CHECKM_UNTAR.out.untar.map { it[1] } + ch_checkm_db = CHECKM_UNTAR.out.untar.map { _meta, db -> db } } else { ch_checkm_db = [] @@ -75,7 +75,7 @@ workflow BIN_QC { ch_gunc_db = file(params.gunc_db, checkIfExists: true) } else { - ch_gunc_db = Channel.empty() + ch_gunc_db = channel.empty() } /* @@ -93,7 +93,7 @@ workflow BIN_QC { if (ch_busco_db && ch_busco_db.extension in ['gz', 'tgz']) { BUSCO_UNTAR([[id: ch_busco_db.getSimpleName()], ch_busco_db]) ch_versions = ch_versions.mix(BUSCO_UNTAR.out.versions) - ch_busco_db = BUSCO_UNTAR.out.untar.map { it[1] } + ch_busco_db = BUSCO_UNTAR.out.untar.map { _meta, db -> db } } else if (ch_busco_db && ch_busco_db.isDirectory()) { ch_busco_db = ch_busco_db @@ -109,13 +109,19 @@ workflow BIN_QC { .map { _meta, summary -> [[id: 'busco'], summary] } .groupTuple() ch_multiqc_files = ch_multiqc_files.mix( - BUSCO_BUSCO.out.short_summaries_txt.map { it[1] }.flatten() + BUSCO_BUSCO.out.short_summaries_txt.map { _meta, summary -> summary }.flatten() ) CONCAT_BUSCO_TSV(ch_busco_summaries, 'tsv', 'tsv') ch_versions = ch_versions.mix(CONCAT_BUSCO_TSV.out.versions) - ch_busco_final_summaries = ch_busco_final_summaries.mix(CONCAT_BUSCO_TSV.out.csv.map { it[1] }) - ch_qc_summaries = ch_qc_summaries.mix(CONCAT_BUSCO_TSV.out.csv.splitCsv(header: true, sep: '\t').map { _meta, summary -> [bin_qc_tool: 'busco'] + summary }) + ch_busco_final_summaries = ch_busco_final_summaries.mix( + CONCAT_BUSCO_TSV.out.csv.map { _meta, csv -> csv } + ) + ch_qc_summaries = ch_qc_summaries.mix( + CONCAT_BUSCO_TSV.out.csv + .splitCsv(header: true, sep: '\t') + .map { _meta, summary -> [bin_qc_tool: 'busco'] + summary } + ) } if (params.run_checkm) { /* @@ -147,13 +153,19 @@ workflow BIN_QC { .map { _meta, summary -> [[id: 'checkm'], summary] } .groupTuple() ch_multiqc_files = ch_multiqc_files.mix( - CHECKM_QA.out.output.map { it[1] }.flatten() + CHECKM_QA.out.output.map { _meta, summary -> summary }.flatten() ) CONCAT_CHECKM_TSV(ch_checkm_summaries, 'tsv', 'tsv') ch_versions = ch_versions.mix(CONCAT_CHECKM_TSV.out.versions) - ch_checkm_final_summaries = ch_checkm_final_summaries.mix(CONCAT_CHECKM_TSV.out.csv.map { it[1] }) - ch_qc_summaries = ch_qc_summaries.mix(CONCAT_CHECKM_TSV.out.csv.splitCsv(header: true, sep: '\t').map { _meta, summary -> [bin_qc_tool: 'checkm'] + summary }) + ch_checkm_final_summaries = ch_checkm_final_summaries.mix( + CONCAT_CHECKM_TSV.out.csv.map { _meta, csv -> csv } + ) + ch_qc_summaries = ch_qc_summaries.mix( + CONCAT_CHECKM_TSV.out.csv + .splitCsv(header: true, sep: '\t') + .map { _meta, summary -> [bin_qc_tool: 'checkm'] + summary } + ) } if (params.run_checkm2) { /* @@ -166,13 +178,19 @@ workflow BIN_QC { .map { _meta, summary -> [[id: 'checkm2'], summary] } .groupTuple() ch_multiqc_files = ch_multiqc_files.mix( - CHECKM2_PREDICT.out.checkm2_tsv.map { it[1] }.flatten() + CHECKM2_PREDICT.out.checkm2_tsv.map { _meta, summary -> summary }.flatten() ) CONCAT_CHECKM2_TSV(ch_checkm2_summaries, 'tsv', 'tsv') ch_versions = ch_versions.mix(CONCAT_CHECKM2_TSV.out.versions) - ch_checkm2_final_summaries = ch_checkm2_final_summaries.mix(CONCAT_CHECKM2_TSV.out.csv.map { it[1] }) - ch_qc_summaries = ch_qc_summaries.mix(CONCAT_CHECKM2_TSV.out.csv.splitCsv(header: true, sep: '\t').map { _meta, summary -> [bin_qc_tool: 'checkm2'] + summary }) + ch_checkm2_final_summaries = ch_checkm2_final_summaries.mix( + CONCAT_CHECKM2_TSV.out.csv.map { _meta, csv -> csv } + ) + ch_qc_summaries = ch_qc_summaries.mix( + CONCAT_CHECKM2_TSV.out.csv + .splitCsv(header: true, sep: '\t') + .map { _meta, summary -> [bin_qc_tool: 'checkm2'] + summary } + ) } if (params.run_gunc) { diff --git a/subworkflows/local/binning/main.nf b/subworkflows/local/binning/main.nf index f6c77de17..67e716fd6 100644 --- a/subworkflows/local/binning/main.nf +++ b/subworkflows/local/binning/main.nf @@ -20,22 +20,22 @@ include { SPLIT_FASTA workflow BINNING { take: - ch_assemblies // channel: [ val(meta), path(assembly), path(bams), path(bais) ] - val_bin_min_size - val_bin_max_size + ch_assemblies // [val(meta), path(assembly), path(bams), path(bais)] + val_bin_min_size // val(int) + val_bin_max_size // val(int) main: - ch_versions = Channel.empty() - ch_input_splitfasta = Channel.empty() + ch_versions = channel.empty() + ch_input_splitfasta = channel.empty() // generate coverage depths for each contig and branch by assembler type ch_summarizedepth_input = ch_assemblies .map { meta, _assembly, bams, bais -> [meta, bams, bais] } - .branch { - longread: it[0].assembler in ['FLYE', 'METAMDBG'] + .branch { meta, _bams, _bais -> + longread: meta.assembler in ['FLYE', 'METAMDBG'] shortread: true } @@ -47,7 +47,9 @@ workflow BINNING { ch_versions = ch_versions.mix(METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_SHORTREAD.out.versions) // Merge the outputs - ch_combined_depths = METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_LONGREAD.out.depth.mix(METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_SHORTREAD.out.depth) + ch_combined_depths = METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_LONGREAD.out.depth.mix( + METABAT2_JGISUMMARIZEBAMCONTIGDEPTHS_SHORTREAD.out.depth + ) ch_metabat_depths = ch_combined_depths.map { meta, depths -> def meta_new = meta + [binner: 'MetaBAT2'] [meta_new, depths] @@ -76,10 +78,10 @@ workflow BINNING { } // main bins for decompressing for MAG_DEPTHS - ch_bins_for_seqkit = Channel.empty() + ch_bins_for_seqkit = channel.empty() // final gzipped bins - ch_binning_results_gzipped_final = Channel.empty() + ch_binning_results_gzipped_final = channel.empty() // MetaBAT2 if (!params.skip_metabat2) { @@ -128,7 +130,7 @@ workflow BINNING { // COMEBin if (!params.skip_comebin) { ch_comebin_input = ch_assemblies - .map { meta, assembly, bams, bais -> + .map { meta, assembly, bams, _bais -> def meta_new = meta + [binner: 'COMEBin'] [meta_new, assembly, bams] } @@ -179,12 +181,12 @@ workflow BINNING { // filtering is 0. Error if so, but only if we had bins to begin with. // ch_seqkitstats_results - .map { meta, stats -> stats.bin_total_length } + .map { _meta, stats -> stats.bin_total_length } .collect().ifEmpty([]) .subscribe { stats -> def n_bins = stats.size() - def n_filtered_bins = stats.findAll { - it >= val_bin_min_size && (val_bin_max_size ? it <= val_bin_max_size : true) + def n_filtered_bins = stats.findAll { bin_size -> + bin_size >= val_bin_min_size && (val_bin_max_size ? bin_size <= val_bin_max_size : true) }.size() if (n_bins > 0 && n_filtered_bins == 0) { error( diff --git a/subworkflows/local/binning_metabinner/main.nf b/subworkflows/local/binning_metabinner/main.nf index 319555c52..2adbdd888 100644 --- a/subworkflows/local/binning_metabinner/main.nf +++ b/subworkflows/local/binning_metabinner/main.nf @@ -6,7 +6,7 @@ include { METABINNER_BINS } from '../../../modules/local/metabinner_bi workflow BINNING_METABINNER { take: - ch_input // channel (mandatory): [ val(meta), path(fasta), path(depth) ] (fasta: raw contigs from assembly) + ch_input // [val(meta), path(fasta), path(depth)] (mandatory) main: ch_versions = channel.empty() @@ -14,7 +14,7 @@ workflow BINNING_METABINNER { // produce k-mer composition table METABINNER_KMER( ch_input - .map { meta, assembly, depths -> + .map { meta, assembly, _depths -> [meta, assembly] }, params.min_contig_size @@ -24,7 +24,7 @@ workflow BINNING_METABINNER { // extract contigs over length threshold METABINNER_TOOSHORT( ch_input - .map { meta, assembly, depths -> + .map { meta, assembly, _depths -> [meta, assembly] }, params.min_contig_size @@ -35,13 +35,13 @@ workflow BINNING_METABINNER { ch_metabinner_input = METABINNER_TOOSHORT.out.sizefiltered .join(METABINNER_KMER.out.composition_profile) - .join(ch_input.map { meta, assembly, depths -> [meta, depths] } ) + .join(ch_input.map { meta, _assembly, depths -> [meta, depths] } ) METABINNER_METABINNER(ch_metabinner_input, params.min_contig_size) ch_versions = ch_versions.mix(METABINNER_METABINNER.out.versions) // extract bin sequences METABINNER_BINS( - ch_input.map { meta, assembly, depths -> [meta, assembly] } + ch_input.map { meta, assembly, _depths -> [meta, assembly] } .join(METABINNER_METABINNER.out.membership), params.min_contig_size ) diff --git a/subworkflows/local/binning_preparation/main.nf b/subworkflows/local/binning_preparation/main.nf index c706e0b34..c51997b76 100644 --- a/subworkflows/local/binning_preparation/main.nf +++ b/subworkflows/local/binning_preparation/main.nf @@ -3,21 +3,23 @@ include { LONGREAD_BINNING_PREPARATION } from '../binning_preparation_longread/ workflow BINNING_PREPARATION { take: - ch_shortread_assemblies // channel: [ val(meta), path(assembly) ] - ch_shortreads // channel: [ val(meta), [ reads ] ] - ch_longread_assemblies // channel: [ val(meta), path(assembly) ] - ch_longreads // channel: [ val(meta), [ reads ] ] + ch_shortread_assemblies // [val(meta), path(assembly)] + ch_shortreads // [val(meta), path(reads)] + ch_longread_assemblies // [val(meta), path(assembly)] + ch_longreads // [val(meta), path(reads)] main: - ch_versions = Channel.empty() - ch_multiqc_files = Channel.empty() + ch_versions = channel.empty() + ch_multiqc_files = channel.empty() SHORTREAD_BINNING_PREPARATION(ch_shortread_assemblies, ch_shortreads) ch_versions = ch_versions.mix(SHORTREAD_BINNING_PREPARATION.out.versions) LONGREAD_BINNING_PREPARATION(ch_longread_assemblies, ch_longreads) ch_versions = ch_versions.mix(LONGREAD_BINNING_PREPARATION.out.versions) - ch_grouped_mappings = SHORTREAD_BINNING_PREPARATION.out.grouped_mappings.mix(LONGREAD_BINNING_PREPARATION.out.grouped_mappings) + ch_grouped_mappings = SHORTREAD_BINNING_PREPARATION.out.grouped_mappings.mix( + LONGREAD_BINNING_PREPARATION.out.grouped_mappings + ) ch_multiqc_files = ch_multiqc_files.mix(SHORTREAD_BINNING_PREPARATION.out.bowtie2_assembly_multiqc) diff --git a/subworkflows/local/binning_preparation_longread/main.nf b/subworkflows/local/binning_preparation_longread/main.nf index 546b72e7a..624e59a8d 100644 --- a/subworkflows/local/binning_preparation_longread/main.nf +++ b/subworkflows/local/binning_preparation_longread/main.nf @@ -3,11 +3,11 @@ include { MINIMAP2_ALIGN as MINIMAP2_ASSEMBLY_ALIGN } from '../../../modules/nf- workflow LONGREAD_BINNING_PREPARATION { take: - ch_assemblies // channel: [ val(meta), path(assembly) ] - ch_reads // channel: [ val(meta), [ reads ] ] + ch_assemblies // [val(meta), path(assembly)] + ch_reads // [val(meta), path(reads)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() MINIMAP2_ASSEMBLY_INDEX(ch_assemblies) ch_versions = ch_versions.mix(MINIMAP2_ASSEMBLY_INDEX.out.versions) diff --git a/subworkflows/local/binning_preparation_shortread/main.nf b/subworkflows/local/binning_preparation_shortread/main.nf index e24e92e2f..299b63c6f 100644 --- a/subworkflows/local/binning_preparation_shortread/main.nf +++ b/subworkflows/local/binning_preparation_shortread/main.nf @@ -7,12 +7,12 @@ include { BOWTIE2_ASSEMBLY_ALIGN } from '../../../modules/local/bowtie2_assembly workflow SHORTREAD_BINNING_PREPARATION { take: - ch_assemblies // channel: [ val(meta), path(assembly) ] - ch_reads // channel: [ val(meta), [ reads ] ] + ch_assemblies // [val(meta), path(assembly)] + ch_reads // [val(meta), path(reads)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() // build bowtie2 index for all assemblies BOWTIE2_ASSEMBLY_BUILD(ch_assemblies) ch_versions = ch_versions.mix(BOWTIE2_ASSEMBLY_BUILD.out.versions) diff --git a/subworkflows/local/binning_refinement/main.nf b/subworkflows/local/binning_refinement/main.nf index 1a1472c9e..bad83ae81 100644 --- a/subworkflows/local/binning_refinement/main.nf +++ b/subworkflows/local/binning_refinement/main.nf @@ -17,11 +17,11 @@ include { RENAME_POSTDASTOOL } from workflow BINNING_REFINEMENT { take: - ch_contigs_for_dastool // channel: [ val(meta), path(contigs) ] - ch_in_bins // channel: [ val(meta), path(bins) ] + ch_contigs_for_dastool // [val(meta), path(contigs)] + ch_in_bins // [val(meta), path(bins)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() // remove domain information, will add it back later // everything here is either unclassified or a prokaryote @@ -36,11 +36,11 @@ workflow BINNING_REFINEMENT { } // prepare bins - ch_bins_for_fastatocontig2bin = RENAME_PREDASTOOL(ch_bins).renamed_bins.branch { - metabat2: it[0]['binner'] == 'MetaBAT2' - maxbin2: it[0]['binner'] == 'MaxBin2' - concoct: it[0]['binner'] == 'CONCOCT' - comebin: it[0]['binner'] == 'COMEBin' + ch_bins_for_fastatocontig2bin = RENAME_PREDASTOOL(ch_bins).renamed_bins.branch { meta, _bin -> + metabat2: meta.binner == 'MetaBAT2' + maxbin2: meta.binner == 'MaxBin2' + concoct: meta.binner == 'CONCOCT' + comebin: meta.binner == 'COMEBin' } ch_versions = ch_versions.mix(RENAME_PREDASTOOL.out.versions) @@ -60,7 +60,7 @@ workflow BINNING_REFINEMENT { ch_versions = ch_versions.mix(DASTOOL_FASTATOCONTIG2BIN_COMEBIN.out.versions) // Run DASTOOL - ch_fastatocontig2bin_for_dastool = Channel.empty() + ch_fastatocontig2bin_for_dastool = channel.empty() ch_fastatocontig2bin_for_dastool = ch_fastatocontig2bin_for_dastool .mix(DASTOOL_FASTATOCONTIG2BIN_METABAT2.out.fastatocontig2bin) .mix(DASTOOL_FASTATOCONTIG2BIN_MAXBIN2.out.fastatocontig2bin) diff --git a/subworkflows/local/catpack/main.nf b/subworkflows/local/catpack/main.nf index 443fadddf..5bb680498 100644 --- a/subworkflows/local/catpack/main.nf +++ b/subworkflows/local/catpack/main.nf @@ -14,11 +14,11 @@ include { UNTAR as CAT_DB_UNTAR } from '../../../modules workflow CATPACK { take: - ch_bins // channel: [ val(meta), [bins] ] - ch_unbins // channel: [ val(meta), [unbins] ] + ch_bins // [val(meta), path(fasta)] + ch_unbins // [val(meta), path(fasta)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() /* ======================================== @@ -34,7 +34,7 @@ workflow CATPACK { ch_cat_db_dir = CAT_DB_UNTAR.out.untar } else { - ch_cat_db_dir = Channel.fromPath(params.cat_db, checkIfExists: true, type: 'dir') + ch_cat_db_dir = channel.fromPath(params.cat_db, checkIfExists: true, type: 'dir') .map { dir -> [[id: 'cat_db'], dir] } .first() } diff --git a/subworkflows/local/depths/main.nf b/subworkflows/local/depths/main.nf index 608150170..d775ce664 100644 --- a/subworkflows/local/depths/main.nf +++ b/subworkflows/local/depths/main.nf @@ -20,12 +20,12 @@ def getRowNo(filename) { workflow DEPTHS { take: - ch_bins_unbins // channel: val(meta), [ path(bins) ] - ch_depths // channel: val(meta), path(depths) - ch_reads // channel: val(meta), path(reads) + ch_bins_unbins // [val(meta), path(fasta)] + ch_depths // [val(meta), path(depth)] + ch_reads // [val(meta), path(fastq)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() // Compute bin depths for different samples (according to `binning_map_mode`) // Create a new meta combine key first, but copy meta so that @@ -52,7 +52,9 @@ workflow DEPTHS { // Plot bin depths heatmap for each assembly and mapped samples (according to `binning_map_mode`) // create file containing group information for all samples - ch_sample_groups = ch_reads.collectFile(name: 'sample_groups.tsv') { meta, _sample_reads -> meta.id + '\t' + meta.group + '\n' } + ch_sample_groups = ch_reads.collectFile(name: 'sample_groups.tsv') { meta, _sample_reads -> + meta.id + '\t' + meta.group + '\n' + } // Filter MAG depth files: use only those for plotting that contain depths for > 2 samples // as well as > 2 bins diff --git a/subworkflows/local/domain_classification/main.nf b/subworkflows/local/domain_classification/main.nf index b7d39c2ba..433f022d8 100644 --- a/subworkflows/local/domain_classification/main.nf +++ b/subworkflows/local/domain_classification/main.nf @@ -6,12 +6,12 @@ include { TIARA } from '../../../subworkflows/local/tiara' workflow DOMAIN_CLASSIFICATION { take: - ch_assemblies // tuple val(meta), path(assembly) - ch_bins // tuple val(meta), path( [ bins ] ) - ch_unbins // tuple val(meta), path( [ unbins ] ) + ch_assemblies // [val(meta), path(assembly)] + ch_bins // [val(meta), path(fasta)] + ch_unbins // [val(meta), path(fasta)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() if (params.bin_domain_classification_tool == "tiara") { TIARA(ch_assemblies, ch_bins, ch_unbins) diff --git a/subworkflows/local/gtdbtk/main.nf b/subworkflows/local/gtdbtk/main.nf index 855ff309a..c12483a28 100644 --- a/subworkflows/local/gtdbtk/main.nf +++ b/subworkflows/local/gtdbtk/main.nf @@ -9,12 +9,12 @@ include { GTDBTK_SUMMARY } from '../../../modules/local/gtdbtk_summary/ma workflow GTDBTK { take: - ch_bins // channel: [ val(meta), [bins] ] - ch_bin_qc_summary // channel: path - val_gtdb // value: path + ch_bins // [val(meta), path(fasta)] + ch_bin_qc_summary // path + val_gtdb // path main: - ch_versions = Channel.empty() + ch_versions = channel.empty() // Collect bin quality metrics qc_columns = [ @@ -52,13 +52,20 @@ workflow GTDBTK { .transpose() .map { meta, bin -> [bin.getName(), bin, meta] } .join(ch_bin_metrics) - .map { bin_name, bin, meta, _bin_qc_tool, completeness, contamination -> [bin_name, meta, bin, completeness, contamination] } + .map { bin_name, bin, meta, _bin_qc_tool, completeness, contamination -> + [bin_name, meta, bin, completeness, contamination] + } .groupTuple(by: 0) .branch { _bin_name, meta, bin, completeness, contamination -> - passed: (completeness.any { it != -1 } && completeness.any { it >= params.gtdbtk_min_completeness } && contamination.any { it != -1 } && contamination.any { it <= params.gtdbtk_max_contamination }) - return [meta[0], bin[0]] + passed: ( + completeness.any { bin_completeness -> bin_completeness != -1 } && + completeness.any { bin_completeness -> bin_completeness >= params.gtdbtk_min_completeness } && + contamination.any { bin_contamination -> bin_contamination != -1 } && + contamination.any { bin_contamination -> bin_contamination <= params.gtdbtk_max_contamination } + ) + return [meta[0], bin[0]] discarded: true - return [meta[0], bin[0]] + return [meta[0], bin[0]] } // Note we have to call `meta[0], bin[0]` because of the groupTuple above @@ -92,8 +99,8 @@ workflow GTDBTK { } GTDBTK_SUMMARY( - ch_filtered_bins.discarded.map { it[1] }.collect().ifEmpty([]), - GTDBTK_CLASSIFYWF.out.summary.map { it[1] }.collect().ifEmpty { ([]) }, + ch_filtered_bins.discarded.map { _meta, bin -> bin }.collect().ifEmpty([]), + GTDBTK_CLASSIFYWF.out.summary.map { _meta, summary -> summary }.collect().ifEmpty { ([]) }, [], [], ) diff --git a/subworkflows/local/hostremoval_longread/main.nf b/subworkflows/local/hostremoval_longread/main.nf index a5f5aef97..75e160eca 100644 --- a/subworkflows/local/hostremoval_longread/main.nf +++ b/subworkflows/local/hostremoval_longread/main.nf @@ -12,14 +12,14 @@ include { SAMTOOLS_UNMAPPED as SAMTOOLS_HOSTREMOVED_UNMAPPED } from '../../../mo workflow LONGREAD_HOSTREMOVAL { take: - ch_reads // [ [ meta ], [ reads ] ] + ch_reads // [val(meta), path(fastq)] val_reference // path main: - ch_versions = Channel.empty() - ch_multiqc_files = Channel.empty() + ch_versions = channel.empty() + ch_multiqc_files = channel.empty() - ch_host_reference = val_reference.map { [[:], it] } + ch_host_reference = val_reference.map { ref -> [[:], ref] } ch_host_fasta_for_build = ch_host_reference .combine(ch_reads) .map { host_meta, host_fasta, _meta, _reads -> diff --git a/subworkflows/local/preprocessing_longread/main.nf b/subworkflows/local/preprocessing_longread/main.nf index d794ae9c3..5094bd736 100644 --- a/subworkflows/local/preprocessing_longread/main.nf +++ b/subworkflows/local/preprocessing_longread/main.nf @@ -17,15 +17,15 @@ include { LONGREAD_HOSTREMOVAL } from '../hostremoval_longread/main' workflow LONGREAD_PREPROCESSING { take: - ch_raw_long_reads // [ [meta] , fastq] (mandatory) - ch_short_reads // [ [meta] , fastq1, fastq2] - ch_lambda_db // [fasta] - ch_host_fasta // [fasta] - val_skip_qc // [boolean] + ch_raw_long_reads // [val(meta), path(fastq)] (mandatory) + ch_short_reads // [val(meta), path(fastq1), path(fastq2)] + ch_lambda_db // [val(meta), path(fasta)] + ch_host_fasta // [val(meta), path(fasta)] + val_skip_qc // val(boolean) main: - ch_versions = Channel.empty() - ch_multiqc_files = Channel.empty() + ch_versions = channel.empty() + ch_multiqc_files = channel.empty() NANOPLOT_RAW( ch_raw_long_reads @@ -72,7 +72,7 @@ workflow LONGREAD_PREPROCESSING { ch_short_and_long_reads = ch_long_reads .map { meta, lr -> [meta.id, meta, lr] } .join(ch_short_reads_tmp, by: 0, remainder: true) - .filter { it[1] != null } + .filter { row -> row[1] != null } // filter out samples with no long reads .map { _id, meta_lr, lr, sr -> [meta_lr, sr ? sr : [], lr] } // should not occur for single-end, since SPAdes (hybrid) does not support single-end @@ -120,9 +120,7 @@ workflow LONGREAD_PREPROCESSING { */ if (!(val_skip_qc && !(params.host_fasta || params.host_genome))) { if (!(params.skip_adapter_trimming && params.skip_longread_filtering && params.keep_lambda && !(params.host_fasta || params.host_genome))) { - NANOPLOT_FILTERED( - ch_long_reads - ) + NANOPLOT_FILTERED(ch_long_reads) ch_versions = ch_versions.mix(NANOPLOT_FILTERED.out.versions) } } diff --git a/subworkflows/local/preprocessing_shortread/main.nf b/subworkflows/local/preprocessing_shortread/main.nf index cb3095a11..5d7116544 100644 --- a/subworkflows/local/preprocessing_shortread/main.nf +++ b/subworkflows/local/preprocessing_shortread/main.nf @@ -19,19 +19,17 @@ include { BOWTIE2_REMOVAL_ALIGN as BOWTIE2_PHIX_REMOVAL_ALIGN } from '../../../m workflow SHORTREAD_PREPROCESSING { take: - ch_raw_short_reads // [ [meta] , fastq1, fastq2] (mandatory) - ch_host_fasta // [fasta] (optional) - ch_host_genome_index // fasta (optional) - ch_phix_db_file // [fasta] (optional) - val_skip_qc // [boolean] + ch_raw_short_reads // [val(meta), [path(fastq1), path(fastq2)]] (mandatory) + ch_host_fasta // [val(meta), path(fasta)] (optional) + ch_host_genome_index // path(fasta) (optional) + ch_phix_db_file // [val(meta), path(fasta)] (optional) + val_skip_qc // val(boolean) main: - ch_versions = Channel.empty() - ch_multiqc_files = Channel.empty() + ch_versions = channel.empty() + ch_multiqc_files = channel.empty() - FASTQC_RAW( - ch_raw_short_reads - ) + FASTQC_RAW(ch_raw_short_reads) ch_versions = ch_versions.mix(FASTQC_RAW.out.versions) ch_multiqc_files = ch_multiqc_files.mix(FASTQC_RAW.out.zip) @@ -52,9 +50,9 @@ workflow SHORTREAD_PREPROCESSING { // due to strange output file scheme in AR2, have to manually separate // SE/PE to allow correct pulling of reads after. - ch_adapterremoval_in = ch_raw_short_reads.branch { - single: it[0]['single_end'] - paired: !it[0]['single_end'] + ch_adapterremoval_in = ch_raw_short_reads.branch { meta, _reads -> + single: meta.single_end + paired: !meta.single_end } ADAPTERREMOVAL_PE(ch_adapterremoval_in.paired, []) @@ -62,8 +60,11 @@ workflow SHORTREAD_PREPROCESSING { ADAPTERREMOVAL_SE(ch_adapterremoval_in.single, []) ch_versions = ch_versions.mix(ADAPTERREMOVAL_SE.out.versions) - ch_short_reads_prepped = Channel.empty() - ch_short_reads_prepped = ch_short_reads_prepped.mix(ADAPTERREMOVAL_SE.out.singles_truncated, ADAPTERREMOVAL_PE.out.paired_truncated) + ch_short_reads_prepped = channel.empty() + ch_short_reads_prepped = ch_short_reads_prepped.mix( + ADAPTERREMOVAL_SE.out.singles_truncated, + ADAPTERREMOVAL_PE.out.paired_truncated, + ) ch_multiqc_files = ch_multiqc_files.mix(ADAPTERREMOVAL_PE.out.settings) ch_multiqc_files = ch_multiqc_files.mix(ADAPTERREMOVAL_SE.out.settings) @@ -73,7 +74,7 @@ workflow SHORTREAD_PREPROCESSING { TRIMMOMATIC(ch_raw_short_reads) ch_versions = ch_versions.mix(TRIMMOMATIC.out.versions) - ch_short_reads_prepped = Channel.empty() + ch_short_reads_prepped = channel.empty() ch_short_reads_prepped = TRIMMOMATIC.out.trimmed_reads ch_multiqc_files = ch_multiqc_files.mix(TRIMMOMATIC.out.out_log) @@ -185,7 +186,7 @@ workflow SHORTREAD_PREPROCESSING { } // Combine single run and multi-run-merged data - ch_short_reads = Channel.empty() + ch_short_reads = channel.empty() ch_short_reads = CAT_FASTQ.out.reads.mix(ch_short_reads_catskipped) if (params.bbnorm) { @@ -194,13 +195,15 @@ workflow SHORTREAD_PREPROCESSING { // for dropping the single_end parameter, but keeps assembly modules as they are, i.e. not // accepting a mix of single end and pairs. SEQTK_MERGEPE( - ch_short_reads.filter { !it[0].single_end } + ch_short_reads.filter { meta, _reads -> !meta.single_end } ) ch_versions = ch_versions.mix(SEQTK_MERGEPE.out.versions) // Combine the interleaved pairs with any single end libraries. Set the meta.single_end to true (used by the bbnorm module). ch_bbnorm = SEQTK_MERGEPE.out.reads - .mix(ch_short_reads.filter { it[0].single_end }) - .map { [[id: "group${it[0].group}", group: it[0].group, single_end: true], it[1]] } + .mix(ch_short_reads.filter { meta, _reads -> meta.single_end }) + .map { meta, reads -> + [[id: "group${meta.group}", group: meta.group, single_end: true], reads] + } .groupTuple() } else { diff --git a/subworkflows/local/tiara/main.nf b/subworkflows/local/tiara/main.nf index 9eac84e33..27f9b9f68 100644 --- a/subworkflows/local/tiara/main.nf +++ b/subworkflows/local/tiara/main.nf @@ -6,12 +6,12 @@ include { TIARA_CLASSIFY } from '. workflow TIARA { take: - ch_assemblies // tuple val(meta), path(assembly) - ch_in_bins // tuple val(meta), path( [ bins ] ) - ch_in_unbins // tuple val(meta), path( [ unbins ] ) + ch_assemblies // [val(meta), path(fasta)] + ch_in_bins // [val(meta), path(fasta)] + ch_in_unbins // [val(meta), path(fasta)] main: - ch_versions = Channel.empty() + ch_versions = channel.empty() ch_bins = ch_in_bins.map { meta, bin_list -> def meta_new = meta + [bin: 'bins'] diff --git a/subworkflows/local/utils_nfcore_mag_pipeline/main.nf b/subworkflows/local/utils_nfcore_mag_pipeline/main.nf index 85bb90410..ac8e80940 100644 --- a/subworkflows/local/utils_nfcore_mag_pipeline/main.nf +++ b/subworkflows/local/utils_nfcore_mag_pipeline/main.nf @@ -37,7 +37,7 @@ workflow PIPELINE_INITIALISATION { main: - ch_versions = Channel.empty() + ch_versions = channel.empty() // // Print version and exit if required and dump pipeline parameters to JSON file @@ -62,7 +62,7 @@ workflow PIPELINE_INITIALISATION { \033[0;35m nf-core/mag ${workflow.manifest.version}\033[0m -\033[2m----------------------------------------------------\033[0m- """ - after_text = """${workflow.manifest.doi ? "\n* The pipeline\n" : ""}${workflow.manifest.doi.tokenize(",").collect { " https://doi.org/${it.trim().replace('https://doi.org/', '')}" }.join("\n")}${workflow.manifest.doi ? "\n" : ""} + after_text = """${workflow.manifest.doi ? "\n* The pipeline\n" : ""}${workflow.manifest.doi.tokenize(",").collect { doi -> " https://doi.org/${doi.trim().replace('https://doi.org/', '')}" }.join("\n")}${workflow.manifest.doi ? "\n" : ""} * The nf-core framework https://doi.org/10.1038/s41587-020-0439-x @@ -99,9 +99,9 @@ workflow PIPELINE_INITIALISATION { // // Validate FASTQ input - ch_samplesheet = Channel.fromList(samplesheetToList(input, "${projectDir}/assets/schema_input.json")) - .map { - validateInputSamplesheet(it[0], it[1], it[2], it[3]) + ch_samplesheet = channel.fromList(samplesheetToList(input, "${projectDir}/assets/schema_input.json")) + .map { meta, sr1, sr2, lr -> + validateInputSamplesheet(meta, sr1, sr2, lr) } // if coassemble_group or binning_map_mode is set to not 'own', check if all samples in a group have the same platform @@ -182,7 +182,9 @@ workflow PIPELINE_INITIALISATION { // Validate PRE-ASSEMBLED CONTIG input when supplied if (params.assembly_input) { - ch_input_assemblies = Channel.fromList(samplesheetToList(params.assembly_input, "${projectDir}/assets/schema_assembly_input.json")) + ch_input_assemblies = channel.fromList( + samplesheetToList(params.assembly_input, "${projectDir}/assets/schema_assembly_input.json") + ) } // Prepare ASSEMBLY input channel @@ -192,7 +194,7 @@ workflow PIPELINE_INITIALISATION { } } else { - ch_input_assemblies = Channel.empty() + ch_input_assemblies = channel.empty() } // Cross validation of input assembly and read IDs: ensure groups are all represented between reads and assemblies @@ -365,7 +367,7 @@ def validateInputParameters(hybrid) { log.warn('[nf-core/mag]: WARNING: You have supplied a database to --busco_db - BUSCO will run in offline mode. Please note that BUSCO may fail if you have an incomplete database and are running with --busco_db_lineage auto!') } - if (params.busco_db && file(params.busco_db).isDirectory() && !file(params.busco_db).listFiles().any { it.toString().contains('lineages') }) { + if (params.busco_db && file(params.busco_db).isDirectory() && !file(params.busco_db).listFiles().any { file -> file.toString().contains('lineages') }) { error("[nf-core/mag] ERROR: Directory supplied to `--busco_db` must contain a `lineages/` subdirectory that itself contains one or more BUSCO lineage files! Check: --busco_db ${params.busco_db}") } } diff --git a/subworkflows/local/virus_identification/main.nf b/subworkflows/local/virus_identification/main.nf index bbdcc876d..ab3ff8026 100644 --- a/subworkflows/local/virus_identification/main.nf +++ b/subworkflows/local/virus_identification/main.nf @@ -8,11 +8,11 @@ include { UNTAR as GENOMAD_UNTAR } from '../../../modules/nf-core/untar/main' workflow VIRUS_IDENTIFICATION { take: - ch_assemblies // [ [ meta] , fasta ], input scaffolds (mandatory) - ch_genomad_db // [ db ], presupplied geNomad database (optional) + ch_assemblies // [val(meta), path(fasta)] input scaffolds (mandatory) + ch_genomad_db // [path(db)] presupplied geNomad database (optional) main: - ch_versions = Channel.empty() + ch_versions = channel.empty() if (params.genomad_db && ch_genomad_db.extension == 'gz') { GENOMAD_UNTAR([[id: 'db'], ch_genomad_db]) diff --git a/workflows/mag.nf b/workflows/mag.nf index 9e75b764c..f955d03c9 100644 --- a/workflows/mag.nf +++ b/workflows/mag.nf @@ -51,8 +51,8 @@ workflow MAG { main: - ch_versions = Channel.empty() - ch_multiqc_files = Channel.empty() + ch_versions = channel.empty() + ch_multiqc_files = channel.empty() //////////////////////////////////////////////////// /* -- Create channel for reference databases -- */ @@ -60,44 +60,48 @@ workflow MAG { if (params.host_genome) { host_fasta = params.genomes[params.host_genome].fasta ?: false - ch_host_fasta = Channel.value(file("${host_fasta}")) + ch_host_fasta = channel.value(file("${host_fasta}")) host_bowtie2index = params.genomes[params.host_genome].bowtie2 ?: false - ch_host_bowtie2index = Channel.fromPath("${host_bowtie2index}", checkIfExists: true).first() + ch_host_bowtie2index = channel.fromPath("${host_bowtie2index}", checkIfExists: true).first() } else if (params.host_fasta) { - ch_host_fasta = Channel.fromPath("${params.host_fasta}", checkIfExists: true).first() ?: false + ch_host_fasta = channel.fromPath("${params.host_fasta}", checkIfExists: true).first() ?: false if (params.host_fasta_bowtie2index) { - ch_host_bowtie2index = Channel.fromPath("${params.host_fasta_bowtie2index}", checkIfExists: true).first() + ch_host_bowtie2index = channel.fromPath("${params.host_fasta_bowtie2index}", checkIfExists: true).first() } else { - ch_host_bowtie2index = Channel.empty() + ch_host_bowtie2index = channel.empty() } } else { - ch_host_fasta = Channel.empty() - ch_host_bowtie2index = Channel.empty() + ch_host_fasta = channel.empty() + ch_host_bowtie2index = channel.empty() } if (!params.keep_phix) { - ch_phix_db_file = params.phix_reference ? Channel.value(file("${params.phix_reference}", checkIfExists: true)) : Channel.value(file("${projectDir}/assets/data/GCA_002596845.1_ASM259684v1_genomic.fna.gz", checkIfExists: true)) + ch_phix_db_file = params.phix_reference + ? channel.value(file("${params.phix_reference}", checkIfExists: true)) + : channel.value(file("${projectDir}/assets/data/GCA_002596845.1_ASM259684v1_genomic.fna.gz", checkIfExists: true)) } else { - ch_phix_db_file = Channel.empty() + ch_phix_db_file = channel.empty() } if (!params.keep_lambda) { - ch_lambda_db = params.lambda_reference ? Channel.value(file("${params.lambda_reference}", checkIfExists: true)) : Channel.value(file("${projectDir}/assets/data/GCA_000840245.1_ViralProj14204_genomic.fna.gz", checkIfExists: true)) + ch_lambda_db = params.lambda_reference + ? channel.value(file("${params.lambda_reference}", checkIfExists: true)) + : channel.value(file("${projectDir}/assets/data/GCA_000840245.1_ViralProj14204_genomic.fna.gz", checkIfExists: true)) } else { - ch_lambda_db = Channel.value([]) + ch_lambda_db = channel.value([]) } if (params.genomad_db) { ch_genomad_db = file(params.genomad_db, checkIfExists: true) } else { - ch_genomad_db = Channel.empty() + ch_genomad_db = channel.empty() } gtdb = params.skip_binqc || params.skip_gtdbtk ? false : params.gtdb_db @@ -110,10 +114,10 @@ workflow MAG { } if (params.metaeuk_db && !params.skip_metaeuk) { - ch_metaeuk_db = Channel.value(file("${params.metaeuk_db}", checkIfExists: true)) + ch_metaeuk_db = channel.value(file("${params.metaeuk_db}", checkIfExists: true)) } else { - ch_metaeuk_db = Channel.empty() + ch_metaeuk_db = channel.empty() } // Get mmseqs db for MetaEuk if requested @@ -138,7 +142,9 @@ workflow MAG { params.skip_shortread_qc, ) ch_versions = ch_versions.mix(SHORTREAD_PREPROCESSING.out.versions) - ch_multiqc_files = ch_multiqc_files.mix(SHORTREAD_PREPROCESSING.out.multiqc_files.collect { it[1] }.ifEmpty([])) + ch_multiqc_files = ch_multiqc_files.mix( + SHORTREAD_PREPROCESSING.out.multiqc_files.collect { _meta, report -> report }.ifEmpty([]) + ) ch_short_reads = SHORTREAD_PREPROCESSING.out.short_reads ch_short_reads_assembly = SHORTREAD_PREPROCESSING.out.short_reads_assembly } @@ -163,7 +169,9 @@ workflow MAG { params.skip_longread_qc, ) ch_versions = ch_versions.mix(LONGREAD_PREPROCESSING.out.versions) - ch_multiqc_files = ch_multiqc_files.mix(LONGREAD_PREPROCESSING.out.multiqc_files.collect { it[1] }.ifEmpty([])) + ch_multiqc_files = ch_multiqc_files.mix( + LONGREAD_PREPROCESSING.out.multiqc_files.collect { _meta, report -> report }.ifEmpty([]) + ) ch_long_reads = LONGREAD_PREPROCESSING.out.long_reads /* @@ -194,10 +202,10 @@ workflow MAG { GUNZIP_ASSEMBLYINPUT(ch_assemblies_split.gzipped) ch_versions = ch_versions.mix(GUNZIP_ASSEMBLYINPUT.out.versions) - ch_assemblies = Channel.empty() + ch_assemblies = channel.empty() ch_assemblies = ch_assemblies.mix(ch_assemblies_split.ungzip, GUNZIP_ASSEMBLYINPUT.out.gunzip) - ch_shortread_assemblies = ch_assemblies.filter { it[0].assembler.toUpperCase() in ['SPADES', 'SPADESHYBRID', 'MEGAHIT'] } - ch_longread_assemblies = ch_assemblies.filter { it[0].assembler.toUpperCase() in ['FLYE', 'METAMDBG'] } + ch_shortread_assemblies = ch_assemblies.filter { meta, _contigs -> meta.assembler.toUpperCase() in ['SPADES', 'SPADESHYBRID', 'MEGAHIT'] } + ch_longread_assemblies = ch_assemblies.filter { meta, _contigs -> meta.assembler.toUpperCase() in ['FLYE', 'METAMDBG'] } } if (!params.skip_quast) { @@ -268,7 +276,11 @@ workflow MAG { // Make sure if running aDNA subworkflow to use the damage-corrected contigs for higher accuracy if (params.ancient_dna && !params.skip_ancient_damagecorrection) { BINNING( - BINNING_PREPARATION.out.grouped_mappings.join(ANCIENT_DNA_ASSEMBLY_VALIDATION.out.contigs_recalled).map { it -> [it[0], it[4], it[2], it[3]] }, + BINNING_PREPARATION.out.grouped_mappings + .join(ANCIENT_DNA_ASSEMBLY_VALIDATION.out.contigs_recalled) + .map { meta, _contigs, bams, bais, corrected_contigs -> + [meta, corrected_contigs, bams, bais] + }, params.bin_min_size, params.bin_max_size, ) @@ -382,7 +394,7 @@ workflow MAG { * Bin QC subworkflows: for checking bin completeness with either BUSCO, CHECKM, CHECKM2, and/or GUNC */ - ch_bin_qc_summary = Channel.empty() + ch_bin_qc_summary = channel.empty() if (!params.skip_binqc) { BIN_QC(ch_input_for_postbinning) ch_versions = ch_versions.mix(BIN_QC.out.versions) @@ -392,7 +404,7 @@ workflow MAG { ch_checkm2_summary = BIN_QC.out.checkm2_summary } - ch_quast_bins_summary = Channel.empty() + ch_quast_bins_summary = channel.empty() if (!params.skip_quast) { ch_input_for_quast_bins = ch_input_for_postbinning .groupTuple() @@ -415,7 +427,7 @@ workflow MAG { /* * CATPACK: bin / contig taxonomic classification */ - ch_catpack_summary = Channel.empty() + ch_catpack_summary = channel.empty() if (params.cat_db || params.cat_db_generate) { CATPACK( ch_input_for_postbinning_bins, @@ -431,7 +443,7 @@ workflow MAG { */ if (!params.skip_gtdbtk) { - ch_gtdbtk_summary = Channel.empty() + ch_gtdbtk_summary = channel.empty() if (gtdb) { ch_gtdb_bins = ch_input_for_postbinning.filter { meta, _bins -> @@ -448,7 +460,7 @@ workflow MAG { } } else { - ch_gtdbtk_summary = Channel.empty() + ch_gtdbtk_summary = channel.empty() } if ((!params.skip_binqc) || !params.skip_quast || !params.skip_gtdbtk) { BIN_SUMMARY( @@ -518,29 +530,29 @@ workflow MAG { // // MODULE: MultiQC // - ch_multiqc_config = Channel.fromPath( + ch_multiqc_config = channel.fromPath( "${projectDir}/assets/multiqc_config.yml", checkIfExists: true ) ch_multiqc_custom_config = params.multiqc_config - ? Channel.fromPath(params.multiqc_config, checkIfExists: true) - : Channel.empty() + ? channel.fromPath(params.multiqc_config, checkIfExists: true) + : channel.empty() ch_multiqc_logo = params.multiqc_logo - ? Channel.fromPath(params.multiqc_logo, checkIfExists: true) - : Channel.fromPath("${workflow.projectDir}/docs/images/mag_logo_mascot_light.png", checkIfExists: true) + ? channel.fromPath(params.multiqc_logo, checkIfExists: true) + : channel.fromPath("${workflow.projectDir}/docs/images/mag_logo_mascot_light.png", checkIfExists: true) summary_params = paramsSummaryMap( workflow, parameters_schema: "nextflow_schema.json" ) - ch_workflow_summary = Channel.value(paramsSummaryMultiqc(summary_params)) + ch_workflow_summary = channel.value(paramsSummaryMultiqc(summary_params)) ch_multiqc_files = ch_multiqc_files.mix( ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml') ) ch_multiqc_custom_methods_description = params.multiqc_methods_description ? file(params.multiqc_methods_description, checkIfExists: true) : file("${projectDir}/assets/methods_description_template.yml", checkIfExists: true) - ch_methods_description = Channel.value( + ch_methods_description = channel.value( methodsDescriptionText(ch_multiqc_custom_methods_description) ) @@ -565,7 +577,7 @@ workflow MAG { } if (!params.skip_binning && !params.skip_prokka) { - ch_multiqc_files = ch_multiqc_files.mix(PROKKA.out.txt.collect { it[1] }.ifEmpty([])) + ch_multiqc_files = ch_multiqc_files.mix(PROKKA.out.txt.collect { _meta, report -> report }.ifEmpty([])) } if (!params.skip_binning && !params.skip_binqc) { ch_multiqc_files = ch_multiqc_files.mix(BIN_QC.out.multiqc_files.collect().ifEmpty([]))