scripts/last-dotplot
changeset 837 2c3511fa1734
parent 836 1b4db1600728
child 838 7b972338fe04
     1.1 --- a/scripts/last-dotplot	Tue Feb 28 18:21:21 2017 +0900
     1.2 +++ b/scripts/last-dotplot	Tue Feb 28 18:43:58 2017 +0900
     1.3 @@ -117,12 +117,12 @@
     1.4  
     1.5  def get_seq_info(seq_size_dic, font, fontsize, image_mode):
     1.6      '''Return miscellaneous information about the sequences.'''
     1.7 -    seq_names = seq_size_dic.keys()
     1.8 -    seq_names.sort(key=natural_sort_key)
     1.9 -    seq_sizes = [seq_size_dic[i] for i in seq_names]
    1.10 -    name_sizes = get_text_sizes(seq_names, font, fontsize, image_mode)
    1.11 +    seqNames = seq_size_dic.keys()
    1.12 +    seqNames.sort(key=natural_sort_key)
    1.13 +    seq_sizes = [seq_size_dic[i] for i in seqNames]
    1.14 +    name_sizes = get_text_sizes(seqNames, font, fontsize, image_mode)
    1.15      margin = max(zip(*name_sizes)[1])  # maximum text height
    1.16 -    return seq_names, seq_sizes, name_sizes, margin
    1.17 +    return seqNames, seq_sizes, name_sizes, margin
    1.18  
    1.19  def div_ceil(x, y):
    1.20      '''Return x / y rounded up.'''
    1.21 @@ -258,14 +258,14 @@
    1.22              nonoverlapping_labels.append(i)
    1.23      return nonoverlapping_labels
    1.24  
    1.25 -def get_axis_image(seq_names, name_sizes, seq_starts, seq_pix,
    1.26 +def get_axis_image(seqNames, name_sizes, seq_starts, seq_pix,
    1.27                     font, image_mode, opts):
    1.28      '''Make an image of axis labels.'''
    1.29      min_pos = seq_starts[0]
    1.30      max_pos = seq_starts[-1] + seq_pix[-1]
    1.31      height = max(zip(*name_sizes)[1])
    1.32      labels = [make_label(i, j, k, l) for i, j, k, l in
    1.33 -              zip(seq_names, name_sizes, seq_starts, seq_pix)]
    1.34 +              zip(seqNames, name_sizes, seq_starts, seq_pix)]
    1.35      labels = [i for i in labels if i[1] >= min_pos and i[2] <= max_pos]
    1.36      labels.sort()
    1.37      labels = get_nonoverlapping_labels(labels, opts.label_space)
    1.38 @@ -277,8 +277,8 @@
    1.39          draw.text(position, i[3], font=font, fill=opts.text_color)
    1.40      return im
    1.41  
    1.42 -def seqOrigins(seq_names, seq_starts, bp_per_pix):
    1.43 -    for i, j in zip(seq_names, seq_starts):
    1.44 +def seqOrigins(seqNames, seq_starts, bp_per_pix):
    1.45 +    for i, j in zip(seqNames, seq_starts):
    1.46          yield i, bp_per_pix * j
    1.47  
    1.48  def lastDotplot(opts, args):
    1.49 @@ -299,8 +299,8 @@
    1.50  
    1.51      seq_info1 = get_seq_info(seq_size_dic1, font, opts.fontsize, image_mode)
    1.52      seq_info2 = get_seq_info(seq_size_dic2, font, opts.fontsize, image_mode)
    1.53 -    seq_names1, seq_sizes1, name_sizes1, margin1 = seq_info1
    1.54 -    seq_names2, seq_sizes2, name_sizes2, margin2 = seq_info2
    1.55 +    seqNames1, seq_sizes1, name_sizes1, margin1 = seq_info1
    1.56 +    seqNames2, seq_sizes2, name_sizes2, margin2 = seq_info2
    1.57  
    1.58      warn("choosing bp per pixel...")
    1.59      pix_limit1 = opts.width  - margin1
    1.60 @@ -314,8 +314,8 @@
    1.61                                                   opts.pix_tween_seqs, margin1)
    1.62      seq_pix2, seq_starts2, height = get_pix_info(seq_sizes2, bp_per_pix,
    1.63                                                   opts.pix_tween_seqs, margin2)
    1.64 -    origins1 = dict(seqOrigins(seq_names1, seq_starts1, bp_per_pix))
    1.65 -    origins2 = dict(seqOrigins(seq_names2, seq_starts2, bp_per_pix))
    1.66 +    origins1 = dict(seqOrigins(seqNames1, seq_starts1, bp_per_pix))
    1.67 +    origins2 = dict(seqOrigins(seqNames2, seq_starts2, bp_per_pix))
    1.68  
    1.69      warn("processing alignments...")
    1.70      hits = alignmentPixels(width, height, alignments, bp_per_pix,
    1.71 @@ -348,9 +348,9 @@
    1.72              elif store_value == 3: im.putpixel(xy, overlap_color)
    1.73  
    1.74      if opts.fontsize != 0:
    1.75 -        axis1 = get_axis_image(seq_names1, name_sizes1, seq_starts1, seq_pix1,
    1.76 +        axis1 = get_axis_image(seqNames1, name_sizes1, seq_starts1, seq_pix1,
    1.77                                 font, image_mode, opts)
    1.78 -        axis2 = get_axis_image(seq_names2, name_sizes2, seq_starts2, seq_pix2,
    1.79 +        axis2 = get_axis_image(seqNames2, name_sizes2, seq_starts2, seq_pix2,
    1.80                                 font, image_mode, opts)
    1.81          axis2 = axis2.transpose(Image.ROTATE_270)  # !!! bug hotspot
    1.82          im.paste(axis1, (0, 0))