Skip to content

Commit 90e64d5

Browse files
committed
fix: allow empty seqeunce in BAM record in perbase only-depth
Handle empty sequences in BAM record when generating a pileup to fix an out of bound error in `perbase only-depth` when a BAM record does not have an associated sequence (`*` in sequence column in SAM format). Fixes: #91
1 parent 7dce6f4 commit 90e64d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/position/pileup_position.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ impl PileupPosition {
107107
// Check if we are checking the base quality score
108108
// && Check if the base quality score is greater or equal to than the cutoff
109109
if let Some(base_qual_filter) = base_filter
110-
&& record.qual()[alignment.qpos().unwrap()] < base_qual_filter
110+
&& (record.seq().is_empty() || record.qual()[alignment.qpos().unwrap()] < base_qual_filter)
111111
{
112112
self.n += 1
113113
} else if let Some(b) = recommended_base {
@@ -124,6 +124,8 @@ impl PileupPosition {
124124
Base::M => self.m += 1,
125125
_ => self.n += 1,
126126
}
127+
} else if record.seq().is_empty() {
128+
self.n += 1
127129
} else {
128130
match (record.seq()[alignment.qpos().unwrap()] as char).to_ascii_uppercase() {
129131
'A' => self.a += 1,

0 commit comments

Comments
 (0)