Refactoring.
authorMartin C. Frith
Mon Oct 19 11:21:24 2015 +0900 (2015-10-19)
changeset 64250a6e3e00d36
parent 641 281e6460a6a9
child 643 3868726068b0
Refactoring.
scripts/last-dotplot
     1.1 --- a/scripts/last-dotplot	Mon Oct 19 11:13:11 2015 +0900
     1.2 +++ b/scripts/last-dotplot	Mon Oct 19 11:21:24 2015 +0900
     1.3 @@ -229,22 +229,22 @@
     1.4    %prog [options] last-tabular-output dotplot.png
     1.5    %prog [options] last-tabular-output dotplot.gif
     1.6    etc."""
     1.7 -parser = optparse.OptionParser(usage=usage)
     1.8 +op = optparse.OptionParser(usage=usage)
     1.9  # Replace "width" & "height" with a single "length" option?
    1.10 -parser.add_option("-x", "--width", type="int", dest="width", default=1000,
    1.11 -                  help="maximum width in pixels (default: %default)")
    1.12 -parser.add_option("-y", "--height", type="int", dest="height", default=1000,
    1.13 -                  help="maximum height in pixels (default: %default)")
    1.14 -parser.add_option("-f", "--fontfile", dest="fontfile",
    1.15 -                  help="TrueType or OpenType font file")
    1.16 -parser.add_option("-s", "--fontsize", type="int", dest="fontsize", default=11,
    1.17 -                  help="TrueType or OpenType font size (default: %default)")
    1.18 -parser.add_option("-c", "--forwardcolor", dest="forwardcolor", default="red",
    1.19 -                  help="Color for forward alignments (default: %default)")
    1.20 -parser.add_option("-r", "--reversecolor", dest="reversecolor", default="blue",
    1.21 -                  help="Color for reverse alignments (default: %default)")
    1.22 -(opts, args) = parser.parse_args()
    1.23 -if len(args) != 2: parser.error("2 arguments needed")
    1.24 +op.add_option("-x", "--width", type="int", default=1000,
    1.25 +              help="maximum width in pixels (default: %default)")
    1.26 +op.add_option("-y", "--height", type="int", default=1000,
    1.27 +              help="maximum height in pixels (default: %default)")
    1.28 +op.add_option("-f", "--fontfile",
    1.29 +              help="TrueType or OpenType font file")
    1.30 +op.add_option("-s", "--fontsize", type="int", default=11,
    1.31 +              help="TrueType or OpenType font size (default: %default)")
    1.32 +op.add_option("-c", "--forwardcolor", default="red",
    1.33 +              help="Color for forward alignments (default: %default)")
    1.34 +op.add_option("-r", "--reversecolor", default="blue",
    1.35 +              help="Color for reverse alignments (default: %default)")
    1.36 +(opts, args) = op.parse_args()
    1.37 +if len(args) != 2: op.error("2 arguments needed")
    1.38  
    1.39  if opts.fontfile:  font = ImageFont.truetype(opts.fontfile, opts.fontsize)
    1.40  else:              font = ImageFont.load_default()
    1.41 @@ -253,13 +253,14 @@
    1.42  text_color = "black"
    1.43  background_color = "white"
    1.44  pix_tween_seqs = 2  # number of border pixels between sequences
    1.45 -border_shade = 239, 239, 239  # the shade of grey to use for border pixels
    1.46 +border_shade = 239, 239, 239  # the shade of grey for border pixels
    1.47  label_space = 5     # minimum number of pixels between axis labels
    1.48  
    1.49  image_mode = 'RGB'
    1.50  forward_color = ImageColor.getcolor(opts.forwardcolor, image_mode)
    1.51  reverse_color = ImageColor.getcolor(opts.reversecolor, image_mode)
    1.52 -overlap_color = tuple([(i+j)//2 for i, j in zip(forward_color, reverse_color)])
    1.53 +zipped_colors = zip(forward_color, reverse_color)
    1.54 +overlap_color = tuple([(i + j) // 2 for i, j in zipped_colors])
    1.55  
    1.56  sys.stderr.write(my_name + ": reading alignments...\n")
    1.57  input = fileinput.input(args[0])