Fix variant numbering.
authorTom Clegg <tom@tomclegg.ca>
Thu, 4 Nov 2021 18:10:14 +0000 (14:10 -0400)
committerTom Clegg <tom@tomclegg.ca>
Thu, 4 Nov 2021 19:18:44 +0000 (15:18 -0400)
Renumbering code was incorrectly reserving ranking spots for no-calls.

refs #17763

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

slice_test.go
slicenumpy.go

index 42bceee9b870a054e084fc5dcfd5c10450c320c3..d84d95f30fa402c9130c27c6d476f68a57a133f6 100644 (file)
@@ -99,7 +99,7 @@ func (s *sliceSuite) TestImportAndSlice(c *check.C) {
        c.Assert(err, check.IsNil)
        c.Check(npy.Shape, check.DeepEquals, []int{4, 4})
        variants, err := npy.GetInt16()
-       c.Check(variants, check.DeepEquals, []int16{3, 2, 1, 2, -1, -1, 1, 1, 3, 2, 1, 2, -1, -1, 1, 1})
+       c.Check(variants, check.DeepEquals, []int16{2, 1, 1, 2, -1, -1, 1, 1, 2, 1, 1, 2, -1, -1, 1, 1})
 
        annotations, err := ioutil.ReadFile(npydir + "/matrix.0000.annotations.csv")
        c.Assert(err, check.IsNil)
index 5c55b35af0a26eabb9217be302a8401e22cb0042..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