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 0
/
Copy pathvariant_test.go
91 lines (68 loc) · 2.02 KB
/
variant_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
package vcfgo_test
import (
"fmt"
"io"
"strings"
"github.com/mendelics/vcfgo"
. "gopkg.in/check.v1"
)
type VariantSuite struct {
reader io.Reader
}
var _ = Suite(&VariantSuite{})
func (s *VariantSuite) SetUpTest(c *C) {
s.reader = strings.NewReader(vcfStr)
}
func (s *VariantSuite) TestVariantGetInt(c *C) {
rdr, err := vcfgo.NewReader(s.reader, true)
c.Assert(err, IsNil)
v := rdr.Read() //.(*vcfgo.Variant)
v.Info()
ns, err := v.Info_.Get("NS")
c.Assert(err, IsNil)
c.Assert(ns, Equals, 3)
dp, err := v.Info_.Get("DP")
c.Assert(dp, Equals, 14)
c.Assert(err, IsNil)
nsf, err := v.Info_.Get("NS")
c.Assert(err, IsNil)
c.Assert(nsf, Equals, int(3))
dpf, err := v.Info_.Get("DP")
c.Assert(err, IsNil)
c.Assert(dpf, Equals, int(14))
hqs, err := v.Info_.Get("AF")
c.Assert(hqs, DeepEquals, []float32{0.5})
c.Assert(err, IsNil)
dpfs, err := v.Info_.Get("DP")
c.Assert(err, IsNil)
c.Assert(dpfs, DeepEquals, 14)
}
func (s *VariantSuite) TestInfoField(c *C) {
rdr, err := vcfgo.NewReader(s.reader, false)
c.Assert(err, IsNil)
v := rdr.Read() //.(*vcfgo.Variant)
vstr := fmt.Sprintf("%s", v.Info())
c.Assert(vstr, Equals, "NS=3;DP=14;AF=0.5;DB;H2")
}
func (s *VariantSuite) TestInfoMap(c *C) {
rdr, err := vcfgo.NewReader(s.reader, false)
c.Assert(err, IsNil)
v := rdr.Read() //.(*vcfgo.Variant)
vstr := fmt.Sprintf("%s", v)
c.Assert(vstr, 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:.,.")
v.Info_.Set("asdf", 123)
v.Info_.Set("float", 123.2001)
has, err := v.Info_.Get("asdf")
c.Assert(has, Equals, "123")
_, err = v.Info_.Get("float")
c.Assert(err, ErrorMatches, ".*float not found in header.*")
c.Assert(fmt.Sprintf("%s", v.Info_), Equals, "NS=3;DP=14;AF=0.5;DB;H2;asdf=123;float=123.2001")
rdr.Clear()
}
func (s *VariantSuite) TestStartEnd(c *C) {
rdr, err := vcfgo.NewReader(s.reader, false)
c.Assert(err, IsNil)
v := rdr.Read()
c.Assert(int(v.Start()), Equals, 14369)
c.Assert(int(v.End()), Equals, 14370)
}