Skip to content

Commit

Permalink
Prevent divide-by-zero crash
Browse files Browse the repository at this point in the history
  • Loading branch information
rrwick committed Jan 22, 2022
1 parent f859595 commit 1800212
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions unicycler/bridge_long_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1800212

Please sign in to comment.