From 3ca4511b5bd83f81b4197cde34e04215344cccf8 Mon Sep 17 00:00:00 2001 From: Sarah Griffiths Date: Tue, 26 May 2026 14:44:50 +0000 Subject: [PATCH] Add force alignment option [CW-7274] --- README.md | 1 + docs/07_input_parameters.md | 1 + lib/common.nf | 2 +- lib/ingress.nf | 4 +++- main.nf | 1 + nextflow.config | 1 + nextflow_schema.json | 6 ++++++ 7 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 17f620a..f9dcb47 100644 --- a/README.md +++ b/README.md @@ -356,6 +356,7 @@ directories: | threads | integer | Thread count to use for the core workflow processes. | | 4 | | mod_codes | string | Comma-separated modified base codes to pass to modkit pileup. | Provide values accepted by `modkit pileup --modified-bases`, for example `A:a,C:m`. If omitted, the workflow infers `primary_base:mod_code` pairs from the BAM with `modkit modbam check-tags`. | | | minimap2_opts | string | Extra command-line options to pass to minimap2. | | | +| force_alignment | boolean | Force re-alignment of input BAM files. | Read alignment is skipped if the existing sequence names in the aligned BAM match the provided reference. Enable this if the existing alignments used incorrect minimap2 presets (e.g. missing --splice or direct RNA settings). | False | | ndr | number | Optional bambu novel discovery rate override. | | | | skip_sqanti | boolean | Skip SQANTI3 transcript classification and QC. | | False | | sqanti_skip_orf | boolean | Skip ORF prediction during SQANTI3 QC. | | True | diff --git a/docs/07_input_parameters.md b/docs/07_input_parameters.md index 12105b2..ba2c9c3 100644 --- a/docs/07_input_parameters.md +++ b/docs/07_input_parameters.md @@ -52,6 +52,7 @@ | threads | integer | Thread count to use for the core workflow processes. | | 4 | | mod_codes | string | Comma-separated modified base codes to pass to modkit pileup. | Provide values accepted by `modkit pileup --modified-bases`, for example `A:a,C:m`. If omitted, the workflow infers `primary_base:mod_code` pairs from the BAM with `modkit modbam check-tags`. | | | minimap2_opts | string | Extra command-line options to pass to minimap2. | | | +| force_alignment | boolean | Force re-alignment of input BAM files. | Read alignment is skipped if the existing sequence names in the aligned BAM match the provided reference. Enable this if the existing alignments used incorrect minimap2 presets (e.g. missing --splice or direct RNA settings). | False | | ndr | number | Optional bambu novel discovery rate override. | | | | skip_sqanti | boolean | Skip SQANTI3 transcript classification and QC. | | False | | sqanti_skip_orf | boolean | Skip ORF prediction during SQANTI3 QC. | | True | diff --git a/lib/common.nf b/lib/common.nf index ac739c6..32ccd05 100644 --- a/lib/common.nf +++ b/lib/common.nf @@ -80,7 +80,7 @@ process minimap2_alignment { path("bamstats_results"), emit: alignment script: - String reset_cmd_body = "samtools reset -x tp,cm,s1,s2,NM,MD,AS,SA,ms,nn,ts,cg,cs,dv,de,rl" + String reset_cmd_body = "samtools reset -x tp,cm,s1,s2,NM,MD,AS,SA,ms,nn,ts,cg,cs,dv,de,rl,zd" String fastq_cmd_body = "samtools fastq -T '*'" // Default required threads is 6 // Samtools x3 and bamstats will all be single threaded diff --git a/lib/ingress.nf b/lib/ingress.nf index 4f7050d..35c502c 100644 --- a/lib/ingress.nf +++ b/lib/ingress.nf @@ -337,6 +337,7 @@ def fastq_ingress(Map arguments, aln_ref_ch = null) * - "alignment_threads": number of threads to use for alignment process (default: 6) * - "output_xam_fmt": alignment output format, `bam` outputs an BAM file with index (.bam, .bai), `cram` outputs a CRAM file with index (.cram, .crai) +* - "force_alignment": boolean. Run alignment regardless of inputs. * @param aln_ref_ch: optional channel with a reference tuple (ref, ref_idx) to align against. * If provided alignment will be attempted if inputs are unaligned or not already aligned to this ref. * @return: channel of `[Map(alias, barcode, type, ...), Path|null, Path|null]`. @@ -357,6 +358,7 @@ def xam_ingress(Map arguments, aln_ref_ch = null) "return_fastq": false, "fastcat_extra_args": "", "fastq_chunk": null, + "force_alignment": false, ] ) margs["fastq_chunk"] ?= 0 // cant pass null through channel @@ -427,7 +429,7 @@ def xam_ingress(Map arguments, aln_ref_ch = null) alignment_fork = ch_check_bams | branch { meta, paths -> - to_align: (meta.is_unaligned == true) && (meta.has_reads == true) + to_align: (meta.is_unaligned || margs.force_alignment) && meta.has_reads noalign: true } if (margs["output_xam_fmt"] == "bam"){ diff --git a/main.nf b/main.nf index 012bc0a..8d0ebd9 100644 --- a/main.nf +++ b/main.nf @@ -304,6 +304,7 @@ workflow { } else { samples = xam_ingress([ "input": params.bam, + "force_alignment": params.force_alignment, ] + ingress_args, ref_genome) } analysis_samples = samples diff --git a/nextflow.config b/nextflow.config index 35f7034..d9fedec 100644 --- a/nextflow.config +++ b/nextflow.config @@ -27,6 +27,7 @@ params { mod_codes = null minimap2_index_opts = "" minimap2_opts = "" + force_alignment = false ndr = null skip_sqanti = false sqanti_skip_orf = true diff --git a/nextflow_schema.json b/nextflow_schema.json index 508c1f1..5cf3de9 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -194,6 +194,12 @@ "default": "", "description": "Extra command-line options to pass to minimap2." }, + "force_alignment" : { + "type": "boolean", + "default": false, + "description": "Force re-alignment of input BAM files.", + "help_text": "Read alignment is skipped if the existing sequence names in the aligned BAM match the provided reference. Enable this if the existing alignments used incorrect minimap2 presets (e.g. missing --splice or direct RNA settings)." + }, "ndr": { "type": "number", "description": "Optional bambu novel discovery rate override."