a33f1b928200549e10005e79e6db16a9d79b801e
braney
  Thu Jan 25 13:37:37 2024 -0800
use summary information in bigBeds when filters are off and there are
too many items in the region

diff --git src/hg/hgTracks/bigBedTrack.c src/hg/hgTracks/bigBedTrack.c
index 964a8d0..9ef56cf 100644
--- src/hg/hgTracks/bigBedTrack.c
+++ src/hg/hgTracks/bigBedTrack.c
@@ -389,74 +389,86 @@
     #endif
 
     bbi = track->bbiFile = bigBedFileOpenAlias(fileName, chromAliasFindAliases);
     }
 return bbi;
 }
 
 static unsigned bigBedMaxItems()
 /* Get the maximum number of items to grab from a bigBed file.  Defaults to ten thousand . */
 {
 static boolean set = FALSE;
 static unsigned maxItems = 0;
 
 if (!set)
     {
-    char *maxItemsStr = cfgOptionDefault("bigBedMaxItems", "10000");
+    char *maxItemsStr = cfgOptionDefault("bigBedMaxItems", "50000");
 
     maxItems = sqlUnsigned(maxItemsStr);
     }
 
 return maxItems;
 }
 
 struct bigBedInterval *bigBedSelectRangeExt(struct track *track,
 	char *chrom, int start, int end, struct lm *lm, int maxItems)
 /* Return list of intervals in range. */
 {
 struct bigBedInterval *result = NULL;
 /* protect against temporary network error */
 struct errCatch *errCatch = errCatchNew();
+boolean filtering = FALSE; // for the moment assume we're not filtering
 if (errCatchStart(errCatch))
     {
     struct bbiFile *bbi = fetchBbiForTrack(track);
     result = bigBedIntervalQuery(bbi, chrom, start, end, bigBedMaxItems() + 1, lm);
     if (slCount(result) > bigBedMaxItems())
 	{
+        if (filtering)
             errAbort("Too many items in window to filter.Zoom in or remove filters to view track.");
-
-#ifdef NOTNOW  // we may want to use summary levels if filters are off and folks don't want color
+        else
+            {
+            // use summary levels
+            if (track->visibility != tvDense)
+                {
+                track->limitedVis = tvFull;
+                track->limitWiggle = TRUE;
+                track->limitedVisSet = TRUE;
+                }
+            else
+                {
                 track->limitedVis = tvDense;
                 track->limitedVisSet = TRUE;
+                }
             result = NULL;
             AllocArray(track->summary, insideWidth);
             if (bigBedSummaryArrayExtended(bbi, chrom, start, end, insideWidth, track->summary))
                 {
                 char *denseCoverage = trackDbSettingClosestToHome(track->tdb, "denseCoverage");
                 if (denseCoverage != NULL)
                     {
                     double endVal = atof(denseCoverage);
                     if (endVal <= 0)
                         {
                         AllocVar(track->sumAll);
                         *track->sumAll = bbiTotalSummary(bbi);
                         }
                     }
                 }
             else
                 freez(&track->summary);
-#endif
+            }
         }
     track->bbiFile = NULL;
     }
 errCatchEnd(errCatch);
 if (errCatch->gotError)
     {
     track->networkErrMsg = cloneString(errCatch->message->string);
     track->drawItems = bigDrawWarning;
     track->totalHeight = bigWarnTotalHeight;
     result = NULL;
     }
 errCatchFree(&errCatch);
 
 return result;
 }