b6ea7e02e7c946b1cb700d3cab07decce272d4c7 hiram Tue Feb 26 16:00:40 2019 -0800 better counting of legitimate tracks refs #18869 diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c index dd0eddd..45a44b1 100644 --- src/hg/hubApi/hubApi.c +++ src/hg/hubApi/hubApi.c @@ -47,101 +47,162 @@ } static struct hubPublic *hubPublicLoad(char **row) /* Load a hubPublic from row fetched with select * from hubPublic * from database. Dispose of this with hubPublicFree(). */ { struct hubPublic *ret; AllocVar(ret); ret->hubUrl = cloneString(row[0]); ret->shortLabel = cloneString(row[1]); ret->longLabel = cloneString(row[2]); ret->registrationTime = cloneString(row[3]); ret->dbCount = sqlUnsigned(row[4]); ret->dbList = cloneString(row[5]); -// if (row[6]) ret->descriptionUrl = cloneString(row[6]); -// else -// ret->descriptionUrl = cloneString(""); return ret; } struct hubPublic *hubPublicLoadAll() +/* read entire hubPublic table in hgcentral and return resulting list */ { char query[1024]; struct hubPublic *list = NULL; struct sqlConnection *conn = hConnectCentral(); sqlSafef(query, sizeof(query), "select * from %s", hubPublicTableName()); struct sqlResult *sr = sqlGetResult(conn, query); char **row; while ((row = sqlNextRow(sr)) != NULL) { struct hubPublic *el = hubPublicLoad(row); slAddHead(&list, el); } sqlFreeResult(&sr); hDisconnectCentral(&conn); publicHubSortCase(&list); int listSize = slCount(list); AllocArray(shortLabels, listSize); struct hubPublic *el = list; int i = 0; for ( ; el != NULL; el = el->next ) { shortLabels[i++] = el->shortLabel; ++publicHubCount; } return list; } static boolean timeOutReached() +/* see if the timeout has been reached to determine if an exit + * is appropriate at this time + */ { long nowTime = clock1000(); timedOut = FALSE; if ((nowTime - enteredMainTime) > (1000 * timeOutSeconds)) timedOut= TRUE; return timedOut; } -static void trackSettings(struct trackDb *tdb) -/* process the settingsHash for a trackDb, recursive if subtracks */ +#ifdef NOT +static void showCounts(struct hash *countTracks) +{ +if (countTracks->elCount) + { + hPrintf(" \n"); + } +} +#endif + +static void hashCountTrack(struct trackDb *tdb, struct hash *countTracks) +/* this is counting up track types into the hash countTracks */ +{ +char *stripType = cloneString(tdb->type); +if (startsWith("chain ", tdb->type)) + stripType = cloneString("chain"); +else if (startsWith("netAlign ", tdb->type)) + stripType = cloneString("netAlign"); +else if (startsWith("genePred ", tdb->type)) + stripType = cloneString("genePred"); +else if (startsWith("bigWig ", tdb->type)) + stripType = cloneString("bigWig"); +else if (startsWith("wigMaf ", tdb->type)) + stripType = cloneString("wigMaf"); +else if (startsWith("wig ", tdb->type)) + stripType = cloneString("wig"); +else + stripType = cloneString(tdb->type); +// char *compositeTrack = trackDbLocalSetting(tdb, "compositeTrack"); +boolean compositeContainer = tdbIsComposite(tdb); +boolean compositeView = tdbIsCompositeView(tdb); +// char *superTrack = trackDbLocalSetting(tdb, "superTrack"); +boolean superChild = tdbIsSuperTrackChild(tdb); +if (compositeContainer) + hashIncInt(countTracks, "composite container"); +else if (compositeView) + hashIncInt(countTracks, "composite view"); +else if (superChild) + { + hashIncInt(countTracks, "superTrack child"); + hashIncInt(countTracks, stripType); + hashIncInt(countTracks, "track count"); + } +else if (isEmpty(tdb->type)) + hashIncInt(countTracks, "no type specified"); +else + { + hashIncInt(countTracks, stripType); + hashIncInt(countTracks, "track count"); + } +freeMem(stripType); +// showCounts(countTracks); +} + +static void trackSettings(struct trackDb *tdb, struct hash *countTracks) +/* process the settingsHash for a trackDb, recursive when 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) @@ -218,140 +279,146 @@ retVal = 1; } } errCatchEnd(errCatch); if (errCatch->gotError) { retVal = 1; dyStringPrintf(errors, "%s", errCatch->message->string); } errCatchFree(&errCatch); return retVal; } /* static int bbiBriefMeasure() */ -static void hubTrackList(struct trackDb *topTrackDb, struct trackHubGenome *genome) -/* process the track list to show all tracks, return trackDb list */ -{ -if (topTrackDb) - { - struct hash *countTracks = hashNew(0); - hPrintf(" \n"); return retList; } /* static struct slName *genomeList () */ static char *urlFromShortLabel(char *shortLabel) /* this is not a fair way to get the URL since shortLabel's are not * necessarily unique. This is temporary. TBD: need to always use URL * and then get the shortLabel */ { char hubUrl[1024]; char query[1024]; struct sqlConnection *conn = hConnectCentral(); // Build a query to select the hubUrl for the given shortLabel @@ -474,112 +541,60 @@ 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) apiErrAbort("unknown endpoint command: '/%s'", pathInfo); 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) +static void tracksForUcscDb(char *db) +/* scan the specified database for all tracks */ { struct hash *countTracks = hashNew(0); -struct sqlConnection *conn = hAllocConn(ucscDb); -hPrintf("

