Skip to content

Commit

Permalink
Merge pull request #13 from pontushojer/fix-12
Browse files Browse the repository at this point in the history
Fix ZeroDivisionError when no mapped pairs on contig
  • Loading branch information
pontushojer committed May 23, 2024
2 parents 272c483 + 3af32ce commit 7b99a8b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/naibr/get_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ def parse_chromosome(chrom, configs):
# - Otherwise calculate accurately across each chromosome (or subsection).
coverage = cov / (reads_end - reads_start)
logger.info(f"Done reading chromosome {chrom}: coverage = {coverage:.3f}X")
fraction_conc = n_conc / n_total if n_total != 0 else 0
fraction_disc = n_disc / n_total if n_total != 0 else 0
logger.info(
f"{chrom}: total pairs: {n_total:,}, discordant: {n_disc:,} ({n_disc/n_total:.2%}), "
f"concordant: {n_conc:,} ({n_conc/n_total:.2%})"
f"{chrom}: total pairs: {n_total:,}, discordant: {n_disc:,} ({fraction_disc:.2%}), "
f"concordant: {n_conc:,} ({fraction_conc:.2%})"
)

return (
Expand Down

0 comments on commit 7b99a8b

Please sign in to comment.