From f1d2b5acaeabf6aff3f9be494dc42f8b4591cc96 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Sat, 16 Nov 2024 15:12:56 -0600 Subject: [PATCH] refactor: Move uniqmap generation to references https://github.com/nf-core/references/issues/3 --- main.nf | 1 + modules/nf-core/homer/findpeaks/main.nf | 3 +- nextflow_schema.json | 6 ++++ subworkflows/nf-core/homer/groseq/main.nf | 42 ++++++----------------- workflows/nascent.nf | 2 ++ 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/main.nf b/main.nf index 4e0cbc32..e698542d 100644 --- a/main.nf +++ b/main.nf @@ -69,6 +69,7 @@ workflow NFCORE_NASCENT { params.bowtie2_index, params.hisat2_index, params.star_index, + params.homer_uniqmap ) emit: multiqc_report = NASCENT.out.multiqc_report // channel: /path/to/multiqc_report.html diff --git a/modules/nf-core/homer/findpeaks/main.nf b/modules/nf-core/homer/findpeaks/main.nf index 71e26679..bce67462 100644 --- a/modules/nf-core/homer/findpeaks/main.nf +++ b/modules/nf-core/homer/findpeaks/main.nf @@ -23,13 +23,14 @@ process HOMER_FINDPEAKS { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def VERSION = '4.11' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. + def uniqmap_flag = uniqmap ? "-uniqmap $uniqmap" : "" """ findPeaks \\ $tagDir \\ $args \\ -o ${prefix}.peaks.txt \\ - -uniqmap $uniqmap + $uniqmap_flag cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/nextflow_schema.json b/nextflow_schema.json index 60465a52..ba327409 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -254,6 +254,12 @@ "fa_icon": "fas fa-copy", "help_text": "> **NB** If none provided, index will be generated automatically from the FASTA reference." }, + "homer_uniqmap": { + "type": "string", + "description": "Path to HOMER uniqmap file or URL to download.", + "fa_icon": "fas fa-file-archive", + "help_text": "> **NB** If none provided, will be downloaded automatically from the HOMER website. See nf-core/references for generation" + }, "save_reference": { "type": "boolean", "description": "If generated by the pipeline save the BWA index in the results directory.", diff --git a/subworkflows/nf-core/homer/groseq/main.nf b/subworkflows/nf-core/homer/groseq/main.nf index 4df5b089..68afb1fc 100644 --- a/subworkflows/nf-core/homer/groseq/main.nf +++ b/subworkflows/nf-core/homer/groseq/main.nf @@ -2,49 +2,29 @@ * Identify transcripts with homer */ -include { HOMER_GETMAPPABLEREGIONS } from '../../../../modules/local/homer/getmappableregions/main' -include { HOMER_CREATEUNIQMAP } from '../../../../modules/local/homer/createuniqmap/main' -include { UNZIP } from '../../../../modules/nf-core/unzip/main' +include { UNZIP } from '../../../../modules/nf-core/unzip/main' -include { HOMER_MAKETAGDIRECTORY } from '../../../../modules/nf-core/homer/maketagdirectory/main' -include { HOMER_MAKEUCSCFILE } from '../../../../modules/nf-core/homer/makeucscfile/main' -include { HOMER_FINDPEAKS } from '../../../../modules/nf-core/homer/findpeaks/main' -include { HOMER_POS2BED } from '../../../../modules/nf-core/homer/pos2bed/main' +include { HOMER_MAKETAGDIRECTORY } from '../../../../modules/nf-core/homer/maketagdirectory/main' +include { HOMER_MAKEUCSCFILE } from '../../../../modules/nf-core/homer/makeucscfile/main' +include { HOMER_FINDPEAKS } from '../../../../modules/nf-core/homer/findpeaks/main' +include { HOMER_POS2BED } from '../../../../modules/nf-core/homer/pos2bed/main' workflow HOMER_GROSEQ { take: - bam // channel: [ val(meta), [ reads ] ] - fasta // file: /path/to/bwa/index/ + bam // channel: [ val(meta), [ reads ] ] + fasta // file: /path/to/bwa/index/ + uniqmap main: ch_versions = Channel.empty() ch_uniqmap = Channel.empty() - if (!params.homer_uniqmap) { - // Split FASTA by chromosome - split_fastas = fasta - .splitFasta(by: 1, file: true) - .toSortedList() - - // Generate mappable regions - HOMER_GETMAPPABLEREGIONS( - split_fastas, - 1000000000, - 50 - ) - ch_versions = ch_versions.mix(HOMER_GETMAPPABLEREGIONS.out.versions) - - // Create uniqmap directory - HOMER_CREATEUNIQMAP( - HOMER_GETMAPPABLEREGIONS.out.txt - ) - ch_versions = ch_versions.mix(HOMER_CREATEUNIQMAP.out.versions) - - ch_uniqmap = HOMER_CREATEUNIQMAP.out.uniqmap_dir + if (uniqmap.endsWith('.zip')) { + ch_uniqmap = UNZIP([[:], params.homer_uniqmap]).map { it[1] } } else { - ch_uniqmap = UNZIP([[:], params.homer_uniqmap]).map { it[1] } + ch_uniqmap = uniqmap } /* diff --git a/workflows/nascent.nf b/workflows/nascent.nf index 0eb1b33e..af9b1996 100644 --- a/workflows/nascent.nf +++ b/workflows/nascent.nf @@ -59,6 +59,7 @@ workflow NASCENT { ch_bowtie2_index ch_hisat2_index ch_star_index + ch_uniqmap main: @@ -294,6 +295,7 @@ workflow NASCENT { ch_gxf, PREPARE_GENOME.out.fasta, PREPARE_GENOME.out.chrom_sizes, + ch_uniqmap ) ch_grohmm_multiqc = TRANSCRIPT_INDENTIFICATION.out.grohmm_td_plot.collect() ch_homer_multiqc = TRANSCRIPT_INDENTIFICATION.out.homer_peaks