Skip to content

Commit

Permalink
Add a safe to avoid ZeroDivision if no HQ MAGs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ABignaud committed Nov 20, 2023
1 parent cb57553 commit 62bc0fa
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions metator/quality_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,17 @@ def hic_quality(
n_informative_inter += 1
else:
n_inter_mags += 1
rat_info = (
100
* (n_informative_intra + n_informative_inter)
/ (n_intra_mags + n_inter_mags)
)
noise_ratio = 100 * n_inter_mags / (n_inter_mags + n_intra_mags)
if n_intra_mags + n_inter_mags > 0:
rat_info = (
100
* (n_informative_intra + n_informative_inter)
/ (n_intra_mags + n_inter_mags)
)
noise_ratio = 100 * n_inter_mags / (n_inter_mags + n_intra_mags)
else:
logger.warning("No pairs have benn extracted. All scores set to 0.")
rat_info = 0
noise_ratio = 0
if n_mags > 1:
noise_score = (n_inter_mags / (n_mags * (n_mags - 1) * 0.5)) / (
n_intra_mags / n_mags + n_inter_mags / (n_mags * (n_mags - 1) * 0.5)
Expand Down

0 comments on commit 62bc0fa

Please sign in to comment.