changeset 5:efca385ce679 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/medaka commit 13769e7d51b30a1d15eb62a9ba89ee2064f3ddc3"
author iuc
date Fri, 16 Oct 2020 17:05:01 +0000
parents 5c959a2dde5f
children ea1833858055
files annotateVCF.py
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/annotateVCF.py	Tue Oct 13 15:59:54 2020 +0000
+++ b/annotateVCF.py	Fri Oct 16 17:05:01 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=<ID=DP,Number=1,Type=Integer,Description=\"Raw Depth\">\n")
             out_vcf.write("##INFO=<ID=AF,Number=1,Type=Float,Description=\"Allele Frequency\">\n")
             out_vcf.write("##INFO=<ID=FAF,Number=1,Type=Float,Description=\"Forward Allele Frequency\">\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: