Add border options to last-dotplot
authorMartin C. Frith
Tue May 02 14:04:09 2017 +0900 (2017-05-02)
changeset 852f3b6c666afad
parent 851 5b2acb7fdb3e
child 853 791ec91ac03c
Add border options to last-dotplot
doc/last-dotplot.txt
scripts/last-dotplot
     1.1 --- a/doc/last-dotplot.txt	Tue May 02 13:35:07 2017 +0900
     1.2 +++ b/doc/last-dotplot.txt	Tue May 02 14:04:09 2017 +0900
     1.3 @@ -81,6 +81,10 @@
     1.4        Trim unaligned sequence flanks from the 1st (horizontal) genome.
     1.5    --trim2
     1.6        Trim unaligned sequence flanks from the 2nd (vertical) genome.
     1.7 +  --border-pixels=INT
     1.8 +      Number of pixels between sequences.
     1.9 +  --border-color=COLOR
    1.10 +      Color for pixels between sequences.
    1.11    --bed1=FILE
    1.12        Read `BED-format
    1.13        <https://genome.ucsc.edu/FAQ/FAQformat.html#format1>`_
     2.1 --- a/scripts/last-dotplot	Tue May 02 13:35:07 2017 +0900
     2.2 +++ b/scripts/last-dotplot	Tue May 02 14:04:09 2017 +0900
     2.3 @@ -379,7 +379,7 @@
     2.4      labels.sort()
     2.5      labels = get_nonoverlapping_labels(labels, opts.label_space)
     2.6      image_size = max_pos, height
     2.7 -    im = Image.new(image_mode, image_size, opts.border_shade)
     2.8 +    im = Image.new(image_mode, image_size, opts.border_color)
     2.9      draw = ImageDraw.Draw(im)
    2.10      for i in labels:
    2.11          position = i[1], 0
    2.12 @@ -417,15 +417,15 @@
    2.13      warn("choosing bp per pixel...")
    2.14      pix_limit1 = opts.width  - margin1
    2.15      pix_limit2 = opts.height - margin2
    2.16 -    bp_per_pix1 = get_bp_per_pix(seqSizes1, opts.pix_tween_seqs, pix_limit1)
    2.17 -    bp_per_pix2 = get_bp_per_pix(seqSizes2, opts.pix_tween_seqs, pix_limit2)
    2.18 +    bp_per_pix1 = get_bp_per_pix(seqSizes1, opts.border_pixels, pix_limit1)
    2.19 +    bp_per_pix2 = get_bp_per_pix(seqSizes2, opts.border_pixels, pix_limit2)
    2.20      bp_per_pix = max(bp_per_pix1, bp_per_pix2)
    2.21      warn("bp per pixel = " + str(bp_per_pix))
    2.22  
    2.23      seq_pix1, seq_starts1, width  = get_pix_info(seqSizes1, bp_per_pix,
    2.24 -                                                 opts.pix_tween_seqs, margin1)
    2.25 +                                                 opts.border_pixels, margin1)
    2.26      seq_pix2, seq_starts2, height = get_pix_info(seqSizes2, bp_per_pix,
    2.27 -                                                 opts.pix_tween_seqs, margin2)
    2.28 +                                                 opts.border_pixels, margin2)
    2.29      warn("width:  " + str(width))
    2.30      warn("height: " + str(height))
    2.31  
    2.32 @@ -480,12 +480,12 @@
    2.33          im.paste(axis2, (0, 0))
    2.34  
    2.35      for i in seq_starts1[1:]:
    2.36 -        box = i - opts.pix_tween_seqs, margin2, i, height
    2.37 -        im.paste(opts.border_shade, box)
    2.38 +        box = i - opts.border_pixels, margin2, i, height
    2.39 +        im.paste(opts.border_color, box)
    2.40  
    2.41      for i in seq_starts2[1:]:
    2.42 -        box = margin1, i - opts.pix_tween_seqs, width, i
    2.43 -        im.paste(opts.border_shade, box)
    2.44 +        box = margin1, i - opts.border_pixels, width, i
    2.45 +        im.paste(opts.border_color, box)
    2.46  
    2.47      im.save(args[1])
    2.48  
    2.49 @@ -521,6 +521,11 @@
    2.50                    help="trim unaligned sequence flanks from the 1st genome")
    2.51      op.add_option("--trim2", action="store_true",
    2.52                    help="trim unaligned sequence flanks from the 2nd genome")
    2.53 +    op.add_option("--border-pixels", metavar="INT", type="int", default=1,
    2.54 +                  help="number of pixels between sequences (default=%default)")
    2.55 +    op.add_option("--border-color", metavar="COLOR", default="#dcdcdc",
    2.56 +                  help="color for pixels between sequences (default=%default)")
    2.57 +    # xxx --margin-color?
    2.58      op.add_option("--bed1", metavar="FILE",
    2.59                    help="read genome1 annotations from bed file")
    2.60      op.add_option("--bed2", metavar="FILE",
    2.61 @@ -552,8 +557,6 @@
    2.62  
    2.63      opts.text_color = "black"
    2.64      opts.background_color = "white"
    2.65 -    opts.pix_tween_seqs = 2  # number of border pixels between sequences
    2.66 -    opts.border_shade = 239, 239, 239  # the shade of grey for border pixels
    2.67      opts.label_space = 5     # minimum number of pixels between axis labels
    2.68  
    2.69      try: lastDotplot(opts, args)