Skip to content

Commit

Permalink
fix: allow leading deletions in read_pos method of CigarStringView.
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Nov 12, 2024
1 parent 4b3cbcb commit 8e83763
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/bam/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2097,10 +2097,15 @@ impl CigarStringView {
}
break;
},
Cigar::Del(_) => {
return Err(Error::BamUnexpectedCigarOperation {
msg: "'deletion' (D) found before any operation describing read sequence".to_owned()
});
Cigar::Del(l) => {
// METHOD: leading deletions can happen in case of trimmed reads where
// a primer has been removed AFTER read mapping.
// Example: 24M8I8D18M9S before trimming, 32H8D18M9S after trimming
// with fgbio. While leading deletions should be impossible with
// normal read mapping, they make perfect sense with primer trimming
// because the mapper still had the evidence to decide in favor of
// the deletion via the primer sequence.
rpos += l;
},
Cigar::RefSkip(_) => {
return Err(Error::BamUnexpectedCigarOperation {
Expand Down

0 comments on commit 8e83763

Please sign in to comment.