Repository navigation
Write the real VX tag and skip invalid barcodes in duplicate marking - #31
Merged
Merged
Conversation
buildRecord wrote VX:i:1 for every record. The barcode's validity was read from the input (FastQRecord.Valid) but only used to decide whether to run the EM or RFA, so it never reached the output. - Alignment carries valid_barcode, set from the input record in GetAlignments, and VX is written from it (0 or 1). - Reads with an invalid barcode no longer take part in duplicate marking. They were deduplicated before, contrary to docs/usage.md, which already says invalid-barcoded alignments are not. Output is unchanged when every barcode is valid (EM and RFA, sorted records identical to main). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BUHUTLHfLoVtWa4XbCL9ZH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two related fixes for how barcode validity is handled on output.
VXwas always written as1.buildRecordwroteVX:i:1on every record (aligner/samwriter.go, unchanged since the initial import). The input's validity was parsed intoFastQRecord.Validbut only used to decide whether to run the EM or RFA, so it never reached the output. Reads with an invalid barcode were reported as valid.markDuplicatesran unconditionally in bothem.goandrfa.go, so invalid-barcoded reads got0x400flags.docs/usage.mdalready states that invalid-barcoded alignments do not go through deduplication; the code now matches that, so the docs are unchanged.What changed
Alignmentgets avalid_barcodefield, set from the input record inGetAlignments(placeholders for unmapped or missing reads included).buildRecordwritesVX:i:0orVX:i:1from it.mappedForDup(the eligibility check for duplicate marking) now also requires a valid barcode, so invalid-barcode reads are never flagged and never count as the original of a duplicate set. The check is in one place, so it applies to both the EM and RFA paths.Behaviour to be aware of
Reads with no
VXtag at all are treated as invalid, becauseParseBarcodesreports "not valid" when either tag is missing. They will now getVX:i:0and skip deduplication; before they gotVX:i:1and were deduplicated.Testing
go vet,gofmtandgo test ./...pass.VXis written as 0 or 1 according to validity; invalid-barcode pairs at identical positions are not flagged while valid ones still are;GetAlignmentscarries validity onto every alignment, placeholders included. The existing duplicate-marking test helpers now setvalid_barcodebecause the zero value means invalid.VX:i:0and injected duplicate pairs:main: all 42,416 records getVX:i:1, and 2,050 are flagged duplicate.VX:i:0and none is flagged; the valid barcodes keepVX:i:1and have 1,008 duplicates marked, about half the old count, as expected.mainfor both the default EM and--rfa.Generated by Claude Code