From be1780786ec33270edc668e995580c07335c3f90 Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Fri, 23 Aug 2024 15:11:56 -0400 Subject: [PATCH 01/11] parametrize clustersets --- conf/modules.config | 2 ++ modules/local/presto/presto_clustersets.nf | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index 2ba31638..7027c0ca 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -267,6 +267,8 @@ process { mode: params.publish_dir_mode, pattern: "*{txt,log,tab}" ] + ext.args = '--exec vsearch' + ext.args2 = '-f ID BARCODE SEQCOUNT CLUSTERS' } withName: PRESTO_PARSE_CLUSTER { diff --git a/modules/local/presto/presto_clustersets.nf b/modules/local/presto/presto_clustersets.nf index 32061f0e..3a5eae2a 100644 --- a/modules/local/presto/presto_clustersets.nf +++ b/modules/local/presto/presto_clustersets.nf @@ -19,10 +19,12 @@ process PRESTO_CLUSTERSETS { path("versions.yml"), emit: versions script: + def args = task.ext.args ?: '' + def args2 = task.ext.args2 ?: '' """ - ClusterSets.py set --nproc ${task.cpus} -s $R1 --outname ${meta.id}_R1 --exec vsearch --log ${meta.id}_R1.log > ${meta.id}_command_log.txt - ClusterSets.py set --nproc ${task.cpus} -s $R2 --outname ${meta.id}_R2 --exec vsearch --log ${meta.id}_R2.log >> ${meta.id}_command_log.txt - ParseLog.py -l ${meta.id}_R1.log ${meta.id}_R2.log -f ID BARCODE SEQCOUNT CLUSTERS + ClusterSets.py set --nproc ${task.cpus} -s $R1 --outname ${meta.id}_R1 $args --log ${meta.id}_R1.log > ${meta.id}_command_log.txt + ClusterSets.py set --nproc ${task.cpus} -s $R2 --outname ${meta.id}_R2 $args --log ${meta.id}_R2.log >> ${meta.id}_command_log.txt + ParseLog.py -l ${meta.id}_R1.log ${meta.id}_R2.log $args2 cat <<-END_VERSIONS > versions.yml "${task.process}": From a052e12a03b03b3cdc272ed5e2fe23c6a1ac96b7 Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Wed, 28 Aug 2024 16:11:50 -0400 Subject: [PATCH 02/11] update clustersets umi --- conf/modules.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index 7027c0ca..4ccbf661 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -261,13 +261,13 @@ process { ext.args = '--coord illumina' } - withName: PRESTO_CLUSTERSETS { + withName: PRESTO_CLUSTERSETS_UMI { publishDir = [ path: { "${params.outdir}/presto/04-clustersets/${meta.id}" }, mode: params.publish_dir_mode, pattern: "*{txt,log,tab}" ] - ext.args = '--exec vsearch' + ext.args = '--exec vsearch --ident 0.9' ext.args2 = '-f ID BARCODE SEQCOUNT CLUSTERS' } From 39eae165adc95362977d148e48e69821a6a4b5ae Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Wed, 28 Aug 2024 16:27:58 -0400 Subject: [PATCH 03/11] update modules config --- conf/modules.config | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/conf/modules.config b/conf/modules.config index 4ccbf661..c455f826 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -279,6 +279,15 @@ process { ] } + withName: PRESTO_PAIRSEQ_CLUSTERSETS { + publishDir = [ + path: { "${params.outdir}/presto/05-parse-clusters/${meta.id}" }, + mode: params.publish_dir_mode, + pattern: "*{txt,log,tab}" + ] + ext.args = '--coord illumina' + } + withName: PRESTO_BUILDCONSENSUS_UMI { publishDir = [ path: { "${params.outdir}/presto/06-build-consensus/${meta.id}" }, From b7fd1aafb397298ed7f0b768ee2d02a5621d3b4b Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Fri, 30 Aug 2024 11:28:37 -0400 Subject: [PATCH 04/11] remove vprimer and cprimer requirement for maskprimers_extract --- conf/test_maskprimers_extract.config | 2 -- subworkflows/local/sequence_assembly.nf | 27 +++++++++++++++---------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/conf/test_maskprimers_extract.config b/conf/test_maskprimers_extract.config index cda79a6b..b43040bc 100644 --- a/conf/test_maskprimers_extract.config +++ b/conf/test_maskprimers_extract.config @@ -21,8 +21,6 @@ params { // Input data input = pipelines_testdata_base_path + 'testdata-bcr/Metadata_test_airr.tsv' - cprimers = pipelines_testdata_base_path + 'testdata-bcr/C_primers.fasta' - vprimers = pipelines_testdata_base_path + 'testdata-bcr/V_primers.fasta' reference_fasta = pipelines_testdata_base_path + 'database-cache/imgtdb_base.zip' reference_igblast = pipelines_testdata_base_path + 'database-cache/igblast_base.zip' diff --git a/subworkflows/local/sequence_assembly.nf b/subworkflows/local/sequence_assembly.nf index d001b124..ddcd5f64 100644 --- a/subworkflows/local/sequence_assembly.nf +++ b/subworkflows/local/sequence_assembly.nf @@ -67,18 +67,23 @@ workflow SEQUENCE_ASSEMBLY { // Validate library generation method parameter if (params.library_generation_method == 'specific_pcr_umi'){ - if (params.vprimers) { - ch_vprimers_fasta = Channel.fromPath(params.vprimers, checkIfExists: true) + if (!params.maskprimers_extract){ + if (params.vprimers) { + ch_vprimers_fasta = Channel.fromPath(params.vprimers, checkIfExists: true) + } else { + error "Please provide a V-region primers fasta file with the '--vprimers' option when using the 'specific_pcr_umi' library generation method." + } + if (params.cprimers) { + ch_cprimers_fasta = Channel.fromPath(params.cprimers, checkIfExists: true) + } else { + error "Please provide a C-region primers fasta file with the '--cprimers' option when using the 'specific_pcr_umi' library generation method." + } + if (params.race_linker) { + error "Please do not set '--race_linker' when using the 'specific_pcr_umi' library generation method." + } } else { - error "Please provide a V-region primers fasta file with the '--vprimers' option when using the 'specific_pcr_umi' library generation method." - } - if (params.cprimers) { - ch_cprimers_fasta = Channel.fromPath(params.cprimers, checkIfExists: true) - } else { - error "Please provide a C-region primers fasta file with the '--cprimers' option when using the 'specific_pcr_umi' library generation method." - } - if (params.race_linker) { - error "Please do not set '--race_linker' when using the 'specific_pcr_umi' library generation method." + ch_vprimers_fasta = Channel.of([]) + ch_cprimers_fasta = Channel.of([]) } if (params.umi_length < 2) { error "The 'specific_pcr_umi' library generation method requires setting the '--umi_length' to a value greater than 1." From 26621d88c67c9a7aff34c9fa1ea133df49ac599e Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Tue, 3 Sep 2024 09:39:33 -0400 Subject: [PATCH 05/11] do not stage log to results dir --- modules/local/presto/presto_assemblepairs.nf | 1 - modules/local/presto/presto_assemblepairs_sequential.nf | 1 - modules/local/presto/presto_buildconsensus.nf | 2 -- modules/local/presto/presto_clustersets.nf | 1 - modules/local/presto/presto_collapseseq.nf | 1 - modules/local/presto/presto_filterseq.nf | 2 -- modules/local/presto/presto_filterseq_postassembly.nf | 1 - modules/local/presto/presto_maskprimers.nf | 2 -- modules/local/presto/presto_maskprimers_align.nf | 3 +-- modules/local/presto/presto_maskprimers_extract.nf | 1 - modules/local/presto/presto_maskprimers_postassembly.nf | 1 - modules/local/presto/presto_maskprimers_score.nf | 1 - 12 files changed, 1 insertion(+), 16 deletions(-) diff --git a/modules/local/presto/presto_assemblepairs.nf b/modules/local/presto/presto_assemblepairs.nf index c6ba4287..e108f62a 100644 --- a/modules/local/presto/presto_assemblepairs.nf +++ b/modules/local/presto/presto_assemblepairs.nf @@ -14,7 +14,6 @@ process PRESTO_ASSEMBLEPAIRS { output: tuple val(meta), path("*_assemble-pass.fastq"), emit: reads path("*_command_log.txt"), emit: logs - path("*.log") path("*_table.tab") path "versions.yml" , emit: versions diff --git a/modules/local/presto/presto_assemblepairs_sequential.nf b/modules/local/presto/presto_assemblepairs_sequential.nf index 7d9cabb0..b47b9098 100644 --- a/modules/local/presto/presto_assemblepairs_sequential.nf +++ b/modules/local/presto/presto_assemblepairs_sequential.nf @@ -15,7 +15,6 @@ process PRESTO_ASSEMBLEPAIRS_SEQUENTIAL { output: tuple val(meta), path("*_assemble-pass.fastq"), emit: reads path("*_command_log.txt"), emit: logs - path("*.log") path("*_table.tab") path "versions.yml" , emit: versions diff --git a/modules/local/presto/presto_buildconsensus.nf b/modules/local/presto/presto_buildconsensus.nf index 9572b159..9e6c6c4d 100644 --- a/modules/local/presto/presto_buildconsensus.nf +++ b/modules/local/presto/presto_buildconsensus.nf @@ -14,8 +14,6 @@ process PRESTO_BUILDCONSENSUS { output: tuple val(meta), path("*_R1_consensus-pass.fastq"), path("*_R2_consensus-pass.fastq"), emit: reads path("*_command_log.txt"), emit: logs - path("*_R1.log") - path("*_R2.log") path("*.tab"), emit: log_tab path "versions.yml" , emit: versions diff --git a/modules/local/presto/presto_clustersets.nf b/modules/local/presto/presto_clustersets.nf index 3a5eae2a..71868b5b 100644 --- a/modules/local/presto/presto_clustersets.nf +++ b/modules/local/presto/presto_clustersets.nf @@ -14,7 +14,6 @@ process PRESTO_CLUSTERSETS { output: tuple val(meta), path("*_R1_cluster-pass.fastq"), path("*_R2_cluster-pass.fastq"), emit: reads path "*_command_log.txt", emit: logs - path "*.log" path "*.tab", emit: log_tab path("versions.yml"), emit: versions diff --git a/modules/local/presto/presto_collapseseq.nf b/modules/local/presto/presto_collapseseq.nf index efbe4def..84177805 100644 --- a/modules/local/presto/presto_collapseseq.nf +++ b/modules/local/presto/presto_collapseseq.nf @@ -14,7 +14,6 @@ process PRESTO_COLLAPSESEQ { output: tuple val(meta), path("*_collapse-unique.fastq") , emit: reads path("*_command_log.txt") , emit: logs - path("*.log") path("*_table.tab") path("versions.yml"), emit: versions diff --git a/modules/local/presto/presto_filterseq.nf b/modules/local/presto/presto_filterseq.nf index a7733147..ee474865 100644 --- a/modules/local/presto/presto_filterseq.nf +++ b/modules/local/presto/presto_filterseq.nf @@ -15,8 +15,6 @@ process PRESTO_FILTERSEQ { tuple val(meta), path("*R1_quality-pass.fastq"), path("*R2_quality-pass.fastq") , emit: reads path "*_command_log_R?.txt" , emit: logs path "versions.yml" , emit: versions - path "*_R1.log" - path "*_R2.log" path "*.tab" , emit: log_tab script: diff --git a/modules/local/presto/presto_filterseq_postassembly.nf b/modules/local/presto/presto_filterseq_postassembly.nf index 0f821f5b..45dfea17 100644 --- a/modules/local/presto/presto_filterseq_postassembly.nf +++ b/modules/local/presto/presto_filterseq_postassembly.nf @@ -15,7 +15,6 @@ process PRESTO_FILTERSEQ_POSTASSEMBLY { tuple val(meta), path("*quality-pass.fastq") , emit: reads path "*_command_log.txt" , emit: logs path "versions.yml" , emit: versions - path "*.log" path "*.tab" , emit: log_tab script: diff --git a/modules/local/presto/presto_maskprimers.nf b/modules/local/presto/presto_maskprimers.nf index 64ba8ac3..26c88854 100644 --- a/modules/local/presto/presto_maskprimers.nf +++ b/modules/local/presto/presto_maskprimers.nf @@ -16,8 +16,6 @@ process PRESTO_MASKPRIMERS { output: tuple val(meta), path("*_R1_primers-pass.fastq"), path("*_R2_primers-pass.fastq") , emit: reads path "*_command_log_R?.txt", emit: logs - path "*_R1.log" - path "*_R2.log" path "*.tab", emit: log_tab path "versions.yml" , emit: versions diff --git a/modules/local/presto/presto_maskprimers_align.nf b/modules/local/presto/presto_maskprimers_align.nf index 055e5d93..8f45b814 100644 --- a/modules/local/presto/presto_maskprimers_align.nf +++ b/modules/local/presto/presto_maskprimers_align.nf @@ -17,8 +17,7 @@ process PRESTO_MASKPRIMERS_ALIGN { output: tuple val(meta), path("*_R1_primers-pass.fastq") , emit: reads - path "*_command_log_R1.txt", emit: logs - path "*_R1.log" + path "*_command_log_R1.txt", emit: logss path "*.tab", emit: log_tab path "versions.yml" , emit: versions diff --git a/modules/local/presto/presto_maskprimers_extract.nf b/modules/local/presto/presto_maskprimers_extract.nf index ddaae736..fad8d624 100644 --- a/modules/local/presto/presto_maskprimers_extract.nf +++ b/modules/local/presto/presto_maskprimers_extract.nf @@ -19,7 +19,6 @@ process PRESTO_MASKPRIMERS_EXTRACT { output: tuple val(meta), path("*_primers-pass.fastq") , emit: reads path "*.txt", emit: logs - path "*.log" path "*.tab", emit: log_tab path "versions.yml" , emit: versions diff --git a/modules/local/presto/presto_maskprimers_postassembly.nf b/modules/local/presto/presto_maskprimers_postassembly.nf index e69a1226..ef5cd4c7 100644 --- a/modules/local/presto/presto_maskprimers_postassembly.nf +++ b/modules/local/presto/presto_maskprimers_postassembly.nf @@ -16,7 +16,6 @@ process PRESTO_MASKPRIMERS_POSTASSEMBLY { output: tuple val(meta), path("*REV_primers-pass.fastq") , emit: reads path "*command_log.txt", emit: logs - path "*.log" path "*.tab", emit: log_tab path "versions.yml" , emit: versions diff --git a/modules/local/presto/presto_maskprimers_score.nf b/modules/local/presto/presto_maskprimers_score.nf index 1e48ea9b..77b90cfc 100644 --- a/modules/local/presto/presto_maskprimers_score.nf +++ b/modules/local/presto/presto_maskprimers_score.nf @@ -21,7 +21,6 @@ process PRESTO_MASKPRIMERS_SCORE { output: tuple val(meta), path("*_primers-pass.fastq"), emit: reads path "*.txt", emit: logs - path "*.log" path "*.tab", emit: log_tab path "versions.yml" , emit: versions From 2915aca01b0ed2b74356d3b3700a2d8a72c642ea Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Sun, 15 Sep 2024 14:11:03 -0400 Subject: [PATCH 06/11] fix maskprimers test noumi --- subworkflows/local/presto_sans_umi.nf | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/subworkflows/local/presto_sans_umi.nf b/subworkflows/local/presto_sans_umi.nf index df121477..9a9c7c5e 100644 --- a/subworkflows/local/presto_sans_umi.nf +++ b/subworkflows/local/presto_sans_umi.nf @@ -57,15 +57,18 @@ workflow PRESTO_SANS_UMI { // Mask primers def suffix_FWD = "R1" def suffix_REV = "R2" + def barcode_R1 = false + def barcode_R2 = false ch_reads = PRESTO_FILTERSEQ_POSTASSEMBLY_SANS_UMI.out.reads if (params.cprimer_position == "R1") { - def start_FWD = "--start ${params.cprimer_start}" - def start_REV = "--start ${params.vprimer_start}" + def start_FWD = "${params.cprimer_start}" + def start_REV = "${params.vprimer_start}" def revpr_FWD = false PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( ch_reads, ch_cprimers.collect(), start_FWD, + barcode_R1, params.primer_r1_maxerror, params.primer_r1_mask_mode, revpr_FWD, @@ -75,14 +78,15 @@ workflow PRESTO_SANS_UMI { PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.reads, ch_vprimers.collect(), start_REV, + barcode_R2, params.primer_r2_maxerror, params.primer_r2_mask_mode, params.primer_revpr, suffix_REV ) } else if (params.cprimer_position == "R2") { - def start_FWD = "--start ${params.vprimer_start}" - def start_REV = "--start ${params.cprimer_start}" + def start_FWD = "${params.vprimer_start}" + def start_REV = "${params.cprimer_start}" def revpr_FWD = false PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( From 10ca483d2d0f75395d1b255783a49029f73e69a7 Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Sun, 15 Sep 2024 14:17:54 -0400 Subject: [PATCH 07/11] fix maskprimers sansumi --- subworkflows/local/presto_sans_umi.nf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/subworkflows/local/presto_sans_umi.nf b/subworkflows/local/presto_sans_umi.nf index 9a9c7c5e..3e07497f 100644 --- a/subworkflows/local/presto_sans_umi.nf +++ b/subworkflows/local/presto_sans_umi.nf @@ -64,6 +64,7 @@ workflow PRESTO_SANS_UMI { def start_FWD = "${params.cprimer_start}" def start_REV = "${params.vprimer_start}" def revpr_FWD = false + def revpr_REV = true PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( ch_reads, ch_cprimers.collect(), @@ -92,6 +93,7 @@ workflow PRESTO_SANS_UMI { PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( ch_reads, ch_vprimers.collect(), + start_FWD, barcode_R1, params.primer_r1_maxerror, params.primer_r1_mask_mode, @@ -101,6 +103,7 @@ workflow PRESTO_SANS_UMI { PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV( PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.reads, ch_cprimers.collect(), + start_REV, barcode_R2, params.primer_r2_maxerror, params.primer_r2_mask_mode, From e0c53b8d3453d9126a3280154f0da64c8c0ca744 Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Sun, 15 Sep 2024 15:01:19 -0400 Subject: [PATCH 08/11] fix assemblepairs sansumi --- conf/modules.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/modules.config b/conf/modules.config index c455f826..30c50dab 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -371,7 +371,7 @@ process { mode: params.publish_dir_mode, pattern: "*{txt,log,tab}" ] - ext.args = '--rc tail' + ext.args = '--rc tail --coord illumina' ext.args2 = '-f ID SEQCOUNT PRIMER PRCOUNT PRFREQ LENGTH OVERLAP ERROR PVALUE' } From a048e95195f2639fbcd11ecad92acc778802596f Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Sun, 15 Sep 2024 18:28:26 -0400 Subject: [PATCH 09/11] maskprimers align sansumi --- conf/modules.config | 24 ++- .../local/presto/presto_maskprimers_align.nf | 13 +- subworkflows/local/presto_sans_umi.nf | 167 ++++++++++++------ subworkflows/local/presto_umi.nf | 11 +- subworkflows/local/sequence_assembly.nf | 2 - 5 files changed, 146 insertions(+), 71 deletions(-) diff --git a/conf/modules.config b/conf/modules.config index 30c50dab..a1abbb14 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -216,7 +216,7 @@ process { ext.args2 = '-f ID PRIMER ERROR PRSTART' } - withName: 'PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD' { + withName: PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD { publishDir = [ path: { "${params.outdir}/presto/03-maskprimers/${meta.id}" }, mode: params.publish_dir_mode, @@ -225,7 +225,7 @@ process { ext.args2 = '-f ID PRIMER ERROR' } - withName: 'PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV' { + withName: PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV { publishDir = [ path: { "${params.outdir}/presto/03-maskprimers/${meta.id}" }, mode: params.publish_dir_mode, @@ -234,6 +234,26 @@ process { ext.args2 = '-f ID PRIMER ERROR' } + withName: PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD { + publishDir = [ + path: { "${params.outdir}/presto/03-maskprimers/${meta.id}" }, + mode: params.publish_dir_mode, + pattern: "*{txt,log,tab}" + ] + ext.args2 = '-f ID PRIMER ERROR' + } + + withName: PRESTO_MASKPRIMERS_ALIGN_SANSUMI_REV { + publishDir = [ + path: { "${params.outdir}/presto/03-maskprimers/${meta.id}" }, + mode: params.publish_dir_mode, + pattern: "*{txt,log,tab}" + ] + ext.args = '--revpr' + ext.args2 = '-f ID PRIMER ERROR' + } + + withName: PRESTO_PAIRSEQ { publishDir = [ path: { "${params.outdir}/presto/03-pairseq/${meta.id}" }, diff --git a/modules/local/presto/presto_maskprimers_align.nf b/modules/local/presto/presto_maskprimers_align.nf index 8f45b814..2fe44182 100644 --- a/modules/local/presto/presto_maskprimers_align.nf +++ b/modules/local/presto/presto_maskprimers_align.nf @@ -10,14 +10,15 @@ process PRESTO_MASKPRIMERS_ALIGN { input: tuple val(meta), path(R1) - path(cprimers) + path(primers) val(max_len) val(max_error) val(mask_mode) + val(suffix) output: - tuple val(meta), path("*_R1_primers-pass.fastq") , emit: reads - path "*_command_log_R1.txt", emit: logss + tuple val(meta), path("*_primers-pass.fastq") , emit: reads + path "*.txt", emit: logs path "*.tab", emit: log_tab path "versions.yml" , emit: versions @@ -27,13 +28,13 @@ process PRESTO_MASKPRIMERS_ALIGN { """ MaskPrimers.py align --nproc ${task.cpus} \\ -s $R1 \\ - -p ${cprimers} \\ + -p ${primers} \\ --maxlen ${max_len} \\ --maxerror ${max_error} \\ --mode ${mask_mode} \\ $args \\ - --outname ${meta.id}_R1 \\ - --log ${meta.id}_R1.log > ${meta.id}_command_log_R1.txt + --outname ${meta.id}_${suffix} \\ + --log ${meta.id}_R1.log > ${meta.id}_command_log_${suffix}.txt ParseLog.py -l ${meta.id}_R1.log $args2 cat <<-END_VERSIONS > versions.yml diff --git a/subworkflows/local/presto_sans_umi.nf b/subworkflows/local/presto_sans_umi.nf index 3e07497f..0161d769 100644 --- a/subworkflows/local/presto_sans_umi.nf +++ b/subworkflows/local/presto_sans_umi.nf @@ -9,6 +9,8 @@ include { PRESTO_ASSEMBLEPAIRS as PRESTO_ASSEMBLEPAIRS_SANS_UMI } include { PRESTO_FILTERSEQ_POSTASSEMBLY as PRESTO_FILTERSEQ_POSTASSEMBLY_SANS_UMI } from '../../modules/local/presto/presto_filterseq_postassembly' include { PRESTO_MASKPRIMERS_SCORE as PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD } from '../../modules/local/presto/presto_maskprimers_score' include { PRESTO_MASKPRIMERS_SCORE as PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV } from '../../modules/local/presto/presto_maskprimers_score' +include { PRESTO_MASKPRIMERS_ALIGN as PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD } from '../../modules/local/presto/presto_maskprimers_align' +include { PRESTO_MASKPRIMERS_ALIGN as PRESTO_MASKPRIMERS_ALIGN_SANSUMI_REV } from '../../modules/local/presto/presto_maskprimers_align' include { PRESTO_PARSEHEADERS_PRIMERS as PRESTO_PARSEHEADERS_PRIMERS_SANS_UMI } from '../../modules/local/presto/presto_parseheaders_primers' include { PRESTO_PARSEHEADERS_METADATA as PRESTO_PARSEHEADERS_METADATA_SANS_UMI } from '../../modules/local/presto/presto_parseheaders_metadata' include { PRESTO_COLLAPSESEQ as PRESTO_COLLAPSESEQ_SANS_UMI } from '../../modules/local/presto/presto_collapseseq' @@ -60,74 +62,123 @@ workflow PRESTO_SANS_UMI { def barcode_R1 = false def barcode_R2 = false ch_reads = PRESTO_FILTERSEQ_POSTASSEMBLY_SANS_UMI.out.reads - if (params.cprimer_position == "R1") { - def start_FWD = "${params.cprimer_start}" - def start_REV = "${params.vprimer_start}" - def revpr_FWD = false - def revpr_REV = true - PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( - ch_reads, - ch_cprimers.collect(), - start_FWD, - barcode_R1, - params.primer_r1_maxerror, - params.primer_r1_mask_mode, - revpr_FWD, - suffix_FWD - ) - PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV( - PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.reads, - ch_vprimers.collect(), - start_REV, - barcode_R2, - params.primer_r2_maxerror, - params.primer_r2_mask_mode, - params.primer_revpr, - suffix_REV - ) - } else if (params.cprimer_position == "R2") { - def start_FWD = "${params.vprimer_start}" - def start_REV = "${params.cprimer_start}" - def revpr_FWD = false - - PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( - ch_reads, - ch_vprimers.collect(), - start_FWD, - barcode_R1, - params.primer_r1_maxerror, - params.primer_r1_mask_mode, - revpr_FWD, - suffix_FWD - ) - PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV( - PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.reads, - ch_cprimers.collect(), - start_REV, - barcode_R2, - params.primer_r2_maxerror, - params.primer_r2_mask_mode, - params.primer_revpr, - suffix_REV - ) + if (params.maskprimers_align){ + if (params.cprimer_position == "R1") { + PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD( + ch_reads, + ch_cprimers.collect(), + params.primer_maxlen, + params.primer_r1_maxerror, + params.primer_r1_mask_mode, + suffix_FWD + ) + PRESTO_MASKPRIMERS_ALIGN_SANSUMI_REV( + PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD.out.reads, + ch_vprimers.collect(), + params.primer_maxlen, + params.primer_r2_maxerror, + params.primer_r2_mask_mode, + suffix_REV + ) + } else if (params.cprimer_position == "R2") { + PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD( + ch_reads, + ch_vprimers.collect(), + params.primer_maxlen, + params.primer_r1_maxerror, + params.primer_r1_mask_mode, + suffix_FWD + ) + PRESTO_MASKPRIMERS_ALIGN_SANSUMI_REV( + PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD.out.reads, + ch_cprimers.collect(), + params.primer_maxlen, + params.primer_r2_maxerror, + params.primer_r2_mask_mode, + suffix_REV + ) + } else { + error "Error in determining cprimer position. Please choose R1 or R2." + } + + ch_versions = ch_versions.mix(PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD.out.versions) + + ch_maskprimers_logs = PRESTO_MASKPRIMERS_ALIGN_SANSUMI_FWD.out.logs + ch_maskprimers_logs = ch_maskprimers_logs.mix(PRESTO_MASKPRIMERS_ALIGN_SANSUMI_REV.out.logs) + + ch_masked_reads = PRESTO_MASKPRIMERS_ALIGN_SANSUMI_REV.out.reads } else { - error "Error in determining cprimer position. Please choose R1 or R2." - } - - ch_versions = ch_versions.mix(PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.versions) + if (params.cprimer_position == "R1") { + def start_FWD = "${params.cprimer_start}" + def start_REV = "${params.vprimer_start}" + def revpr_FWD = false + PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( + ch_reads, + ch_cprimers.collect(), + start_FWD, + barcode_R1, + params.primer_r1_maxerror, + params.primer_r1_mask_mode, + revpr_FWD, + suffix_FWD + ) + PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV( + PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.reads, + ch_vprimers.collect(), + start_REV, + barcode_R2, + params.primer_r2_maxerror, + params.primer_r2_mask_mode, + params.primer_revpr, + suffix_REV + ) + } else if (params.cprimer_position == "R2") { + def start_FWD = "${params.vprimer_start}" + def start_REV = "${params.cprimer_start}" + def revpr_FWD = false + + PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD( + ch_reads, + ch_vprimers.collect(), + start_FWD, + barcode_R1, + params.primer_r1_maxerror, + params.primer_r1_mask_mode, + revpr_FWD, + suffix_FWD + ) + PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV( + PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.reads, + ch_cprimers.collect(), + start_REV, + barcode_R2, + params.primer_r2_maxerror, + params.primer_r2_mask_mode, + params.primer_revpr, + suffix_REV + ) + } else { + error "Error in determining cprimer position. Please choose R1 or R2." + } + + ch_versions = ch_versions.mix(PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.versions) + + ch_maskprimers_logs = PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.logs + ch_maskprimers_logs = ch_maskprimers_logs.mix(PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV.out.logs) + + ch_masked_reads = PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV.out.reads - ch_maskprimers_logs = PRESTO_MASKPRIMERS_SCORE_SANSUMI_FWD.out.logs - ch_maskprimers_logs = ch_maskprimers_logs.mix(PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV.out.logs) + } // Generate QC stats after reads paired and filtered but before collapsed FASTQC_POSTASSEMBLY_SANS_UMI ( - PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV.out.reads + ch_masked_reads ) ch_versions = ch_versions.mix(FASTQC_POSTASSEMBLY_SANS_UMI.out.versions) // Annotate primers in C_PRIMER and V_PRIMER field PRESTO_PARSEHEADERS_PRIMERS_SANS_UMI ( - PRESTO_MASKPRIMERS_SCORE_SANSUMI_REV.out.reads + ch_masked_reads ) ch_versions = ch_versions.mix(PRESTO_PARSEHEADERS_PRIMERS_SANS_UMI.out.versions) diff --git a/subworkflows/local/presto_umi.nf b/subworkflows/local/presto_umi.nf index 959c42a2..53a932cc 100644 --- a/subworkflows/local/presto_umi.nf +++ b/subworkflows/local/presto_umi.nf @@ -51,6 +51,11 @@ workflow PRESTO_UMI { ch_versions = Channel.empty() + // Validate params + if (params.maskprimers_align & params.umi_position == 'R1') {error "The maskprimers align option is only supported with UMI barcodes in the R2 reads (reads containing V region)."} + if (params.maskprimers_align & params.cprimer_position == 'R2') {error "The maskprimers align option is only supported with Cprimers in the R1 reads (reads containing C region)."} + + // Merge UMI from index file to R1 if provided if (params.index_file) { @@ -120,10 +125,10 @@ workflow PRESTO_UMI { ch_cprimers.collect(), params.primer_maxlen, params.primer_r1_maxerror, - params.primer_r1_mask_mode + params.primer_r1_mask_mode, + "R1" ) - def r2_suffix = "R2" def barcode = true PRESTO_MASKPRIMERS_EXTRACT( ch_reads_R2, @@ -131,7 +136,7 @@ workflow PRESTO_UMI { params.primer_r2_extract_len, params.primer_r2_mask_mode, barcode, - r2_suffix + "R2" ) ch_versions = ch_versions.mix(PRESTO_ALIGN_PRIMERS.out.versions) diff --git a/subworkflows/local/sequence_assembly.nf b/subworkflows/local/sequence_assembly.nf index ddcd5f64..4358394e 100644 --- a/subworkflows/local/sequence_assembly.nf +++ b/subworkflows/local/sequence_assembly.nf @@ -169,8 +169,6 @@ workflow SEQUENCE_ASSEMBLY { if (params.index_file & params.umi_position == 'R2') {error "Please do not set `--umi_position` option if index file with UMIs is provided."} if (params.umi_length < 0) {error "Please provide the UMI barcode length in the option `--umi_length`. To run without UMIs, set umi_length to 0."} if (!params.index_file & params.umi_start != 0) {error "Setting a UMI start position is only allowed when providing the UMIs in a separate index read file. If so, please provide the `--index_file` flag as well."} - if (params.maskprimers_align & params.umi_position == 'R1') {error "The maskprimers align option is only supported with UMI barcodes in the R2 reads (reads containing V region)."} - if (params.maskprimers_align & params.cprimer_position == 'R2') {error "The maskprimers align option is only supported with Cprimers in the R1 reads (reads containing C region)."} // // SUBWORKFLOW: Read in samplesheet, validate and stage input files From dd49edeabbf3b21c20b346f813d9a414b98d8307 Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Mon, 16 Sep 2024 14:15:39 -0400 Subject: [PATCH 10/11] maskprimers sansumi assemble --- conf/modules.config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/modules.config b/conf/modules.config index a1abbb14..ca616785 100644 --- a/conf/modules.config +++ b/conf/modules.config @@ -240,6 +240,7 @@ process { mode: params.publish_dir_mode, pattern: "*{txt,log,tab}" ] + ext.args = '--pf FWD_PRIMER' ext.args2 = '-f ID PRIMER ERROR' } @@ -249,7 +250,7 @@ process { mode: params.publish_dir_mode, pattern: "*{txt,log,tab}" ] - ext.args = '--revpr' + ext.args = '--revpr --pf REV_PRIMER' ext.args2 = '-f ID PRIMER ERROR' } From c5afe4c5d59f0361ca46a81bbff58bae722c056a Mon Sep 17 00:00:00 2001 From: Gisela Gabernet Date: Sun, 22 Sep 2024 18:09:09 -0400 Subject: [PATCH 11/11] fix suffix maskprimers algin --- modules/local/presto/presto_maskprimers_align.nf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/local/presto/presto_maskprimers_align.nf b/modules/local/presto/presto_maskprimers_align.nf index 2fe44182..59930674 100644 --- a/modules/local/presto/presto_maskprimers_align.nf +++ b/modules/local/presto/presto_maskprimers_align.nf @@ -35,7 +35,7 @@ process PRESTO_MASKPRIMERS_ALIGN { $args \\ --outname ${meta.id}_${suffix} \\ --log ${meta.id}_R1.log > ${meta.id}_command_log_${suffix}.txt - ParseLog.py -l ${meta.id}_R1.log $args2 + ParseLog.py -l ${meta.id}_${suffix}.log $args2 cat <<-END_VERSIONS > versions.yml "${task.process}":