Refactoring.
authorMartin C. Frith
Tue Feb 28 17:33:22 2017 +0900 (2017-02-28)
changeset 835cdb1e40c28e4
parent 834 1514199bb31b
child 836 1b4db1600728
Refactoring.
scripts/last-dotplot
     1.1 --- a/scripts/last-dotplot	Tue Feb 28 16:35:02 2017 +0900
     1.2 +++ b/scripts/last-dotplot	Tue Feb 28 17:33:22 2017 +0900
     1.3 @@ -161,23 +161,23 @@
     1.4      tot_pix = seq_starts[-1] + seq_pix[-1]
     1.5      return seq_pix, seq_starts, tot_pix
     1.6  
     1.7 -def drawLineForward(hits, width, bp_per_pix, origin, beg1, beg2, size):
     1.8 +def drawLineForward(hits, width, bp_per_pix, beg1, beg2, size):
     1.9      while True:
    1.10          q1, r1 = divmod(beg1, bp_per_pix)
    1.11          q2, r2 = divmod(beg2, bp_per_pix)
    1.12 -        hits[origin + q2 * width + q1] |= 1
    1.13 +        hits[q2 * width + q1] |= 1
    1.14          next_pix = min(bp_per_pix - r1, bp_per_pix - r2)
    1.15          if next_pix >= size: break
    1.16          beg1 += next_pix
    1.17          beg2 += next_pix
    1.18          size -= next_pix
    1.19  
    1.20 -def drawLineReverse(hits, width, bp_per_pix, origin, beg1, beg2, size):
    1.21 +def drawLineReverse(hits, width, bp_per_pix, beg1, beg2, size):
    1.22      beg2 = -1 - beg2
    1.23      while True:
    1.24          q1, r1 = divmod(beg1, bp_per_pix)
    1.25          q2, r2 = divmod(beg2, bp_per_pix)
    1.26 -        hits[origin + q2 * width + q1] |= 2
    1.27 +        hits[q2 * width + q1] |= 2
    1.28          next_pix = min(bp_per_pix - r1, r2 + 1)
    1.29          if next_pix >= size: break
    1.30          beg1 += next_pix
    1.31 @@ -188,19 +188,18 @@
    1.32                      seq_start_dic1, seq_start_dic2):
    1.33      hits = [0] * (width * height)  # the image data
    1.34      for seq1, seq2, blocks in alignments:
    1.35 -        seq_start1 = seq_start_dic1[seq1]
    1.36 -        seq_start2 = seq_start_dic2[seq2]
    1.37 -        origin = seq_start2 * width + seq_start1
    1.38 +        ori1 = seq_start_dic1[seq1] * bp_per_pix
    1.39 +        ori2 = seq_start_dic2[seq2] * bp_per_pix
    1.40          for beg1, beg2, size in blocks:
    1.41              if beg1 < 0:
    1.42                  beg1 = -(beg1 + size)
    1.43                  beg2 = -(beg2 + size)
    1.44              if beg2 >= 0:
    1.45 -                drawLineForward(hits, width, bp_per_pix, origin,
    1.46 -                                beg1, beg2, size)
    1.47 +                drawLineForward(hits, width, bp_per_pix,
    1.48 +                                beg1 + ori1, beg2 + ori2, size)
    1.49              else:
    1.50 -                drawLineReverse(hits, width, bp_per_pix, origin,
    1.51 -                                beg1, beg2, size)
    1.52 +                drawLineReverse(hits, width, bp_per_pix,
    1.53 +                                beg1 + ori1, beg2 - ori2, size)
    1.54      return hits
    1.55  
    1.56  def expandedSeqDict(seqDict):