05887790b4eb57e11fc8997594d59459cc617984 braney Thu Nov 3 12:19:48 2011 -0700 put assemblies supported by hubs into table. #4679 diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index cd80e3a..351d45f 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -42,30 +42,42 @@ puts("<TD>"); } static void ourCellEnd() { puts("</TD>"); } static void ourPrintCell(char *str) { ourCellStart(); puts(str); ourCellEnd(); } +static char *removeLastComma(char *string) +{ +if (string != NULL) + { + int len = strlen(string); + + if ( string[len - 1] == ',') + string[len - 1] = 0; + } +return string; +} + static void addGenomesToHash(struct hubConnectStatus *hub, struct hash *hash) /* add supported assembly names from trackHub to hash */ { if (hub == NULL) return; struct trackHub *thub = hub->trackHub; if (thub != NULL) { /* List of associated genomes. */ struct trackHubGenome *genomes = thub->genomeList; for(; genomes; genomes = genomes->next) hashStore(hash, genomes->name); } @@ -79,87 +91,78 @@ printf("<div id=\"unlistedHubs\" class=\"hubList\"> " "<table id=\"unlistedHubsTable\"> " "<thead><tr> " "<th colspan=\"5\" id=\"addHubBar\"><label for \"hubUrl\">URL:</label> " "<input name=\"hubText\" id=\"hubUrl\" class=\"hubField\"" "type=\"text\" size=\"65\"> " "<input name=\"hubAddButton\"" "onClick=\"document.addHubForm.elements['hubUrl'].value=hubText.value;" "document.addHubForm.submit();return true;\" " "class=\"hubField\" type=\"button\" value=\"Add Hub\">" "</th> " "</tr> "); // count up the number of unlisted hubs we currently have int unlistedHubCount = 0; -int otherHubCount = 0; struct hubConnectStatus *unlistedHubList = NULL; struct hubConnectStatus *hub, *nextHub; struct hash *assHash = newHash(5); for(hub = hubList; hub; hub = nextHub) { nextHub = hub->next; if (isHubUnlisted(hub) ) { addGenomesToHash(hub, assHash); - if ((hub->trackHub == NULL) || trackHubHasDatabase(hub->trackHub, database) ) - { unlistedHubCount++; slAddHead(&unlistedHubList, hub); } - else - { - otherHubCount++; - } - } } hubList = NULL; // hubList no longer valid struct hashCookie cookie = hashFirst(assHash); struct dyString *dy = newDyString(100); struct hashEl *hel; int numAssemblies = 0; while ((hel = hashNext(&cookie)) != NULL) { dyStringPrintf(dy,"%s,", hel->name); numAssemblies++; } -if (numAssemblies) // take off the final ',' - dy->string[strlen(dy->string) - 1] = 0; + +char *dbList = NULL; +if (numAssemblies) + dbList = dyStringCannibalize(&dy); if (unlistedHubCount == 0) { // nothing to see here printf( - "<tr><td>No Track Hubs for this genome assembly</td></tr>" + "<tr><td>No Unlisted Track Hubs</td></tr>" "</td>"); - if (otherHubCount) - printf( - "<tr><td>%d Track Hubs for other genome assemblies: %s</tr></td>", - otherHubCount, dy->string); printf("</table></thead></div>"); return; } // time to output the big table. First the header printf( "<tr> " "<th>Display</th> " "<th>Hub Name</th> " "<th>Description</th> " + "<th>Assemblies</th> " "<th>URL</th> " "<th>Disconnect</th> " "</tr></thead>\n"); // start first row printf("<tbody><tr>"); int count = 0; for(hub = unlistedHubList; hub; hub = hub->next) { if (count) webPrintLinkTableNewRow(); // ends last row and starts a new one count++; // if there's an error message, we don't let people select it @@ -185,88 +188,74 @@ } if (hub->trackHub != NULL) ourPrintCell(hub->trackHub->shortLabel); else ourPrintCell(""); if (!isEmpty(hub->errorMessage)) printf("<TD><span class=\"hubError\">ERROR: %s </span>" "<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug</a></TD>", hub->errorMessage); else if (hub->trackHub != NULL) ourPrintCell(hub->trackHub->longLabel); else ourPrintCell(""); + ourPrintCell(removeLastComma(dbList)); ourPrintCell(hub->hubUrl); ourCellStart(); printf( "<input name=\"hubDisconnectButton\"" "onClick=\"document.disconnectHubForm.elements['hubId'].value='%d';" "document.disconnectHubForm.submit();return true;\" " "class=\"hubField\" type=\"button\" value=\"X\">" , hub->id); ourCellEnd(); } printf("</TR></tbody></TABLE>\n"); - if (otherHubCount) - printf( "%d Track Hubs for other genome assemblies: %s", - otherHubCount, dy->string); printf("</div>"); } -static void makeGenomePrint() -/* print out the name of the current database etc. */ -{ -getDbAndGenome(cart, &database, &organism, oldVars); -printf("<div id=\"assemblyInfo\"> \n"); -printf("<B>genome:</B> %s <B>assembly:</B> %s ", - organism, hFreezeDate(database)); -printf("</div>\n"); -} - - void hgHubConnectPublic() /* Put up the list of public hubs and other controls for the page. */ { struct sqlConnection *conn = hConnectCentral(); char query[512]; safef(query, sizeof(query), "select hubUrl,shortLabel,longLabel,dbList from %s", hubPublicTableName); struct sqlResult *sr = sqlGetResult(conn, query); char **row; boolean gotAnyRows = FALSE; while ((row = sqlNextRow(sr)) != NULL) { char *url = row[0], *shortLabel = row[1], *longLabel = row[2], *dbList = row[3]; - if (nameInCommaList(database, dbList)) - { if (gotAnyRows) webPrintLinkTableNewRow(); else { /* output header */ printf("<div id=\"publicHubs\" class=\"hubList\"> \n"); printf("<table id=\"publicHubsTable\"> " "<thead><tr> " "<th>Display</th> " "<th>Hub Name</th> " "<th>Description</th> " + "<th>Assemblies</th> " "<th>URL</th> " "</tr></thead>\n"); // start first row printf("<tbody> <tr>"); gotAnyRows = TRUE; } char *errorMessage = NULL; // get an id for this hub unsigned id = hubFindOrAddUrlInStatusTable(database, cart, url, &errorMessage); if ((id != 0) && isEmpty(errorMessage)) { @@ -287,33 +276,33 @@ "class=\"hubField\" type=\"button\" value=\"check hub\">" , url); ourCellEnd(); } else errAbort("cannot get id for hub with url %s\n", url); ourPrintCell(shortLabel); if (isEmpty(errorMessage)) ourPrintCell(longLabel); else printf("<TD><span class=\"hubError\">ERROR: %s </span>" "<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug</a></TD>", errorMessage); + ourPrintCell(removeLastComma(dbList)); ourPrintCell(url); } - } sqlFreeResult(&sr); if (gotAnyRows) { printf("</TR></tbody></TABLE>\n"); } else { printf("<div id=\"publicHubs\" class=\"hubList\"> \n"); printf("No Public Track Hubs for this genome assembly<BR>"); } printf("</div>"); hDisconnectCentral(&conn); @@ -441,32 +430,31 @@ printf("<div id=\"hgHubConnectUI\"> <div id=\"description\"> \n"); printf( "<P>Track data hubs are collections of tracks from outside of UCSC that " "can be imported into the Genome Browser. To import a public hub check " "the box in the list below. " "After import the hub will show up as a group of tracks with its own blue " "bar and label underneath the main browser graphic, and in the " "configure page. For more information, see the " "<A HREF=\"../goldenPath/help/hgTrackHubHelp.html\" TARGET=_blank>" "User's Guide</A>.</P>\n" "<P><B>NOTE: Because Track Hubs are created and maintained by external sources," " UCSC cannot be held responsible for their content.</B></P>" ); printf("</div>\n"); -// figure out and print out genome name -makeGenomePrint(); +getDbAndGenome(cart, &database, &organism, oldVars); char *survey = cfgOptionEnv("HGDB_HUB_SURVEY", "hubSurvey"); char *surveyLabel = cfgOptionEnv("HGDB_HUB_SURVEY_LABEL", "hubSurveyLabel"); if (survey && differentWord(survey, "off")) hPrintf("<span style='background-color:yellow;'><A HREF='%s' TARGET=_BLANK><EM><B>%s</EM></B></A></span>\n", survey, surveyLabel ? surveyLabel : "Take survey"); hPutc('\n'); // check to see if we have any new hubs hubCheckForNew(database, cart); // grab all the hubs that are listed in the cart struct hubConnectStatus *hubList = hubConnectStatusListFromCartAll(cart); checkTrackDbs(hubList);