scripts/last-dotplot
changeset 646 504ecca38a3e
parent 645 9daf814fa381
child 647 25c8084d7f6e
     1.1 --- a/scripts/last-dotplot	Mon Oct 19 11:43:47 2015 +0900
     1.2 +++ b/scripts/last-dotplot	Mon Oct 19 11:48:25 2015 +0900
     1.3 @@ -218,13 +218,13 @@
     1.4                zip(seq_names, name_sizes, seq_starts, seq_pix)]
     1.5      labels = [i for i in labels if i[1] >= min_pos and i[2] <= max_pos]
     1.6      labels.sort()
     1.7 -    labels = get_nonoverlapping_labels(labels, label_space)
     1.8 +    labels = get_nonoverlapping_labels(labels, opts.label_space)
     1.9      image_size = max_pos, height
    1.10 -    im = Image.new(image_mode, image_size, border_shade)
    1.11 +    im = Image.new(image_mode, image_size, opts.border_shade)
    1.12      draw = ImageDraw.Draw(im)
    1.13      for i in labels:
    1.14          position = i[1], 0
    1.15 -        draw.text(position, i[3], font=font, fill=text_color)
    1.16 +        draw.text(position, i[3], font=font, fill=opts.text_color)
    1.17      return im
    1.18  
    1.19  if __name__ == "__main__":
    1.20 @@ -254,12 +254,11 @@
    1.21      if opts.fontfile:  font = ImageFont.truetype(opts.fontfile, opts.fontsize)
    1.22      else:              font = ImageFont.load_default()
    1.23  
    1.24 -    # Make these options too?
    1.25 -    text_color = "black"
    1.26 -    background_color = "white"
    1.27 -    pix_tween_seqs = 2  # number of border pixels between sequences
    1.28 -    border_shade = 239, 239, 239  # the shade of grey for border pixels
    1.29 -    label_space = 5     # minimum number of pixels between axis labels
    1.30 +    opts.text_color = "black"
    1.31 +    opts.background_color = "white"
    1.32 +    opts.pix_tween_seqs = 2  # number of border pixels between sequences
    1.33 +    opts.border_shade = 239, 239, 239  # the shade of grey for border pixels
    1.34 +    opts.label_space = 5     # minimum number of pixels between axis labels
    1.35  
    1.36      image_mode = 'RGB'
    1.37      forward_color = ImageColor.getcolor(opts.forwardcolor, image_mode)
    1.38 @@ -281,15 +280,15 @@
    1.39      warn("choosing bp per pixel...")
    1.40      pix_limit1 = opts.width  - margin1
    1.41      pix_limit2 = opts.height - margin2
    1.42 -    bp_per_pix1 = get_bp_per_pix(seq_sizes1, pix_tween_seqs, pix_limit1)
    1.43 -    bp_per_pix2 = get_bp_per_pix(seq_sizes2, pix_tween_seqs, pix_limit2)
    1.44 +    bp_per_pix1 = get_bp_per_pix(seq_sizes1, opts.pix_tween_seqs, pix_limit1)
    1.45 +    bp_per_pix2 = get_bp_per_pix(seq_sizes2, opts.pix_tween_seqs, pix_limit2)
    1.46      bp_per_pix = max(bp_per_pix1, bp_per_pix2)
    1.47      warn("bp per pixel = " + str(bp_per_pix))
    1.48  
    1.49      seq_pix1, seq_starts1, width  = get_pix_info(seq_sizes1, bp_per_pix,
    1.50 -                                                 pix_tween_seqs, margin1)
    1.51 +                                                 opts.pix_tween_seqs, margin1)
    1.52      seq_pix2, seq_starts2, height = get_pix_info(seq_sizes2, bp_per_pix,
    1.53 -                                                 pix_tween_seqs, margin2)
    1.54 +                                                 opts.pix_tween_seqs, margin2)
    1.55      seq_start_dic1 = dict(zip(seq_names1, seq_starts1))
    1.56      seq_start_dic2 = dict(zip(seq_names2, seq_starts2))
    1.57  
    1.58 @@ -299,7 +298,7 @@
    1.59      warn("done")
    1.60  
    1.61      image_size = width, height
    1.62 -    im = Image.new(image_mode, image_size, background_color)
    1.63 +    im = Image.new(image_mode, image_size, opts.background_color)
    1.64  
    1.65      for i in range(height):
    1.66          for j in range(width):
    1.67 @@ -317,11 +316,11 @@
    1.68          im.paste(axis2, (0, 0))
    1.69  
    1.70      for i in seq_starts1[1:]:
    1.71 -        box = i - pix_tween_seqs, margin2, i, height
    1.72 -        im.paste(border_shade, box)
    1.73 +        box = i - opts.pix_tween_seqs, margin2, i, height
    1.74 +        im.paste(opts.border_shade, box)
    1.75  
    1.76      for i in seq_starts2[1:]:
    1.77 -        box = margin1, i - pix_tween_seqs, width, i
    1.78 -        im.paste(border_shade, box)
    1.79 +        box = margin1, i - opts.pix_tween_seqs, width, i
    1.80 +        im.paste(opts.border_shade, box)
    1.81  
    1.82      im.save(args[1])