Just changed last-dotplot's help messages a bit.
authorMartin C. Frith
Mon Oct 19 13:54:50 2015 +0900 (2015-10-19)
changeset 64994f7cda3507b
parent 648 33e285b3e428
child 650 157301c5c6fd
Just changed last-dotplot's help messages a bit.
scripts/last-dotplot
     1.1 --- a/scripts/last-dotplot	Mon Oct 19 12:34:17 2015 +0900
     1.2 +++ b/scripts/last-dotplot	Mon Oct 19 13:54:50 2015 +0900
     1.3 @@ -127,7 +127,7 @@
     1.4      seq_num = len(seq_sizes)
     1.5      seq_pix_limit = pix_limit - pix_tween_seqs * (seq_num - 1)
     1.6      if seq_pix_limit < seq_num:
     1.7 -        sys.exit(my_name + ": can't fit the image: too many sequences?")
     1.8 +        raise Exception("can't fit the image: too many sequences?")
     1.9      lower_bound = div_ceil(sum(seq_sizes), seq_pix_limit)
    1.10      for bp_per_pix in itertools.count(lower_bound):  # slow linear search
    1.11          if tot_seq_pix(seq_sizes, bp_per_pix) <= seq_pix_limit: break
    1.12 @@ -243,8 +243,7 @@
    1.13      alignments, seq_size_dic1, seq_size_dic2 = readAlignments(input)
    1.14      warn("done")
    1.15  
    1.16 -    if not alignments:
    1.17 -        sys.exit(my_name + ": there are no alignments")
    1.18 +    if not alignments: raise Exception("there are no alignments")
    1.19  
    1.20      seq_info1 = get_seq_info(seq_size_dic1, font, opts.fontsize, image_mode)
    1.21      seq_info2 = get_seq_info(seq_size_dic2, font, opts.fontsize, image_mode)
    1.22 @@ -302,26 +301,25 @@
    1.23      im.save(args[1])
    1.24  
    1.25  if __name__ == "__main__":
    1.26 -    my_name = os.path.basename(sys.argv[0])
    1.27 -    usage = """
    1.28 -  %prog --help
    1.29 -  %prog [options] last-tabular-output dotplot.png
    1.30 -  %prog [options] last-tabular-output dotplot.gif
    1.31 -  etc."""
    1.32 -    op = optparse.OptionParser(usage=usage)
    1.33 +    usage = """%prog --help
    1.34 +   or: %prog [options] maf-or-tab-alignments dotplot.png
    1.35 +   or: %prog [options] maf-or-tab-alignments dotplot.gif
    1.36 +   or: ..."""
    1.37 +    description = "Draw a dotplot of pair-wise sequence alignments in MAF or tabular format."
    1.38 +    op = optparse.OptionParser(usage=usage, description=description)
    1.39      # Replace "width" & "height" with a single "length" option?
    1.40      op.add_option("-x", "--width", type="int", default=1000,
    1.41                    help="maximum width in pixels (default: %default)")
    1.42      op.add_option("-y", "--height", type="int", default=1000,
    1.43                    help="maximum height in pixels (default: %default)")
    1.44 -    op.add_option("-f", "--fontfile",
    1.45 +    op.add_option("-f", "--fontfile", metavar="FILE",
    1.46                    help="TrueType or OpenType font file")
    1.47 -    op.add_option("-s", "--fontsize", type="int", default=11,
    1.48 +    op.add_option("-s", "--fontsize", metavar="SIZE", type="int", default=11,
    1.49                    help="TrueType or OpenType font size (default: %default)")
    1.50 -    op.add_option("-c", "--forwardcolor", default="red",
    1.51 -                  help="Color for forward alignments (default: %default)")
    1.52 -    op.add_option("-r", "--reversecolor", default="blue",
    1.53 -                  help="Color for reverse alignments (default: %default)")
    1.54 +    op.add_option("-c", "--forwardcolor", metavar="COLOR", default="red",
    1.55 +                  help="color for forward alignments (default: %default)")
    1.56 +    op.add_option("-r", "--reversecolor", metavar="COLOR", default="blue",
    1.57 +                  help="color for reverse alignments (default: %default)")
    1.58      (opts, args) = op.parse_args()
    1.59      if len(args) != 2: op.error("2 arguments needed")
    1.60  
    1.61 @@ -331,4 +329,8 @@
    1.62      opts.border_shade = 239, 239, 239  # the shade of grey for border pixels
    1.63      opts.label_space = 5     # minimum number of pixels between axis labels
    1.64  
    1.65 -    lastDotplot(opts, args)
    1.66 +    try: lastDotplot(opts, args)
    1.67 +    except KeyboardInterrupt: pass  # avoid silly error message
    1.68 +    except Exception, e:
    1.69 +        prog = os.path.basename(sys.argv[0])
    1.70 +        sys.exit(prog + ": error: " + str(e))