src/lib/bwgQuery.c 1.19
1.19 2009/02/24 03:29:10 kent
Adding byte-swapping routines for floating point items. Using them in the bigWig read routines.
Index: src/lib/bwgQuery.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/bwgQuery.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -b -B -U 4 -r1.18 -r1.19
--- src/lib/bwgQuery.c 10 Feb 2009 22:09:37 -0000 1.18
+++ src/lib/bwgQuery.c 24 Feb 2009 03:29:10 -0000 1.19
@@ -125,14 +125,16 @@
struct bbiInterval *bigWigIntervalQuery(struct bbiFile *bwf, char *chrom, bits32 start, bits32 end,
struct lm *lm)
/* Get data for interval. Return list allocated out of lm. */
{
+uglyf("bigWigIntervalQuery %s %d %d. bwf->isSwapped=%d\n", chrom, start, end, bwf->isSwapped);
if (bwf->typeSig != bigWigSig)
errAbort("Trying to do bigWigIntervalQuery on a non big-wig file.");
bbiAttachUnzoomedCir(bwf);
struct bbiInterval *el, *list = NULL;
struct fileOffsetSize *blockList = bbiOverlappingBlocks(bwf, bwf->unzoomedCir,
chrom, start, end, NULL);
+uglyf("%d in blockList\n", slCount(blockList));
struct fileOffsetSize *block;
struct udcFile *udc = bwf->udc;
boolean isSwapped = bwf->isSwapped;
float val;
@@ -141,8 +143,9 @@
// slSort(&blockList, fileOffsetSizeCmp);
struct fileOffsetSize *mergedBlocks = fileOffsetSizeMerge(blockList);
for (block = mergedBlocks; block != NULL; block = block->next)
{
+ uglyf("block offset %llu, size %llu\n", block->offset, block->size);
udcSeek(udc, block->offset);
char *blockBuf = needLargeMem(block->size);
udcRead(udc, blockBuf, block->size);
char *blockPt = blockBuf, *blockEnd = blockBuf + block->size;
@@ -157,9 +160,9 @@
for (i=0; i<head.itemCount; ++i)
{
bits32 s = memReadBits32(&blockPt, isSwapped);
bits32 e = memReadBits32(&blockPt, isSwapped);
- memReadOne(&blockPt, val);
+ val = memReadFloat(&blockPt, isSwapped);
if (s < start) s = start;
if (e > end) e = end;
if (s < e)
{
@@ -177,9 +180,9 @@
for (i=0; i<head.itemCount; ++i)
{
bits32 s = memReadBits32(&blockPt, isSwapped);
bits32 e = s + head.itemSpan;
- memReadOne(&blockPt, val);
+ val = memReadFloat(&blockPt, isSwapped);
if (s < start) s = start;
if (e > end) e = end;
if (s < e)
{
@@ -197,9 +200,9 @@
bits32 s = head.start;
bits32 e = s + head.itemSpan;
for (i=0; i<head.itemCount; ++i)
{
- memReadOne(&blockPt, val);
+ val = memReadFloat(&blockPt, isSwapped);
bits32 clippedS = s, clippedE = e;
if (clippedS < start) clippedS = start;
if (clippedE > end) clippedE = end;
if (clippedS < clippedE)