Skip to content

Commit

Permalink
Fix cram_dependent_data_series when FN is used.
Browse files Browse the repository at this point in the history
If we get into the primary loop of cram_decode_seq, iterating over
feature (count FN) then we have unguarded code that always checks for
sequence overlapping the reference.  To do this, seq_pos must be set.
Some data series we know how seq_pos is adjusted irrespective of
whether we decode, eg BS is always +1, but others are strings and the
only way we know how to update seq_pos is to decode them.

Hence added FN as having a dependency on SC, IN and BB.

Fixes samtools/samtools#1475
  • Loading branch information
jkbonfield committed Aug 4, 2021
1 parent d16bed5 commit 5184f81
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cram/cram_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,13 @@ int cram_dependent_data_series(cram_fd *fd,
s->data_series |= CRAM_CF | CRAM_NF;
if (s->data_series & (CRAM_BA | CRAM_QS | CRAM_BB | CRAM_QQ))
s->data_series |= CRAM_BF | CRAM_CF | CRAM_RL;
if (s->data_series & CRAM_FN) {
// The CRAM_FN loop checks for reference length boundaries,
// which needs a working seq_pos. Some fields are fixed size
// irrespective of if we decode (BS), both others need to know
// the size of the string fetched back (SC, IN, BB).
s->data_series |= CRAM_SC | CRAM_IN | CRAM_BB;
}

orig_ds = s->data_series;

Expand Down

0 comments on commit 5184f81

Please sign in to comment.