3f92bea76f09e3b46d8f1ebc44db19d9e508b67e hiram Tue Feb 5 14:41:23 2019 -0800 correctly returning track list for any UCSC database genome refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index fbd8b3b..8998abe 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -568,31 +568,45 @@ printf("{\"source\":\"UCSantaCruz\",\"ucscGenomes\":["); for ( el=dbList; el != NULL; el = el->next ) { dbDbJsonOutput(el, stdout); if (el->next) printf(","); } printf("]}\n"); } static void ucscDbTrackList(char *db) /* return track list from specified UCSC database name */ { struct trackDb *tdbList = hTrackDb(db); struct trackDb *el; -for (el +fputc('{',stdout); +jsonStringOut(stdout, "source", "UCSantaCruz"); +fputc(',',stdout); +jsonStringOut(stdout, "db", db); +fputc(',',stdout); +printf("\"tracks\":["); +for (el = tdbList; el != NULL; el = el->next ) + { + char *a = jsonStringEscape(el->track); + printf("\"%s\"", a); + freeMem(a); + if (el->next) + fputc(',',stdout); + } +printf("]}\n"); } #define MAX_PATH_INFO 32 static void apiList(char *words[MAX_PATH_INFO]) /* 'list' function */ { if (sameWord("publicHubs", words[1])) jsonPublicHubs(); else if (sameWord("ucscGenomes", words[1])) jsonDbDb(); else if (sameWord("genomes", words[1])) { char *hubUrl = cgiOptionalString("hubUrl"); if (isEmpty(hubUrl)) errAbort("# must supply hubUrl='http:...' some URL to a hub for /list/genomes\n"); @@ -638,34 +652,33 @@ warn("# must supply genome='someName' the name of a genome in a hub for /list/tracks\n"); if (isEmpty(hubUrl)) warn("# must supply hubUrl='http:...' some URL to a hub for /list/genomes\n"); errAbort("# ERROR exit"); } struct trackHub *hub = trackHubOpen(hubUrl, ""); if (hub->genomeList) { struct slName *dbTrackList = NULL; (void) genomeList(hub, &dbTrackList, genome); printf("{\"source\":\"UCSantaCruz\","); jsonStringOut(stdout, "hubUrl", hubUrl); fputc(',',stdout); jsonStringOut(stdout, "genome", genome); fputc(',',stdout); - printf("\"tracks\":["); slNameSort(&dbTrackList); struct slName *el = dbTrackList; - for ( ; el ; el = el->next ) + for ( ; el != NULL; el = el->next ) { char *a = jsonStringEscape(el->name); printf("\"%s\"", a); freeMem(a); if (el->next) fputc(',',stdout); } printf("]}\n"); } } else errAbort("# ERROR: do not recognize command '%s' for 'list' function\n", words[1]); } static struct hash *apiFunctionHash = NULL;