scripts/last-dotplot
changeset 640 374bc3ee1115
parent 639 047baa399047
child 641 281e6460a6a9
     1.1 --- a/scripts/last-dotplot	Mon Oct 19 10:53:05 2015 +0900
     1.2 +++ b/scripts/last-dotplot	Mon Oct 19 11:09:26 2015 +0900
     1.3 @@ -229,23 +229,28 @@
     1.4          beg2 -= next_pix
     1.5          size -= next_pix
     1.6  
     1.7 -hits = [0] * (width * height)  # the image data
     1.8 +def alignmentPixels(width, height, alignments, bp_per_pix,
     1.9 +                    seq_start_dic1, seq_start_dic2):
    1.10 +    hits = [0] * (width * height)  # the image data
    1.11 +    for seq1, seq2, blocks in alignments:
    1.12 +        seq_start1 = seq_start_dic1[seq1]
    1.13 +        seq_start2 = seq_start_dic2[seq2]
    1.14 +        origin = seq_start2 * width + seq_start1
    1.15 +        for beg1, beg2, size in blocks:
    1.16 +            if beg1 < 0:
    1.17 +                beg1 = -(beg1 + size)
    1.18 +                beg2 = -(beg2 + size)
    1.19 +            if beg2 >= 0:
    1.20 +                drawLineForward(hits, width, bp_per_pix, origin,
    1.21 +                                beg1, beg2, size)
    1.22 +            else:
    1.23 +                drawLineReverse(hits, width, bp_per_pix, origin,
    1.24 +                                beg1, beg2, size)
    1.25 +    return hits
    1.26  
    1.27  sys.stderr.write(my_name + ": processing alignments...\n")
    1.28 -for seq1, seq2, blocks in alignments:
    1.29 -    seq_start1 = seq_start_dic1[seq1]
    1.30 -    seq_start2 = seq_start_dic2[seq2]
    1.31 -    my_start = seq_start2 * width + seq_start1
    1.32 -    for beg1, beg2, size in blocks:
    1.33 -        if beg1 < 0:
    1.34 -            beg1 = -(beg1 + size)
    1.35 -            beg2 = -(beg2 + size)
    1.36 -        if beg2 >= 0:
    1.37 -            drawLineForward(hits, width, bp_per_pix, my_start,
    1.38 -                            beg1, beg2, size)
    1.39 -        else:
    1.40 -            drawLineReverse(hits, width, bp_per_pix, my_start,
    1.41 -                            beg1, beg2, size)
    1.42 +hits = alignmentPixels(width, height, alignments, bp_per_pix,
    1.43 +                       seq_start_dic1, seq_start_dic2)
    1.44  sys.stderr.write(my_name + ": done\n")
    1.45  
    1.46  def make_label(text, text_size, range_start, range_size):