You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
samtools flagstat: reads with both SECONDARY and SUPPLEMENTARY flags are double-counted in the supplementary total #125
Summary: When a BAM contains alignment records with both the SECONDARY (0x100) and SUPPLEMENTARY (0x800) flags set, RustQC's flagstat module counts those records in both the secondary and supplementary totals, inflating the supplementary count and breaking primary + secondary + supplementary == total. Real samtools flagstat gives the SECONDARY flag priority and counts such dual-flagged records only as secondary.
Environment:
RustQC 0.2.1 (c868466, built 2026-04-09), Docker image seqinfomics/rustqc:0.2.1, run via Apptainer 1.4.5
Input: paired-end STAR-aligned BAM (--paired), single contig, 156,370 total records
154662 + 0 primary
1121 + 0 secondary (matches, 309 + 812)
1399 + 0 supplementary (587 + 812 <- the 812 dual-flagged reads are counted again here)
Note 154662 + 1121 + 1399 = 157182, which exceeds the true total of 156370 — the sum invariant that samtools flagstat maintains is violated.
Fix suggestion: In the flagstat counting logic, categorize each record by flag priority (secondary > supplementary > primary) rather than checking the supplementary bit independently of the secondary bit.
Activity
fix(flagstat): combine QC counts with samtools alignment priority
ewels commentedon Nov 27, 2026
Fixed in #198