From 1800212eb15170dcab99268c03dd3a62a8aa1595 Mon Sep 17 00:00:00 2001 From: Ryan Wick Date: Sat, 22 Jan 2022 16:00:33 +1100 Subject: [PATCH] Prevent divide-by-zero crash --- unicycler/bridge_long_read.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/unicycler/bridge_long_read.py b/unicycler/bridge_long_read.py index c66787fc..fa8953d3 100644 --- a/unicycler/bridge_long_read.py +++ b/unicycler/bridge_long_read.py @@ -296,8 +296,11 @@ def finalise(self, scoring_scheme, min_alignment_length, read_lengths, estimated # The number of reads which contribute to a bridge is a big deal, so the read count factor # scales linearly. This value is capped at 1, which means that bridges with too few reads # are punished but bridges with excess reads are not rewarded. - read_count_factor = min(1.0, actual_read_count / expected_read_count) - self.quality *= read_count_factor + try: + read_count_factor = min(1.0, actual_read_count / expected_read_count) + self.quality *= read_count_factor + except ZeroDivisionError: + pass # The length of alignments to the start/end segments is positively correlated with quality # to reward bridges with long alignments. Specifically, we want there to be at least one