1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
12 "github.com/kshedden/gonpy"
16 type sliceSuite struct{}
18 var _ = check.Suite(&sliceSuite{})
20 func (s *sliceSuite) TestImportAndSlice(c *check.C) {
22 err := os.Mkdir(tmpdir+"/lib1", 0777)
23 c.Assert(err, check.IsNil)
24 err = os.Mkdir(tmpdir+"/lib2", 0777)
25 c.Assert(err, check.IsNil)
26 err = os.Mkdir(tmpdir+"/lib3", 0777)
27 c.Assert(err, check.IsNil)
28 cwd, err := os.Getwd()
29 c.Assert(err, check.IsNil)
30 err = os.Symlink(cwd+"/testdata/pipeline1", tmpdir+"/pipeline1")
31 c.Assert(err, check.IsNil)
32 err = os.Symlink(cwd+"/testdata/pipeline1", tmpdir+"/pipeline1dup")
33 c.Assert(err, check.IsNil)
35 err = ioutil.WriteFile(tmpdir+"/chr1-12-100.bed", []byte("chr1\t12\t100\ttest.1\n"), 0644)
36 c.Check(err, check.IsNil)
38 c.Log("=== import testdata/ref ===")
39 exited := (&importer{}).RunCommand("import", []string{
41 "-tag-library", "testdata/tags",
43 "-save-incomplete-tiles",
44 "-o", tmpdir + "/lib1/library1.gob",
46 }, nil, os.Stderr, os.Stderr)
47 c.Assert(exited, check.Equals, 0)
49 c.Log("=== import testdata/pipeline1 ===")
50 exited = (&importer{}).RunCommand("import", []string{
52 "-tag-library", "testdata/tags",
54 "-o", tmpdir + "/lib2/library2.gob",
55 tmpdir + "/pipeline1",
56 }, nil, os.Stderr, os.Stderr)
57 c.Assert(exited, check.Equals, 0)
59 c.Log("=== import pipeline1dup ===")
60 exited = (&importer{}).RunCommand("import", []string{
62 "-tag-library", "testdata/tags",
64 "-o", tmpdir + "/lib3/library3.gob",
65 tmpdir + "/pipeline1dup",
66 }, nil, os.Stderr, os.Stderr)
67 c.Assert(exited, check.Equals, 0)
71 c.Log("=== slice ===")
72 exited = (&slicecmd{}).RunCommand("slice", []string{
74 "-output-dir=" + slicedir,
79 }, nil, os.Stderr, os.Stderr)
80 c.Check(exited, check.Equals, 0)
81 out, _ := exec.Command("find", slicedir, "-ls").CombinedOutput()
87 exited = (&dump{}).RunCommand("dump", []string{
90 "-input-dir=" + slicedir,
91 "-output-dir=" + dumpdir,
92 }, nil, os.Stderr, os.Stderr)
93 c.Check(exited, check.Equals, 0)
94 out, _ := exec.Command("find", dumpdir, "-ls").CombinedOutput()
96 dumped, err := ioutil.ReadFile(dumpdir + "/variants.csv")
97 c.Assert(err, check.IsNil)
99 c.Check("\n"+string(dumped), check.Matches, `(?ms).*\n6,1,1,chr2,349,AAAACTG.*`)
102 c.Log("=== slice-numpy ===")
105 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
107 "-input-dir=" + slicedir,
108 "-output-dir=" + npydir,
109 }, nil, os.Stderr, os.Stderr)
110 c.Check(exited, check.Equals, 0)
111 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
114 f, err := os.Open(npydir + "/matrix.0000.npy")
115 c.Assert(err, check.IsNil)
117 npy, err := gonpy.NewReader(f)
118 c.Assert(err, check.IsNil)
119 c.Check(npy.Shape, check.DeepEquals, []int{4, 4})
120 variants, err := npy.GetInt16()
121 c.Check(variants, check.DeepEquals, []int16{2, 1, 1, 2, -1, -1, 1, 1, 2, 1, 1, 2, -1, -1, 1, 1})
123 annotations, err := ioutil.ReadFile(npydir + "/matrix.0000.annotations.csv")
124 c.Assert(err, check.IsNil)
125 c.Logf("%s", annotations)
126 for _, s := range []string{
129 "chr1:g.1_3delinsGGC",
132 c.Check(string(annotations), check.Matches, "(?ms).*"+s+".*")
135 annotations, err = ioutil.ReadFile(npydir + "/matrix.0002.annotations.csv")
136 c.Assert(err, check.IsNil)
137 c.Logf("%s", annotations)
138 for _, s := range []string{
139 ",2,chr2:g.1_3delinsAAA",
140 ",2,chr2:g.125_127delinsAAA",
141 ",4,chr2:g.125_127delinsAAA",
143 c.Check(string(annotations), check.Matches, "(?ms).*"+s+".*")
147 c.Log("=== slice-numpy + regions ===")
150 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
152 "-regions=" + tmpdir + "/chr1-12-100.bed",
153 "-input-dir=" + slicedir,
154 "-output-dir=" + npydir,
155 "-chunked-hgvs-matrix=true",
156 }, nil, os.Stderr, os.Stderr)
157 c.Check(exited, check.Equals, 0)
158 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
161 f, err := os.Open(npydir + "/matrix.0000.npy")
162 c.Assert(err, check.IsNil)
164 npy, err := gonpy.NewReader(f)
165 c.Assert(err, check.IsNil)
166 c.Check(npy.Shape, check.DeepEquals, []int{4, 2})
167 variants, err := npy.GetInt16()
168 c.Check(variants, check.DeepEquals, []int16{2, 1, -1, -1, 2, 1, -1, -1})
170 annotations, err := ioutil.ReadFile(npydir + "/matrix.0000.annotations.csv")
171 c.Assert(err, check.IsNil)
172 c.Logf("%s", annotations)
173 for _, s := range []string{
176 "chr1:g.1_3delinsGGC",
179 c.Check(string(annotations), check.Matches, "(?ms).*"+s+".*")
182 for _, fnm := range []string{
183 npydir + "/matrix.0001.annotations.csv",
184 npydir + "/matrix.0002.annotations.csv",
186 annotations, err := ioutil.ReadFile(fnm)
187 c.Assert(err, check.IsNil)
188 c.Check(string(annotations), check.Equals, "", check.Commentf(fnm))
192 err = ioutil.WriteFile(tmpdir+"/chr1and2-100-200.bed", []byte("chr1\t100\t200\ttest.1\nchr2\t100\t200\ttest.2\n"), 0644)
193 c.Check(err, check.IsNil)
195 c.Log("=== slice-numpy + regions + merge ===")
198 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
200 "-regions=" + tmpdir + "/chr1and2-100-200.bed",
201 "-input-dir=" + slicedir,
202 "-output-dir=" + npydir,
203 "-merge-output=true",
204 "-single-hgvs-matrix=true",
205 }, nil, os.Stderr, os.Stderr)
206 c.Check(exited, check.Equals, 0)
207 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
210 f, err := os.Open(npydir + "/matrix.npy")
211 c.Assert(err, check.IsNil)
213 npy, err := gonpy.NewReader(f)
214 c.Assert(err, check.IsNil)
215 c.Check(npy.Shape, check.DeepEquals, []int{4, 4})
216 variants, err := npy.GetInt16()
217 if c.Check(err, check.IsNil) {
218 c.Check(variants, check.DeepEquals, []int16{
226 annotations, err := ioutil.ReadFile(npydir + "/matrix.annotations.csv")
227 c.Assert(err, check.IsNil)
228 c.Logf("%s", annotations)
229 for _, s := range []string{
230 "0,0,1,chr1:g.161A>T",
231 "0,0,1,chr1:g.178A>T",
232 "4,1,2,chr2:g.125_127delinsAAA",
234 c.Check(string(annotations), check.Matches, "(?ms).*"+s+".*")
238 c.Log("=== slice-numpy + chunked hgvs matrix ===")
240 err = ioutil.WriteFile(tmpdir+"/casecontrol.tsv", []byte(`SampleID CC
243 pipeline1dup/input1 1
244 pipeline1dup/input2 0
246 c.Assert(err, check.IsNil)
248 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
250 "-chunked-hgvs-matrix=true",
251 "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
252 "-chi2-case-control-column=CC",
254 "-min-coverage=0.75",
255 "-input-dir=" + slicedir,
256 "-output-dir=" + npydir,
257 }, nil, os.Stderr, os.Stderr)
258 c.Check(exited, check.Equals, 0)
259 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
262 annotations, err := ioutil.ReadFile(npydir + "/hgvs.chr2.annotations.csv")
263 c.Assert(err, check.IsNil)
264 c.Check(string(annotations), check.Equals, `0,chr2:g.1_3delinsAAA
265 1,chr2:g.125_127delinsAAA
266 2,chr2:g.241_245delinsAAAAA
274 c.Log("=== slice-numpy + onehotChunked ===")
276 err = ioutil.WriteFile(tmpdir+"/casecontrol.tsv", []byte(`SampleID CC
279 pipeline1dup/input1 1
280 pipeline1dup/input2 0
282 c.Assert(err, check.IsNil)
284 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
286 "-chunked-onehot=true",
287 "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
288 "-chi2-case-control-column=CC",
290 "-min-coverage=0.75",
291 "-input-dir=" + slicedir,
292 "-output-dir=" + npydir,
293 }, nil, os.Stderr, os.Stderr)
294 c.Check(exited, check.Equals, 0)
295 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
298 f, err := os.Open(npydir + "/onehot.0002.npy")
299 c.Assert(err, check.IsNil)
301 npy, err := gonpy.NewReader(f)
302 c.Assert(err, check.IsNil)
303 c.Check(npy.Shape, check.DeepEquals, []int{4, 3})
304 onehot, err := npy.GetInt8()
305 if c.Check(err, check.IsNil) {
306 for r := 0; r < npy.Shape[0]; r++ {
307 c.Logf("%v", onehot[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
309 c.Check(onehot, check.DeepEquals, []int8{
312 0, 1, 0, // dup/input1
313 1, 0, 1, // dup/input2
318 c.Log("=== slice-numpy + onehotSingle ===")
320 err = ioutil.WriteFile(tmpdir+"/casecontrol.tsv", []byte(`SampleID CC
323 pipeline1dup/input1 1
324 pipeline1dup/input2 0
326 c.Assert(err, check.IsNil)
328 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
330 "-single-onehot=true",
331 "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
332 "-chi2-case-control-column=CC",
334 "-min-coverage=0.75",
335 "-input-dir=" + slicedir,
336 "-output-dir=" + npydir,
338 }, nil, os.Stderr, os.Stderr)
339 c.Check(exited, check.Equals, 0)
340 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
343 f, err := os.Open(npydir + "/onehot.npy")
344 c.Assert(err, check.IsNil)
346 npy, err := gonpy.NewReader(f)
347 c.Assert(err, check.IsNil)
348 c.Check(npy.Shape, check.DeepEquals, []int{2, 12})
349 onehot, err := npy.GetUint32()
350 if c.Check(err, check.IsNil) {
351 for r := 0; r < npy.Shape[0]; r++ {
352 c.Logf("%v", onehot[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
354 c.Check(onehot, check.DeepEquals, []uint32{
355 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 0, 2,
356 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5,
360 f, err = os.Open(npydir + "/onehot-columns.npy")
361 c.Assert(err, check.IsNil)
363 npy, err = gonpy.NewReader(f)
364 c.Assert(err, check.IsNil)
365 c.Check(npy.Shape, check.DeepEquals, []int{5, 6})
366 onehotcols, err := npy.GetInt32()
367 if c.Check(err, check.IsNil) {
368 for r := 0; r < npy.Shape[0]; r++ {
369 c.Logf("%v", onehotcols[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
371 c.Check(onehotcols, check.DeepEquals, []int32{
375 157299, 157299, 157299, 157299, 157299, 157299,
376 803273, 803273, 803273, 803273, 803273, 803273,
382 func (s *sliceSuite) TestSpanningTile(c *check.C) {
384 err := os.Mkdir(tmpdir+"/lib1", 0777)
385 c.Assert(err, check.IsNil)
386 err = os.Mkdir(tmpdir+"/lib2", 0777)
387 c.Assert(err, check.IsNil)
388 cwd, err := os.Getwd()
389 c.Assert(err, check.IsNil)
390 err = os.Symlink(cwd+"/testdata/pipeline1", tmpdir+"/pipeline1")
391 c.Assert(err, check.IsNil)
392 err = os.Symlink(cwd+"/testdata/pipeline1", tmpdir+"/pipeline1dup")
393 c.Assert(err, check.IsNil)
395 err = ioutil.WriteFile(tmpdir+"/chr1-12-100.bed", []byte("chr1\t12\t100\ttest.1\n"), 0644)
396 c.Check(err, check.IsNil)
398 c.Log("=== import testdata/ref ===")
399 exited := (&importer{}).RunCommand("import", []string{
401 "-tag-library", "testdata/tags",
403 "-save-incomplete-tiles",
404 "-o", tmpdir + "/lib1/library1.gob",
405 "testdata/ref.fasta",
406 }, nil, os.Stderr, os.Stderr)
407 c.Assert(exited, check.Equals, 0)
409 c.Log("=== import testdata/spanningtile ===")
410 exited = (&importer{}).RunCommand("import", []string{
412 "-tag-library", "testdata/tags",
414 "-o", tmpdir + "/lib2/library2.gob",
415 cwd + "/testdata/spanningtile",
416 }, nil, os.Stderr, os.Stderr)
417 c.Assert(exited, check.Equals, 0)
419 slicedir := c.MkDir()
421 c.Log("=== slice ===")
422 exited = (&slicecmd{}).RunCommand("slice", []string{
424 "-output-dir=" + slicedir,
428 }, nil, os.Stderr, os.Stderr)
429 c.Check(exited, check.Equals, 0)
430 out, _ := exec.Command("find", slicedir, "-ls").CombinedOutput()
433 c.Log("=== dump ===")
436 exited = (&dump{}).RunCommand("dump", []string{
439 "-input-dir=" + slicedir,
440 "-output-dir=" + dumpdir,
441 }, nil, os.Stderr, os.Stderr)
442 c.Check(exited, check.Equals, 0)
443 out, _ := exec.Command("find", dumpdir, "-ls").CombinedOutput()
445 dumped, err := ioutil.ReadFile(dumpdir + "/variants.csv")
446 c.Assert(err, check.IsNil)
448 // spanning tile for tag 5 with A>G snp in tag 6
449 c.Check("\n"+string(dumped), check.Matches, `(?ms).*\n5,2,0,chr2,225,.*AAAACTGATCCGAAAAAAATACAA.*`)
450 c.Check("\n"+string(dumped), check.Matches, `(?ms).*\n6,1,1,chr2,349,AAAACTGATCCAAAAAAAATACAA.*`)
453 c.Log("=== slice-numpy ===")
456 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
458 "-input-dir=" + slicedir,
459 "-output-dir=" + npydir,
460 }, nil, os.Stderr, os.Stderr)
461 c.Check(exited, check.Equals, 0)
462 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
465 f, err := os.Open(npydir + "/matrix.0000.npy")
466 c.Assert(err, check.IsNil)
468 npy, err := gonpy.NewReader(f)
469 c.Assert(err, check.IsNil)
470 c.Check(npy.Shape, check.DeepEquals, []int{2, 4})
471 variants, err := npy.GetInt16()
472 c.Check(variants, check.DeepEquals, []int16{
477 annotations, err := ioutil.ReadFile(npydir + "/matrix.0000.annotations.csv")
478 c.Assert(err, check.IsNil)
479 c.Logf("%s", annotations)
481 f, err = os.Open(npydir + "/matrix.0002.npy")
482 c.Assert(err, check.IsNil)
484 npy, err = gonpy.NewReader(f)
485 c.Assert(err, check.IsNil)
486 c.Check(npy.Shape, check.DeepEquals, []int{2, 4})
487 variants, err = npy.GetInt16()
488 c.Check(variants, check.DeepEquals, []int16{
493 annotations, err = ioutil.ReadFile(npydir + "/matrix.0002.annotations.csv")
494 c.Assert(err, check.IsNil)
495 c.Logf("%s", annotations)
496 for _, s := range []string{
499 c.Check(string(annotations), check.Matches, "(?ms).*"+s+".*")
503 c.Log("=== slice-numpy + regions ===")
506 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
508 "-regions=" + tmpdir + "/chr1-12-100.bed",
509 "-input-dir=" + slicedir,
510 "-output-dir=" + npydir,
511 "-chunked-hgvs-matrix=true",
512 }, nil, os.Stderr, os.Stderr)
513 c.Check(exited, check.Equals, 0)
514 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
517 f, err := os.Open(npydir + "/matrix.0000.npy")
518 c.Assert(err, check.IsNil)
520 npy, err := gonpy.NewReader(f)
521 c.Assert(err, check.IsNil)
522 c.Check(npy.Shape, check.DeepEquals, []int{2, 2})
523 variants, err := npy.GetInt16()
524 c.Check(variants, check.DeepEquals, []int16{-1, -1, -1, -1})
526 annotations, err := ioutil.ReadFile(npydir + "/matrix.0000.annotations.csv")
527 c.Assert(err, check.IsNil)
528 c.Check(string(annotations), check.Equals, "0,0,1,=,chr1,0,,,\n")
530 for _, fnm := range []string{
531 npydir + "/matrix.0001.annotations.csv",
532 npydir + "/matrix.0002.annotations.csv",
534 annotations, err := ioutil.ReadFile(fnm)
535 c.Assert(err, check.IsNil)
536 c.Check(string(annotations), check.Equals, "", check.Commentf(fnm))
540 err = ioutil.WriteFile(tmpdir+"/chr1and2-100-200.bed", []byte("chr1\t100\t200\ttest.1\nchr2\t100\t200\ttest.2\n"), 0644)
541 c.Check(err, check.IsNil)
543 c.Log("=== slice-numpy + regions + merge ===")
546 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
548 "-regions=" + tmpdir + "/chr1and2-100-200.bed",
549 "-input-dir=" + slicedir,
550 "-output-dir=" + npydir,
551 "-merge-output=true",
552 "-single-hgvs-matrix=true",
553 }, nil, os.Stderr, os.Stderr)
554 c.Check(exited, check.Equals, 0)
555 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
558 f, err := os.Open(npydir + "/matrix.npy")
559 c.Assert(err, check.IsNil)
561 npy, err := gonpy.NewReader(f)
562 c.Assert(err, check.IsNil)
563 c.Check(npy.Shape, check.DeepEquals, []int{2, 4})
564 variants, err := npy.GetInt16()
565 if c.Check(err, check.IsNil) {
566 c.Check(variants, check.DeepEquals, []int16{
572 annotations, err := ioutil.ReadFile(npydir + "/matrix.annotations.csv")
573 c.Assert(err, check.IsNil)
574 c.Check(string(annotations), check.Equals, "")
577 c.Log("=== slice-numpy + chunked hgvs matrix ===")
579 err = ioutil.WriteFile(tmpdir+"/casecontrol.tsv", []byte(`SampleID CC
580 spanningtile/input1 1
582 c.Assert(err, check.IsNil)
584 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
586 "-chunked-hgvs-matrix=true",
587 "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
588 "-chi2-case-control-column=CC",
590 "-min-coverage=0.75",
591 "-input-dir=" + slicedir,
592 "-output-dir=" + npydir,
593 }, nil, os.Stderr, os.Stderr)
594 c.Check(exited, check.Equals, 0)
595 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
598 annotations, err := ioutil.ReadFile(npydir + "/hgvs.chr2.annotations.csv")
599 c.Assert(err, check.IsNil)
600 c.Check(string(annotations), check.Equals, `0,chr2:g.360A>G
604 c.Log("=== slice-numpy + onehotChunked ===")
606 err = ioutil.WriteFile(tmpdir+"/casecontrol.tsv", []byte(`SampleID CC
607 spanningtile/input1 1
609 c.Assert(err, check.IsNil)
611 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
613 "-chunked-onehot=true",
614 "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
615 "-chi2-case-control-column=CC",
617 "-min-coverage=0.75",
618 "-input-dir=" + slicedir,
619 "-output-dir=" + npydir,
620 }, nil, os.Stderr, os.Stderr)
621 c.Check(exited, check.Equals, 0)
622 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
625 f, err := os.Open(npydir + "/onehot.0002.npy")
626 c.Assert(err, check.IsNil)
628 npy, err := gonpy.NewReader(f)
629 c.Assert(err, check.IsNil)
630 c.Check(npy.Shape, check.DeepEquals, []int{1, 2})
631 onehot, err := npy.GetInt8()
632 if c.Check(err, check.IsNil) {
633 for r := 0; r < npy.Shape[0]; r++ {
634 c.Logf("%v", onehot[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
636 c.Check(onehot, check.DeepEquals, []int8{
642 c.Log("=== slice-numpy + onehotSingle ===")
644 err = ioutil.WriteFile(tmpdir+"/casecontrol.tsv", []byte(`SampleID CC
645 spanningtile/input1 1
647 c.Assert(err, check.IsNil)
649 exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
651 "-single-onehot=true",
652 "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
653 "-chi2-case-control-column=CC",
655 "-min-coverage=0.75",
656 "-input-dir=" + slicedir,
657 "-output-dir=" + npydir,
659 }, nil, os.Stderr, os.Stderr)
660 c.Check(exited, check.Equals, 0)
661 out, _ := exec.Command("find", npydir, "-ls").CombinedOutput()
664 f, err := os.Open(npydir + "/onehot.npy")
665 c.Assert(err, check.IsNil)
667 npy, err := gonpy.NewReader(f)
668 c.Assert(err, check.IsNil)
669 c.Check(npy.Shape, check.DeepEquals, []int{2, 1})
670 onehot, err := npy.GetUint32()
671 if c.Check(err, check.IsNil) {
672 for r := 0; r < npy.Shape[0]; r++ {
673 c.Logf("%v", onehot[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
675 c.Check(onehot, check.DeepEquals, []uint32{0, 3})
678 f, err = os.Open(npydir + "/onehot-columns.npy")
679 c.Assert(err, check.IsNil)
681 npy, err = gonpy.NewReader(f)
682 c.Assert(err, check.IsNil)
683 c.Check(npy.Shape, check.DeepEquals, []int{5, 4})
684 onehotcols, err := npy.GetInt32()
685 if c.Check(err, check.IsNil) {
686 for r := 0; r < npy.Shape[0]; r++ {
687 c.Logf("%v", onehotcols[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
689 c.Check(onehotcols, check.DeepEquals, []int32{
693 1000000, 1000000, 1000000, 1000000,
700 func (s *sliceSuite) Test_tv2homhet(c *check.C) {
702 cgnames: []string{"sample1", "sample2", "sample3", "sample4"},
703 chi2Cases: []bool{false, true, true, false},
705 includeVariant1: true,
708 cgs := map[string]CompactGenome{
709 "sample1": CompactGenome{
710 Variants: []tileVariantID{0, 0, 1, 1}, // hom tv=1
712 "sample2": CompactGenome{
713 Variants: []tileVariantID{0, 0, 5, 5}, // hom tv=2
715 "sample3": CompactGenome{
716 Variants: []tileVariantID{0, 0, 5, 1}, // het tv=1, tv=2
718 "sample4": CompactGenome{
719 Variants: []tileVariantID{0, 0, 9, 9}, // hom tv=3
722 maxv := tileVariantID(3)
723 remap := []tileVariantID{0, 1, 0, 0, 0, 2, 0, 0, 0, 3}
724 chunkstarttag := tagID(10)
725 fakevariant := TileVariant{Sequence: []byte("ACGT")}
726 seq := map[tagID][]TileVariant{}
727 for tag := tagID(10); tag < 12; tag++ {
728 seq[tag-chunkstarttag] = []TileVariant{TileVariant{}, fakevariant, TileVariant{}, TileVariant{}, TileVariant{}, fakevariant}
729 c.Logf("=== tag %d", tag)
730 chunk, xref := cmd.tv2homhet(cgs, maxv, remap, tag, chunkstarttag, seq)
731 c.Logf("chunk len=%d", len(chunk))
732 for _, x := range chunk {
735 c.Logf("xref len=%d", len(xref))
736 for _, x := range xref {
739 out := onehotcols2int8(chunk)
740 c.Logf("onehotcols2int8(chunk) len=%d", len(out))
741 for i := 0; i < len(out); i += len(chunk) {
742 c.Logf("%+v", out[i:i+len(chunk)])
744 coords := onehotChunk2Indirect(chunk)
745 c.Logf("onehotChunk2Indirect(chunk) len=%d", len(coords))
746 for _, x := range coords {