Skip to content

Commit 0b2defa

Browse files
authored
Fix #9
1 parent 1821661 commit 0b2defa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib2bit/2bit.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ uint8_t getByteMaskFromOffset(int offset) {
278278
void *twobitBasesWorker(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end, int fraction) {
279279
void *out;
280280
uint32_t tmp[4] = {0, 0, 0, 0}, len = end - start + (start % 4), i = 0, j = 0;
281+
uint32_t seqLen = end - start;
281282
uint32_t blockStart, blockEnd, maskIdx = (uint32_t) -1, maskStart, maskEnd, foo;
282283
uint8_t *bytes = NULL, mask = 0, offset;
283284

@@ -375,10 +376,10 @@ void *twobitBasesWorker(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end,
375376
//out is in TCAG order, since that's how 2bit is stored.
376377
//However, for whatever reason I went with ACTG in the first release...
377378
if(fraction) {
378-
((double*) out)[0] = ((double) tmp[2])/((double) len);
379-
((double*) out)[1] = ((double) tmp[1])/((double) len);
380-
((double*) out)[2] = ((double) tmp[0])/((double) len);
381-
((double*) out)[3] = ((double) tmp[3])/((double) len);
379+
((double*) out)[0] = ((double) tmp[2])/((double) seqLen);
380+
((double*) out)[1] = ((double) tmp[1])/((double) seqLen);
381+
((double*) out)[2] = ((double) tmp[0])/((double) seqLen);
382+
((double*) out)[3] = ((double) tmp[3])/((double) seqLen);
382383
} else {
383384
((uint32_t*) out)[0] = tmp[2];
384385
((uint32_t*) out)[1] = tmp[1];

0 commit comments

Comments
 (0)