5847cd8496ad3bc5783f9f6eb03f97c7ff3699a1
braney
  Tue Jul 24 15:30:33 2018 -0700
fix problems with filtering on beds with less than 9 fields, and work
around brain damaged cart variables that different based on the storage
class of a bigBed field  ... argh!

diff --git src/hg/hgTracks/bigBedTrack.c src/hg/hgTracks/bigBedTrack.c
index e2e7c54..0c81fe7 100644
--- src/hg/hgTracks/bigBedTrack.c
+++ src/hg/hgTracks/bigBedTrack.c
@@ -22,36 +22,64 @@
 #include "bigWarn.h"
 #include "errCatch.h"
 #include "trackHub.h"
 #include "net.h"
 #include "bigPsl.h"
 #include "bigBedFilter.h"
 
 struct bigBedFilter *bigBedMakeNumberFilter(struct cart *cart, struct bbiFile *bbi, struct trackDb *tdb, char *filter, char *defaultLimits,  char *field)
 /* Make a filter on this column if the trackDb or cart wants us to. */
 {
 struct bigBedFilter *ret = NULL;
 char *setting = trackDbSettingClosestToHome(tdb, filter);
 int fieldNum =  bbExtraFieldIndex(bbi, field) + 3;
 if (setting)
     {
+    struct asObject *as = bigBedAsOrDefault(bbi);
+    // All this isFloat conditional code is here because the cart
+    // variables used for floats are different than those used for ints
+    // in ../lib/hui.c so we have to use the correct getScore*() routine
+    // to access them..    We're doomed.
+    boolean isFloat = FALSE;
+    struct asColumn *asCol = asColumnFind(as, field);
+    if (asCol != NULL)
+        isFloat = asTypesIsFloating(asCol->lowType->type);
     boolean invalid = FALSE;
     double minValueTdb = 0,maxValueTdb = NO_VALUE;
-    colonPairToDoubles(setting,&minValueTdb,&maxValueTdb);
     double minLimit=NO_VALUE,maxLimit=NO_VALUE,min = minValueTdb,max = maxValueTdb;
+    if (!isFloat)
+        {
+        int minValueTdbInt = 0,maxValueTdbInt = NO_VALUE;
+        colonPairToInts(setting,&minValueTdbInt,&maxValueTdbInt);
+        int minLimitInt=NO_VALUE,maxLimitInt=NO_VALUE,minInt=minValueTdbInt,maxInt=maxValueTdbInt;
+        colonPairToInts(defaultLimits,&minLimitInt,&maxLimitInt);
+        getScoreIntRangeFromCart(cart,tdb,FALSE,filter,&minLimitInt,&maxLimitInt,&minInt,&maxInt);
+
+        // copy all the ints over to the doubles (sigh)
+        min = minInt;
+        max = maxInt;
+        minLimit = minLimitInt;
+        maxLimit = maxLimitInt;
+        minValueTdb = minValueTdbInt;
+        maxValueTdb = maxValueTdbInt;
+        }
+    else
+        {
+        colonPairToDoubles(setting,&minValueTdb,&maxValueTdb);
         colonPairToDoubles(defaultLimits,&minLimit,&maxLimit);
         getScoreFloatRangeFromCart(cart,tdb,FALSE,filter,&minLimit,&maxLimit,&min,&max);
+        }
     if ((int)minLimit != NO_VALUE || (int)maxLimit != NO_VALUE)
         {
         // assume tdb default values within range!
         // (don't give user errors that have no consequence)
         if ((min != minValueTdb && (((int)minLimit != NO_VALUE && min < minLimit)
                                 || ((int)maxLimit != NO_VALUE && min > maxLimit)))
         ||  (max != maxValueTdb && (((int)minLimit != NO_VALUE && max < minLimit)
                                 || ((int)maxLimit != NO_VALUE && max > maxLimit))))
             {
             invalid = TRUE;
             char value[64];
             if ((int)max == NO_VALUE) // min only is allowed, but max only is not
                 safef(value, sizeof(value), "entered minimum (%g)", min);
             else
                 safef(value, sizeof(value), "entered range (min:%g and max:%g)", min, max);