From e963569d87f4bb0e9d733a166aa3b62c72a7a32a Mon Sep 17 00:00:00 2001 From: svarona Date: Fri, 25 Oct 2024 16:13:17 +0200 Subject: [PATCH] made adapters channel instead of meta --- modules/nf-core/cutadapt/cutadapt.diff | 19 +++++++++++++------ modules/nf-core/cutadapt/main.nf | 10 +++++----- workflows/illumina.nf | 18 ++++-------------- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/modules/nf-core/cutadapt/cutadapt.diff b/modules/nf-core/cutadapt/cutadapt.diff index fcbff0f2..2a450c54 100644 --- a/modules/nf-core/cutadapt/cutadapt.diff +++ b/modules/nf-core/cutadapt/cutadapt.diff @@ -3,22 +3,29 @@ Changes in module 'nf-core/cutadapt' Changes in 'cutadapt/main.nf': --- modules/nf-core/cutadapt/main.nf +++ modules/nf-core/cutadapt/main.nf -@@ -22,11 +22,26 @@ +@@ -9,6 +9,7 @@ + + input: + tuple val(meta), path(reads) ++ path adapters + + output: + tuple val(meta), path('*.trim.fastq.gz'), emit: reads +@@ -22,11 +23,25 @@ def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def trimmed = meta.single_end ? "-o ${prefix}.trim.fastq.gz" : "-o ${prefix}_1.trim.fastq.gz -p ${prefix}_2.trim.fastq.gz" -+ def threeprime_adapters = params.threeprime_adapters ?: false + + // Ajustar primers segĂșn las condiciones dadas + def primers + if (params.threeprime_adapters && meta.single_end) { -+ primers = "-a file:${meta.primers}" ++ primers = "-a file:${adapters}" + } else if (params.threeprime_adapters && !meta.single_end) { -+ primers = "-a file:${meta.primers} -A file:${meta.primers}" ++ primers = "-a file:${adapters} -A file:${adapters}" + } else if (!params.threeprime_adapters && meta.single_end) { -+ primers = "-g file:${meta.primers}" ++ primers = "-g file:${adapters}" + } else { -+ primers = "-g file:${meta.primers} -G file:${meta.primers}" ++ primers = "-g file:${adapters} -G file:${adapters}" + } + """ diff --git a/modules/nf-core/cutadapt/main.nf b/modules/nf-core/cutadapt/main.nf index 2a1f92c6..01ff1173 100644 --- a/modules/nf-core/cutadapt/main.nf +++ b/modules/nf-core/cutadapt/main.nf @@ -9,6 +9,7 @@ process CUTADAPT { input: tuple val(meta), path(reads) + path adapters output: tuple val(meta), path('*.trim.fastq.gz'), emit: reads @@ -22,18 +23,17 @@ process CUTADAPT { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" def trimmed = meta.single_end ? "-o ${prefix}.trim.fastq.gz" : "-o ${prefix}_1.trim.fastq.gz -p ${prefix}_2.trim.fastq.gz" - def threeprime_adapters = params.threeprime_adapters ?: false // Ajustar primers segĂșn las condiciones dadas def primers if (params.threeprime_adapters && meta.single_end) { - primers = "-a file:${meta.primers}" + primers = "-a file:${adapters}" } else if (params.threeprime_adapters && !meta.single_end) { - primers = "-a file:${meta.primers} -A file:${meta.primers}" + primers = "-a file:${adapters} -A file:${adapters}" } else if (!params.threeprime_adapters && meta.single_end) { - primers = "-g file:${meta.primers}" + primers = "-g file:${adapters}" } else { - primers = "-g file:${meta.primers} -G file:${meta.primers}" + primers = "-g file:${adapters} -G file:${adapters}" } """ diff --git a/workflows/illumina.nf b/workflows/illumina.nf index 75da7b31..668e7c09 100644 --- a/workflows/illumina.nf +++ b/workflows/illumina.nf @@ -577,27 +577,17 @@ workflow ILLUMINA { // ch_cutadapt_multiqc = Channel.empty() if (params.protocol == 'amplicon' && !params.skip_assembly && !params.skip_cutadapt) { + ch_primers = PREPARE_GENOME.out.primer_fasta.collect { it[1] } if (!params.skip_noninternal_primers){ PREPARE_PRIMER_FASTA( PREPARE_GENOME.out.primer_fasta.collect { it[1] } ) - ch_assembly_fastq - .map { info, reads -> - def meta = info + - [primers: PREPARE_PRIMER_FASTA.out.adapters.value] - return [meta, reads] } - .set{ ch_assembly_fastq } - } else { - ch_assembly_fastq - .map { info, reads -> - def meta = info + - [primers: PREPARE_GENOME.out.primer_fasta.value[1]] - return [meta, reads] } - .set{ ch_assembly_fastq } + ch_primers = PREPARE_PRIMER_FASTA.out.adapters } CUTADAPT ( - ch_assembly_fastq + ch_assembly_fastq, + ch_primers ) ch_assembly_fastq = CUTADAPT.out.reads ch_cutadapt_multiqc = CUTADAPT.out.log