Skip to content

fix(counting): claim a chromosome name mismatch only when names don't overlap - #176

Draft
NicoDeVeaux wants to merge 2 commits into
mainfrom
ndv/fix-no-genic-reads-diagnostic
Draft

NicoDeVeaux wants to merge 2 commits into
mainfrom
ndv/fix-no-genic-reads-diagnostic

Conversation

@NicoDeVeaux

Copy link
Copy Markdown

fix(counting): claim a chromosome name mismatch only when names don't overlap

What

When mapped reads exist but none is assigned to a gene, count_reads now checks whether any alignment chromosome, after chromosome_prefix / chromosome_mapping, is a GTF chromosome. If one is, it reports:

No reads could be assigned to any gene: none of the 1 mapped reads overlaps a gene in the GTF.

Chromosomes in both the alignment and the GTF (first 5): chr1

The chromosome names match, so check that the GTF annotates the regions the reads align to (same genome assembly).

Only when no name is shared does it keep the existing "Chromosome name mismatch" message and its chromosome_mapping advice. The run still exits non-zero in both cases.

Why

The condition (src/rna/dupradar/counting.rs:1646-1652) only tests "mapped reads > 0 and no gene has a read"; it never compares names, so it tells users to add a chromosome_mapping that cannot help. Minimal input: one mapped read at chr1:11, one gene at chr1:900-3000 (a second gene on chr2). main prints:

Chromosome name mismatch: no reads could be assigned to any gene.

Alignment chromosomes (first 5): chr1, chr2
GTF chromosomes (first 5): chr1, chr2

The alignment and GTF files appear to use different chromosome naming conventions.
...
chromosome_mapping:
  chr1: chr1
  chr2: chr2

How tested

Integration tests (one mapped read outside the only gene):

  • test_no_genic_reads_with_shared_names_is_not_a_name_mismatch (BAM and GTF both chr1): fails at main, passes here.
  • test_no_genic_reads_with_prefix_mapped_names_is_not_a_name_mismatch (BAM 1, GTF chr1, config chromosome_prefix: "chr"): fails at main, passes here.
  • test_no_genic_reads_with_disjoint_names_is_a_name_mismatch (BAM 1, GTF chr1, no config): passes on both; guards the existing message.

All three assert a non-zero exit. cargo test --release --locked --offline: 200 unit, 12 bin, 21 integration, 2 doc tests pass. cargo fmt --check passes. cargo clippy -- -D warnings reports the same three needless_range_loop errors as unmodified main with the local toolchain (clippy 0.1.90); with that lint allowed, --all-targets is clean. The formal-review harness's edge_inputs.py shows only E2 (mapped read outside genes) changing, from "Chromosome name mismatch" to the new message; E1, E3-E5 are unchanged.

Not changed, and why

  • Exit behaviour: whether RustQC should abort on this input at all is an open question. Upstream dupRadar 1.38.0 also exits non-zero here, while featureCounts, Qualimap and samtools succeed. This change keeps the abort and changes only the message.
  • The mismatch branch's chromosome_mapping example still pairs the first five names of each file by position; it is unchanged.

🤖 Generated with Claude Code

NicoDeVeaux and others added 2 commits October 23, 2026 11:20
…mosome names

When mapped reads exist but none lands in a gene, `count_reads` reports
"Chromosome name mismatch" without comparing names. These tests fail where
the BAM and GTF share a name (directly, or through chromosome_prefix) and
keep the mismatch message for disjoint names. All three expect a non-zero
exit: whether to abort on this input is a separate question.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… overlap

When mapped reads exist but none is assigned to a gene, check whether any
alignment chromosome (after chromosome_prefix / chromosome_mapping) is a
GTF chromosome. If one is, report that no reads could be assigned to any
gene instead of "Chromosome name mismatch" and its chromosome_mapping
advice. The run still fails in both cases; only the diagnostic changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant