# HG changeset patch # User iuc # Date 1602867875 0 # Node ID 22f6a0e7424f42bfecc5109e2454df187cfd1b77 # Parent 5901bb39119817c7cac5f76108ab48b22f995906 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/medaka commit 13769e7d51b30a1d15eb62a9ba89ee2064f3ddc3" diff -r 5901bb391198 -r 22f6a0e7424f annotateVCF.py --- a/annotateVCF.py Tue Oct 13 15:59:31 2020 +0000 +++ b/annotateVCF.py Fri Oct 16 17:04:35 2020 +0000 @@ -75,6 +75,7 @@ ins_str += base else: ins_len = int(ins_str) - 1 + ins_str = "" insertion = base ins_flag = False elif del_flag: @@ -82,6 +83,7 @@ del_str += base else: del_len = int(del_str) - 1 + del_str = "" deletion = base del_flag = False else: @@ -107,7 +109,10 @@ else: counts[base_to_idx[base]] += 1 stranded_counts[base_to_idx_stranded[base]] += 1 - af = float(counts[base_to_idx[alt_base]]) / float(sum(counts)) + if sum(counts) == 0: + af = float("nan") + else: + af = float(counts[base_to_idx[alt_base]]) / float(sum(counts)) if float(sum(stranded_counts[0:4])) == 0: faf = float("nan") else: @@ -293,7 +298,10 @@ else: counts[8] += 1 dp = int(fields[3]) - af = float(counts[3]) / float(sum([counts[0], counts[3], counts[6]])) + if sum([counts[0], counts[3], counts[6]]) == 0: + af = float("nan") + else: + af = float(counts[3]) / float(sum([counts[0], counts[3], counts[6]])) if sum([counts[1], counts[4], counts[7]]) == 0: faf = float("nan") else: @@ -317,7 +325,7 @@ if line[0:2] == "##": out_vcf.write(line) elif line[0] == "#": - out_vcf.write("##annotateVCFVersion=0.1\n") + out_vcf.write("##annotateVCFVersion=0.2\n") out_vcf.write("##INFO=\n") out_vcf.write("##INFO=\n") out_vcf.write("##INFO=\n") @@ -376,7 +384,10 @@ else: info = fields[7].split(';') info.append("DP=%d" % (dp)) - info.append("AF=%.6f" % (af)) + if isnan(af): + info.append("AF=NaN") + else: + info.append("AF=%.6f" % (af)) if isnan(faf): info.append("FAF=NaN") else: