78fd91be04dff4959bde5bf8b404677576c11603
kate
  Wed Jan 9 10:25:06 2019 -0800
Fix computation on interact cluster mode region coordinates on details page. refs #22750

diff --git src/hg/hgc/interactClick.c src/hg/hgc/interactClick.c
index 54cd223..e00380d 100644
--- src/hg/hgc/interactClick.c
+++ src/hg/hgc/interactClick.c
@@ -104,32 +104,32 @@
 static struct interactPlusRow *getInteractions(struct trackDb *tdb, char *chrom, int start, int end, 
                                                 char *name, char *foot, int *retStart, int *retEnd)
 /* Retrieve interact items at this position or name. 
  * Also any others with the same endpoint, if endpoint clicked on.
  * Return full extent of included interactions in returned start, end */
 // NOTE: Consider sortable table of matching interactions
 {
 struct interactPlusRow *ipr, *iprs = NULL, *next, *filtered = NULL;
 char *file = trackDbSetting(tdb, "bigDataUrl");
 char *clusterMode = interactUiClusterMode(cart, tdb->track, tdb);
 if (file != NULL)
     iprs = getInteractsFromFile(file, chrom, start, end, name, foot);
 else
     iprs = getInteractsFromTable(tdb, chrom, start, end, name, foot);
 
-int minStart = iprs->interact->chromStart;
-int maxEnd = iprs->interact->chromEnd;
+int minStart = 999999999;
+int maxEnd = 0;
 for (ipr = iprs; ipr; ipr = next)
     {
     struct interact *inter = ipr->interact;
     next = ipr->next;
     if (!name || sameString(name, "."))
         {
         if (inter->chromStart != start || inter->chromEnd != end)
             continue;
         }
     else
         {
         char *match = inter->name;
         if (clusterMode)
             match = sameString(clusterMode, INTERACT_CLUSTER_SOURCE) ?
                                                 inter->sourceName : inter->targetName;
@@ -268,31 +268,31 @@
 struct interactPlusRow *iprs = getInteractions(tdb, chrom, start, end, item, foot, &minStart, &maxEnd);
 start = minStart;
 end = maxEnd;
 if (iprs == NULL)
     errAbort("Can't find interaction %s", item ? item : "");
 int count = slCount(iprs);
 char *clusterMode = interactUiClusterMode(cart, tdb->track, tdb);
 if (count > 1 || clusterMode)
     {
     printf("<b>Interactions:</b> %d<p>", count);
     if (clusterMode || foot)
         {
         char startBuf[1024], endBuf[1024], sizeBuf[1024];
         sprintLongWithCommas(startBuf, start + 1);
         sprintLongWithCommas(endBuf, end);
-        sprintLongWithCommas(sizeBuf, end - start);
+        sprintLongWithCommas(sizeBuf, end - start + 1);
         printf("<b>%s interactions region:</b> &nbsp;&nbsp;"
                         "<a href='hgTracks?position=%s:%d-%d' target='_blank'>%s:%s-%s</a> ",
                         item, chrom, start+1, end, chrom, startBuf, endBuf);
         printf("&nbsp;&nbsp;%s bp<br>\n", sizeBuf);
         }
     else
         {
         doInteractRegionDetails(tdb, iprs->interact);
         }
     printf("</p>");
     }
 
 genericHeader(tdb, item);
 static struct interactPlusRow *ipr = NULL;
 for (ipr = iprs; ipr != NULL; ipr = ipr->next)