Skip to content

Commit

Permalink
fix: return error if problem in normalization
Browse files Browse the repository at this point in the history
Return an error rather than using `unwrap()` if an exon cannot be
found for transcript normalization.  This occured for NR_111984.1
on GRCh37 where the first exons are not properly aligned.
  • Loading branch information
holtgrewe committed Mar 30, 2023
1 parent f70bb91 commit f5742ab
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/normalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,15 +272,21 @@ impl<'a> Normalizer<'a> {
.find(|(idx, _x)| {
loc_range.start >= exon_starts[*idx] && loc_range.start < exon_ends[*idx]
})
.unwrap()
.ok_or(anyhow::anyhow!(
"Cannot find exon for normalization of start of {}",
&var
))?
.0;
let j = exon_starts
.iter()
.enumerate()
.find(|(idx, _x)| {
loc_range.end > exon_starts[*idx] && loc_range.end - 1 < exon_ends[*idx]
})
.unwrap()
.ok_or(anyhow::anyhow!(
"Cannot find exon for normalization of end of {}",
&var
))?
.0;

if i != j {
Expand Down

0 comments on commit f5742ab

Please sign in to comment.