def draw_exon_intron_profile_plot(metaexon_breaks,avg_metaexon,metaintron_breaks,avg_metaintron,elowers,euppers,ilowers,iuppers):    
    
    n_rows = 3
    # exon and intron profiles
    rscript = ''
    
    temp_metaexon = filter(lambda x: x, avg_metaexon)
    temp_metaintron = filter(lambda x: x, avg_metaintron)
    
    # ge the global minimum and global maximum
    ylim = [0, 0]
    if temp_metaexon:
        mins_avg_metaexon = map(min_w_nan, temp_metaexon)
        maxs_avg_metaexon = map(max_w_nan, temp_metaexon)
    else:
        mins_avg_metaexon = []
        maxs_avg_metaexon = []
    
    if temp_metaintron:
        mins_avg_metaintron = map(min_w_nan, temp_metaintron)
        maxs_avg_metaintron = map(max_w_nan, temp_metaintron)
    else:
        mins_avg_metaintron = []
        maxs_avg_metaintron = []
    
    try:
        ylim[0] = min(mins_avg_metaexon + mins_avg_metaintron)
    except ValueError:
        ylim[0] = 0
        
    try:
        ylim[1] = max(maxs_avg_metaexon + maxs_avg_metaintron)
    except ValueError:
        ylim[1] = 0
        
    ylim = [ylim[0], ylim[1]+0.2*ylim[1]]
    row = 0
    #for metaexon_break, metaintron_break, ame, ami, elower, eupper, ilower, iupper in itertools.izip(metaexon_breaks, metaintron_breaks, avg_metaexon, avg_metaintron, elowers, euppers, ilowers, iuppers):
    for metaexon_break, metaintron_break, ame, ami, elower, eupper, ilower, iupper in map(None, metaexon_breaks, metaintron_breaks, avg_metaexon, avg_metaintron, elowers, euppers, ilowers, iuppers):
        if row % n_rows == 0: rscript+=R.par(mar=[4,4,5,3.8],oma=[4,2,4,2],mfrow=[n_rows,2])
        if ame:
            rscript+=draw_single_profile(metaexon_break, ame, main='Average Exon Profile\n(%d <= length < %d bp)' %(elower, eupper),xlab='Relative Location (%)',ylab='Average Profile',ylim=ylim)
        else:   # when nothing, just draw null plot
            rscript+=draw_nullbar()
            
        if ami:
            rscript+=draw_single_profile(metaintron_break, ami,main='Average Intron Profile\n(%d <= length < %d bp)' %(ilower, iupper),xlab='Relative Location (%)',ylab='Average Profile',ylim=ylim)
        else:
            rscript+=draw_nullbar()
        row += 1
        
    return rscript
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/draw_exon_intron_profile_plot/original