73b74e92fd0ccbea53939947f6b7d593bc663375
galt
  Wed Aug 15 14:23:42 2012 -0700
fix hgc/encodeClick doEncodePeak to support items and use them to match unique display - even though multiples are now incredibly rare with new item=name matching, the code improves the display of the multiples by separating them with a vertical space
diff --git src/hg/hgc/encodeClick.c src/hg/hgc/encodeClick.c
index 22e7c9f..679f983 100644
--- src/hg/hgc/encodeClick.c
+++ src/hg/hgc/encodeClick.c
@@ -36,67 +36,76 @@
     }
 return TRUE;
 }
 
 static void rAddMatching(struct trackDb *tdb, struct slPair *selGroupList, struct slName **pList)
 /* Add track and any descendents that match selGroupList to pList */
 {
 if (selGroupListMatch(tdb, selGroupList))
     slNameAddHead(pList, tdb->track);
 struct trackDb *sub;
 for (sub = tdb->subtracks; sub != NULL; sub = sub->next)
     rAddMatching(sub, selGroupList, pList);
 }
 #endif//def UNUSED
 
-void doEncodePeak(struct trackDb *tdb, struct customTrack *ct)
+void doEncodePeak(struct trackDb *tdb, struct customTrack *ct, char *item)
 /*  details for encodePeak type tracks. */
 {
 struct sqlConnection *conn;
 struct sqlResult *sr;
 enum encodePeakType peakType;
 char **row;
 char *db;
 char *table = tdb->table;
 char *chrom = cartString(cart,"c");
 int start = cgiInt("o");
 int end = cgiInt("t");
 int rowOffset;
+boolean firstTime = TRUE;
 /* connect to DB */
 if (ct)
     {
     db = CUSTOM_TRASH;
     table = ct->dbTableName;
     }
 else
     db = database;
 conn = hAllocConn(db);
 peakType = encodePeakInferTypeFromTable(db, table, tdb->type);
 if (peakType == 0)
     errAbort("unrecognized peak type from table %s", tdb->table);
-genericHeader(tdb, NULL);
+genericHeader(tdb, NULL);  // genericClickHandlerPlus gets there first anyway and overrides this which is now moot.
 sr = hOrderedRangeQuery(conn, table, chrom, start, end,
 			NULL, &rowOffset);
 while((row = sqlNextRow(sr)) != NULL)
     {
     char **rowPastOffset = row + rowOffset;
     if ((sqlUnsigned(rowPastOffset[1]) != start) ||  (sqlUnsigned(rowPastOffset[2]) != end))
 	continue;
+    if (!sameString(rowPastOffset[3], item))
+	continue;
 
     float signal = -1;
     float pValue = -1;
     float qValue = -1;
+
+    if (firstTime)
+	firstTime = FALSE;
+    else // print separator
+	printf("<BR>\n");
+
     /* Name */
     if (rowPastOffset[3][0] != '.')
 	printf("<B>Name:</B> %s<BR>\n", rowPastOffset[3]);
     /* Position */
     printf("<B>Position:</B> "
        "<A HREF=\"%s&db=%s&position=%s%%3A%d-%d\">%s:%d-%d</a><BR>\n",
        hgTracksPathAndSettings(), database, chrom, start+1, end, chrom, start+1, end);
     /* Print peak base */
     if ((peakType == narrowPeak) || (peakType == encodePeak))
 	{
 	int peak = sqlSigned(rowPastOffset[9]);
 	if (peak > -1)
 	    printf("<B>Peak point:</B> %d<BR>\n", start + peak + 1); // one based
 	}
     /* Strand, score */