scripts/last-dotplot
changeset 644 08cf5e7f1629
parent 643 3868726068b0
child 645 9daf814fa381
     1.1 --- a/scripts/last-dotplot	Mon Oct 19 11:25:48 2015 +0900
     1.2 +++ b/scripts/last-dotplot	Mon Oct 19 11:30:34 2015 +0900
     1.3 @@ -15,6 +15,10 @@
     1.4  try: from PIL import Image, ImageDraw, ImageFont, ImageColor
     1.5  except ImportError: import Image, ImageDraw, ImageFont, ImageColor
     1.6  
     1.7 +def warn(message):
     1.8 +    prog = os.path.basename(sys.argv[0])
     1.9 +    sys.stderr.write(prog + ": " + message + "\n")
    1.10 +
    1.11  def tabBlocks(beg1, beg2, blocks):
    1.12      '''Get the gapless blocks of an alignment, from LAST tabular format.'''
    1.13      for i in blocks.split(","):
    1.14 @@ -263,10 +267,10 @@
    1.15      zipped_colors = zip(forward_color, reverse_color)
    1.16      overlap_color = tuple([(i + j) // 2 for i, j in zipped_colors])
    1.17  
    1.18 -    sys.stderr.write(my_name + ": reading alignments...\n")
    1.19 +    warn("reading alignments...")
    1.20      input = fileinput.input(args[0])
    1.21      alignments, seq_size_dic1, seq_size_dic2 = readAlignments(input)
    1.22 -    sys.stderr.write(my_name + ": done\n")
    1.23 +    warn("done")
    1.24  
    1.25      if not alignments:
    1.26          sys.exit(my_name + ": there are no alignments")
    1.27 @@ -274,21 +278,21 @@
    1.28      seq_names1, seq_sizes1, name_sizes1, margin1 = get_seq_info(seq_size_dic1)
    1.29      seq_names2, seq_sizes2, name_sizes2, margin2 = get_seq_info(seq_size_dic2)
    1.30  
    1.31 -    sys.stderr.write(my_name + ": choosing bp per pixel...\n")
    1.32 +    warn("choosing bp per pixel...")
    1.33      bp_per_pix1 = get_bp_per_pix(seq_sizes1, opts.width  - margin1)
    1.34      bp_per_pix2 = get_bp_per_pix(seq_sizes2, opts.height - margin2)
    1.35      bp_per_pix = max(bp_per_pix1, bp_per_pix2)
    1.36 -    sys.stderr.write(my_name + ": bp per pixel = " + str(bp_per_pix) + "\n")
    1.37 +    warn("bp per pixel = " + str(bp_per_pix))
    1.38  
    1.39      seq_pix1, seq_starts1, width  = get_pix_info(seq_sizes1, margin1)
    1.40      seq_pix2, seq_starts2, height = get_pix_info(seq_sizes2, margin2)
    1.41      seq_start_dic1 = dict(zip(seq_names1, seq_starts1))
    1.42      seq_start_dic2 = dict(zip(seq_names2, seq_starts2))
    1.43  
    1.44 -    sys.stderr.write(my_name + ": processing alignments...\n")
    1.45 +    warn("processing alignments...")
    1.46      hits = alignmentPixels(width, height, alignments, bp_per_pix,
    1.47                             seq_start_dic1, seq_start_dic2)
    1.48 -    sys.stderr.write(my_name + ": done\n")
    1.49 +    warn("done")
    1.50  
    1.51      image_size = width, height
    1.52      im = Image.new(image_mode, image_size, background_color)