Fix race.
[lightning.git] / export_test.go
1 package lightning
2
3 import (
4         "bytes"
5         "io/ioutil"
6         "os"
7
8         "gopkg.in/check.v1"
9 )
10
11 type exportSuite struct{}
12
13 var _ = check.Suite(&exportSuite{})
14
15 func (s *exportSuite) TestFastaToHGVS(c *check.C) {
16         tmpdir := c.MkDir()
17
18         err := ioutil.WriteFile(tmpdir+"/chr1-12-100.bed", []byte("chr1\t12\t100\ttest.1\n"), 0644)
19         c.Check(err, check.IsNil)
20
21         var buffer bytes.Buffer
22         exited := (&importer{}).RunCommand("import", []string{"-local=true", "-tag-library", "testdata/tags", "-output-tiles", "-save-incomplete-tiles", "testdata/pipeline1", "testdata/ref.fasta"}, &bytes.Buffer{}, &buffer, os.Stderr)
23         c.Assert(exited, check.Equals, 0)
24         ioutil.WriteFile(tmpdir+"/library.gob", buffer.Bytes(), 0644)
25         var output bytes.Buffer
26         exited = (&exporter{}).RunCommand("export", []string{
27                 "-local=true",
28                 "-i=" + tmpdir + "/library.gob",
29                 "-output-format=hgvs-onehot",
30                 "-output-labels=" + tmpdir + "/labels.csv",
31                 "-ref=testdata/ref.fasta",
32         }, &buffer, &output, os.Stderr)
33         c.Check(exited, check.Equals, 0)
34         c.Check(sortLines(output.String()), check.Equals, sortLines(`chr1.1_3delinsGGC  1       0
35 chr1.41_42delinsAA      1       0
36 chr1.161A>T     1       0
37 chr1.178A>T     1       0
38 chr1.222_224del 1       0
39 chr1.302_305delinsAAAA  1       0
40 chr2.1_3delinsAAA       0       1
41 chr2.125_127delinsAAA   0       1
42 chr2.241_254del 1       0
43 chr2.258_269delinsAA    1       0
44 chr2.315C>A     1       0
45 chr2.470_472del 1       0
46 chr2.471_472delinsAA    1       0
47 `))
48         labels, err := ioutil.ReadFile(tmpdir + "/labels.csv")
49         c.Check(err, check.IsNil)
50         c.Check(string(labels), check.Equals, `0,"input1","-"
51 1,"input2","-"
52 `)
53 }