2c21f6206ae7c0b230a2c05b6da14e64d7372215 jcasper Tue Oct 29 16:20:22 2019 -0700 Improving auto-scale performance in Hi-C, fixing a bad assumption about the order of available resolutions in a list, refs #24308 diff --git src/hg/lib/hicUi.c src/hg/lib/hicUi.c index 648d728..d06f07f 100644 --- src/hg/lib/hicUi.c +++ src/hg/lib/hicUi.c @@ -63,48 +63,55 @@ int sanityCheck = sameOk(selected, "Auto"); int i; for (i=0; i<meta->nRes; i++) { if (sameOk(selected, meta->resolutions[i])) sanityCheck = 1; } if (!sanityCheck) selected = "Auto"; return selected; } int hicUiFetchResolutionAsInt(struct cart *cart, struct trackDb *tdb, struct hicMeta *meta, int windowSize) /* Return the current resolution selection as an integer. If there is no selection, or if "Auto" * has been selected, return the largest available value that still partitions the window into at - * least 5000 bins. */ + * least 500 bins. */ { char *resolutionString = hicUiFetchResolution(cart, tdb, meta); int result; -if (sameString(resolutionString, "Auto")) +if (sameOk(resolutionString, "Auto")) { - int idealRes = windowSize/5000; - char *autoRes = meta->resolutions[meta->nRes-1]; - int i; + int idealRes = windowSize/500; + int autoRes = atoi(meta->resolutions[meta->nRes-1]); + int smallestRes = autoRes; // in case the ideal resolution is smaller than anything available + int i, success = 0; for (i=meta->nRes-1; i>= 0; i--) { - if (atoi(meta->resolutions[i]) < idealRes) + int thisRes = atoi(meta->resolutions[i]); + if (thisRes < smallestRes) + smallestRes = thisRes; // not sure about the sort order of the list + if (thisRes < idealRes && thisRes >= autoRes) { - autoRes = meta->resolutions[i]; - break; + autoRes = thisRes; + success = 1; } } - result = atoi(autoRes); + if (success) + result = autoRes; + else + result = smallestRes; } else result = atoi(resolutionString); return result; } void hicUiResolutionDropDown(struct cart *cart, struct trackDb *tdb, struct hicMeta *meta) { char cartVar[1024]; char autoscale[10] = "Auto"; safef(cartVar, sizeof(cartVar), "%s.%s", tdb->track, HIC_RESOLUTION); char **menu = NULL; AllocArray(menu, meta->nRes+1); char **values = NULL; AllocArray(values, meta->nRes+1);