Fix some tests.
[lightning.git] / slice_test.go
index b61ba18eebfd97000a2c8be384cd0aff9ce760d4..7b81e0ec661ca75f9147a239aa86bb1e24432d77 100644 (file)
@@ -244,12 +244,21 @@ pipeline1dup/input1       1
 pipeline1dup/input2    0
 `), 0600)
                c.Assert(err, check.IsNil)
+
+               exited := (&chooseSamples{}).RunCommand("choose-samples", []string{
+                       "-local=true",
+                       "-case-control-file=" + tmpdir + "/casecontrol.tsv",
+                       "-case-control-column=CC",
+                       "-input-dir=" + slicedir,
+                       "-output-dir=" + tmpdir,
+               }, nil, os.Stderr, os.Stderr)
+               c.Check(exited, check.Equals, 0)
+
                npydir := c.MkDir()
-               exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
+               exited = (&sliceNumpy{}).RunCommand("slice-numpy", []string{
                        "-local=true",
                        "-chunked-hgvs-matrix=true",
-                       "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
-                       "-chi2-case-control-column=CC",
+                       "-samples=" + tmpdir + "/samples.csv",
                        "-chi2-p-value=0.5",
                        "-min-coverage=0.75",
                        "-input-dir=" + slicedir,
@@ -280,12 +289,21 @@ pipeline1dup/input1       1
 pipeline1dup/input2    0
 `), 0600)
                c.Assert(err, check.IsNil)
+
+               exited := (&chooseSamples{}).RunCommand("choose-samples", []string{
+                       "-local=true",
+                       "-case-control-file=" + tmpdir + "/casecontrol.tsv",
+                       "-case-control-column=CC",
+                       "-input-dir=" + slicedir,
+                       "-output-dir=" + tmpdir,
+               }, nil, os.Stderr, os.Stderr)
+               c.Check(exited, check.Equals, 0)
+
                npydir := c.MkDir()
