From e63cb6ae370b8cff6ba73c2a52b6096214465a18 Mon Sep 17 00:00:00 2001 From: Stuart Byma Date: Thu, 15 Jun 2017 11:34:36 +0200 Subject: [PATCH] fixing off by one bug in BAM reader decodeSeqRC --- SNAPLib/Bam.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SNAPLib/Bam.cpp b/SNAPLib/Bam.cpp index 47049a18..914b0170 100644 --- a/SNAPLib/Bam.cpp +++ b/SNAPLib/Bam.cpp @@ -279,7 +279,8 @@ char* o_sequence, const _uint8* nibbles, int bases) { - _uint16 *o_sequence_pairs = (_uint16 *)o_sequence; + size_t offset = bases % 2 == 1 ? 1 : 0; + _uint16 *o_sequence_pairs = (_uint16 *)(o_sequence+offset); int pairs = bases / 2; for (int i = 0; i < pairs; i++) { o_sequence_pairs[pairs-i-1] = CodeToSeqPairRC[nibbles[i]];