[go: nahoru, domu]

Skip to content

Commit

Permalink
fixed ZerroDivisionError for VCFs without SNVs or INDELs
Browse files Browse the repository at this point in the history
  • Loading branch information
LindoNkambule committed Nov 5, 2019
1 parent 518aee1 commit 39fe23e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
11 changes: 6 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Todo list for VCFCompare
====

##Tasks
## Tasks

- [ ] 1. Add png output for upset plots. The current output format is PDF
- [ ] 2. Currently, the program assumes both the truth and query VCF files contain both SNVs and INDELs. If one (or both, SNVs and INDELs) are not present in the of two files, you will get a ZeroDivisionError
- [ ] 3. Write a function for handling no-ALT alleles
- [ ] 4. Write a function for genotype concordance
- [ ] 1. Parallelize the comparison for SNVs and INDELs to save time
- [ ] 2. Add png output for upset plots. The current output format is PDF
- [x] 3. Currently, the program assumes both the truth and query VCF files contain both SNVs and INDELs. If one or both (SNVs and INDELs) are not present in the two files, you will get a ZeroDivisionError
- [ ] 4. Write a function for handling no-ALT alleles
- [ ] 5. Write a function for genotype concordance
19 changes: 12 additions & 7 deletions src/python/VCFCompare.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,25 @@ def main():
lensfp = len(sfp)
lensfn = len(sfn)

snvRecall = lenstp/(lenstp+lensfn)
snvPrecision = lenstp/(lenstp+lensfp)
try:
snvRecall = lenstp/(lenstp+lensfn)
snvPrecision = lenstp/(lenstp+lensfp)
snv.extend(('SNV', truthSNVs, lenstp, lensfp, lensfn, querySNVs, snvRecall, snvPrecision))
except Exception:
print("No SNVs were detected in one or both the files")

#2.INDELs
itp, ifp, ifn = fun.variantCalls(tindel, qindel)
lenitp = len(itp)
lenifp = len(ifp)
lenifn = len(ifn)

indelRecall = lenitp/(lenitp+lenifn)
indelPrecision = lenitp/(lenitp+lenifp)

snv.extend(('SNV', truthSNVs, lenstp, lensfp, lensfn, querySNVs, snvRecall, snvPrecision))
indel.extend(('INDEL', truthINDELs, lenitp, lenifn, lenifn, queryINDELs, indelRecall, indelPrecision))
try:
indelRecall = lenitp/(lenitp+lenifn)
indelPrecision = lenitp/(lenitp+lenifp)
indel.extend(('INDEL', truthINDELs, lenitp, lenifn, lenifn, queryINDELs, indelRecall, indelPrecision))
except Exception:
print("No INDELs were detected in one or both the files")

csvfile = args.output + ".csv"
with open(csvfile, "w", newline='') as f:
Expand Down

0 comments on commit 39fe23e

Please sign in to comment.