def plot_alignment4mummer( seqs, ax, heatmap, size, fn ): with open( fn , 'r' ) as file: for line in file: buf = line.rstrip( '\n' ).split( ) i = common.detect_index( buf[11], int( buf[0] ), int( buf[1] ), seqs ) j = common.detect_index( buf[12], int( buf[3] ), int( buf[4] ), seqs ) color = heatmap.convert_identity2color( float( buf[9] )) if( i == -1 or j == -1 ): continue x, y = convert_position2coord( seqs[i][buf[11]], seqs[j][buf[12]], int( buf[0] ), int( buf[1] ), int( buf[3] ), int( buf[4] ), size.margin_bw_scaffold_alignment, size.histograms[i], size.histograms[j] ) ax.fill( x, y, color=color, alpha=heatmap.alpha, lw=0 )
def plot_histogram(seqs, ax, size, fn): min_y = 0 max_y = 4 color = 'tomato' msize = 3 with open(fn, 'r') as file: x_list = [] y_list = [] for line in file: buf = line.rstrip('\n').split('\t') i = common.detect_index(buf[0], int(buf[2]), int(buf[2]), seqs) if (i == -1): continue if (float(buf[4]) < min_y or max_y < float(buf[4])): continue x = seqs[i][buf[0]].convert_position2xcoord(int(buf[2])) y0 = seqs[i][buf[0]].origin_y + seqs[i][ buf[0]].height + size.margin_bw_scaffold_alignment y1 = seqs[i][buf[0]].origin_y + size.histograms[ i] - size.margin_bw_scaffold_alignment y = ((y1 - y0) * (float(buf[4]) - min_y)) / (max_y - min_y) + y0 x_list.append(x) y_list.append(y) if (len(x_list) != 0): ax.scatter(x_list, y_list, color=color, marker='.', s=msize, zorder=2, lw=0)
def plot_alignment4lastz( seqs, ax, heatmap, size, fn ): with open( fn , 'r' ) as file: for line in file: if( line[0:1] == "#" ): continue buf = line.rstrip( '\n' ).split( '\t' ) i = common.detect_index( buf[1], int( buf[4] ), int( buf[5] ), seqs ) if( buf[7] == '+' ): s_pos = int( buf[9] ) e_pos = int( buf[10] ) j = common.detect_index( buf[6], s_pos, e_pos, seqs ) else: s_pos = int( buf[8] ) - int( buf[9] ) e_pos = int( buf[8] ) - int( buf[10] ) j = common.detect_index( buf[6], e_pos, s_pos, seqs ) color = heatmap.convert_identity2color( float( buf[12][:-1] )) if( i == -1 or j == -1 ): continue x, y = convert_position2coord( seqs[i][buf[1]], seqs[j][buf[6]], int( buf[4] ), int( buf[5] ), s_pos, e_pos, size.margin_bw_scaffold_alignment, size.histograms[i], size.histograms[j] ) ax.fill( x, y, color=color, alpha=heatmap.alpha, lw=0 )
def plot_mark_v(seqs, ax, size, fn): height = size.ylim_max / 50 width = size.xlim_max / 150 #color = 'tomato' color = '#043c78' with open(fn, 'r') as file: for line in file: buf = line.rstrip('\n').split('\t') i = common.detect_index(buf[0], int(buf[3]), int(buf[4]), seqs) if (i == -1): continue aninstance = Vmark(seqs[i][buf[0]], buf, width, height, color) aninstance.plot(ax)
def plot_genes(seqs, ax, size, fn): color = 'darkorange' RATIO = 3 #color = 'tomato' with open(fn, 'r') as file: for line in file: buf = line.rstrip('\n').split('\t') if (len(buf) < 4): continue if (buf[2] != 'gene'): continue i = common.detect_index(buf[0], int(buf[3]), int(buf[4]), seqs) if (i == -1): continue height = seqs[i][buf[0]].height * RATIO tail_length = (height / 2) * (size.xlim_max / size.ylim_max) * ( size.figsize_inch[1] / size.figsize_inch[0]) aninstance = Gene(seqs[i][buf[0]], buf, height, tail_length, color) aninstance.plot(ax)