Bring memory back down.
[lightning.git] / pipeline_test.go
index 4dd544d81388a8975c33e8ed781aa234f14c2c52..6735cd802221f4998c91723973e2cfce097b6611 100644 (file)
@@ -1,4 +1,4 @@
-package main
+package lightning
 
 import (
        "bytes"
@@ -6,6 +6,8 @@ import (
        "io"
        "io/ioutil"
        "os"
+       "sort"
+       "strings"
        "sync"
 
        "gopkg.in/check.v1"
@@ -35,7 +37,7 @@ func (s *pipelineSuite) TestImport(c *check.C) {
                wg.Add(1)
                go func() {
                        defer wg.Done()
-                       code := (&stats{}).RunCommand("lightning stats", []string{"-local"}, statsin, statsout, os.Stderr)
+                       code := (&statscmd{}).RunCommand("lightning stats", []string{"-local"}, statsin, statsout, os.Stderr)
                        c.Check(code, check.Equals, 0)
                }()
                wg.Wait()
@@ -61,7 +63,7 @@ func (s *pipelineSuite) TestImportMerge(c *check.C) {
                        args := []string{"-local=true", "-o=" + libfile[i], "-skip-ooo=true", "-output-tiles", "-tag-library", "testdata/tags"}
                        if i == 0 {
                                // ref only
-                               args = append(args, "-include-no-calls")
+                               args = append(args, "-save-incomplete-tiles")
                        }
                        args = append(args, infile)
                        code := (&importer{}).RunCommand("lightning import", args, bytes.NewReader(nil), &bytes.Buffer{}, os.Stderr)
@@ -76,7 +78,7 @@ func (s *pipelineSuite) TestImportMerge(c *check.C) {
        c.Logf("len(merged) %d", merged.Len())
 
        statsout := &bytes.Buffer{}
-       code = (&stats{}).RunCommand("lightning stats", []string{"-local"}, bytes.NewReader(merged.Bytes()), statsout, os.Stderr)
+       code = (&statscmd{}).RunCommand("lightning stats", []string{"-local"}, bytes.NewReader(merged.Bytes()), statsout, os.Stderr)
        c.Check(code, check.Equals, 0)
        c.Check(statsout.Len() > 0, check.Equals, true)
        c.Logf("%s", statsout.String())
@@ -125,7 +127,7 @@ chr2        471     GG      AA      0/1     0/0
        bedout, err := ioutil.ReadFile(tmpdir + "/export.bed")
        c.Check(err, check.IsNil)
        c.Logf("%s", string(bedout))
-       c.Check(string(bedout), check.Equals, `chr1 0 248 0 500 . 0 224
+       c.Check(string(bedout), check.Equals, `chr1 0 248 0 1000 . 0 224
 chr1 224 372 1 1000 . 248 348
 chr1 348 496 2 1000 . 372 472
 chr1 472 572 3 1000 . 496 572
@@ -134,4 +136,33 @@ chr2 224 372 5 750 . 248 348
 chr2 348 496 6 1000 . 372 472
 chr2 472 572 7 1000 . 496 572
 `)
+
+       annotateout := &bytes.Buffer{}
+       code = (&annotatecmd{}).RunCommand("lightning annotate", []string{"-local", "-variant-hash=true", "-i", tmpdir + "/merged.gob"}, bytes.NewReader(nil), annotateout, os.Stderr)
+       c.Check(code, check.Equals, 0)
+       c.Check(annotateout.Len() > 0, check.Equals, true)
+       sorted := sortLines(annotateout.String())
+       c.Logf("%s", sorted)
+       c.Check(sorted, check.Equals, sortLines(`0,0,8d4fe9a63921b,chr1:g.161A>T
+0,0,8d4fe9a63921b,chr1:g.178A>T
+0,0,8d4fe9a63921b,chr1:g.1_3delinsGGC
+0,0,8d4fe9a63921b,chr1:g.222_224del
+0,0,ba4263ca4199c,chr1:g.1_3delinsGGC
+0,0,ba4263ca4199c,chr1:g.222_224del
+0,0,ba4263ca4199c,chr1:g.41_42delinsAA
+1,1,139890345dbb8,chr1:g.302_305delinsAAAA
+4,4,cbfca15d241d3,chr2:g.125_127delinsAAA
+4,4,cbfca15d241d3,chr2:g.1_3delinsAAA
+4,4,f5fafe9450b02,chr2:g.241_245delinsAAAAA
+4,4,f5fafe9450b02,chr2:g.291C>A
+4,4,fe9a71a42adb4,chr2:g.125_127delinsAAA
+6,6,e36dce85efbef,chr2:g.471_472delinsAA
+6,6,f81388b184f4a,chr2:g.470_472del
+`))
+}
+
+func sortLines(txt string) string {
+       lines := strings.Split(strings.TrimRightFunc(txt, func(c rune) bool { return c == '\n' }), "\n")
+       sort.Strings(lines)
+       return strings.Join(lines, "\n") + "\n"
 }