src/utils/bedGraphToBigWig/bedGraphToBigWig.c 1.16
1.16 2009/11/05 19:35:38 kent
Bumping version number. Making sectionCount and zoomCount more consistent. Also fixing bug with sumSquares being just sum.
Index: src/utils/bedGraphToBigWig/bedGraphToBigWig.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/utils/bedGraphToBigWig/bedGraphToBigWig.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -b -B -U 4 -r1.15 -r1.16
--- src/utils/bedGraphToBigWig/bedGraphToBigWig.c 10 Sep 2009 01:49:38 -0000 1.15
+++ src/utils/bedGraphToBigWig/bedGraphToBigWig.c 5 Nov 2009 19:35:38 -0000 1.16
@@ -174,10 +174,10 @@
}
assert(sectionIx == sectionCount);
}
-struct bbiSummary *writeReducedOnceReturnReducedTwice(struct bbiChromUsage *usageList,
- struct lineFile *lf, int initialReduction, int initialReductionCount,
+static struct bbiSummary *writeReducedOnceReturnReducedTwice(struct bbiChromUsage *usageList,
+ struct lineFile *lf, bits32 initialReduction, bits32 initialReductionCount,
int zoomIncrement, int blockSize, int itemsPerSlot,
struct lm *lm, FILE *f, bits64 *retDataStart, bits64 *retIndexStart)
/* Write out data reduced by factor of initialReduction. Also calculate and keep in memory
* next reduction level. This is more work than some ways, but it keeps us from having to
@@ -191,8 +191,9 @@
boundsPt = AllocArray(boundsArray, initialReductionCount);
boundsEnd = boundsPt + initialReductionCount;
*retDataStart = ftell(f);
+writeOne(f, initialReductionCount);
for (;;)
{
/* Get next line of input if any. */
char *row[5];
@@ -252,9 +253,9 @@
sum->validCount += overlap;
if (sum->minVal > val) sum->minVal = val;
if (sum->maxVal < val) sum->maxVal = val;
sum->sumData += val * overlap;
- sum->sumSquares += val * overlap;
+ sum->sumSquares += val*val * overlap;
bbiOutputOneSummaryFurtherReduce(sum, &twiceReducedList, doubleReductionSize,
&boundsPt, boundsEnd, usage->size, lm, f);
/* Move summary to next part. */
@@ -271,9 +272,9 @@
sum->validCount += size;
if (sum->minVal > val) sum->minVal = val;
if (sum->maxVal < val) sum->maxVal = val;
sum->sumData += val * size;
- sum->sumSquares += val * size;
+ sum->sumSquares += val*val * size;
}
/* Write out 1st zoom index. */
int indexOffset = *retIndexStart = ftell(f);
@@ -293,11 +294,12 @@
verboseTime(2, NULL);
struct lineFile *lf = lineFileOpen(inName, TRUE);
struct hash *chromSizesHash = bbiChromSizesFromFile(chromSizes);
verbose(2, "%d chroms in %s\n", chromSizesHash->elCount, chromSizes);
-int minDiff, i;
-double aveSize;
-struct bbiChromUsage *usageList = bbiChromUsageFromBedFile(lf, chromSizesHash, &minDiff, &aveSize);
+int minDiff = 0, i;
+double aveSize = 0;
+bits64 bedCount = 0;
+struct bbiChromUsage *usageList = bbiChromUsageFromBedFile(lf, chromSizesHash, &minDiff, &aveSize, &bedCount);
verboseTime(2, "pass1");
verbose(2, "%d chroms in %s\n", slCount(usageList), inName);
/* Write out dummy header, zoom offsets. */
@@ -327,9 +329,10 @@
resTryCount = 0;
/* Write out primary full resolution data in sections, collect stats to use for reductions. */
bits64 dataOffset = ftell(f);
-bits32 sectionCount = bbiCountSectionsNeeded(usageList, itemsPerSlot);
+bits64 sectionCount = bbiCountSectionsNeeded(usageList, itemsPerSlot);
+writeOne(f, sectionCount);
struct bbiBoundsArray *boundsArray;
AllocArray(boundsArray, sectionCount);
lineFileRewind(lf);
writeSections(usageList, lf, itemsPerSlot, boundsArray, sectionCount, f,
@@ -407,9 +410,9 @@
/* Go back and rewrite header. */
rewind(f);
bits32 sig = bigWigSig;
-bits16 version = 1;
+bits16 version = bbiCurrentVersion;
bits16 summaryCount = zoomLevels;
bits32 reserved32 = 0;
bits32 reserved64 = 0;