2440f4bf5df832b2914a49e25f3bb48e640fa3f1 braney Mon Oct 24 16:42:02 2011 -0700 checking this in, though it's likely to change upon review from Greg. diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 3084bc3..f7dff40 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -42,138 +42,186 @@ puts("<TD>"); } static void ourCellEnd() { puts("</TD>"); } static void ourPrintCell(char *str) { ourCellStart(); puts(str); ourCellEnd(); } +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); + } +} + static void hgHubConnectUnlisted(struct hubConnectStatus *hubList) /* Put up the list of unlisted hubs and other controls for the page. */ { // put out the top of our page printf("<div id=\"unlistedHubs\" class=\"hubList\"> " "<table id=\"unlistedHubsTable\"> " "<thead><tr> " "<th colspan=\"5\" id=\"addHubBar\"><label>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 count = 0; -struct hubConnectStatus *hub; -for(hub = hubList; hub; hub = hub->next) +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) { - if (isHubUnlisted(hub) && ((hub->trackHub == NULL) || trackHubHasDatabase(hub->trackHub, database) )) - count++; + nextHub = hub->next; + if (isHubUnlisted(hub) ) + { + addGenomesToHash(hub, assHash); + if ((hub->trackHub == NULL) || trackHubHasDatabase(hub->trackHub, database) ) + { + unlistedHubCount++; + slAddHead(&unlistedHubList, hub); + } + else + { + otherHubCount++; + } + } } -if (count == 0) +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; + +if (unlistedHubCount == 0) { // nothing to see here printf( "<tr><td>No Track Hubs for this genome assembly</td></tr>" - "</td></table>"); - printf("</thead></div>"); + "</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>URL</th> " "<th>Disconnect</th> " "</tr></thead>\n"); // start first row printf("<tbody><tr>"); -count = 0; -for(hub = hubList; hub; hub = hub->next) +int count = 0; +for(hub = unlistedHubList; hub; hub = hub->next) { - /* if the hub is public, then don't list it here */ - if (!(isHubUnlisted(hub) && ((hub->trackHub == NULL) || trackHubHasDatabase(hub->trackHub, database) ))) - continue; - 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 if (isEmpty(hub->errorMessage)) { ourCellStart(); char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, hub->id); cartMakeCheckBox(cart, hubName, FALSE); ourCellEnd(); } else { // give people a chance to clear the error ourCellStart(); printf( "<input name=\"hubClearButton\"" "onClick=\"document.resetHubForm.elements['hubUrl'].value='%s';" "document.resetHubForm.submit();return true;\" " - "class=\"hubField\" type=\"button\" value=\"clear error\">" + "class=\"hubField\" type=\"button\" value=\"check hub\">" , hub->hubUrl); ourCellEnd(); } 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(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() @@ -221,31 +269,31 @@ { ourCellStart(); char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id); cartMakeCheckBox(cart, hubName, FALSE); ourCellEnd(); } else if (!isEmpty(errorMessage)) { // give user a chance to clear the error ourCellStart(); printf( "<input name=\"hubClearButton\"" "onClick=\"document.resetHubForm.elements['hubUrl'].value='%s';" "document.resetHubForm.submit();return true;\" " - "class=\"hubField\" type=\"button\" value=\"clear error\">" + "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(url);