scripts/last-dotplot
changeset 1069 da8b081ec496
parent 1068 a29f9cec16e1
child 1070 6cf9358f80da
     1.1 --- a/scripts/last-dotplot	Thu Jul 30 21:14:13 2020 +0900
     1.2 +++ b/scripts/last-dotplot	Thu Jul 30 21:25:14 2020 +0900
     1.3 @@ -614,7 +614,8 @@
     1.4      for line in myOpen(fileName):
     1.5          fields = line.split()
     1.6          if not fields: continue
     1.7 -        if fields[2] not in "+-": fields = fields[1:]
     1.8 +        if fields[2] not in "+-":
     1.9 +            fields = fields[1:]
    1.10          seqName = fields[1]
    1.11          if seqName not in rangeDict: continue
    1.12          #strand = fields[2]
    1.13 @@ -765,10 +766,10 @@
    1.14              origin = bpPerPix * j - rangeBeg
    1.15          yield seqName, (rangeBeg, rangeEnd, isReverseRange, origin)
    1.16  
    1.17 -def rangesPerSeq(sortedRanges, rangePixBegs, rangePixLens, bpPerPix):
    1.18 +def rangesAndOriginsPerSeq(sortedRanges, rangePixBegs, rangePixLens, bpPerPix):
    1.19      a = rangesWithOrigins(sortedRanges, rangePixBegs, rangePixLens, bpPerPix)
    1.20 -    for k, v in itertools.groupby(a, itemgetter(0)):
    1.21 -        yield k, sorted(i[1] for i in v)
    1.22 +    for seqName, group in itertools.groupby(a, itemgetter(0)):
    1.23 +        yield seqName, sorted(i[1] for i in group)
    1.24  
    1.25  def getFont(opts):
    1.26      if opts.fontfile:
    1.27 @@ -883,13 +884,13 @@
    1.28  
    1.29      p1 = pixelData(rangeSizes1, bpPerPix, opts.border_pixels, lMargin)
    1.30      rangePixBegs1, rangePixLens1, width = p1
    1.31 -    rangeDict1 = dict(rangesPerSeq(sortedRanges1, rangePixBegs1,
    1.32 -                                   rangePixLens1, bpPerPix))
    1.33 +    rangeDict1 = dict(rangesAndOriginsPerSeq(sortedRanges1, rangePixBegs1,
    1.34 +                                             rangePixLens1, bpPerPix))
    1.35  
    1.36      p2 = pixelData(rangeSizes2, bpPerPix, opts.border_pixels, tMargin)
    1.37      rangePixBegs2, rangePixLens2, height = p2
    1.38 -    rangeDict2 = dict(rangesPerSeq(sortedRanges2, rangePixBegs2,
    1.39 -                                   rangePixLens2, bpPerPix))
    1.40 +    rangeDict2 = dict(rangesAndOriginsPerSeq(sortedRanges2, rangePixBegs2,
    1.41 +                                             rangePixLens2, bpPerPix))
    1.42  
    1.43      logging.info("width:  " + str(width))
    1.44      logging.info("height: " + str(height))
    1.45 @@ -906,16 +907,16 @@
    1.46                              readRmsk(opts.rmsk1, rangeDict1),
    1.47                              readGenePred(opts, opts.genePred1, rangeDict1),
    1.48                              readGaps(opts, opts.gap1, rangeDict1))
    1.49 -    b1 = bedBoxes(beds1, rangeDict1, tMargin, height, True, bpPerPix)
    1.50 +    boxes1 = bedBoxes(beds1, rangeDict1, tMargin, height, True, bpPerPix)
    1.51  
    1.52      rangeDict2 = expandedSeqDict(rangeDict2)
    1.53      beds2 = itertools.chain(readBed(opts.bed2, rangeDict2),
    1.54                              readRmsk(opts.rmsk2, rangeDict2),
    1.55                              readGenePred(opts, opts.genePred2, rangeDict2),
    1.56                              readGaps(opts, opts.gap2, rangeDict2))
    1.57 -    b2 = bedBoxes(beds2, rangeDict2, lMargin, width, False, bpPerPix)
    1.58 +    boxes2 = bedBoxes(beds2, rangeDict2, lMargin, width, False, bpPerPix)
    1.59  
    1.60 -    boxes = sorted(itertools.chain(b1, b2))
    1.61 +    boxes = sorted(itertools.chain(boxes1, boxes2))
    1.62  
    1.63      logging.info("drawing...")
    1.64