8aba55de743fd795f8c26d730567ff8a359254e8 hiram Tue Feb 5 15:58:07 2019 -0800 beginning to show everything about a track in ucsc database refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index 8264495..3c81333 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -55,30 +55,31 @@ 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; 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 void jsonInteger(FILE *f, char *tag, int value) /* output one json interger: "tag":value appropriately quoted and encoded */ { fprintf(f,"\"%s\":%d",tag, value); } static void jsonStringOut(FILE *f, char *tag, char *value) /* output one json string: "tag":"value" appropriately quoted and encoded */ @@ -536,47 +537,55 @@ hubPublicJsonOutput(el, stdout); if (el->next) printf(","); } printf("]}\n"); } static int dbDbCmpName(const void *va, const void *vb) /* Compare two dbDb elements: name, ignore case. */ { const struct dbDb *a = *((struct dbDb **)va); const struct dbDb *b = *((struct dbDb **)vb); return strcasecmp(a->name, b->name); } -static void jsonDbDb() -/* output the dbDb SQL table */ +static struct dbDb *ucscDbDb() +/* return the dbDb table as an slList */ { char query[1024]; struct sqlConnection *conn = hConnectCentral(); sqlSafef(query, sizeof(query), "select * from dbDb"); struct dbDb *dbList = NULL, *el = NULL; struct sqlResult *sr = sqlGetResult(conn, query); char **row; while ((row = sqlNextRow(sr)) != NULL) { el = dbDbLoad(row); slAddHead(&dbList, el); } sqlFreeResult(&sr); hDisconnectCentral(&conn); slSort(&dbList, dbDbCmpName); +return dbList; +} + +static void jsonDbDb() +/* output the dbDb SQL table */ +{ +struct dbDb *dbList = ucscDbDb(); +struct dbDb *el; printf("{\"source\":\"UCSantaCruz\",\"ucscGenomes\":["); for ( el=dbList; el != NULL; el = el->next ) { dbDbJsonOutput(el, stdout); if (el->next) printf(","); } printf("]}\n"); } static void trackDbJsonOutput(char *db, FILE *f) /* return track list from specified UCSC database name */ { struct trackDb *tdbList = hTrackDb(db); struct trackDb *el; @@ -700,30 +709,46 @@ { hPrintDisable(); /* turn off all normal HTML output, doing JSON output */ /* the leading slash has been removed from the pathInfo, therefore, the * chop will have the first word in words[0] */ char *words[MAX_PATH_INFO];/*expect no more than MAX_PATH_INFO number of words*/ int wordCount = chopByChar(pathInfo, '/', words, ArraySize(words)); if (wordCount < 2) errAbort("ERROR: no commands found in path info\n"); 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;
+hPrintf("
\n"); cartDump(cart); hPrintf("\n"); hPrintf("
URL: %s - %s
\n", urlInput, sameWord("go",goPublicHub) ? "public hub" : "other hub");
hPrintf("name: %s
\n", hub->shortLabel);
hPrintf("description: %s
\n", hub->longLabel);
hPrintf("default db: '%s'
\n", isEmpty(hub->defaultDb) ? "(none available)" : hub->defaultDb);
printf("docRoot:'%s'
\n", docRoot);
if (hub->genomeList)
(void) genomeList(hub, NULL, NULL); /* ignore returned list */
-
hPrintf("