scripts/last-dotplot
changeset 913 e87abc7ae9c6
parent 912 8834139fa8a8
child 914 f4ca19d126e3
     1.1 --- a/scripts/last-dotplot	Wed Nov 08 18:14:51 2017 +0900
     1.2 +++ b/scripts/last-dotplot	Tue Dec 05 13:41:22 2017 +0900
     1.3 @@ -269,8 +269,9 @@
     1.4  def sizeKey(oneSeqRanges):
     1.5      return sum(b - e for n, b, e in oneSeqRanges), nameKey(oneSeqRanges)
     1.6  
     1.7 -def getSortedRanges(seqRanges, sortOpt):
     1.8 -    g = [list(v) for k, v in itertools.groupby(seqRanges, itemgetter(0))]
     1.9 +def mySortedRanges(seqRanges, sortOpt):
    1.10 +    rangesGroupedBySeqName = itertools.groupby(seqRanges, itemgetter(0))
    1.11 +    g = [list(ranges) for seqName, ranges in rangesGroupedBySeqName]
    1.12      if sortOpt == "1":
    1.13          g.sort(key=nameKey)
    1.14      if sortOpt == "2":
    1.15 @@ -279,7 +280,7 @@
    1.16  
    1.17  def allSortedRanges(seqRanges, seqRangesB, sortOpt):
    1.18      x, y = twoValuesFromOption(sortOpt, ":")
    1.19 -    return getSortedRanges(seqRanges, x) + getSortedRanges(seqRangesB, y)
    1.20 +    return mySortedRanges(seqRanges, x) + mySortedRanges(seqRangesB, y)
    1.21  
    1.22  def prettyNum(n):
    1.23      t = str(n)
    1.24 @@ -323,16 +324,17 @@
    1.25          yield text, x, y
    1.26  
    1.27  def dataFromRanges(cutRanges, cutRangesB, sortOpt, font,
    1.28 -                   fontsize, image_mode, labelOpt, textRot):
    1.29 -    s = allSortedRanges(cutRanges, cutRangesB, sortOpt)
    1.30 -    for i in s:
    1.31 +                   fontSize, imageMode, labelOpt, textRot):
    1.32 +    sortedRanges = allSortedRanges(cutRanges, cutRangesB, sortOpt)
    1.33 +    for i in sortedRanges:
    1.34          warn("\t".join(map(str, i)))
    1.35      warn("")
    1.36 -    rangeSizes = [e - b for n, b, e in s]
    1.37 -    labs = list(rangeLabels(s, labelOpt, font, fontsize, image_mode, textRot))
    1.38 +    rangeSizes = [e - b for n, b, e in sortedRanges]
    1.39 +    labs = list(rangeLabels(sortedRanges, labelOpt, font, fontSize,
    1.40 +                            imageMode, textRot))
    1.41      margin = max(i[2] for i in labs)
    1.42      # xxx the margin may be too big, because some labels may get omitted
    1.43 -    return s, rangeSizes, labs, margin
    1.44 +    return sortedRanges, rangeSizes, labs, margin
    1.45  
    1.46  def div_ceil(x, y):
    1.47      '''Return x / y rounded up.'''