This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
forked from brentp/vcfgo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
reader_test.go
93 lines (75 loc) · 2.97 KB
/
reader_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package vcfgo_test
import (
"io"
"strings"
"github.com/mendelics/vcfgo"
. "gopkg.in/check.v1"
)
type ReaderSuite struct {
reader io.Reader
}
var _ = Suite(&ReaderSuite{})
func (s *ReaderSuite) SetUpTest(c *C) {
s.reader = strings.NewReader(vcfStr)
}
func (s *ReaderSuite) TestReaderHeaderSamples(c *C) {
v, err := vcfgo.NewReader(s.reader, false)
c.Assert(err, IsNil)
c.Assert(v.Header.SampleNames, DeepEquals, []string{"NA00001", "NA00002", "NA00003"})
}
func (s *ReaderSuite) TestLazyReader(c *C) {
rdr, err := vcfgo.NewReader(s.reader, true)
c.Assert(err, IsNil)
rec := rdr.Read() //.(*vcfgo.Variant)
c.Assert(rec.String(), Equals, "20\t14370\trs6054257\tG\tA\t29.0\tPASS\tNS=3;DP=14;AF=0.5;DB;H2\tGT:GQ:DP:HQ\t0|0:48:1:51,51\t1|0:48:8:51,51\t1/1:43:5:.,.")
}
func (s *ReaderSuite) TestReaderHeaderInfos(c *C) {
v, err := vcfgo.NewReader(s.reader, false)
c.Assert(err, IsNil)
c.Assert(v.Header.Infos["NS"], DeepEquals, &vcfgo.Info{Id: "NS", Number: "1", Type: "Integer", Description: "Number of Samples With Data"})
c.Assert(v.Header.Filters["q10"], Equals, "Quality below 10")
c.Assert(v.Header.SampleFormats["GT"], DeepEquals, &vcfgo.SampleFormat{Id: "GT", Number: "1", Type: "String", Description: "Genotype"})
}
func (s *ReaderSuite) TestReaderHeaderExtras(c *C) {
v, err := vcfgo.NewReader(s.reader, true)
c.Assert(err, IsNil)
c.Assert(len(v.Header.Extras), Equals, 4)
c.Assert(v.Header.Extras[0], Equals, "##fileDate=20090805")
}
func (s *ReaderSuite) TestReaderRead(c *C) {
rdr, err := vcfgo.NewReader(s.reader, false)
c.Assert(err, IsNil)
rec := rdr.Read() //.(*vcfgo.Variant)
c.Assert(rec.Chromosome, Equals, "20")
c.Assert(rec.Pos, Equals, uint64(14370))
c.Assert(rec.Id(), Equals, "rs6054257")
c.Assert(rec.Ref(), Equals, "G")
c.Assert(rec.Alt()[0], Equals, "A")
c.Assert(rec.Quality, Equals, float32(29.0))
c.Assert(rec.Filter, Equals, "PASS")
//20 17330 . T A 3 q10 NS=3;DP=11;AF=0.017 GT:GQ:DP:HQ 0|0:49:3:58,50 0|1:3:5:65,3 0/0:41:3
rec0 := rdr.Read() //.(*vcfgo.Variant)
c.Assert(rec0.Chromosome, Equals, "20")
c.Assert(rec0.Pos, Equals, uint64(17330))
c.Assert(rec0.Id(), Equals, ".")
c.Assert(rec0.Ref(), Equals, "T")
c.Assert(rec0.Alt()[0], Equals, "A")
c.Assert(rec0.Quality, Equals, float32(3))
c.Assert(rec0.Filter, Equals, "q10")
//20 1110696 rs6040355 A G,T 67 PASS NS=2;DP=10;AF=0.333,0.667;AA=T;DB GT:GQ:DP:HQ 1|2:21:6:23,27 2|1:2:0:18,2 2/2:35:4
rec = rdr.Read() //.(*vcfgo.Variant)
c.Assert(rec.Chromosome, Equals, "20")
c.Assert(int(rec.Pos), Equals, 1110696)
c.Assert(rec.Id(), Equals, "rs6040355")
c.Assert(rec.Ref(), Equals, "A")
c.Assert(rec.Alt(), DeepEquals, []string{"G", "T"})
c.Assert(rec.Quality, Equals, float32(67))
c.Assert(rec.Filter, Equals, "PASS")
c.Assert(rec0.Chromosome, Equals, "20")
c.Assert(rec0.Pos, Equals, uint64(17330))
c.Assert(rec0.Id(), Equals, ".")
c.Assert(rec0.Ref(), Equals, "T")
c.Assert(rec0.Alt()[0], Equals, "A")
c.Assert(rec0.Quality, Equals, float32(3))
c.Assert(rec0.Filter, Equals, "q10")
}