-
Notifications
You must be signed in to change notification settings - Fork 0
/
coverage_test.go
105 lines (82 loc) · 3.66 KB
/
coverage_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
94
95
96
97
98
99
100
101
102
103
104
105
package main
import "testing"
func TestCoveragePerGeneFromBed(t *testing.T) {
tt := []struct {
ENSG string
Symbol string
TotalTargetedBases int
BasesCovered5x int
BasesCovered10x int
BasesCovered20x int
BasesCovered30x int
}{
{"ENSG00000001626", "CFTR", 4443, 4443, 4443, 4313, 4129},
{"ENSG00000012048", "BRCA1", 5797, 5797, 5797, 5797, 5704},
{"ENSG00000277027", "RMRP", 0, 0, 0, 0, 0},
{"ENSG00000172062", "SMN1", 900, 900, 900, 900, 893},
{"ENSG00000198947", "DMD", 11621, 11621, 11621, 11621, 11503},
}
for i, test := range tt {
targets, _, _, _, _, _ := parseMosdepthBed("samples/example_mosdepth_coverage.bed.gz")
resultMap := getGeneCoverage(targets)
gene := resultMap[test.ENSG]
if gene.Symbol != test.Symbol {
t.Errorf("expected %s symbol, got %s on gene %s, test number %d", test.Symbol, gene.Symbol, gene.ENSG, i)
}
if gene.TotalBases != test.TotalTargetedBases {
t.Errorf("expected %d total bases for gene %s, got %d on test number %d", test.TotalTargetedBases, test.Symbol, gene.TotalBases, i)
}
if gene.BasesCovered5x != test.BasesCovered5x {
t.Errorf("expected %d bases covered at 5x for gene %s, got %d on test number %d", test.BasesCovered5x, test.Symbol, gene.BasesCovered5x, i)
}
if gene.BasesCovered10x != test.BasesCovered10x {
t.Errorf("expected %d bases covered at 10x for gene %s, got %d on test number %d", test.BasesCovered10x, test.Symbol, gene.BasesCovered10x, i)
}
if gene.BasesCovered20x != test.BasesCovered20x {
t.Errorf("expected %d bases covered at 20x for gene %s, got %d on test number %d", test.BasesCovered20x, test.Symbol, gene.BasesCovered20x, i)
}
if gene.BasesCovered30x != test.BasesCovered30x {
t.Errorf("expected %d bases covered at 30x for gene %s, got %d on test number %d", test.BasesCovered30x, test.Symbol, gene.BasesCovered30x, i)
}
}
}
func TestCoveragePerGeneFromVcf(t *testing.T) {
tt := []struct {
ENSG string
Symbol string
TotalTargetedBases int
BasesCovered5x int
BasesCovered10x int
BasesCovered20x int
BasesCovered30x int
}{
{"ENSG00000001626", "CFTR", 4443, 0, 4443, 0, 0},
{"ENSG00000012048", "BRCA1", 5658, 0, 5658, 0, 0},
{"ENSG00000277027", "RMRP", 0, 0, 0, 0, 0},
{"ENSG00000172062", "SMN1", 900, 0, 900, 0, 0},
{"ENSG00000198947", "DMD", 11213, 0, 11213, 0, 0},
}
for i, test := range tt {
targets, _, _ := parseGatkVcf("samples/example_gatk_coverage.vcf.gz")
resultMap := getGeneCoverage(targets)
gene := resultMap[test.ENSG]
if gene.Symbol != test.Symbol {
t.Errorf("expected %s symbol, got %s on gene %s, test number %d", test.Symbol, gene.Symbol, gene.ENSG, i)
}
if gene.TotalBases != test.TotalTargetedBases {
t.Errorf("expected %d total bases for gene %s, got %d on test number %d", test.TotalTargetedBases, test.Symbol, gene.TotalBases, i)
}
if gene.BasesCovered5x != test.BasesCovered5x {
t.Errorf("expected %d bases covered at 5x for gene %s, got %d on test number %d", test.BasesCovered5x, test.Symbol, gene.BasesCovered5x, i)
}
if gene.BasesCovered10x != test.BasesCovered10x {
t.Errorf("expected %d bases covered at 10x for gene %s, got %d on test number %d", test.BasesCovered10x, test.Symbol, gene.BasesCovered10x, i)
}
if gene.BasesCovered20x != test.BasesCovered20x {
t.Errorf("expected %d bases covered at 20x for gene %s, got %d on test number %d", test.BasesCovered20x, test.Symbol, gene.BasesCovered20x, i)
}
if gene.BasesCovered30x != test.BasesCovered30x {
t.Errorf("expected %d bases covered at 30x for gene %s, got %d on test number %d", test.BasesCovered30x, test.Symbol, gene.BasesCovered30x, i)
}
}
}