-               exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
+               exited = (&sliceNumpy{}).RunCommand("slice-numpy", []string{
                        "-local=true",
                        "-chunked-onehot=true",
-                       "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
-                       "-chi2-case-control-column=CC",
+                       "-samples=" + tmpdir + "/samples.csv",
                        "-chi2-p-value=0.5",
                        "-min-coverage=0.75",
                        "-input-dir=" + slicedir,
@@ -324,12 +342,21 @@ pipeline1dup/input1       1
 pipeline1dup/input2    0
 `), 0600)
                c.Assert(err, check.IsNil)
+
+               exited := (&chooseSamples{}).RunCommand("choose-samples", []string{
+                       "-local=true",
+                       "-case-control-file=" + tmpdir + "/casecontrol.tsv",
+                       "-case-control-column=CC",
+                       "-input-dir=" + slicedir,
+                       "-output-dir=" + tmpdir,
+               }, nil, os.Stderr, os.Stderr)
+               c.Check(exited, check.Equals, 0)
+
                npydir := c.MkDir()
-               exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
+               exited = (&sliceNumpy{}).RunCommand("slice-numpy", []string{
                        "-local=true",
                        "-single-onehot=true",
-                       "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
-                       "-chi2-case-control-column=CC",
+                       "-samples=" + tmpdir + "/samples.csv",
                        "-chi2-p-value=0.5",
                        "-min-coverage=0.75",
                        "-input-dir=" + slicedir,
@@ -446,7 +473,7 @@ func (s *sliceSuite) TestSpanningTile(c *check.C) {
                c.Assert(err, check.IsNil)
                c.Logf("%s", dumped)
                // spanning tile for tag 5 with A>G snp in tag 6
-               c.Check("\n"+string(dumped), check.Matches, `(?ms).*\n5,1,0,chr2,225,.*AAAACTGATCCGAAAAAAATACAA.*`)
+               c.Check("\n"+string(dumped), check.Matches, `(?ms).*\n5,2,0,chr2,225,.*AAAACTGATCCGAAAAAAATACAA.*`)
                c.Check("\n"+string(dumped), check.Matches, `(?ms).*\n6,1,1,chr2,349,AAAACTGATCCAAAAAAAATACAA.*`)
        }
 
@@ -467,9 +494,12 @@ func (s *sliceSuite) TestSpanningTile(c *check.C) {
                defer f.Close()
                npy, err := gonpy.NewReader(f)
                c.Assert(err, check.IsNil)
-               c.Check(npy.Shape, check.DeepEquals, []int{1, 4})
+               c.Check(npy.Shape, check.DeepEquals, []int{2, 4})
                variants, err := npy.GetInt16()
-               c.Check(variants, check.DeepEquals, []int16{-1, -1, 1, 1})
+               c.Check(variants, check.DeepEquals, []int16{
+                       -1, -1, 1, 1,
+                       -1, -1, 1, 2,
+               })
 
                annotations, err := ioutil.ReadFile(npydir + "/matrix.0000.annotations.csv")
                c.Assert(err, check.IsNil)
@@ -480,9 +510,12 @@ func (s *sliceSuite) TestSpanningTile(c *check.C) {
                defer f.Close()
                npy, err = gonpy.NewReader(f)
                c.Assert(err, check.IsNil)
-               c.Check(npy.Shape, check.DeepEquals, []int{1, 4})
+               c.Check(npy.Shape, check.DeepEquals, []int{2, 4})
                variants, err = npy.GetInt16()
-               c.Check(variants, check.DeepEquals, []int16{1, 1, 1, 2})
+               c.Check(variants, check.DeepEquals, []int16{
+                       1, 1, 2, 1,
+                       1, 1, 1, 1,
+               })
 
                annotations, err = ioutil.ReadFile(npydir + "/matrix.0002.annotations.csv")
                c.Assert(err, check.IsNil)
@@ -513,9 +546,9 @@ func (s *sliceSuite) TestSpanningTile(c *check.C) {
                defer f.Close()
                npy, err := gonpy.NewReader(f)
                c.Assert(err, check.IsNil)
-               c.Check(npy.Shape, check.DeepEquals, []int{1, 2})
+               c.Check(npy.Shape, check.DeepEquals, []int{2, 2})
                variants, err := npy.GetInt16()
-               c.Check(variants, check.DeepEquals, []int16{-1, -1})
+               c.Check(variants, check.DeepEquals, []int16{-1, -1, -1, -1})
 
                annotations, err := ioutil.ReadFile(npydir + "/matrix.0000.annotations.csv")
                c.Assert(err, check.IsNil)
@@ -554,11 +587,12 @@ func (s *sliceSuite) TestSpanningTile(c *check.C) {
                defer f.Close()
                npy, err := gonpy.NewReader(f)
                c.Assert(err, check.IsNil)
-               c.Check(npy.Shape, check.DeepEquals, []int{1, 4})
+               c.Check(npy.Shape, check.DeepEquals, []int{2, 4})
                variants, err := npy.GetInt16()
                if c.Check(err, check.IsNil) {
                        c.Check(variants, check.DeepEquals, []int16{
                                -1, -1, 1, 1,
+                               -1, -1, 1, 1,
                        })
                }
 
@@ -573,12 +607,21 @@ func (s *sliceSuite) TestSpanningTile(c *check.C) {
 spanningtile/input1    1
 `), 0600)
                c.Assert(err, check.IsNil)
+
+               exited := (&chooseSamples{}).RunCommand("choose-samples", []string{
+                       "-local=true",
+                       "-case-control-file=" + tmpdir + "/casecontrol.tsv",
+                       "-case-control-column=CC",
+                       "-input-dir=" + slicedir,
+                       "-output-dir=" + tmpdir,
+               }, nil, os.Stderr, os.Stderr)
+               c.Check(exited, check.Equals, 0)
+
                npydir := c.MkDir()
-               exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
+               exited = (&sliceNumpy{}).RunCommand("slice-numpy", []string{
                        "-local=true",
                        "-chunked-hgvs-matrix=true",
-                       "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
-                       "-chi2-case-control-column=CC",
+                       "-samples=" + tmpdir + "/samples.csv",
                        "-chi2-p-value=1",
                        "-min-coverage=0.75",
                        "-input-dir=" + slicedir,
@@ -600,12 +643,21 @@ spanningtile/input1       1
 spanningtile/input1    1
 `), 0600)
                c.Assert(err, check.IsNil)
+
+               exited := (&chooseSamples{}).RunCommand("choose-samples", []string{
+                       "-local=true",
+                       "-case-control-file=" + tmpdir + "/casecontrol.tsv",
+                       "-case-control-column=CC",
+                       "-input-dir=" + slicedir,
+                       "-output-dir=" + tmpdir,
+               }, nil, os.Stderr, os.Stderr)
+               c.Check(exited, check.Equals, 0)
+
                npydir := c.MkDir()
-               exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
+               exited = (&sliceNumpy{}).RunCommand("slice-numpy", []string{
                        "-local=true",
                        "-chunked-onehot=true",
-                       "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
-                       "-chi2-case-control-column=CC",
+                       "-samples=" + tmpdir + "/samples.csv",
                        "-chi2-p-value=1",
                        "-min-coverage=0.75",
                        "-input-dir=" + slicedir,
@@ -638,12 +690,21 @@ spanningtile/input1       1
 spanningtile/input1    1
 `), 0600)
                c.Assert(err, check.IsNil)
+
+               exited := (&chooseSamples{}).RunCommand("choose-samples", []string{
+                       "-local=true",
+                       "-case-control-file=" + tmpdir + "/casecontrol.tsv",
+                       "-case-control-column=CC",
+                       "-input-dir=" + slicedir,
+                       "-output-dir=" + tmpdir,
+               }, nil, os.Stderr, os.Stderr)
+               c.Check(exited, check.Equals, 0)
+
                npydir := c.MkDir()
-               exited := (&sliceNumpy{}).RunCommand("slice-numpy", []string{
+               exited = (&sliceNumpy{}).RunCommand("slice-numpy", []string{
                        "-local=true",
                        "-single-onehot=true",
-                       "-chi2-case-control-file=" + tmpdir + "/casecontrol.tsv",
-                       "-chi2-case-control-column=CC",
+                       "-samples=" + tmpdir + "/samples.csv",
                        "-chi2-p-value=1",
                        "-min-coverage=0.75",
                        "-input-dir=" + slicedir,
@@ -665,9 +726,7 @@ spanningtile/input1 1
                        for r := 0; r < npy.Shape[0]; r++ {
                                c.Logf("%v", onehot[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
                        }
-                       c.Check(onehot, check.DeepEquals, []uint32{
-                               0, 1,
-                       })
+                       c.Check(onehot, check.DeepEquals, []uint32{0, 3})
                }
 
                f, err = os.Open(npydir + "/onehot-columns.npy")
@@ -675,18 +734,18 @@ spanningtile/input1       1
                defer f.Close()
                npy, err = gonpy.NewReader(f)
                c.Assert(err, check.IsNil)
-               c.Check(npy.Shape, check.DeepEquals, []int{5, 2})
+               c.Check(npy.Shape, check.DeepEquals, []int{5, 4})
                onehotcols, err := npy.GetInt32()
                if c.Check(err, check.IsNil) {
                        for r := 0; r < npy.Shape[0]; r++ {
                                c.Logf("%v", onehotcols[r*npy.Shape[1]:(r+1)*npy.Shape[1]])
                        }
                        c.Check(onehotcols, check.DeepEquals, []int32{
-                               5, 5,
-                               2, 2,
-                               1, 0,
-                               1000000, 1000000,
-                               0, 0,
+                               1, 1, 5, 5,
+                               2, 2, 2, 2,
+                               1, 0, 1, 0,
+                               1000000, 1000000, 1000000, 1000000,
+                               0, 0, 0, 0,
                        })
                }
        }