Skip to content

Commit

Permalink
Further improve MM tag consistency checking.
Browse files Browse the repository at this point in the history
If we have an MM tag with base-type specific coordinates beyond the
end of the sequence as there are too few bases of that type, then we
now detect this within bam_parse_basemod.

This was already checked within bam_next_basemod for forward reads,
but not spotted in reverse complemented ones.

Fixes #1466
  • Loading branch information
jkbonfield authored and daviesrob committed Jul 8, 2022
1 parent b014804 commit 506f479
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -6289,6 +6289,11 @@ int bam_parse_basemod(const bam1_t *b, hts_base_mod_state *state) {
state->MLstride [mod_num] = stride;
state->implicit [mod_num] = implicit;

if (delta < 0) {
hts_log_error("MM tag refers to bases beyond sequence "
"length");
return -1;
}
state->MMcount [mod_num] = delta;
if (b->core.flag & BAM_FREVERSE) {
state->MM [mod_num] = cp+1;
Expand Down

0 comments on commit 506f479

Please sign in to comment.