f8d4a7651a5843d1c0bfa90cdb7da7582615c263
kate
  Thu Aug 9 13:47:29 2018 -0700
Add filter to hide interactions lacking one or both ends in the window. Helpful for busy/noisy datasets.  refs #21109

diff --git src/hg/lib/interactUi.c src/hg/lib/interactUi.c
index 804c57dc..5ae8967 100644
--- src/hg/lib/interactUi.c
+++ src/hg/lib/interactUi.c
@@ -33,48 +33,68 @@
 // track height control
 char buffer[1024];      
 int min, max, deflt, current;
 cartTdbFetchMinMaxPixels(cart, tdb, INTERACT_MINHEIGHT, INTERACT_MAXHEIGHT, 
                                 atoi(INTERACT_DEFHEIGHT),
                                 &min, &max, &deflt, &current);
 safef(buffer, sizeof buffer, "%s.%s", track, INTERACT_HEIGHT);
 printf("<br><br><b>Track height:&nbsp;</b>");
 cgiMakeIntVar(buffer, current, 3);
 printf("&nbsp;<span>pixels&nbsp;(range: %d to %d, default: %d)<span>",
         min, max, deflt);
 }
 
 void interactUiDrawMode(struct cart *cart, char *track, struct trackDb *tdb)
 /* Radio buttons to select drawing mode */
-
 {
 char *drawMode = cartUsualStringClosestToHome(cart, tdb, isNameAtParentLevel(tdb, track),
                                                 INTERACT_DRAW, INTERACT_DRAW_DEFAULT);
 char cartVar[1024];
 puts("<b>Draw mode:</b> ");
 safef(cartVar, sizeof(cartVar), "%s.%s", track, INTERACT_DRAW);
 cgiMakeRadioButton(cartVar, INTERACT_DRAW_CURVE , sameString(INTERACT_DRAW_CURVE, drawMode));
 printf("&nbsp;%s&nbsp;", "curve");
 cgiMakeRadioButton(cartVar, INTERACT_DRAW_ELLIPSE, sameString(INTERACT_DRAW_ELLIPSE, drawMode));
 printf("&nbsp;%s&nbsp;", "ellipse");
 cgiMakeRadioButton(cartVar, INTERACT_DRAW_LINE, sameString(INTERACT_DRAW_LINE, drawMode));
 printf("&nbsp;%s&nbsp;", "rectangle");
 }
 
+void interactUiEndpointFilter(struct cart *cart, char *track, struct trackDb *tdb)
+/* Radio buttons to allow excluding items lacking endpoints in window */
+{
+char *endsVisible = cartUsualStringClosestToHome(cart, tdb, isNameAtParentLevel(tdb, track),
+                                    INTERACT_ENDS_VISIBLE, INTERACT_ENDS_VISIBLE_DEFAULT);
+char cartVar[1024];
+puts("<br><br><b>Show interactions:</b> ");
+//puts("<br><br><b>Exclude interactions:</b> ");
+safef(cartVar, sizeof(cartVar), "%s.%s", track, INTERACT_ENDS_VISIBLE);
+cgiMakeRadioButton(cartVar, INTERACT_ENDS_VISIBLE_ANY, sameString(INTERACT_ENDS_VISIBLE_ANY, endsVisible));
+printf("&nbsp;%s&nbsp;", "all");
+//printf("&nbsp;%s&nbsp;", "none");
+cgiMakeRadioButton(cartVar, INTERACT_ENDS_VISIBLE_ONE, sameString(INTERACT_ENDS_VISIBLE_ONE, endsVisible));
+printf("&nbsp;%s&nbsp;", "at least one end");
+//printf("&nbsp;%s&nbsp;", "only one end");
+cgiMakeRadioButton(cartVar, INTERACT_ENDS_VISIBLE_TWO , sameString(INTERACT_ENDS_VISIBLE_TWO, endsVisible));
+printf("&nbsp;%s&nbsp;", "both ends in window");
+//printf("&nbsp;%s&nbsp;", "no ends in window");
+}
+
 void interactCfgUi(char *database, struct cart *cart, struct trackDb *tdb, char *track,
                         char *title, boolean boxed)
 /* Configure interact track type */
 {
 if (cartVarExists(cart, "ajax"))
     isPopup = TRUE;
 boxed = cfgBeginBoxAndTitle(tdb, boxed, title);
 if (startsWith("big", tdb->type))
     labelCfgUi(database, cart, tdb);
 //printf("\n<table id=interactControls style='font-size:%d%%' %s>\n<tr><td>",
         //isPopup ? 75 : 100, boxed ?" width='100%'":"");
 interactUiMinScore(cart, track, tdb);
+interactUiEndpointFilter(cart, track, tdb);
 interactUiTrackHeight(cart, track, tdb);
 puts("<div>");
 interactUiDrawMode(cart, track, tdb);
 //puts("\n</table>\n");
 cfgEndBox(boxed);
 }