Skip to content

Commit

Permalink
Fix reading files with >256 contigs...again
Browse files Browse the repository at this point in the history
  • Loading branch information
dpryan79 committed Mar 29, 2016
1 parent a2c3a35 commit 53ce50d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion libBigWig/bigWig.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/*!
* The library version number
*/
#define LIBBIGWIG_VERSION 0.1.6
#define LIBBIGWIG_VERSION 0.1.7

/*!
* The magic number of a bigWig file.
Expand Down
17 changes: 11 additions & 6 deletions libBigWig/bwRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,21 @@ static uint64_t readChromLeaf(bigWigFile_t *bw, chromList_t *cl, uint32_t valueS
}

static uint64_t readChromNonLeaf(bigWigFile_t *bw, chromList_t *cl, uint32_t keySize) {
uint64_t offset;
uint16_t nVals;
uint64_t offset , rv = 0, previous;
uint16_t nVals, i;

if(bwRead((void*) &nVals, sizeof(uint16_t), 1, bw) != 1) return -1;

//These aren't actually used for anything, we just skip to the next block...
offset = nVals * (keySize + 8) + bwTell(bw);
previous = bwTell(bw) + keySize;
for(i=0; i<nVals; i++) {
if(bwSetPos(bw, previous)) return -1;
if(bwRead((void*) &offset, sizeof(uint64_t), 1, bw) != 1) return -1;
if(bwSetPos(bw, offset)) return -1;
rv += readChromBlock(bw, cl, keySize);
previous += 8 + keySize;
}

if(bwSetPos(bw, offset)) return -1;
return readChromBlock(bw, cl, keySize);
return rv;
}

static uint64_t readChromBlock(bigWigFile_t *bw, chromList_t *cl, uint32_t keySize) {
Expand Down

0 comments on commit 53ce50d

Please sign in to comment.