b622d147b7dbac52dbf3ba26928cd18e02d42bd8 braney Sat Feb 26 12:34:37 2022 -0800 add support for using a bigBed as the chromAlias file diff --git src/hg/hgTables/bigWig.c src/hg/hgTables/bigWig.c index 1f747eb..ccdb664 100644 --- src/hg/hgTables/bigWig.c +++ src/hg/hgTables/bigWig.c @@ -232,31 +232,31 @@ resultCount = wigPrintDataVectorOut(dv, wigOutType, maxOut, NULL); dataVectorFree(&dv); return resultCount; } int bigWigOutRegion(char *table, struct sqlConnection *conn, struct region *region, int maxOut, enum wigOutputType wigOutType) /* Write out bigWig for region, doing intersecting and filtering as need be. */ { boolean isMerged = anySubtrackMerge(table, database); int resultCount = 0; char *wigFileName = bigWigFileName(table, conn); if (wigFileName) { - struct bbiFile *bwf = bigWigFileOpenAlias(wigFileName, chromAliasChromToAliasHash(database)); + struct bbiFile *bwf = bigWigFileOpenAlias(wigFileName, chromAliasFindAliases); if (bwf) { /* Easy case, just dump out data. */ if (!anyFilter() && !anyIntersection() && !isMerged && wigOutType == wigOutData) resultCount = bigWigIntervalDump(bwf, region->chrom, region->start, region->end, maxOut, stdout); /* Pretty easy case, still do it ourselves. */ else if (!isMerged && wigOutType == wigOutData) { double ll, ul; enum wigCompare cmp; getWigFilter(database, curTable, &cmp, &ll, &ul); struct lm *lm = lmInit(0); struct bbiInterval *ivList, *iv; ivList = intersectedFilteredBbiIntervalsOnRegion(conn, bwf, region, cmp, ll, ul, lm); @@ -284,31 +284,31 @@ /* Put up page showing summary stats for bigWig track. */ { struct trackDb *track = curTrack; char *table = curTable; char *shortLabel = (track == NULL ? table : track->shortLabel); char *fileName = bigWigFileName(table, conn); long startTime = clock1000(); htmlOpen("%s (%s) Big Wig Summary Statistics", shortLabel, table); if (anySubtrackMerge(database, curTable)) hPrintf("

Note: subtrack merge is currently ignored on this " "page (not implemented yet). Statistics shown here are only for " "the primary table %s (%s).", shortLabel, table); -struct bbiFile *bwf = bigWigFileOpenAlias(fileName, chromAliasChromToAliasHash(database)); +struct bbiFile *bwf = bigWigFileOpenAlias(fileName, chromAliasFindAliases); struct region *region, *regionList = getRegions(); double sumData = 0, sumSquares = 0, minVal = 0, maxVal = 0; bits64 validCount = 0; if (!anyFilter() && !anyIntersection()) { for (region = regionList; region != NULL; region = region->next) { struct bbiSummaryElement sum; if (bbiSummaryArrayExtended(bwf, region->chrom, region->start, region->end, bigWigIntervalQuery, 1, &sum)) { if (validCount == 0) { minVal = sum.minVal; @@ -373,58 +373,58 @@ long wigFetchTime = clock1000() - startTime; floatStatRow("load and calc time", 0.001*wigFetchTime); hTableEnd(); bbiFileClose(&bwf); htmlClose(); } struct bed *bigWigIntervalsToBed(struct sqlConnection *conn, char *table, struct region *region, struct lm *lm) /* Return a list of unfiltered, unintersected intervals in region as bed (for * secondary table in intersection). */ { struct bed *bed, *bedList = NULL; char *fileName = bigWigFileName(table, conn); -struct bbiFile *bwf = bigWigFileOpenAlias(fileName, chromAliasChromToAliasHash(database)); +struct bbiFile *bwf = bigWigFileOpenAlias(fileName, chromAliasFindAliases); struct bbiInterval *iv, *ivList = bigWigIntervalQuery(bwf, region->chrom, region->start, region->end, lm); for (iv = ivList; iv != NULL; iv = iv->next) { lmAllocVar(lm, bed); bed->chrom = region->chrom; bed->chromStart = iv->start; bed->chromEnd = iv->end; slAddHead(&bedList, bed); } slReverse(&bedList); return bedList; } void bigWigFillDataVector(char *table, struct region *region, struct sqlConnection *conn, struct dataVector *vector) /* Fill in data vector with bigWig info on region. Handles filters and intersections. */ { /* Figure out filter values if any. */ double ll, ul; enum wigCompare cmp; getWigFilter(database, curTable, &cmp, &ll, &ul); /* Get intervals that pass filter and intersection. */ struct lm *lm = lmInit(0); char *fileName = bigWigFileName(table, conn); -struct bbiFile *bwf = bigWigFileOpenAlias(fileName, chromAliasChromToAliasHash(database)); +struct bbiFile *bwf = bigWigFileOpenAlias(fileName, chromAliasFindAliases); struct bbiInterval *iv, *ivList; ivList = intersectedFilteredBbiIntervalsOnRegion(conn, bwf, region, cmp, ll, ul, lm); int vIndex = 0; for (iv = ivList; iv != NULL; iv = iv->next) { int start = max(iv->start, region->start); int end = min(iv->end, region->end); double val = iv->val; int i; for (i=start; imaxCount; ++i) { vector->value[vIndex] = val; vector->position[vIndex] = i; ++vIndex; }