Skip to content

Fix unmapped secondary alignments#592

Merged
marcelm merged 4 commits into
mainfrom
no-unmapped-secondary
Jun 5, 2026
Merged

Fix unmapped secondary alignments#592
marcelm merged 4 commits into
mainfrom
no-unmapped-secondary

Conversation

@marcelm

@marcelm marcelm commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

When secondary alignments are enabled, we currently handle unmapped reads incorrectly. So for example, if we have a pair where R1 can be mapped and has multiple mappings but R2 cannot be mapped, we output these SAM records:

  • R1 with primary mapping location
  • R2 marked as unmapped
  • R1 with alternative location, marked as secondary
  • R2 as an unmapped read, not marked as secondary (this is the problematic record)

I first changed it so that the second time R2 is output it is also marked as secondary, but then we have a SAM record that is both unmapped and secondary, which picard ValidateSamFile rightfully complains about. The correct solution seems to be to just not output that last record, which is what this PR does.

Also, we now let strobealign generate secondary alignments within the baseline comparison script. They are ignored when actually comparing the records to the baseline version, but this allows us to run ValidateSamFile on a file with secondary alignments.

The last commit changes the baseline commit because running strobealign with -N 5 and ignoring all secondary alignments does not give the same results as running it with -N 0.

@marcelm marcelm force-pushed the no-unmapped-secondary branch from 9c0b698 to a574fb0 Compare June 5, 2026 09:33
@ksahlin

ksahlin commented Jun 5, 2026

Copy link
Copy Markdown
Owner

very good!

marcelm added 2 commits June 5, 2026 12:25
These are ignored when comparing the outputs, but it allows us to test
whether the BAM output is valid (according to picard ValidateSamFile).
@marcelm marcelm force-pushed the no-unmapped-secondary branch from a574fb0 to fdd5d61 Compare June 5, 2026 10:25
@marcelm marcelm merged commit 08c8031 into main Jun 5, 2026
10 checks passed
@marcelm marcelm deleted the no-unmapped-secondary branch June 5, 2026 11:15
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.

2 participants