Skip to content

fix(markduplicates): avoid duplicate alignment emission under -stub - #2277

Open
gburnett-nvidia wants to merge 4 commits into
devfrom
fix-markduplicates-stub-duplicate
Open

fix(markduplicates): avoid duplicate alignment emission under -stub#2277
gburnett-nvidia wants to merge 4 commits into
devfrom
fix-markduplicates-stub-duplicate

Conversation

@gburnett-nvidia

@gburnett-nvidia gburnett-nvidia commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Fixes #2280

Summary

  • BAM_MARKDUPLICATES mixes the bam and cram output channels from GATK4_MARKDUPLICATES together, trusting that only one is ever populated per sample (real runs: true). Under -stub, the module's stub block touches both bam and cram (+ indices) unconditionally, so the mixed alignment channel emits twice per sample.
  • The duplication silently rides through baserecalibration/applybqsr and only surfaces downstream at the tumor-normal pairing join in workflows/sarek.nf (failOnDuplicate: true), throwing Detected join operation duplicate emission on right channel.
  • Fix: select the bam or cram branch explicitly by params.save_output_as_bam, instead of .mix()-ing both — same pattern already used in bam_sentieon_dedup.
  • Checked the three other subworkflows PR Fix --save_output_as_bam flag #2154 touched with the same .mix()-of-optional-channels pattern (bam_applybqsr, bam_markduplicates_spark, bam_sentieon_dedup) — none of them have this bug:
    • bam_applybqsr: GATK4_APPLYBQSR takes an explicit output_suffix param and its stub branches on that, matching the real script.
    • bam_markduplicates_spark: GATK4SPARK_MARKDUPLICATES has a single unified output emit (one glob, not separate bam/cram declarations) — can't double-emit.
    • bam_sentieon_dedup: already uses the explicit params.save_output_as_bam ? ... : ... branch pattern this PR applies to markduplicates.

Test plan

  • nf-test test tests/default.nf.test --tag cpu_conda_stub --profile test,docker-profile test -stub scenario: pipeline completes successfully (GATK4_MARKDUPLICATES, GATK4_BASERECALIBRATOR, GATK4_APPLYBQSR, INDEX_CRAM each run once per sample, no join-duplicate error). Snapshot mismatch on this run is a pre-existing, unrelated warning-log-format drift (also present on the non-stub scenarios in the same file, before this change).
  • nf-test test tests/default.nf.test --tag cpu,cpu_conda --profile +docker — non-stub scenarios unaffected (same pre-existing snapshot drift, pipeline succeeds).

🤖 Generated with Claude Code

BAM_MARKDUPLICATES mixed the bam and cram output channels together,
trusting that GATK4_MARKDUPLICATES only ever populates one of them.
That holds for real runs, but the module's stub block touches both
bam and cram (+ indices) unconditionally, so under -stub the mixed
`alignment` channel emits twice per sample. The duplication silently
propagates through baserecalibration/applybqsr and only surfaces
downstream at the tumor-normal pairing join in workflows/sarek.nf,
which has failOnDuplicate: true and throws "Detected join operation
duplicate emission".

Select the bam or cram branch explicitly by params.save_output_as_bam
instead, matching the pattern already used in bam_sentieon_dedup.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

nf-core pipelines lint overall result: Passed ✅ ⚠️

Posted for pipeline commit db3e153

+| ✅ 238 tests passed       |+
#| ❔  15 tests were ignored |#
!| ❗   7 tests had warnings |!
Details

❗ Test warnings:

  • pipeline_todos - TODO string in main.nf: Optionally add in-text citation tools to this list.
  • pipeline_todos - TODO string in main.nf: Optionally add bibliographic entries to this list.
  • pipeline_todos - TODO string in main.nf: Only uncomment below if logic in toolCitationText/toolBibliographyText has been filled!
  • pipeline_todos - TODO string in base.config: Check the defaults for all processes
  • schema_lint - Input mimetype is missing or empty
  • schema_description - No description provided in schema for parameter: markduplicates_pixel_distance
  • schema_description - No description provided in schema for parameter: gatk_pcr_indel_model

❔ Tests ignored:

✅ Tests passed:

Run details

  • nf-core/tools version 4.1.0
  • Run at 2026-08-25 17:51:10

// Select explicitly rather than mixing both optional channels together: the module's stub
// block touches both bam and cram outputs unconditionally, so relying on "only one is ever
// populated" doubles every downstream emission under -stub.
alignment = params.save_output_as_bam

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, but let's not use params directly, but get them from input of the subworkflow.
Or fix the stub so that only 1 of these files is produced

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, thank you! Just updated in the latest commit.

gburnett-nvidia added a commit that referenced this pull request Aug 25, 2026
…uctured scenarios

Updates snapshot entries for the 9 currently-passing scenarios to
match the renamed/restructured test_scenario list (dropped "somatic"
suffix, removed real cram-input scenarios, added real+stub pon
scenario on fastq input).

The 3 fastq-default-aligner -stub scenarios still crash before
reaching their snapshot assertion (Detected join operation duplicate
emission), blocked on a separate, unrelated bam_markduplicates bug
being fixed upstream in #2277 — no entries for those yet.
Stale entries from the pre-rename scenario names are left in place;
nf-test only prunes obsolete snapshots when every test in the file
passes, which requires that fix to land first.
@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown

❌ nf-test failed with latest Nextflow version

Note

Tests with Nextflow's latest version failed but it will not cause a CI workflow failure.
Please check if the failure is expected with newer (edge-)releases of Nextflow or if it needs fixing.

  • docker | latest-everything | Shard 6/15

See the full run for details.

@FriederikeHanssen

Copy link
Copy Markdown
Contributor

thanks, @maxulysse this is likley affecting many places in the code base where we wanted to be elegant.

@FriederikeHanssen FriederikeHanssen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the changelog

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BAM_MARKDUPLICATES emits duplicate alignment channel under -stub

3 participants