Tracks in UCSC genome: '%s'
\n", ucscDb); -struct trackDb *tdbList = hTrackDb(ucscDb); +hPrintf("

Tracks in UCSC genome: '%s'
\n", db); +struct trackDb *tdbList = hTrackDb(db); struct trackDb *tdb; hPrintf("

\n"); hPrintf("

\n"); -hFreeConn(&conn); -} // static void tracksForUcscDb(char * ucscDb) +} // static void tracksForUcscDb(char * db) static void showExamples(char *url, struct trackHubGenome *hubGenome, char *ucscDb) { hPrintf("

Example URLs to return json data structures:

\n"); hPrintf("
    \n"); hPrintf("
  1. list public hubs /cgi-bin/hubApi/list/publicHubs
  2. \n"); hPrintf("
  3. list database genomes /cgi-bin/hubApi/list/ucscGenomes
  4. \n"); hPrintf("
  5. list genomes from specified hub /cgi-bin/hubApi/list/hubGenomes?hubUrl=%s
  6. \n", url, url); hPrintf("
  7. list tracks from specified hub and genome /cgi-bin/hubApi/list/tracks?hubUrl=%s&genome=%s
  8. \n", url, url, hubGenome->name, url, hubGenome->name); hPrintf("
  9. list tracks from specified UCSC database /cgi-bin/hubApi/list/tracks?db=%s
  10. \n", ucscDb, ucscDb); hPrintf("
  11. list chromosomes from specified UCSC database /cgi-bin/hubApi/list/chromosomes?db=%s
  12. \n", ucscDb, ucscDb); hPrintf("
  13. list chromosomes from specified track from UCSC databaset /cgi-bin/hubApi/list/chromosomes?db=%s&track=gap
  14. \n", ucscDb, ucscDb); hPrintf("
  15. get sequence from specified database and chromosome /cgi-bin/hubApi/getData/sequence?db=%s&chrom=chrM
  16. \n", ucscDb, ucscDb); hPrintf("
  17. get sequence from specified database, chromosome with start,end coordinates /cgi-bin/hubApi/getData/sequence?db=%s&chrom=chrM&start=0&end=128
  18. \n", ucscDb, ucscDb);