Skip to content

Commit

Permalink
fix division by 0 error during realignment step. Fixes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
iprada committed Mar 10, 2021
1 parent a1d9de1 commit ed88ff6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions circlemap/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1107,9 +1107,13 @@ def realignment_probability(hit_dict,interval_length):
best_hit = hit_dict['alignments'][1][2]

#this might be included on the denominator

posterior = 2**best_hit/(np.sum((2**value[2]) for key,value in hit_dict['alignments'].items()))

try:
posterior = 2**best_hit/(np.sum((2**value[2]) for key,value in hit_dict['alignments'].items()))
except ZeroDivisionError as e:
print(e)
warnings.warn("ZeroDivisionError caught while computing the realignment posterior probability."
"Setting posterior probability to 0")
posterior = 0
return(posterior)


Expand Down

0 comments on commit ed88ff6

Please sign in to comment.