57d153c3caf42b22dd4cff6138a54c1b8545333f kent Fri Mar 8 15:25:37 2013 -0800 Fixing a bug where sometimes zoom summaries would not be written out by bedGraphToBigWig. I'm seeing a lot of code that can be shared between bedGraphToBigWig and bedToBigBed. Refactored to share some now, will do more shortly. diff --git src/inc/bbiFile.h src/inc/bbiFile.h index c66b23e..e492410 100644 --- src/inc/bbiFile.h +++ src/inc/bbiFile.h @@ -371,30 +371,38 @@ bits16 indexCount; /* Number of extra indexes. */ /* Kind of wish next four fields, all of which are arrays indexed * by the same thing, were a single array of a structure instead. */ bits16 *indexFields; /* array of field ids, one for each extra index. */ int *maxFieldSize; /* array of maximum sizes seen for this field. */ struct bbNamedFileChunk **chunkArrayArray; /* where we keep name/start/size triples */ bits64 *fileOffsets; /* array of file offsets where indexes starts. */ int recordCount; /* number of records in file. */ }; struct bbiChromUsage *bbiChromUsageFromBedFile(struct lineFile *lf, struct hash *chromSizesHash, struct bbExIndexMaker *eim, int *retMinDiff, double *retAveSize, bits64 *retBedCount); /* Go through bed file and collect chromosomes and statistics. If eim parameter is non-NULL * collect max field sizes there too. */ +#define bbiMaxZoomLevels 10 /* Max number of zoom levels */ +#define bbiResIncrement 4 /* Amount to reduce at each zoom level */ + +int bbiCalcResScalesAndSizes(int aveSize, + int resScales[bbiMaxZoomLevels], int resSizes[bbiMaxZoomLevels]); +/* Fill in resScales with amount to zoom at each level, and zero out resSizes based + * on average span. Returns the number of zoom levels we actually will use. */ + int bbiCountSectionsNeeded(struct bbiChromUsage *usageList, int itemsPerSlot); /* Count up number of sections needed for data. */ void bbiAddToSummary(bits32 chromId, bits32 chromSize, bits32 start, bits32 end, bits32 validCount, double minVal, double maxVal, double sumData, double sumSquares, int reduction, struct bbiSummary **pOutList); /* Add data range to summary - putting it onto top of list if possible, otherwise * expanding list. */ void bbiAddRangeToSummary(bits32 chromId, bits32 chromSize, bits32 start, bits32 end, double val, int reduction, struct bbiSummary **pOutList); /* Add chromosome range to summary - putting it onto top of list if possible, otherwise * expanding list. */ struct bbiSummary *bbiReduceSummaryList(struct bbiSummary *inList,