8fdef9e866ecc228bfe4ea54102d0079818f0366 braney Fri Apr 8 14:49:38 2022 -0700 let bedGraphToBigWig use chromAlias.bb as chromSizes file. Add tests to both bedGraphToBigWig and bedToBigBed diff --git src/inc/bbiFile.h src/inc/bbiFile.h index ef35638..ae78cd8 100644 --- src/inc/bbiFile.h +++ src/inc/bbiFile.h @@ -90,31 +90,31 @@ struct bbiZoomLevel /* A zoom level in bigWig file. */ { struct bbiZoomLevel *next; /* Next in list. */ bits32 reductionLevel; /* How many bases per item */ bits32 reserved; /* Zero for now. */ bits64 dataOffset; /* Offset of data for this level in file. */ bits64 indexOffset; /* Offset of index for this level in file. */ }; struct bbiZoomLevel *bbiBestZoom(struct bbiZoomLevel *levelList, int desiredReduction); /* Return zoom level that is the closest one that is less than or equal to * desiredReduction. */ typedef struct slName *(*aliasFunc) (char *); // A function that passed a native seqName returns a list of aliases -typedef int (*bbiChromSizeFunc) (void *closure, char *); // A function that passed its closure and an alias or a native seqName returns its size +typedef int (*bbiChromSizeFunc) (void *closure, char *, int); // A function that passed its closure, a line number, and an alias or a native seqName returns its size struct bbiFile /* An open bbiFile */ { struct bbiFile *next; /* Next in list. */ char *fileName; /* Name of file - for better error reporting. */ struct udcFile *udc; /* Open UDC file handle. */ aliasFunc aliasFunc; /* our aliasFunc or NULL. */ bits32 typeSig; /* bigBedSig or bigWigSig for now. */ boolean isSwapped; /* If TRUE need to byte swap everything. */ struct bptFile *chromBpt; /* Index of chromosomes. */ bits16 version; /* Version number - initially 1. */ bits16 zoomLevels; /* Number of zoom levels. */ bits64 chromTreeOffset; /* Offset to chromosome index. */ bits64 unzoomedDataOffset; /* Start of unzoomed data. */ @@ -376,35 +376,30 @@ 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, boolean tabSep); /* Go through bed file and collect chromosomes and statistics. If eim parameter is non-NULL * collect max field sizes there too. Use chromSizesHash to find chrom sizes. */ -struct bbiChromUsage *bbiChromUsageFromBedFileAlias(struct lineFile *lf, bbiChromSizeFunc chromSizeFunc, void *chromSizeClosure, - struct bbExIndexMaker *eim, int *retMinDiff, double *retAveSize, bits64 *retBedCount, boolean tabSep); -/* Go through bed file and collect chromosomes and statistics. If eim parameter is non-NULL - * collect max field sizes there too. Use chromSizeFunc to find chrom sizes.*/ - #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. */ typedef struct bbiSummary *bbiWriteReducedOnceReturnReducedTwice( struct bbiChromUsage *usageList, int fieldCount, struct lineFile *lf, bits32 initialReduction, bits32 initialReductionCount, int zoomIncrement, int blockSize, int itemsPerSlot, boolean doCompress, struct lm *lm, FILE *f, bits64 *retDataStart, bits64 *retIndexStart, struct bbiSummaryElement *totalSum); /* Typedef for a function that writes out data reduced by factor of initial reduction, and @@ -451,16 +446,19 @@ bits64 bbiWriteSummaryAndIndex(struct bbiSummary *summaryList, int blockSize, int itemsPerSlot, boolean doCompress, FILE *f); /* Write out summary and index to summary, returning start position of * summary index. */ boolean bbiFileCheckSigs(char *fileName, bits32 sig, char *typeName); /* check file signatures at beginning and end of file */ time_t bbiUpdateTime(struct bbiFile *bbi); /* return bbi->udc->updateTime */ struct bbiSummary *bbiSummariesInRegion(struct bbiZoomLevel *zoom, struct bbiFile *bbi, int chromId, bits32 start, bits32 end); /* Return list of all summaries in region at given zoom level of bbiFile. */ +struct bbiChromUsage *bbiChromUsageFromBedFileAlias(struct lineFile *lf, char *chromAliasBb, + struct bbExIndexMaker *eim, int *retMinDiff, double *retAveSize, bits64 *retBedCount, boolean tabSep); +/* A wrapper for bbiChromUsageFromBedFileInternal that uses a bigBed to find chromosome sizes. */ #endif /* BBIFILE_H */