From 3b90064ba4d50c7010fdb4eb302686a2006f8bf1 Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Wed, 22 Mar 2023 15:39:45 +0100 Subject: [PATCH] Start adding conditions in modules.conf - non-cat not working --- conf/modules.config | 155 +++++++++++++++++++++--------- nextflow.config | 2 + subworkflows/local/input_check.nf | 3 +- 3 files changed, 111 insertions(+), 49 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index ee1a3d2..5662cb4 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -71,6 +71,12 @@ process { path: { "${params.outdir}/fastp" }, mode: params.publish_dir_mode, pattern: '*.{log,html,json}' + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: !params.perform_runmerging && !params.perform_shortread_hostremoval && !params.shortread_complexityfilter_tool && !params.perform_shortread_qc && params.save_analysis_ready_reads ] ] } @@ -99,6 +105,12 @@ process { path: { "${params.outdir}/fastp" }, mode: params.publish_dir_mode, pattern: '*.{log,html,json}' + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: !params.perform_runmerging && !params.perform_shortread_hostremoval && !params.shortread_complexityfilter_tool && !params.perform_shortread_qc && params.save_analysis_ready_reads ] ] } @@ -122,6 +134,12 @@ process { path: { "${params.outdir}/adapterremoval" }, mode: params.publish_dir_mode, pattern: '*.settings' + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: !params.perform_runmerging && !params.perform_shortread_hostremoval && !params.shortread_complexityfilter_tool && !params.perform_shortread_qc && params.save_analysis_ready_reads ] ] } @@ -148,6 +166,12 @@ process { path: { "${params.outdir}/adapterremoval" }, mode: params.publish_dir_mode, pattern: '*.settings' + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: !params.perform_runmerging && !params.perform_shortread_hostremoval && !params.shortread_complexityfilter_tool && !params.perform_shortread_qc && params.save_analysis_ready_reads ] ] } @@ -166,6 +190,7 @@ process { mode: params.publish_dir_mode, pattern: '*.log' ] + // TODO ANALYSIS READY ] } @@ -190,14 +215,78 @@ process { pattern: '*.log' ] ] + // TODO ANALYSIS READY + } + + withName: BBMAP_BBDUK { + ext.args = [ + "entropy=${params.shortread_complexityfilter_entropy}", + "entropywindow=${params.shortread_complexityfilter_bbduk_windowsize}", + params.shortread_complexityfilter_bbduk_mask ? "entropymask=t" : "entropymask=f" + ].join(' ').trim() + ext.prefix = { "${meta.id}_${meta.run_accession}" } + publishDir = [ + [ + path: { "${params.outdir}/bbduk/" }, + mode: params.publish_dir_mode, + pattern: '*.{fastq.gz,log}', + enabled: params.save_complexityfiltered_reads + ], + [ + path: { "${params.outdir}/bbduk/" }, + mode: params.publish_dir_mode, + pattern: '*.log' + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: !params.perform_runmerging && !params.perform_shortread_hostremoval && params.shortread_complexityfilter_tool && params.save_analysis_ready_reads + ] + ] + } + + withName: PRINSEQPLUSPLUS { + ext.args = [ + params.shortread_complexityfilter_prinseqplusplus_mode == 'dust' ? "-lc_dust=${params.shortread_complexityfilter_prinseqplusplus_dustscore}" : "-lc_entropy=${params.shortread_complexityfilter_entropy}", + "-trim_qual_left=0 -trim_qual_left=0 -trim_qual_window=0 -trim_qual_step=0", + ].join(' ').trim() + ext.prefix = { "${meta.id}_${meta.run_accession}" } + publishDir = [ + [ + path: { "${params.outdir}/prinseqplusplus/" }, + mode: params.publish_dir_mode, + pattern: '*{_good_out.fastq.gz,_good_out_R1.fastq.gz,_good_out_R2.fastq.gz}', + enabled: params.save_complexityfiltered_reads + ], + [ + path: { "${params.outdir}/prinseqplusplus/" }, + mode: params.publish_dir_mode, + pattern: '*.log' + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: !params.perform_runmerging && !params.perform_shortread_hostremoval && params.shortread_complexityfilter_tool && params.save_analysis_ready_reads + ] + ] } withName: BOWTIE2_BUILD { publishDir = [ + [ path: { "${params.outdir}/bowtie2/build" }, mode: params.publish_dir_mode, pattern: 'bowtie2', enabled: params.save_hostremoval_index + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: !params.perform_runmerging && !params.perform_shortread_hostremoval && !params.shortread_complexityfilter_tool && !params.perform_shortread_qc && params.save_analysis_ready_reads + ] ] } @@ -221,6 +310,12 @@ process { mode: params.publish_dir_mode, pattern: '*.fastq.gz', enabled: params.save_hostremoval_unmapped + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + saveAs: { (( !params.perform_runmerging | params.perform_runmerging && !${meta.is_multirun} ) && params.perform_shortread_hostremoval && params.save_analysis_ready_reads ) ? it : null } ] ] } @@ -243,6 +338,7 @@ process { pattern: '*.bam', enabled: params.save_hostremoval_bam ] + // TODO ANALYSIS READY READS } withName: SAMTOOLS_VIEW { @@ -269,56 +365,21 @@ process { ] } - withName: BBMAP_BBDUK { - ext.args = [ - "entropy=${params.shortread_complexityfilter_entropy}", - "entropywindow=${params.shortread_complexityfilter_bbduk_windowsize}", - params.shortread_complexityfilter_bbduk_mask ? "entropymask=t" : "entropymask=f" - ].join(' ').trim() - ext.prefix = { "${meta.id}_${meta.run_accession}" } - publishDir = [ - [ - path: { "${params.outdir}/bbduk/" }, - mode: params.publish_dir_mode, - pattern: '*.{fastq.gz,log}', - enabled: params.save_complexityfiltered_reads - ], - [ - path: { "${params.outdir}/bbduk/" }, - mode: params.publish_dir_mode, - pattern: '*.log' - ] - ] - } - - withName: PRINSEQPLUSPLUS { - ext.args = [ - params.shortread_complexityfilter_prinseqplusplus_mode == 'dust' ? "-lc_dust=${params.shortread_complexityfilter_prinseqplusplus_dustscore}" : "-lc_entropy=${params.shortread_complexityfilter_entropy}", - "-trim_qual_left=0 -trim_qual_left=0 -trim_qual_window=0 -trim_qual_step=0", - ].join(' ').trim() - ext.prefix = { "${meta.id}_${meta.run_accession}" } - publishDir = [ - [ - path: { "${params.outdir}/prinseqplusplus/" }, - mode: params.publish_dir_mode, - pattern: '*{_good_out.fastq.gz,_good_out_R1.fastq.gz,_good_out_R2.fastq.gz}', - enabled: params.save_complexityfiltered_reads - ], - [ - path: { "${params.outdir}/prinseqplusplus/" }, - mode: params.publish_dir_mode, - pattern: '*.log' - ] - ] - } - withName: CAT_FASTQ { ext.prefix = { "${meta.id}" } publishDir = [ - path: { "${params.outdir}/run_merging/" }, - mode: params.publish_dir_mode, - pattern: '*.fastq.gz', - enabled: params.save_runmerged_reads + [ + path: { "${params.outdir}/run_merging/" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: params.save_runmerged_reads + ], + [ + path: { "${params.outdir}/analysis_ready_reads" }, + mode: params.publish_dir_mode, + pattern: '*.fastq.gz', + enabled: params.perform_runmerging && params.save_analysis_ready_reads + ] ] } diff --git a/nextflow.config b/nextflow.config index 05cd7ea..0e6850f 100644 --- a/nextflow.config +++ b/nextflow.config @@ -105,6 +105,8 @@ params { save_hostremoval_bam = false save_hostremoval_unmapped = false + // Publishing final reads going into profiling + save_analysis_ready_reads = false // MALT run_malt = false diff --git a/subworkflows/local/input_check.nf b/subworkflows/local/input_check.nf index a8862b6..f6ac420 100644 --- a/subworkflows/local/input_check.nf +++ b/subworkflows/local/input_check.nf @@ -10,7 +10,7 @@ workflow INPUT_CHECK { main: - // Table to list, group per sample, detect if sample has multi-run, + // Table to list, group per sample, detect if sample has multi-run, // then spread back to per-run rows but with multi-run info added to meta ch_split_samplesheet = SAMPLESHEET_CHECK ( samplesheet ) .csv @@ -43,7 +43,6 @@ workflow INPUT_CHECK { // Channel generation ch_fastq = ch_parsed_samplesheet.fastq .map { create_fastq_channel(it) } - .dump(tag: "boop") ch_nanopore = ch_parsed_samplesheet.nanopore .map { create_fastq_channel(it) }