55b54d043a87a29773ca196c360a0af1346947ec
hiram
Mon Feb 18 07:05:59 2019 -0800
the trackDb from hubs appears to be flattened ? refs #18869
diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c
index 8df3375..a80b2df 100644
--- src/hg/hubApi/hubApi.c
+++ src/hg/hubApi/hubApi.c
@@ -104,30 +104,32 @@
}
static void trackSettings(struct trackDb *tdb)
/* process the settingsHash for a track */
{
hPrintf("
\n");
struct hashEl *hel;
struct hashCookie hc = hashFirst(tdb->settingsHash);
while ((hel = hashNext(&hc)) != NULL)
{
if (isEmpty((char *)hel->val))
hPrintf(" - %s : <empty>
\n", hel->name);
else
hPrintf(" - %s : '%s'
\n", hel->name, (char *)hel->val);
}
+if (tdb->subtracks)
+ trackSettings(tdb->subtracks);
hPrintf("
\n");
}
static int bbiBriefMeasure(char *type, char *bigDataUrl, char *bigDataIndex, long *chromCount, long *itemCount, struct dyString *errors)
/* check a bigDataUrl to find chrom count and item count */
{
int retVal = 0;
*chromCount = 0;
*itemCount = 0;
struct errCatch *errCatch = errCatchNew();
if (errCatchStart(errCatch))
{
if (startsWithWord("bigNarrowPeak", type)
|| startsWithWord("bigBed", type)
|| startsWithWord("bigGenePred", type)
@@ -229,93 +231,97 @@
destination->colorB = source->colorB;
destination->altColorR = source->altColorR;
destination->altColorG = source->altColorG;
destination->altColorB = source->altColorB;
destination->useScore = source->useScore;
destination->private = source->private;
destination->url = cloneString(source->url);
destination->html = cloneString(source->html);
destination->grp = cloneString(source->grp);
destination->canPack = source->canPack;
destination->settings = cloneString(source->settings);
destination->settingsHash = source->settingsHash;
}
#endif
-static void hubTrackList(struct trackDb *tdb, struct trackHubGenome *genome)
+static void hubTrackList(struct trackDb *topTrackDb, struct trackHubGenome *genome)
/* process the track list to show all tracks, return trackDb list */
{
-if (tdb)
+if (topTrackDb)
{
struct hash *countTracks = hashNew(0);
hPrintf(" \n");
- struct trackDb *track = tdb;
- for ( ; track; track = track->next )
+ struct trackDb *tdb = NULL;
+ for ( tdb = topTrackDb; tdb; tdb = tdb->next )
{
- char *bigDataUrl = trackDbSetting(track, "bigDataUrl");
- char *compositeTrack = trackDbSetting(track, "compositeTrack");
- char *superTrack = trackDbSetting(track, "superTrack");
+ char *bigDataUrl = trackDbSetting(tdb, "bigDataUrl");
+ char *compositeTrack = trackDbSetting(tdb, "compositeTrack");
+ char *superTrack = trackDbSetting(tdb, "superTrack");
boolean depthSearch = cartUsualBoolean(cart, "depthSearch", FALSE);
if (compositeTrack)
hashIncInt(countTracks, "composite container");
else if (superTrack)
hashIncInt(countTracks, "superTrack container");
- else if (isEmpty(track->type))
+ else if (isEmpty(tdb->type))
hashIncInt(countTracks, "no type specified");
else
- hashIncInt(countTracks, track->type);
+ hashIncInt(countTracks, tdb->type);
if (depthSearch && bigDataUrl)
{
char *bigDataIndex = NULL;
- char *relIdxUrl = trackDbSetting(tdb, "bigDataIndex");
+ char *relIdxUrl = trackDbSetting(topTrackDb, "bigDataIndex");
if (relIdxUrl != NULL)
bigDataIndex = trackHubRelativeUrl(genome->trackDbFile, relIdxUrl);
long chromCount = 0;
long itemCount = 0;
struct dyString *errors = newDyString(1024);
- int retVal = bbiBriefMeasure(track->type, bigDataUrl, bigDataIndex, &chromCount, &itemCount, errors);
+ int retVal = bbiBriefMeasure(tdb->type, bigDataUrl, bigDataIndex, &chromCount, &itemCount, errors);
if (retVal)
{
- hPrintf(" - %s : %s : ERROR: %s
\n", track->track, track->type, errors->string);
+ hPrintf(" - %s : %s : ERROR: %s
\n", tdb->track, tdb->type, errors->string);
}
else
{
- if (startsWithWord("bigBed", track->type))
- hPrintf(" - %s : %s : %ld chroms : %ld item count
\n", track->track, track->type, chromCount, itemCount);
- else if (startsWithWord("bigWig", track->type))
- hPrintf(" - %s : %s : %ld chroms : %ld bases covered
\n", track->track, track->type, chromCount, itemCount);
+ if (startsWithWord("bigBed", tdb->type))
+ hPrintf(" - %s : %s : %ld chroms : %ld item count
\n", tdb->track, tdb->type, chromCount, itemCount);
+ else if (startsWithWord("bigWig", tdb->type))
+ hPrintf(" - %s : %s : %ld chroms : %ld bases covered
\n", tdb->track, tdb->type, chromCount, itemCount);
else
- hPrintf(" - %s : %s : %ld chroms : %ld count
\n", track->track, track->type, chromCount, itemCount);
+ hPrintf(" - %s : %s : %ld chroms : %ld count
\n", tdb->track, tdb->type, chromCount, itemCount);
}
}
else
{
if (compositeTrack)
- hPrintf(" - %s : %s : composite track container
\n", track->track, track->type);
+ hPrintf(" - %s : %s : composite track container
\n", tdb->track, tdb->type);
else if (superTrack)
- hPrintf(" - %s : %s : superTrack container
\n", track->track, track->type);
+ hPrintf(" - %s : %s : superTrack container
\n", tdb->track, tdb->type);
else if (! depthSearch)
- hPrintf(" - %s : %s : %s
\n", track->track, track->type, bigDataUrl);
+ hPrintf(" - %s : %s : %s
\n", tdb->track, tdb->type, bigDataUrl);
else
- hPrintf(" - %s : %s
\n", track->track, track->type);
+ hPrintf(" - %s : %s
\n", tdb->track, tdb->type);
}
+ if (tdb->subtracks)
+ hPrintf(" - hasSubtracks : TRUE
\n");
+ else
+ hPrintf(" - hasSubtracks : FALSE
\n");
if (allTrackSettings)
- trackSettings(track); /* show all settings */
+ trackSettings(tdb); /* show all settings */
if (timeOutReached())
break;
- } /* for ( ; track; track = track->next ) */
+ } /* for ( tdb = topTrackDb; tdb; tdb = tdb->next ) */
hPrintf(" - %d different track types
\n", countTracks->elCount);
if (countTracks->elCount)
{
hPrintf(" \n");
struct hashEl *hel;
struct hashCookie hc = hashFirst(countTracks);
while ((hel = hashNext(&hc)) != NULL)
{
int prevCount = ptToInt(hashFindVal(trackCounter, hel->name));
totalTracks += ptToInt(hel->val);
hashReplace(trackCounter, hel->name, intToPt(prevCount + ptToInt(hel->val)));
hPrintf(" - %d - %s
\n", ptToInt(hel->val), hel->name);
}
hPrintf("
\n");
}
@@ -484,37 +490,37 @@
struct hashEl *hel = hashLookup(apiFunctionHash, words[0]);
if (hel == NULL)
apiErrAbort("no such command: '%s' for endpoint '/%s'", words[0], pathInfo);
void (*apiFunction)(char **) = hel->val;
// void (*apiFunction)(char **) = hashMustFindVal(apiFunctionHash, words[0]);
(*apiFunction)(words);
} /* static void apiFunctionSwitch(char *pathInfo) */
static void tracksForUcscDb(char * ucscDb)
{
hPrintf("Tracks in UCSC genome: '%s'
\n", ucscDb);
struct trackDb *tdbList = hTrackDb(ucscDb);
-struct trackDb *track;
+struct trackDb *tdb;
hPrintf("
\n");
-for (track = tdbList; track != NULL; track = track->next )
+for (tdb = tdbList; tdb != NULL; tdb = tdb->next )
{
- hPrintf("- %s
\n", track->track);
+ hPrintf("- %s
\n", tdb->track);
if (allTrackSettings)
- trackSettings(track); /* show all settings */
+ trackSettings(tdb); /* show all settings */
}
hPrintf("
\n");
hPrintf("\n");
}
static void showExamples(char *url, struct trackHubGenome *hubGenome, char *ucscDb)
{
hPrintf("Example URLs to return json data structures:
\n");
hPrintf("\n");
hPrintf("- list public hubs /cgi-bin/hubApi/list/publicHubs
\n");
hPrintf("- list database genomes /cgi-bin/hubApi/list/ucscGenomes
\n");
hPrintf("- list genomes from specified hub /cgi-bin/hubApi/list/hubGenomes?hubUrl=%s
\n", url, url);
hPrintf("- list tracks from specified hub and genome /cgi-bin/hubApi/list/tracks?hubUrl=%s&genome=%s
\n", url, hubGenome->name, url, hubGenome->name);
hPrintf("- list tracks from specified UCSC database /cgi-bin/hubApi/list/tracks?db=%s
\n", ucscDb, ucscDb);