Skip to content

Commit

Permalink
Switch of "smart chromosome layout" when using a custom layout.
Browse files Browse the repository at this point in the history
  • Loading branch information
josiahseaman committed Jan 7, 2020
1 parent 7d7db29 commit 6fbc522
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions FluentDNA/TileLayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def __init__(self, use_titles=True, sort_contigs=False,
self.image_length = 0

modulos, padding = parse_custom_layout(custom_layout)
if not modulos:
self.using_custom_layout = bool(modulos)
if not self.using_custom_layout:
chromosome_max_height_nRows = 6
modulos = [base_width, base_width * 10, 100, chromosome_max_height_nRows, 999]
padding = [0, 0, 3, 9, 777, ]
Expand Down Expand Up @@ -330,7 +331,8 @@ def calc_padding(self, total_progress, next_segment_length):
# fill out the remainder so we can start at the beginning
reset_padding = reset_level.chunk_size - total_progress % reset_level.chunk_size
megarow_chunk = self.levels[3].chunk_size
if space_remaining > 1 \
if (not self.using_custom_layout) \
and space_remaining > 1 \
and reset_padding == 1 \
and next_segment_length > megarow_chunk * 2:
reset_padding += megarow_chunk
Expand Down Expand Up @@ -613,6 +615,8 @@ def remember_contig_spacing(self):
def find_layout_height_by_chromosomes(self):
"""Set the number of mega-rows and the height of the layout.
Returns a new layout based on the current fasta file."""
if self.using_custom_layout:
return self.levels
lengths = [len(c.seq) for c in self.contigs]
sum_length, biggest_chromosome = sum(lengths), max(lengths)
nMegaRows = math.ceil(biggest_chromosome / self.megarow_label_size)
Expand Down

0 comments on commit 6fbc522

Please sign in to comment.