import colorsys


def stat_graph_chunk_color(gene):
    """Returns a #rrggbb color, given a gene.  Used for the pretty graph."""
    # Normalizing 0-31 to 0-1 is simple division -- however, pure red shouldn't
    # represent both 0 and 31.  Cut this off at bluish purple instead, which is
    # around 5/6
    hue = gene / 31 * 0.83
    r, g, b = colorsys.hls_to_rgb(hue, 0.67, 0.75)
    return "#%02x%02x%02x" % (r * 256, g * 256, b * 256)