fa326179d9bd70fb1fb1d2fe4996c3a5545257aa hiram Tue Feb 12 14:57:50 2019 -0800 now traversing trackDb recursively to show all composite tracks refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index a554615..ba07c64 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -54,87 +54,102 @@ char *longLabel; /* Hub long label. */ char *registrationTime; /* Time first registered */ unsigned dbCount; /* Number of databases hub has data for. */ char *dbList; /* Comma separated list of databases. */ char *descriptionUrl; /* URL to description HTML */ }; /* Global Variables */ static struct cart *cart; /* CGI and other variables */ static struct hash *oldVars = NULL; static struct hash *trackCounter = NULL; static long totalTracks = 0; static boolean measureTiming = FALSE; /* set by CGI parameters */ static boolean allTrackSettings = FALSE; /* checkbox setting */ static char **shortLabels = NULL; /* public hub short labels in array */ -struct hubPublic *publicHubList = NULL; +// struct hubPublic *publicHubList = NULL; static int publicHubCount = 0; static char *defaultHub = "Plants"; static char *defaultDb = "ce11"; static long enteredMainTime = 0; /* will become = clock1000() on entry */ /* to allow calculation of when to bail out, taking too long */ static long timeOutSeconds = 100; static boolean timedOut = FALSE; /* ######################################################################### */ static struct jsonWrite *jsonStartOutput() -/* begin json output */ +/* begin json output with standard header information for all requests */ { time_t timeNow = time(NULL); // struct tm tm; // gmtime_r(&timeNow, &tm); struct jsonWrite *jw = jsonWriteNew(); jsonWriteObjectStart(jw, NULL); jsonWriteString(jw, "apiVersion", "0.1"); jsonWriteString(jw, "source", "UCSantaCruz"); jsonWriteDateFromUnix(jw, "downloadTime", (long long) timeNow); jsonWriteNumber(jw, "downloadTimeStamp", (long long) timeNow); return jw; } static void jsonErrAbort(char *format, ...) -/* Issue an error message in json format. */ +/* Issue an error message in json format, and exit(0) */ { char errMsg[2048]; va_list args; va_start(args, format); vsnprintf(errMsg, sizeof(errMsg), format, args); struct jsonWrite *jw = jsonStartOutput(); jsonWriteString(jw, "error", errMsg); jsonWriteObjectEnd(jw); fputs(jw->dy->string,stdout); exit(0); } static void hubPublicJsonData(struct jsonWrite *jw, struct hubPublic *el) /* Print array data for one row from hubPublic table, order here * must be same as was stated in the columnName header element * TODO: need to figure out how to use the order of the columns as * they are in the 'desc' request */ { jsonWriteListStart(jw, NULL); jsonWriteString(jw, NULL, el->hubUrl); jsonWriteString(jw, NULL, el->shortLabel); jsonWriteString(jw, NULL, el->longLabel); jsonWriteString(jw, NULL, el->registrationTime); jsonWriteNumber(jw, NULL, (long long)el->dbCount); jsonWriteString(jw, NULL, el->dbList); jsonWriteString(jw, NULL, el->descriptionUrl); jsonWriteListEnd(jw); } +int trackDbTrackCmp(const void *va, const void *vb) +/* Compare to sort based on 'track' name; use shortLabel as secondary sort key. + * Note: parallel code to hgTracks.c:tgCmpPriority */ +{ +const struct trackDb *a = *((struct trackDb **)va); +const struct trackDb *b = *((struct trackDb **)vb); +int dif = strcmp(a->track, b->track); +if (dif < 0) + return -1; +else if (dif == 0.0) + return strcasecmp(a->shortLabel, b->shortLabel); +else + return 1; +} + static int publicHubCmpCase(const void *va, const void *vb) /* Compare two slNames, ignore case. */ { const struct hubPublic *a = *((struct hubPublic **)va); const struct hubPublic *b = *((struct hubPublic **)vb); return strcasecmp(a->shortLabel, b->shortLabel); } static void publicHubSortCase(struct hubPublic **pList) /* Sort slName list, ignore case. */ { slSort(pList, publicHubCmpCase); } static struct hubPublic *hubPublicLoad(char **row) @@ -293,46 +308,73 @@ retVal = 1; } } errCatchEnd(errCatch); if (errCatch->gotError) { retVal = 1; dyStringPrintf(errors, "%s", errCatch->message->string); } errCatchFree(&errCatch); return retVal; } /* static int bbiBriefMeasure() */ -static struct slName *trackList(struct trackDb *tdb, struct trackHubGenome *genome) -/* process the track list to show all tracks */ +#ifdef NOT +static void cloneTdb(struct trackDb *source, struct trackDb *destination) +/* TBD: is there a cloneTdb() function somewhere else ? */ +{ +destination->track = cloneString(source->track); +destination->shortLabel = cloneString(source->shortLabel); +destination->type = cloneString(source->type); +destination->longLabel = cloneString(source->longLabel); +destination->visibility = source->visibility; +destination->priority = source->priority; +destination->colorR = source->colorR; +destination->colorG = source->colorG; +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) +/* process the track list to show all tracks, return trackDb list */ { -struct slName *retList = NULL; /* for return of track list for 'genome' */ if (tdb) { struct hash *countTracks = hashNew(0); hPrintf(" \n"); } -return retList; -} /* static struct slName *trackList() */ +} /* static struct trackDb *hubTrackList() */ -static struct slName *assemblySettings(struct trackHubGenome *genome) +static struct trackDb * assemblySettings(struct trackHubGenome *genome) /* display all the assembly 'settingsHash' */ { -struct slName *retList = NULL; +struct trackDb *retTbd = NULL; hPrintf(" \n"); -return retList; +return retTbd; } -static struct slName *genomeList(struct trackHub *hubTop, struct slName **dbTrackList, char *selectGenome) +static struct slName *genomeList(struct trackHub *hubTop, struct trackDb **dbTrackList, char *selectGenome) /* follow the pointers from the trackHub to trackHubGenome and around * in a circle from one to the other to find all hub resources * return slName list of the genomes in this track hub * optionally, return the trackList from this hub for the specified genome */ { struct slName *retList = NULL; long totalAssemblyCount = 0; struct trackHubGenome *genome = hubTop->genomeList; hPrintf("

genome sequences (and tracks) present in this track hub

\n"); hPrintf("