e143e4b2a0cb6fba837c177f115b819bfd938c0f chmalee Mon Aug 12 12:12:56 2019 -0700 Linking hubCheck into hgHubConnect, requires hg.conf statement, refs #18870 diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 76b7153..726b7af 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -369,148 +369,53 @@ ourPrintCell(""); if (hub->trackHub != NULL) printGenomes(hub->trackHub, count, !hubHasError); else ourPrintCell(""); puts(""); } printf("\n"); printf(""); } -int doCheckTrackDb(struct dyString *errors, struct trackHub *hub, - struct trackHubGenome *genome) -/* Attempt to open a trackDb from a hub and report errors back. - * Eventually will check every stanza and not die if there's an error with the first one*/ -{ -int errorCount = 0; -struct trackDb *tdb = NULL, *tdbList = NULL; -struct errCatch *errCatch = errCatchNew(); -if (errCatchStart(errCatch)) - { - tdbList = trackHubTracksForGenome(hub, genome); - tdbList = trackDbLinkUpGenerations(tdbList); - tdbList = trackDbPolishAfterLinkup(tdbList, genome->name); - trackHubPolishTrackNames(genome->trackHub, tdbList); - for (tdb = tdbList; tdb != NULL; tdb = tdb->next) - { - struct errCatch *trackFileCatch = errCatchNew(); - if (errCatchStart(trackFileCatch)) - hubCheckBigDataUrl(hub, genome, tdb); - errCatchEnd(trackFileCatch); - if (trackFileCatch->gotError) - { - errorCount += 1; - dyStringPrintf(errors, "\n", trackFileCatch->message->string); - } - errCatchFree(&trackFileCatch); - } - if (tdbList != NULL && errorCount == 0) - { - dyStringPrintf(errors, ""); - } - } -errCatchEnd(errCatch); -if (errCatch->gotError) - { - errorCount += 1; - dyStringPrintf(errors, "\n", - errCatch->message->string); - } -errCatchFree(&errCatch); -return errorCount; -} - -int doCheckGenomesFile(struct dyString *errors, struct trackHub *hub) -/* Mostly just calls doCheckTrackDb() but applies correct styling to error messages */ -{ -struct trackHubGenome *genome = NULL; -int errorCount = 0; -int trackDbErrorCount = 0; -struct dyString *trackDbErrorString = dyStringNew(0); -for (genome = hub->genomeList; genome != NULL; genome = genome->next) - { - trackDbErrorCount = 0; - dyStringPrintf(errors, "\n", trackDbErrorCount, trackDbErrorString->string); - else - dyStringPrintf(errors, " (%d errors)\n%s\n", trackDbErrorCount, trackDbErrorString->string); - } - else - dyStringPrintf(errors, ""); - dyStringClear(trackDbErrorString); - } -dyStringFree(&trackDbErrorString); -return errorCount; -} - -struct trackHub *trackHubCheckHubFile(struct dyString *errors, char *hubUrl) -/* Wrap trackHubOpen in an errCatch, HTML style the error message */ -{ -struct trackHub *hub = NULL; -struct errCatch *errCatch = errCatchNew(); -if (errCatchStart(errCatch)) - hub = trackHubOpen(hubUrl, ""); -errCatchEnd(errCatch); -if (errCatch->gotError) - dyStringPrintf(errors, "Error: %s", errCatch->message->string); -errCatchFree(&errCatch); -return hub; -} - void doValidateNewHub(char *hubUrl) -/* Open up a track hub and report errors to user. */ +/* Run hubCheck on a hub. */ { -struct trackHub *hub = NULL; -struct dyString *errors = dyStringNew(0); // string with HTML of all the errors +struct dyString *cmd = dyStringNew(0); udcSetCacheTimeout(1); +dyStringPrintf(cmd, "loader/hubCheck -htmlOut -noTracks %s", hubUrl); printf(""); -hub = trackHubCheckHubFile(errors, hubUrl); -if (hub) - { - // go through each genome and check each trackDb stanza, building up errors string - int errorCount = doCheckGenomesFile(errors, hub); - if (errorCount > 0) - { - printf("
"); - if (errorCount == 1) - printf("
"); +if (pclose(f) == -1) + errAbort("pclose: error for command \"%s\"", cmd->string); +jsInline("hgCollection.init();"); +dyStringFree(&cmd); } void hgHubConnectValidateNewHub() { // put out the top of our page char *hubUrl = cartOptionalString(cart, "validateHubUrl"); printf("
\n" " \n" " \n"); printf("
\n"); if (hubUrl != NULL) { printf(" \n", hubUrl); } @@ -1577,30 +1482,32 @@ cartWebStart(cart, NULL, "%s", pageTitle); printf( "\n" "\n" "\n" "\n" ); jsIncludeFile("utils.js", NULL); jsIncludeFile("jquery-ui.js", NULL); webIncludeResourceFile("jquery-ui.css"); jsIncludeFile("ajax.js", NULL); jsIncludeFile("hgHubConnect.js", NULL); webIncludeResourceFile("hgHubConnect.css"); jsIncludeFile("jquery.cookie.js", NULL); +jsIncludeFile("hgCollection.js", NULL); +jsIncludeFile("spectrum.min.js", NULL); printf("
\n"); printf( "

Track data hubs are collections of external tracks that can be imported into the UCSC Genome Browser. " "Hub tracks show up under the hub's own blue label bar on the main browser page, " "as well as on the configure page. For more information, including where to " "host your track hub, see the " "" "User's Guide." "To import a public hub click its \"Connect\" button below.

" "

NOTE: Because Track Hubs are created and maintained by external sources," " UCSC is not responsible for their content.

" ); printf("
\n");