7df99795b147931dfea8220ed5ab305d11fde6b4
braney
  Thu Mar 10 15:41:46 2022 -0800
move some chromAlias stuff around so bedToBigBed can use a chromAlias
bigBed as a chromAlias file.

diff --git src/inc/bbiFile.h src/inc/bbiFile.h
index 27808a7..ef35638 100644
--- src/inc/bbiFile.h
+++ src/inc/bbiFile.h
@@ -90,30 +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
 
 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. */
@@ -373,31 +374,36 @@
 /* A helper structure to make indexes beyond primary one.  Just used for bigBeds */
     {
     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. */
+ * 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);