Configurable chromosome name pattern.
[lightning.git] / diff_test.go
1 package main
2
3 import (
4         "bytes"
5         "io/ioutil"
6         "os"
7
8         "gopkg.in/check.v1"
9 )
10
11 type diffSuite struct{}
12
13 var _ = check.Suite(&diffSuite{})
14
15 func (s *diffSuite) TestDiff(c *check.C) {
16         tempdir, err := ioutil.TempDir("", "")
17         c.Assert(err, check.IsNil)
18         defer os.RemoveAll(tempdir)
19
20         err = ioutil.WriteFile(tempdir+"/f1.fa", []byte(">f1\nactgactCacgtacgt\nactgactgacgAAcgt\n"), 0700)
21         c.Assert(err, check.IsNil)
22         err = ioutil.WriteFile(tempdir+"/f2.fa", []byte(">f2\nactgactGacgtacgt\nactgactgacgTTcgtA\n"), 0700)
23         c.Assert(err, check.IsNil)
24
25         var output bytes.Buffer
26         exited := (&diffFasta{}).RunCommand("diff-fasta", []string{"-sequence", "chr2", "-offset", "1000", tempdir + "/f1.fa", tempdir + "/f2.fa"}, nil, &output, os.Stderr)
27         c.Check(exited, check.Equals, 0)
28         c.Check("\n"+output.String(), check.Equals, `
29 chr2:g.1008C>G  chr2    1008    C       G       false
30 chr2:g.1028_1029delinsTT        chr2    1028    AA      TT      false
31 chr2:g.1032_1033insA    chr2    1033            A       false
32 `)
33 }