src/lib/bwgCreate.c 1.22
1.22 2009/11/25 07:17:25 kent
Getting rid of largely redundant bwgSectionWriteUnc
Index: src/lib/bwgCreate.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/bwgCreate.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -b -B -U 4 -r1.21 -r1.22
--- src/lib/bwgCreate.c 16 Nov 2009 11:01:22 -0000 1.21
+++ src/lib/bwgCreate.c 25 Nov 2009 07:17:25 -0000 1.22
@@ -106,69 +106,10 @@
sum->chromId, sum->start, sum->end, sum->minVal, sum->maxVal, sum->sumData,
sum->sumSquares, sum->validCount, sum->sumData/sum->validCount);
}
-static int bwgSectionWriteUnc(struct bwgSection *section, FILE *f)
-/* Write out compressed section to file, filling in section->fileOffset. */
-{
-UBYTE type = section->type;
-UBYTE reserved8 = 0;
-
-section->fileOffset = ftell(f);
-writeOne(f, section->chromId);
-writeOne(f, section->start);
-writeOne(f, section->end);
-writeOne(f, section->itemStep);
-writeOne(f, section->itemSpan);
-writeOne(f, type);
-writeOne(f, reserved8);
-writeOne(f, section->itemCount);
-
-int i;
-switch (section->type)
- {
- case bwgTypeBedGraph:
- {
- struct bwgBedGraphItem *item = section->items.bedGraphList;
- for (item = section->items.bedGraphList; item != NULL; item = item->next)
- {
- writeOne(f, item->start);
- writeOne(f, item->end);
- writeOne(f, item->val);
- }
- break;
- }
- case bwgTypeVariableStep:
- {
- struct bwgVariableStepPacked *items = section->items.variableStepPacked;
- for (i=0; i<section->itemCount; ++i)
- {
- writeOne(f, items->start);
- writeOne(f, items->val);
- items += 1;
- }
- break;
- }
- case bwgTypeFixedStep:
- {
- struct bwgFixedStepPacked *items = section->items.fixedStepPacked;
- for (i=0; i<section->itemCount; ++i)
- {
- writeOne(f, items->val);
- items += 1;
- }
- break;
- }
- default:
- internalErr();
- break;
- }
-return 0;
-}
-
-static int bwgSectionWriteComp(struct bwgSection *section, FILE *f)
-/* Write out compressed section to file, filling in section->fileOffset.
- * Returns uncompressed size. */
+static int bwgSectionWrite(struct bwgSection *section, boolean doCompress, FILE *f)
+/* Write out section to file, filling in section->fileOffset. */
{
UBYTE type = section->type;
UBYTE reserved8 = 0;
int itemSize;
@@ -245,23 +186,18 @@
break;
}
assert(bufSize == (bufPt - buf) );
-size_t maxCompSize = zCompBufSize(bufSize);
-char compBuf[maxCompSize];
-int compSize = zCompress(buf, bufSize, compBuf, maxCompSize);
-mustWrite(f, compBuf, compSize);
-return bufSize;
-}
-
-
-static int bwgSectionWrite(struct bwgSection *section, boolean doCompress, FILE *f)
-/* Write out section to file, filling in section->fileOffset. */
-{
if (doCompress)
- return bwgSectionWriteComp(section, f);
+ {
+ size_t maxCompSize = zCompBufSize(bufSize);
+ char compBuf[maxCompSize];
+ int compSize = zCompress(buf, bufSize, compBuf, maxCompSize);
+ mustWrite(f, compBuf, compSize);
+ }
else
- return bwgSectionWriteUnc(section, f);
+ mustWrite(f, buf, bufSize);
+return bufSize;
}
static int bwgSectionCmp(const void *va, const void *vb)