175c26e8907957b668222471a3b33ee0a13b602c
mspeir
  Fri Jul 18 09:04:53 2025 -0700
fixing cbHub to output same number of barChartColors as there are clusters

diff --git src/cbPyLib/cellbrowser/hubmaker.py src/cbPyLib/cellbrowser/hubmaker.py
index 449789e..5c60e9c 100755
--- src/cbPyLib/cellbrowser/hubmaker.py
+++ src/cbPyLib/cellbrowser/hubmaker.py
@@ -659,36 +659,34 @@
     logging.info("Wrote jobList file %s" % jlFh.name)
 
     logging.info("Wrote %s" % tfh.name)
 
 def clamp(x):
     return max(0, min(int(x), 255))
 
 def toHex(rgb):
     r = rgb[0]
     g = rgb[1]
     b = rgb[2]
     return "#{0:02x}{1:02x}{2:02x}".format(clamp(r*255), clamp(g*255), clamp(b*255))
 
 def writeBarChartTdb(tfh, bbFname, clusterNames, unitName, stat, percentile):
     " write the barChart tdb stanza "
-    stepSize = 1.0 / len(clusterNames)
     colorCodes = []
-    x = 0
-    while x < 1.0:
+    for i in range(len(clusterNames)):
+        x = i / len(clusterNames)
         colorCodes.append(colorsys.hsv_to_rgb(x, 1.0, 1.0))
-        x+=stepSize
 
     hexCodes = [toHex(x) for x in colorCodes]
 
     tfh.write('track barChart\n')
     tfh.write('type bigBarChart\n')
     tfh.write('visibility full\n')
     tfh.write('shortLabel Cluster expression\n')
     if stat=="percentile":
         metric = "%dth percentile" % percentile
     else:
         metric = stat.capitalize()
     tfh.write('longLabel %s Cluster expression\n' % metric)
 
     # only remove spaces, this is more readable than sanitizeName
     saneClusterNames = []