1.1 --- a/scripts/last-dotplot Thu May 18 14:46:45 2017 +0900
1.2 +++ b/scripts/last-dotplot Fri Jun 02 18:40:29 2017 +0900
1.3 @@ -202,20 +202,18 @@
1.4 q, r = divmod(x, y)
1.5 return q + (r != 0)
1.6
1.7 -def tot_seq_pix(seq_sizes, bp_per_pix):
1.8 - '''Return the total pixels needed for sequences of the given sizes.'''
1.9 - return sum([div_ceil(i, bp_per_pix) for i in seq_sizes])
1.10 -
1.11 def get_bp_per_pix(seq_sizes, pix_tween_seqs, pix_limit):
1.12 '''Get the minimum bp-per-pixel that fits in the size limit.'''
1.13 seq_num = len(seq_sizes)
1.14 seq_pix_limit = pix_limit - pix_tween_seqs * (seq_num - 1)
1.15 if seq_pix_limit < seq_num:
1.16 raise Exception("can't fit the image: too many sequences?")
1.17 - lower_bound = div_ceil(sum(seq_sizes), seq_pix_limit)
1.18 - for bp_per_pix in itertools.count(lower_bound): # slow linear search
1.19 - if tot_seq_pix(seq_sizes, bp_per_pix) <= seq_pix_limit: break
1.20 - return bp_per_pix
1.21 + negLimit = -seq_pix_limit
1.22 + negBpPerPix = sum(seq_sizes) // negLimit
1.23 + while True:
1.24 + if sum(i // negBpPerPix for i in seq_sizes) >= negLimit:
1.25 + return -negBpPerPix
1.26 + negBpPerPix -= 1
1.27
1.28 def get_seq_starts(seq_pix, pix_tween_seqs, margin):
1.29 '''Get the start pixel for each sequence.'''