feat: add bamqc subcommand for generic genomic BAM/CRAM QC - #135
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
feat: add bamqc subcommand for generic genomic BAM/CRAM QC#135BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
RustQC's Qualimap module only covers rnaseq mode, so pipelines that also want
Qualimap's bamqc mode have to keep the Java tool around alongside RustQC.
Adds `rustqc bamqc`, a single streaming pass over a coordinate-sorted
BAM/CRAM that needs no annotation and reports the bamqc metrics: coverage
depth and breadth (genome-wide and per contig), GC content, insert size,
mapping quality, read lengths and base composition.
Coverage is exact, not sampled: each read contributes +1 over every aligned
block (M/=/X/D) while N skips leave a gap, and because the input is sorted,
depth is finalised as the file streams past. Memory scales with pile-up
depth, not genome size. Secondary alignments are excluded; duplicates are
included by default, matching Qualimap, with --skip-duplicated to exclude
them.
Output file names and layout match Qualimap so MultiQC's Qualimap BamQC
module picks the results up unchanged: genome_results.txt plus
raw_data_qualimapReport/{coverage_histogram, genome_fraction_coverage,
mapped_reads_gc-content_distribution, mapped_reads_nucleotide_content,
insert_size_histogram}.txt.
Both duplicate modes are cross-checked against samtools depth in integration
tests (mean coverage and genome fraction match to the reported precision).
This is the metrics subset, not all of Qualimap bamqc: no HTML report, no
per-window coverage track, no clipping profile, no target-BED restriction.
The docs say so explicitly.
Closes seqeralabs#128
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
Closes #128.
Adds
rustqc bamqc— generic genomic QC in one streaming pass, no GTF required:What it reports
Coverage depth and breadth (genome-wide and per contig), GC content, insert size, mapping quality, read lengths and base composition — the metrics side of Qualimap's
bamqcmode.Output names and layout match Qualimap, so MultiQC's Qualimap BamQC module picks them up unchanged:
Coverage is exact, not sampled
Each read contributes
+1over every aligned block (M/=/X/D);Nskips leave a gap. Since input is coordinate-sorted, depth is finalised as the file streams past, so memory scales with pile-up depth rather than genome size — no per-base array.Secondary alignments are excluded from coverage. Duplicates are included by default (Qualimap's default);
--skip-duplicatedexcludes them.Validation
Cross-checked against
samtools depthontests/data/test.bam, both modes, and pinned in integration tests:samtools depth -a -J -g DUP→ identical--skip-duplicatedsamtools depth -a -J→ identical(The two differ by exactly the 137 duplicate-flagged reads × 50 bp in the test file.)
Scope
This is the metrics subset, not all of Qualimap
bamqc. Not included: the HTML report, per-window coverage tracks, clipping profile, homopolymer indel breakdown, PCR-bias/chimerism estimates, and coverage restricted to a target BED (--feature-file). The docs page states this explicitly. Happy to extend if you'd like any of those in the first cut — and the offer in the issue to validate against real Qualimap output on real data would be well worth taking up, since my validation here is againstsamtools depthrather than Qualimap itself.Note this overlaps in machinery with #18 (single-pass CRAM QC): the depth tracker here is what a mosdepth-equivalent would build on.
cargo test— 204 lib + 20 integration tests passcargo fmt --check,cargo clippy -- -D warningscleandocs/bamqc, AGENTS.md updated🤖 Generated with Claude Code