void hubConnectStatusFree(struct hubConnectStatus **pHub) /* Free hubConnectStatus */ { struct hubConnectStatus *hub = *pHub; if (hub != NULL) { freeMem(hub->hubUrl); freeMem(hub->errorMessage); trackHubClose(&hub->trackHub); freez(pHub); } }
int trackHubCrawl(char *hubUrl) /* Crawl a track data hub and output strings useful in a search */ { struct errCatch *errCatch = errCatchNew(); struct trackHub *hub = NULL; int retVal = 0; if (errCatchStart(errCatch)) { hub = trackHubOpen(hubUrl, "hub_0"); } errCatchEnd(errCatch); if (errCatch->gotError) { retVal = 1; fprintf(stderr, "%s\n", errCatch->message->string); } errCatchFree(&errCatch); if (hub == NULL) return 1; FILE *searchFp =stdout; struct trackHubGenome *genomeList = hub->genomeList; for(; genomeList ; genomeList = genomeList->next) fprintf(searchFp, "%s\t%s\n",hub->url, trackHubSkipHubName(genomeList->name)); fprintf(searchFp, "%s\t%s\t%s\n",hub->url, hub->shortLabel, hub->longLabel); if (hub->descriptionUrl != NULL) { char *html = netReadTextFileIfExists(hub->descriptionUrl); char *stripHtml =htmlTextStripTags(html); strSwapChar(stripHtml, '\n', ' '); strSwapChar(stripHtml, '\t', ' '); strSwapChar(stripHtml, '\015', ' '); strSwapChar(stripHtml, ')', ' '); strSwapChar(stripHtml, '(', ' '); strSwapChar(stripHtml, '[', ' '); strSwapChar(stripHtml, ']', ' '); fprintf(searchFp, "%s\t%s\n",hub->url, stripHtml); } trackHubClose(&hub); return retVal; }
int oneHubTrackSettings(char *hubUrl, struct hash *totals) /* Read hub trackDb files, noting settings used */ { struct trackHub *hub = NULL; struct errCatch *errCatch = errCatchNew(); if (errCatchStart(errCatch)) hub = trackHubOpen(hubUrl, "hub_0"); errCatchEnd(errCatch); errCatchFree(&errCatch); if (hub == NULL) return 1; printf("%s (%s)\n", hubUrl, hub->shortLabel); struct trackHubGenome *genome; struct hash *counts; if (totals) counts = totals; else counts = newHash(0); struct hashEl *el; for (genome = hub->genomeList; genome != NULL; genome = genome->next) { struct trackDb *tdb, *tdbs = trackHubTracksForGenome(hub, genome); for (tdb = tdbs; tdb != NULL; tdb = tdb->next) { struct hashCookie cookie = hashFirst(trackDbHashSettings(tdb)); verbose(2, " track: %s\n", tdb->shortLabel); while ((el = hashNext(&cookie)) != NULL) { int count = hashIntValDefault(counts, el->name, 0); count++; hashReplace(counts, el->name, intToPt(count)); } } } if (!totals) printCounts(counts); trackHubClose(&hub); return 0; }
int trackHubCheck(char *hubUrl, struct trackHubCheckOptions *options, struct dyString *errors) /* Check a track data hub for integrity. Put errors in dyString. * return 0 if hub has no errors, 1 otherwise * if options->checkTracks is TRUE, check remote files of individual tracks */ { struct errCatch *errCatch = errCatchNew(); struct trackHub *hub = NULL; int retVal = 0; if (errCatchStart(errCatch)) { hub = trackHubOpen(hubUrl, "hub_0"); } errCatchEnd(errCatch); if (errCatch->gotError) { retVal = 1; dyStringPrintf(errors, "%s\n", errCatch->message->string); } if (errCatch->gotWarning && !errCatch->gotError) dyStringPrintf(errors, "%s", errCatch->message->string); errCatchFree(&errCatch); if (hub == NULL) return 1; if (options->checkSettings) retVal |= hubSettingsCheckInit(hub, options, errors); struct trackHubGenome *genome; for (genome = hub->genomeList; genome != NULL; genome = genome->next) { retVal |= hubCheckGenome(hub, genome, options, errors); } trackHubClose(&hub); return retVal; }
int hubPublicCheck(char *table) /* hubPublicCheck - checks that the labels in hubPublic match what is in the hub labels. */ { struct sqlConnection *conn = hConnectCentral(); char query[512]; bool hasDescriptionUrl = sqlColumnExists(conn, table, "descriptionUrl"); if (hasDescriptionUrl) sqlSafef(query, sizeof(query), "select hubUrl, shortLabel,longLabel,dbList,descriptionUrl from %s", table); else sqlSafef(query, sizeof(query), "select hubUrl, shortLabel,longLabel,dbList from %s", table); struct sqlResult *sr = sqlGetResult(conn, query); char **row; int differences = 0; while ((row = sqlNextRow(sr)) != NULL) { char *url = row[0], *shortLabel = row[1], *longLabel = row[2], *dbList = row[3], *descriptionUrl = row[4]; struct errCatch *errCatch = errCatchNew(); boolean gotWarning = FALSE; struct trackHub *tHub = NULL; if (errCatchStart(errCatch)) tHub = trackHubOpen(url, "hub_1"); errCatchEnd(errCatch); if (errCatch->gotError) { gotWarning = TRUE; warn("%s", errCatch->message->string); } errCatchFree(&errCatch); if (gotWarning) { continue; } if (!sameString(shortLabel, tHub->shortLabel)) { differences++; printf("update %s set shortLabel=\"%s\" where hubUrl=\"%s\";\n",table, tHub->shortLabel, url); } if (!sameString(longLabel, tHub->longLabel)) { differences++; printf("update %s set longLabel=\"%s\" where hubUrl=\"%s\";\n",table, tHub->longLabel, url); } struct hashCookie cookie = hashFirst(tHub->genomeHash); struct dyString *dy = newDyString(1024); struct hashEl *hel; while ((hel = hashNext(&cookie)) != NULL) dyStringPrintf(dy, "%s,", trackHubSkipHubName(hel->name)); if (!sameString(dy->string, dbList)) { differences++; printf("update %s set dbList=\"%s\" where hubUrl=\"%s\";\n",table, dy->string, url); } if (hasDescriptionUrl && !isEmpty(tHub->descriptionUrl) && ((descriptionUrl == NULL) || !sameString(descriptionUrl, tHub->descriptionUrl))) { differences++; printf("update %s set descriptionUrl=\"%s\" where hubUrl=\"%s\";\n",table, tHub->descriptionUrl, url); } trackHubClose(&tHub); } return differences; }