def draw_pie_distribution_of_elements(ChIP_EP, prom=3000, down=3000):
    """Draw the pie charts of the overall distributions
    """
    
    # get the labels (legend) for the pie chart
    names = ['Promoter (=<%d bp)' %(prom/3), 'Promoter (%d-%d bp)' %(3/prom, 2*prom/3), 'Promoter (%d-%d bp)' %(2*prom/3, prom),\
             'Downstream (<=%d bp)' %(prom/3), 'Downstream (%d-%d bp)' %(prom/3, 2*prom/3), 'Downstream (%d-%d bp)' %(2*prom/3, prom),\
             "5'UTR","3'UTR", "Coding exon", "Intron",\
             'Distal intergenic']
     
    
    # get the proportions to draw
    x = ChIP_EP['whole']['promoter'] + ChIP_EP['whole']['downstream'] + ChIP_EP['whole']['gene'] + [ChIP_EP['whole']['enhancer']]
    x_percent = _percent_str(map(lambda a: 100.0*a, x))
    names_w_percent = map(lambda x, y: x + ': ' + y, names, x_percent)
    # make x values less than .1% .5% because they are too small to see in the pie chart. But x_percent does not change
    x = map(max, x, [0.01]*len(x))
    
    #
    # producing R script return
    #
    
    # put header
    rscript = '\n'
    rscript += R.comment('')
    rscript += R.comment('Distribution of ChIP regions over cis-regulatory element')
    rscript += R.comment('Note that the x may be modified for better graphics in case a value is too small')
    rscript += R.comment('Thus, look at the labels of the pie chart to get the real percentage values' )
    rscript += R.comment('')
    rscript += '\n'
    
    # some graphical parameters
    s = 0.7
    v = 0.8
    init_angle = 45
    main = 'Distribution of ChIP Regions'
    colval = 'piecol'
    #newcolval = 'newpiecol'
    mar = mar=[4,4,5,3.8]
    oma=[4,2,4,2]
    mfrow = [2, 1]
    rscript += R.par(mar=mar, oma=oma, mfrow=mfrow)
    
    # R script
    rscript += R.rainbow(len(x), s = s, v = v, rval=colval)
    #rscript += '%s <- piecol[c(%s)]\n' %(newcolval, str(map(lambda a: a+1, newix))[1:-1])
    rscript += R.pie(x, labels="NA", main=main, col=colval,clockwise=True, border=colval, radius=0.9,init_angle=init_angle, cex=0.8)
    rscript += R.plot([0,1],[0,1], tp="n", axes=False, xlab="", ylab="", main="", frame=False)
    rscript += R.legend(x='top', legend=names_w_percent, pch=15, col=colval, bty="n")
    
    return rscript
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/draw_pie_distribution_of_elements/swapped operands of `/`