Repository 'medaka_consensus_pipeline'
hg clone https://toolshed.g2.bx.psu.edu/repos/iuc/medaka_consensus_pipeline

Changeset 5:b35de691c42c (2020-10-16)
Previous changeset 4:a1b70f038b4a (2020-10-13) Next changeset 6:d915879a88bc (2021-02-10)
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/medaka commit 13769e7d51b30a1d15eb62a9ba89ee2064f3ddc3"
modified:
annotateVCF.py
b
diff -r a1b70f038b4a -r b35de691c42c annotateVCF.py
--- a/annotateVCF.py Tue Oct 13 15:59:11 2020 +0000
+++ b/annotateVCF.py Fri Oct 16 17:04:09 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: