Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 17 additions & 70 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/site_analysis/pileup/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ pub(super) fn parse_row_channel(name: &str) -> Option<(&str, &str, &str, i64, Op
/// (`ENSG00000000001`) query resolve the same row. Case-insensitive.
/// `query_sym` is the pre-canonicalized query symbol.
pub(crate) fn gene_matches(query: &str, query_sym: &str, gene_part: &str) -> bool {
// A position or locus (a BAF row's `chr:pos`) is not a gene name: only
// the whole of it matches, so an alt contig's `_` pieces never do.
if genomic_data::coordinates::is_region(gene_part) {
return gene_part.eq_ignore_ascii_case(query);
}
// Allocation-free component check first — it directly covers symbol and
// Ensembl-ID queries (and subsumes a full-composite match). Fall back to
// the suffix-stripping canonicalizer only when the components miss.
Expand Down
13 changes: 13 additions & 0 deletions src/site_analysis/pileup/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,16 @@ fn a_gene_symbol_may_hold_a_slash() {
assert_eq!(row, Some(("ID1_GENE1/B", "m6a", "chr1", 100, Some(true))));
assert_eq!(parse_row_channel("ID1_GENE1/m6a/chr1:100/other"), None);
}

#[test]
fn an_alt_contig_position_is_not_read_as_a_gene() {
// A BAF row's first segment is a position on an alt contig: no gene
// query may match a piece of it.
let gp = "chr1_KI270706v1_random:12345";
for q in ["random:12345", "random", "KI270706v1", "chr1"] {
assert!(!gene_matches(q, &query_symbol(q), gp), "{q}");
}
assert!(gene_matches(gp, &query_symbol(gp), gp));
// The shared gene rule leaves a coordinate whole.
assert_eq!(&*query_symbol(gp), gp);
}
Loading