dfbe9123d1f485c46cf881308528ce83e2337ab9 kate Fri May 17 11:10:50 2013 -0700 Libify condensed cell table for factorSource tracks, shown in both hgc and hgTrackUi. refs #10097 diff --git src/hg/hgc/peakClusters.c src/hg/hgc/peakClusters.c index 1e59c47..045d845 100644 --- src/hg/hgc/peakClusters.c +++ src/hg/hgc/peakClusters.c @@ -338,114 +338,30 @@ else errAbort("Missing required trackDb setting %s for track %s", "inputTableFieldDisplay", tdb->track); webPrintLinkTableEnd(); } printf("<A HREF=\"%s&g=htcListItemsAssayed&table=%s\" TARGET_blank>", hgcPathAndSettings(), tdb->track); printf("List all items assayed"); printf("</A><BR>\n"); webNewSection("Track Description"); printTrackHtml(tdb); cartWebEnd(); hFreeConn(&conn); } -struct factorSourceInfo -/* Cell type and description */ - { - struct factorSourceInfo *next; - char *name; - char *description; - }; - -int factorSourceInfoCmp(const void *va, const void *vb) -/* Compare two factorSourceInfo's, sorting on name and then description fields */ -{ -static char bufA[64], bufB[64]; -const struct factorSourceInfo *a = *((struct factorSourceInfo **)va); -const struct factorSourceInfo *b = *((struct factorSourceInfo **)vb); -safef(bufA, 64, "%s+%s", a->name, a->description); -safef(bufB, 64, "%s+%s", b->name, b->description); -return strcmp(bufA, bufB); -} - -void factorSourceAbbreviationTable(struct sqlConnection *conn, char *sourceTable, boolean cellsOnly) -/* Print out table of abbreviations. Optionally, extract cell name only (before '+') and uniqify */ -{ -char *label = "Cell Type"; -if (!cellsOnly) - { - hPrintAbbreviationTable(conn, sourceTable, label); - return; - } -char query[256]; -safef(query, sizeof(query), "select name,description from %s order by name", sourceTable); -struct sqlResult *sr = sqlGetResult(conn, query); -webPrintLinkTableStart(); -webPrintLabelCell("Symbol"); -webPrintLabelCell(label); -char **row; -char *plus; -struct factorSourceInfo *source = NULL, *sources = NULL; -while ((row = sqlNextRow(sr)) != NULL) - { - char *name = row[0]; - char *description = row[1]; - if (cellsOnly) - { - // truncate description to just the cell type - if ((plus = strchr(description, '+')) != NULL) - *plus = 0; - } - AllocVar(source); - source->name = cloneString(name); - source->description = cloneString(description); - slAddHead(&sources, source); - } -slUniqify(&sources, factorSourceInfoCmp, NULL); -int count = 0; -/* -while ((source = slPopHead(&sources)) != NULL) - { - printf("</TR><TR>\n"); - webPrintLinkCell(source->name); - webPrintLinkCell(source->description); - count++; - } -*/ -while ((source = slPopHead(&sources)) != NULL) - { - printf("</TR><TR>\n"); - webPrintLinkCell(source->name); - webPrintLinkCellStart(); - puts(source->description); - count++; - while (sources && sameString(sources->name, source->name)) - { - source = slPopHead(&sources); - puts(", "); - puts(source->description); - count++; - } - webPrintLinkCellEnd(); - } -sqlFreeResult(&sr); -webPrintLinkTableEnd(); -printf("Total: %d\n", count); -} - void doFactorSource(struct sqlConnection *conn, struct trackDb *tdb, char *item, int start) /* Display detailed info about a cluster of peaks from other tracks. */ { int rowOffset = hOffsetPastBin(database, seqName, tdb->table); char **row; struct sqlResult *sr; char query[256]; char *motifTable = NULL; #ifdef TXCLUSTER_MOTIFS_TABLE motifTable = TXCLUSTER_MOTIFS_TABLE; #endif safef(query, sizeof(query), "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d", tdb->table, item, seqName, start); @@ -559,20 +475,20 @@ webNewSection("List of cells assayed for %s but without hits in cluster", cluster->name); webPrintLinkTableStart(); printClusterTableHeader(fieldList, TRUE, FALSE, FALSE); printFactorSourceTableHits(cluster, conn, sourceTable, inputTrackTable, fieldList, TRUE, vocab); webPrintLinkTableEnd(); } else { errAbort("Missing required trackDb setting %s for track %s", "inputTableFieldDisplay", tdb->track); } webNewSection("Table of abbreviations for cells"); boolean cellsOnly = (trackDbSetting(tdb, "sourceAbbrevCellsOnly") != NULL); - factorSourceAbbreviationTable(conn, sourceTable, cellsOnly); + hPrintFactorSourceAbbrevTable(conn, sourceTable, cellsOnly); webNewSection("Track Description"); } }