Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZeroDivisionError in whatshap stats when heterozygous variants are absent on one of the contigs #470

Closed
mhulsman opened this issue Jul 12, 2023 · 1 comment · Fixed by #471

Comments

@mhulsman
Copy link

Whatshap stats (using version 2.0) generates an ZeroDivisionError exception if there is no heterozygous variant on one of the contigs.

Command line: whatshap stats whatshap_phased.vcf > phase.stats
Results in:

Traceback (most recent call last):
File "/home/hulsmanm/.snakemake/3846fa4274a6ef7f4cc91bf7fe3c9b94_/bin/whatshap", line 10, in
sys.exit(main())
File "/home/hulsmanm/.snakemake/3846fa4274a6ef7f4cc91bf7fe3c9b94_/lib/python3.10/site-packages/whatshap/main.py", line 64, in main
module.main(args)
File "/home/hulsmanm/.snakemake/3846fa4274a6ef7f4cc91bf7fe3c9b94_/lib/python3.10/site-packages/whatshap/cli/stats.py", line 565, in main
run_stats(**vars(args))
File "/home/hulsmanm/.snakemake/3846fa4274a6ef7f4cc91bf7fe3c9b94_/lib/python3.10/site-packages/whatshap/cli/stats.py", line 544, in run_stats
detailed_stats = stats.get_detailed_stats(chr_lengths)
File "/home/hulsmanm/.snakemake/3846fa4274a6ef7f4cc91bf7fe3c9b94_/lib/python3.10/site-packages/whatshap/cli/stats.py", line 316, in get_detailed_stats
phased_snvs_fraction=phased_snvs / self.heterozygous_snvs,
ZeroDivisionError: division by zero

Information:

  • WhatsHap version 2.0, Python version 3.10
  • Installed with conda
@pontushojer
Copy link
Collaborator

Yes, getting the ZeroDivisionError is not very useful here. I implemented a fix in PR #471. Now stats should be generated regardless if you don't have any heterozygous or phased variants in your VCF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants