scripts/last-dotplot
changeset 850 db0ddc92f2ec
parent 847 3ca7aa4b27a8
child 851 5b2acb7fdb3e
     1.1 --- a/scripts/last-dotplot	Tue Apr 04 14:46:49 2017 +0900
     1.2 +++ b/scripts/last-dotplot	Tue May 02 13:18:23 2017 +0900
     1.3 @@ -179,12 +179,14 @@
     1.4      '''Return miscellaneous information about the sequences.'''
     1.5      seqNames = seqLimits.keys()
     1.6      seqNames.sort(key=natural_sort_key)
     1.7 -    seq_sizes = [seqLimits[i][1] - seqLimits[i][0] for i in seqNames]
     1.8 -    if isShowSize: seqLabels = map(seqNameAndSizeText, seqNames, seq_sizes)
     1.9 -    else:          seqLabels = seqNames
    1.10 +    seqSizes = [seqLimits[i][1] - seqLimits[i][0] for i in seqNames]
    1.11 +    if isShowSize:
    1.12 +        seqLabels = map(seqNameAndSizeText, seqNames, seqSizes)
    1.13 +    else:
    1.14 +        seqLabels = seqNames
    1.15      labelSizes = get_text_sizes(seqLabels, font, fontsize, image_mode)
    1.16      margin = max(zip(*labelSizes)[1])  # maximum text height
    1.17 -    return seqNames, seq_sizes, seqLabels, labelSizes, margin
    1.18 +    return seqNames, seqSizes, seqLabels, labelSizes, margin
    1.19  
    1.20  def div_ceil(x, y):
    1.21      '''Return x / y rounded up.'''
    1.22 @@ -396,22 +398,22 @@
    1.23      if not alignments: raise Exception("there are no alignments")
    1.24  
    1.25      i1 = getSeqInfo(seqLimits1, font, opts.fontsize, image_mode, opts.lengths1)
    1.26 -    seqNames1, seq_sizes1, seqLabels1, labelSizes1, margin1 = i1
    1.27 +    seqNames1, seqSizes1, seqLabels1, labelSizes1, margin1 = i1
    1.28  
    1.29      i2 = getSeqInfo(seqLimits2, font, opts.fontsize, image_mode, opts.lengths2)
    1.30 -    seqNames2, seq_sizes2, seqLabels2, labelSizes2, margin2 = i2
    1.31 +    seqNames2, seqSizes2, seqLabels2, labelSizes2, margin2 = i2
    1.32  
    1.33      warn("choosing bp per pixel...")
    1.34      pix_limit1 = opts.width  - margin1
    1.35      pix_limit2 = opts.height - margin2
    1.36 -    bp_per_pix1 = get_bp_per_pix(seq_sizes1, opts.pix_tween_seqs, pix_limit1)
    1.37 -    bp_per_pix2 = get_bp_per_pix(seq_sizes2, opts.pix_tween_seqs, pix_limit2)
    1.38 +    bp_per_pix1 = get_bp_per_pix(seqSizes1, opts.pix_tween_seqs, pix_limit1)
    1.39 +    bp_per_pix2 = get_bp_per_pix(seqSizes2, opts.pix_tween_seqs, pix_limit2)
    1.40      bp_per_pix = max(bp_per_pix1, bp_per_pix2)
    1.41      warn("bp per pixel = " + str(bp_per_pix))
    1.42  
    1.43 -    seq_pix1, seq_starts1, width  = get_pix_info(seq_sizes1, bp_per_pix,
    1.44 +    seq_pix1, seq_starts1, width  = get_pix_info(seqSizes1, bp_per_pix,
    1.45                                                   opts.pix_tween_seqs, margin1)
    1.46 -    seq_pix2, seq_starts2, height = get_pix_info(seq_sizes2, bp_per_pix,
    1.47 +    seq_pix2, seq_starts2, height = get_pix_info(seqSizes2, bp_per_pix,
    1.48                                                   opts.pix_tween_seqs, margin2)
    1.49      warn("width:  " + str(width))
    1.50      warn("height: " + str(height))
    1.51 @@ -494,10 +496,6 @@
    1.52                    help="maximum width in pixels (default: %default)")
    1.53      op.add_option("-y", "--height", type="int", default=1000,
    1.54                    help="maximum height in pixels (default: %default)")
    1.55 -    op.add_option("-f", "--fontfile", metavar="FILE",
    1.56 -                  help="TrueType or OpenType font file")
    1.57 -    op.add_option("-s", "--fontsize", metavar="SIZE", type="int", default=11,
    1.58 -                  help="TrueType or OpenType font size (default: %default)")
    1.59      op.add_option("-c", "--forwardcolor", metavar="COLOR", default="red",
    1.60                    help="color for forward alignments (default: %default)")
    1.61      op.add_option("-r", "--reversecolor", metavar="COLOR", default="blue",
    1.62 @@ -506,15 +504,22 @@
    1.63                    help="trim unaligned sequence flanks from the 1st genome")
    1.64      op.add_option("--trim2", action="store_true",
    1.65                    help="trim unaligned sequence flanks from the 2nd genome")
    1.66 -    op.add_option("--lengths1", action="store_true",
    1.67 -                  help="show sequence lengths for the 1st genome")
    1.68 -    op.add_option("--lengths2", action="store_true",
    1.69 -                  help="show sequence lengths for the 2nd genome")
    1.70      op.add_option("--bed1", metavar="FILE",
    1.71                    help="read genome1 annotations from bed file")
    1.72      op.add_option("--bed2", metavar="FILE",
    1.73                    help="read genome2 annotations from bed file")
    1.74  
    1.75 +    og = optparse.OptionGroup(op, "Text options")
    1.76 +    og.add_option("-f", "--fontfile", metavar="FILE",
    1.77 +                  help="TrueType or OpenType font file")
    1.78 +    og.add_option("-s", "--fontsize", metavar="SIZE", type="int", default=11,
    1.79 +                  help="TrueType or OpenType font size (default: %default)")
    1.80 +    og.add_option("--lengths1", action="store_true",
    1.81 +                  help="show sequence lengths for the 1st (horizontal) genome")
    1.82 +    og.add_option("--lengths2", action="store_true",
    1.83 +                  help="show sequence lengths for the 2nd (vertical) genome")
    1.84 +    op.add_option_group(og)
    1.85 +
    1.86      og = optparse.OptionGroup(op, "Unsequenced gap options")
    1.87      og.add_option("--gap1", metavar="FILE",
    1.88                    help="read genome1 unsequenced gaps from agp or gap file")