3bbad1670f2e44ca41d06c657b8f8636abfce4fb hiram Wed Mar 27 14:47:11 2019 -0700 provide list chrom function for hubs refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index 75512cb..7213d33 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -308,31 +308,31 @@ } else { if (startsWithWord("bigBed", tdb->type)) hPrintf(" <li>%s : %s%s</li>\n", tdb->track, tdb->type, countsMessage); else if (startsWithWord("bigWig", tdb->type)) hPrintf(" <li>%s : %s%s</li>\n", tdb->track, tdb->type, countsMessage); else hPrintf(" <li>%s : %s%s</li>\n", tdb->track, tdb->type, countsMessage); } } /* static void hubSampleUrl(struct trackHub *hub, struct trackDb *tdb, * long chromCount, long itemCount, char *chromName, unsigned chromSize, * char *genome) */ -static void bbiBiggestChrom(struct bbiChromInfo *chromList, char **chromName, +static void bbiLargestChrom(struct bbiChromInfo *chromList, char **chromName, unsigned *chromSize) /* find largest chromosome name and size in the chromList */ { if (chromName && chromSize) { *chromSize = 0; char *returnName = NULL; struct bbiChromInfo *el; for (el = chromList; el; el = el->next) { if (el->size > *chromSize) { *chromSize = el->size; returnName = el->name; } @@ -355,42 +355,42 @@ { if (startsWithWord("bigNarrowPeak", type) || startsWithWord("bigBed", type) || startsWithWord("bigGenePred", type) || startsWithWord("bigPsl", type) || startsWithWord("bigChain", type) || startsWithWord("bigMaf", type) || startsWithWord("bigBarChart", type) || startsWithWord("bigInteract", type)) { struct bbiFile *bbi = NULL; bbi = bigBedFileOpen(bigDataUrl); struct bbiChromInfo *chromList = bbiChromList(bbi); *chromCount = slCount(chromList); *itemCount = bigBedItemCount(bbi); - bbiBiggestChrom(chromList, chromName, chromSize); + bbiLargestChrom(chromList, chromName, chromSize); bbiChromInfoFreeList(&chromList); bbiFileClose(&bbi); } else if (startsWithWord("bigWig", type)) { struct bbiFile *bwf = bigWigFileOpen(bigDataUrl); struct bbiChromInfo *chromList = bbiChromList(bwf); struct bbiSummaryElement sum = bbiTotalSummary(bwf); *chromCount = slCount(chromList); *itemCount = sum.validCount; - bbiBiggestChrom(chromList, chromName, chromSize); + bbiLargestChrom(chromList, chromName, chromSize); bbiChromInfoFreeList(&chromList); bbiFileClose(&bwf); } else if (startsWithWord("vcfTabix", type)) { struct vcfFile *vcf = vcfTabixFileAndIndexMayOpen(bigDataUrl, bigDataIndex, NULL, 0, 0, 1, 1); if (vcf == NULL) { dyStringPrintf(errors, "Could not open %s and/or its tabix index (.tbi) file. See http://genome.ucsc.edu/goldenPath/help/vcf.html", bigDataUrl); retVal = 1; } else vcfFileFree(&vcf); } else if (startsWithWord("bam", type)) @@ -714,30 +714,32 @@ struct hash *countTracks = hashNew(0); struct trackDb *tdb = NULL; for ( tdb = topTrackDb; tdb; tdb = tdb->next ) { char *bigDataIndex = NULL; char *relIdxUrl = trackDbSetting(topTrackDb, "bigDataIndex"); if (relIdxUrl != NULL) bigDataIndex = trackHubRelativeUrl(genome->trackDbFile, relIdxUrl); char *defaultGenome = NULL; if (isNotEmpty(genome->name)) defaultGenome = genome->name; char *chromName = NULL; unsigned chromSize = 0; if (isEmpty(genome->twoBitPath)) chromSize = largestChrom(defaultGenome, &chromName); + else + hPrintf(" <li>twoBitPath %s genome %s</li>\n", genome->twoBitPath, defaultGenome); hubCountOneTdb(hub, defaultGenome, tdb, bigDataIndex, countTracks, chromName, chromSize, defaultGenome); if (timeOutReached()) break; } /* for ( tdb = topTrackDb; tdb; tdb = tdb->next ) */ hPrintf(" <li>%d different track types</li>\n",countTracks->elCount - 1); /* add this single genome count to the overall multi-genome counts */ if (countTracks->elCount) { hPrintf(" <li><ol>\n"); struct hashEl *hel, *helList = hashElListHash(countTracks); slSort(&helList, hashElCmpIntValDesc); for (hel = helList; hel; hel = hel->next) { if (sameOk("track count", hel->name)) continue; @@ -768,54 +770,79 @@ struct hashEl *hel; struct hashCookie hc = hashFirst(genome->settingsHash); while ((hel = hashNext(&hc)) != NULL) { hPrintf(" <li>%s : %s</li>\n", hel->name, (char *)hel->val); if (sameWord("trackDb", hel->name)) /* examine the trackDb structure */ { hubTrackList(hub, tdb, genome); } if (timeOutReached()) break; } hPrintf(" </ul></li>\n"); } +static unsigned largestChromInfo(struct chromInfo *ci, char **chromName) +/* find largest chrom in this chromInfo, return name and size */ +{ +unsigned size = 0; +char *name = NULL; +struct chromInfo *el; +for (el = ci; el; el = el->next) + { + if (el->size > size) + { + size = el->size; + name = el->chrom; + } + } +if (chromName) + *chromName = name; +return size; +} + static void genomeList(struct trackHub *hubTop) /* follow the pointers from the trackHub to trackHubGenome and around * in a circle from one to the other to find all hub resources */ { long totalAssemblyCount = 0; struct trackHubGenome *genome = hubTop->genomeList; hPrintf("<h4>genome sequences (and tracks) present in this track hub</h4>\n"); if (NULL == genome) { hPrintf("<h4>odd error, can not find a gnomeList ? at url: '%s'</h4>\n", hubTop->url); return; } hPrintf("<ul>\n"); long lastTime = clock1000(); for ( ; genome; genome = genome->next ) { ++totalAssemblyCount; if (isNotEmpty(genome->twoBitPath)) { - hPrintf("<li>assembly hub twoBitFile: %s</li>\n", genome->twoBitPath); + hPrintf("<li>assembly hub %s twoBitFile: %s</li>\n", genome->name, genome->twoBitPath); + char *chromName = NULL; + struct chromInfo *ci = trackHubAllChromInfo(genome->name); + unsigned chromSize = largestChromInfo(ci, &chromName); + char sizeString[64]; + sprintLongWithCommas(sizeString, chromSize); + hPrintf("<li>%d chromosomes, largest %s at %s bases</li>\n", slCount(ci), chromName, sizeString); } if (genome->organism) { hPrintf("<li>%s - %s - %s</li>\n", genome->organism, genome->name, genome->description); } else { /* can there be a description when organism is empty ? */ hPrintf("<li>name: %s</li>\n", genome->name); } hubAssemblySettings(hubTop, genome); if (measureTiming || debug) { long thisTime = clock1000(); hPrintf("<li><em>processing time %s: %ld millis</em></li>\n", genome->name, thisTime - lastTime); }