diff --git a/subworkflows/local/genome_quant.nf b/subworkflows/local/genome_quant.nf index b310c76a..0f97f16b 100644 --- a/subworkflows/local/genome_quant.nf +++ b/subworkflows/local/genome_quant.nf @@ -8,32 +8,19 @@ include { BOWTIE_MAP_SEQ as BOWTIE_MAP_GENOME } from '../../modules/local/bowtie workflow GENOME_QUANT { take: - fasta - index + bowtie_index + fasta_formatted // fasta as generated by bowtie index step reads // channel: [ val(meta), [ reads ] ] main: ch_versions = Channel.empty() - if (!index){ - INDEX_GENOME ( [ [:], fasta ] ) - bowtie_index = INDEX_GENOME.out.index - fasta_formatted = INDEX_GENOME.out.fasta - ch_versions = ch_versions.mix(INDEX_GENOME.out.versions) - } else { - bowtie_index = Channel.fromPath("${index}**ebwt", checkIfExists: true).ifEmpty { exit 1, "Bowtie1 index directory not found: ${index}" } - fasta_formatted = fasta - } + BOWTIE_MAP_GENOME ( reads, bowtie_index.collect() ) + ch_versions = ch_versions.mix(BOWTIE_MAP_GENOME.out.versions) - if (bowtie_index){ - BOWTIE_MAP_GENOME ( reads, bowtie_index.collect() ) - ch_versions = ch_versions.mix(BOWTIE_MAP_GENOME.out.versions) - fasta_formatted - .map { file -> tuple(file.baseName, file) } - .set { sort_input } - BAM_SORT_STATS_SAMTOOLS ( BOWTIE_MAP_GENOME.out.bam, sort_input ) - ch_versions = ch_versions.mix(BAM_SORT_STATS_SAMTOOLS.out.versions) - } + ch_fasta_formatted_for_sort = fasta_formatted .map { file -> tuple(file.baseName, file) } + BAM_SORT_STATS_SAMTOOLS ( BOWTIE_MAP_GENOME.out.bam, ch_fasta_formatted_for_sort ) + ch_versions = ch_versions.mix(BAM_SORT_STATS_SAMTOOLS.out.versions) emit: fasta = fasta_formatted diff --git a/subworkflows/local/umi_dedup.nf b/subworkflows/local/umi_dedup.nf index f8981758..2eda1b60 100644 --- a/subworkflows/local/umi_dedup.nf +++ b/subworkflows/local/umi_dedup.nf @@ -12,7 +12,6 @@ include { CAT_CAT } from '../../modules/nf-core/cat/ workflow DEDUPLICATE_UMIS { take: - fasta bt_index reads // channel: [ val(meta), [ reads ] ] val_get_dedup_stats //boolean true/false @@ -22,16 +21,6 @@ workflow DEDUPLICATE_UMIS { ch_versions = Channel.empty() ch_dedup_stats = Channel.empty() - if (!bt_index){ - INDEX_GENOME ( [ [:], fasta ] ) - bt_index = INDEX_GENOME.out.index - fasta_formatted = INDEX_GENOME.out.fasta - ch_versions = ch_versions.mix(INDEX_GENOME.out.versions) - } else { - fasta_formatted = fasta - } - - UMI_MAP_GENOME ( reads, bt_index.collect() ) ch_versions = ch_versions.mix(UMI_MAP_GENOME.out.versions) diff --git a/workflows/smrnaseq.nf b/workflows/smrnaseq.nf index 4b81796c..56ab5a05 100644 --- a/workflows/smrnaseq.nf +++ b/workflows/smrnaseq.nf @@ -150,29 +150,32 @@ workflow SMRNASEQ { ) ch_versions = ch_versions.mix(FASTQ_FASTQC_UMITOOLS_FASTP.out.versions) + ch_fasta = file(params.fasta) reads_for_mirna = FASTQ_FASTQC_UMITOOLS_FASTP.out.reads + //Prepare bowtie index, unless specified + //This needs to be done here as the index is used by both UMI deduplication and GENOME_QUANT + if(params.bowtie_index) { + ch_bowtie_index = Channel.fromPath("${index}**ebwt", checkIfExists: true).ifEmpty { error "Bowtie1 index directory not found: ${index}" } + ch_fasta_formatted = ch_fasta + } else { + INDEX_GENOME ( [ [:], ch_fasta ] ) + ch_versions = ch_versions.mix(INDEX_GENOME.out.versions) + ch_bowtie_index = INDEX_GENOME.out.index + ch_fasta_formatted = INDEX_GENOME.out.fasta + } + // // SUBWORKFLOW: Deduplicate UMIs by mapping them to the genome // if (params.with_umi){ - if (params.fasta){ - fasta_ch = file(params.fasta) - - //This needs to be done here as GENOME_QUANT should not run prior to the deduplication of UMIs. - INDEX_GENOME ( [ [:], fasta_ch ] ) - - ch_versions = ch_versions.mix(INDEX_GENOME.out.versions) - - DEDUPLICATE_UMIS ( - fasta_ch, - INDEX_GENOME.out.index, - FASTQ_FASTQC_UMITOOLS_FASTP.out.reads, - params.umi_stats - ) - reads_for_mirna = DEDUPLICATE_UMIS.out.reads - ch_versions = ch_versions.mix(DEDUPLICATE_UMIS.out.versions) - } + DEDUPLICATE_UMIS ( + ch_bowtie_index, + FASTQ_FASTQC_UMITOOLS_FASTP.out.reads, + params.umi_stats + ) + reads_for_mirna = DEDUPLICATE_UMIS.out.reads + ch_versions = ch_versions.mix(DEDUPLICATE_UMIS.out.versions) } @@ -225,7 +228,7 @@ workflow SMRNASEQ { // genome_stats = Channel.empty() if (params.fasta){ - GENOME_QUANT ( file(params.fasta), params.bowtie_index, MIRNA_QUANT.out.unmapped ) + GENOME_QUANT ( ch_bowtie_index, ch_fasta_formatted, MIRNA_QUANT.out.unmapped ) genome_stats = GENOME_QUANT.out.stats ch_versions = ch_versions.mix(GENOME_QUANT.out.versions)