def draw_a_chrom_heatmap(wig, chrom, ylim, chrominfo, maxchrom, centromere=None, bot = -1, top = 1, line=True, linecol='cyan'):
    """Draw a chromosome heatmap"""
        
    # draw the frame
    rscript = ''
    #rscript=draw_chrom_frame(chrominfo, chrom, maxchrom, centromere)
        
    if centromere:
        # get the parts of the chromosome before and after centromere
        wig_bef_cent=[[], []]
        wig_aft_cent=[[], []]
        i=0
        between=[]
        for c,v in intertools.izip(wig[0],wig[1]):
            if c < centromeres[0][0]:
               wig_bef_cent[0].append(c)
               wig_bef_cent[1].append(v)
            elif c > centromeres[1][1]:
                wig_aft_cent[0].append(c)
                wig_aft_cent[1].append(v)
            else:
                between=[c,v]
        
        wig_bef_cent[0].append(centromeres[0][0])
        if between:
            wig_aft_cent[0].insert(0,centromeres[1][1])
            wig_aft_cent[1].insert(0,between[1])
        
        rscript+=R.heatmap_bar(wig_bef_cent[0],wig_bef_cent[1],[chrominfo[0],centromere[0][0]],ylim,bot=bot,top=top)
        rscript+=R.heatmap_bar(wig_aft_cent[0],wig_aft_cent[1],[centromere[1][1],chrominfo[1]],ylim,bot=bot,top=top)
            
    else:
        rscript += R.heatmap_bar(wig[0], wig[1], chrominfo, ylim, bot=bot, top=top)
        if line: 
            med = (top + bot)/2         # med position to draw the line
            hdelta = (top - bot)/2      # get the height from the mid to the top
            scaling = 0.8               # scaling factor to shrink the line
            scaled_wig =  map(lambda x: hdelta* scaling * ((max(min(ylim[1],x), ylim[0]) - ylim[1] - ylim[0])/(ylim[1] - ylim[0])) + med, wig[1])
            rscript += R.lines(wig[0], scaled_wig, col=[linecol])
        
    return rscript
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/draw_a_chrom_heatmap/original