229b9f6993152bab7202c2a32f461ecaa478e140
kate
  Mon Oct 1 16:28:22 2018 -0700
Rename merge mode to cluster mode. refs #21917

diff --git src/hg/hgTracks/interactTrack.c src/hg/hgTracks/interactTrack.c
index db95a77..2a57034 100644
--- src/hg/hgTracks/interactTrack.c
+++ src/hg/hgTracks/interactTrack.c
@@ -177,31 +177,31 @@
 {
 return tg->customInt;
 }
 
 static int flipY(struct track *tg, int y)
 /* Invert y coordinate if flipped display is requested */
 {
 int yOff = getYOff(tg);
 int flipped = yOff + tg->height + yOff - y;
 return flipped;
 }
 
 struct interactTrackInfo {
     boolean isDirectional; // source and target are distinct item types
     char *offset;          // which end to draw offset (source or target)
-    char *mergeMode;       // merge by source or target (or no merge if NULL)
+    char *clusterMode;     // cluster by source or target (or no cluster if NULL)
     boolean drawUp;          // draw interactions with peak up (hill)
     boolean doOtherLabels;  // true to suppress labels on other chrom items (prevent overlap)
     int maxSize;        // longest interaction (midpoint to midpoint) in bp
     int fontHeight;
     int sameCount;      // number of same chromosome interactions in window
     int sameHeight;     // vertical space for same chromosome interactions
     int otherCount;     // number of other chromosome interactions in window
     int otherHeight;    // vertical space for other chromosome interactions
 } interactTrackInfo;
 
 static void interactGetLayoutInfo(struct track *tg, int seqStart, struct hvGfx *hvg,                                                       int xOff, MgFont *font, double scale)
 /* Get layout info from interact items in window */
 {
 struct interactTrackInfo *tInfo = tg->customPt;
 tInfo->doOtherLabels = TRUE;
@@ -242,91 +242,91 @@
         prevLabelStart = labelStart;
         prevLabelEnd = labelEnd;
         prevLabel = otherChrom;
         }
     }
 tInfo->fontHeight = vgGetFontPixelHeight(hvg->vg, font);
 tInfo->otherHeight = (tInfo->otherCount) ? 3 * tInfo->fontHeight : 0;
 tInfo->sameHeight = (tInfo->sameCount) ? tg->height - tInfo->otherHeight : 0;
 }
 
 void interactLoadItems(struct track *tg)
 /* Load interact items in interact format */
 {
 struct interactTrackInfo *tInfo = NULL;
 AllocVar(tInfo);
-tInfo->mergeMode = interactUiMergeMode(cart, tg->track, tg->tdb);
+tInfo->clusterMode = interactUiClusterMode(cart, tg->track, tg->tdb);
 tg->customPt = tInfo;
 
 loadAndFilterItems(tg);
-if (tInfo->mergeMode || isLinkedFeaturesMode(tg))
+if (tInfo->clusterMode || isLinkedFeaturesMode(tg))
     {
     // convert to BEDs for linked feature display
     struct interact *inters = tg->items, *inter;
     struct linkedFeatures *lfs = NULL, *lf;
-    struct hash *intersMerge = hashNew(0);
+    struct hash *intersCluster = hashNew(0);
     boolean doColor = !tg->colorShades;
     for (inter = inters; inter; inter = inter->next)
         {
-        if (tInfo->mergeMode)
+        if (tInfo->clusterMode)
             {
-            boolean byTarget = sameString(tInfo->mergeMode, INTERACT_MERGE_TARGET);
+            boolean byTarget = sameString(tInfo->clusterMode, INTERACT_CLUSTER_TARGET);
             // hash by source or target name
             char *name = (byTarget ? inter->targetName : inter->sourceName);
-            lf = (struct linkedFeatures *) hashFindVal(intersMerge, name);
+            lf = (struct linkedFeatures *) hashFindVal(intersCluster, name);
             if (lf)
                 {
                 // add a simple feature for the other end (source or target) to the linked feature
                 struct simpleFeature *sf = NULL;
                 AllocVar(sf);
 
                 // tweak interact struct for intrachromsomal item to ease next steps
                 if (differentString(inter->targetChrom, inter->sourceChrom))
                     {
                     inter->sourceStart = inter->targetStart = inter->chromStart;
                     inter->sourceEnd = inter->targetEnd = inter->chromEnd;
                     }
 
                 sf->start = (byTarget ? inter->sourceStart : inter->targetStart);
                 sf->end = (byTarget ? inter->sourceEnd : inter->targetEnd);
                 struct simpleFeature *sfs = lf->components;
                 slAddHead(&sfs, sf);
                 lf->components = sfs;
                 if (lf->filterColor != inter->color)
                     lf->filterColor = MG_GRAY;
                 }
             else
                 {
                 // create a linked feature for this target
                 lf = interactToLf(inter, doColor);
                 lf->orientation = 0;
                 lf->name = (byTarget ? inter->targetName : inter->sourceName);
                 lf->tallStart = (byTarget ? inter->targetStart : inter->sourceStart);
                 lf->tallEnd = (byTarget ? inter->targetEnd : inter->sourceEnd);
-                hashAdd(intersMerge, lf->name, lf);
+                hashAdd(intersCluster, lf->name, lf);
                 }
             }
         else 
             {
             lf = interactToLf(inter, doColor);
             slAddHead(&lfs, lf);
             }
         }
-    if (tInfo->mergeMode)
+    if (tInfo->clusterMode)
         {
-        // sort simplefeatures and adjust bounds of merged features
-        struct hashEl *el, *els = hashElListHash(intersMerge);
+        // sort simplefeatures and adjust bounds of clustered features
+        struct hashEl *el, *els = hashElListHash(intersCluster);
         for (el = els; el; el = el->next)
             {
             lf = (struct linkedFeatures *)el->val;
             linkedFeaturesSortAndBound(lf);
             slAddHead(&lfs, lf);
             }
         slSort(&lfs, linkedFeaturesCmp);
         }
     else
         {
         slReverse(&lfs);
         }
     tg->items = lfs;
     // TODO: consider freeing interact items
     }
@@ -706,60 +706,60 @@
 void interactLinkedFeaturesDrawAt(struct track *tg, void *item,
                           struct hvGfx *hvg, int xOff, int y, double scale,
                           MgFont *font, Color color, enum trackVisibility vis)
 /* Draw a item with target in contrasting color */
 {
 struct linkedFeatures *lf = item;
 if (tg->visibility == tvDense)
     {
     lf->filterColor = slightlyDarkerColor(hvg, MG_GRAY);
                 // can't distinguish overlapping colors, so force to gray
     }
 linkedFeaturesDrawAt(tg, item, hvg, xOff, y, scale, font, color, vis);
 struct interactTrackInfo *tInfo = tg->customPt;
 
 // draw overlapping items in white
-if (tInfo->mergeMode)
+if (tInfo->clusterMode)
     {
     struct simpleFeature *sf;
     int shortHeight = tg->heightPer/2;
     for (sf = lf->components;  sf; sf = sf->next)
         {
         if (sf->start > lf->tallStart && sf->end < lf->tallEnd)
             {
             drawScaledBox(hvg, sf->start, sf->end, scale, xOff, y + shortHeight/2,
                                 shortHeight, MG_WHITE);
             }
         }
     }
 else
     {
     struct simpleFeature *sf1 = lf->components, *sf2 = sf1->next;
     if (sf2 && sf2->start < sf1->end)
         {
         drawScaledBox(hvg, sf2->start, sf2->end, scale, xOff, y, tg->heightPer, MG_WHITE);
         }
     }
 }
 
 void interactDrawItems(struct track *tg, int seqStart, int seqEnd,
         struct hvGfx *hvg, int xOff, int yOff, int width, 
         MgFont *font, Color color, enum trackVisibility vis)
 /* Draw a list of interact structures. */
 {
 struct interactTrackInfo *tInfo = (struct interactTrackInfo *)tg->customPt;
-if (tInfo->mergeMode || isLinkedFeaturesMode(tg))
+if (tInfo->clusterMode || isLinkedFeaturesMode(tg))
     {
     tg->drawItemAt = interactLinkedFeaturesDrawAt;
     linkedFeaturesDraw(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis);
     }
 else
     // curve, etc. connector display
     drawInteractItems(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis);
 }
 
 void interactMethods(struct track *tg)
 /* Interact track type methods */
 {
 tg->bedSize = 12;
 linkedFeaturesMethods(tg);         // for most vis and mode settings
 tg->loadItems = interactLoadItems;