Write deletions as "TAA T" instead of "AA .".
[lightning.git] / slicenumpy.go
index 5aa97ac5a7c44707b03720ac6631eaa03599ce54..4d3bd2745db43ba2c372c1385b339ece8ae131d3 100644 (file)
@@ -280,10 +280,14 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                                        defer throttleCPU.Release()
                                        count := make(map[[blake2b.Size256]byte]int, len(variants))
                                        for _, cg := range cgs {
-                                               idx := (tag - tagstart) * 2
-                                               if int(idx) < len(cg.Variants) {
-                                                       count[variants[cg.Variants[idx]].Blake2b]++
-                                                       count[variants[cg.Variants[idx+1]].Blake2b]++
+                                               idx := int(tag-tagstart) * 2
+                                               if idx < len(cg.Variants) {
+                                                       for allele := 0; allele < 2; allele++ {
+                                                               v := cg.Variants[idx+allele]
+                                                               if v > 0 && len(variants[v].Sequence) > 0 {
+                                                                       count[variants[v].Blake2b]++
+                                                               }
+                                                       }
                                                }
                                        }
                                        // hash[i] will be the hash of
@@ -339,7 +343,14 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                                outcol := tag - tagID(tagstart)
                                reftilestr := strings.ToUpper(string(rt.tiledata))
                                remap := variantRemap[tag-tagstart]
+                               done := make([]bool, len(variants))
                                for v, tv := range variants {
+                                       v := remap[v]
+                                       if done[v] {
+                                               continue
+                                       } else {
+                                               done[v] = true
+                                       }
                                        if len(tv.Sequence) < taglen || !bytes.HasSuffix(rt.tiledata, tv.Sequence[len(tv.Sequence)-taglen:]) {
                                                continue
                                        }
@@ -349,7 +360,7 @@ func (cmd *sliceNumpy) RunCommand(prog string, args []string, stdin io.Reader, s
                                        diffs, _ := hgvs.Diff(reftilestr, strings.ToUpper(string(tv.Sequence)), 0)
                                        for _, diff := range diffs {
                                                diff.Position += rt.pos
-                                               fmt.Fprintf(annow, "%d,%d,%d,%s:g.%s,%s,%d,%s,%s\n", tag, outcol, remap[v], rt.seqname, diff.String(), rt.seqname, diff.Position, diff.Ref, diff.New)
+                                               fmt.Fprintf(annow, "%d,%d,%d,%s:g.%s,%s,%d,%s,%s,%s\n", tag, outcol, v, rt.seqname, diff.String(), rt.seqname, diff.Position, diff.Ref, diff.New, diff.Left)
                                        }
                                }
                        }