This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
vcf_whitebox_test.go
410 lines (325 loc) · 18.6 KB
/
vcf_whitebox_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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
package vcf
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type ParseVcfLineSuite struct {
suite.Suite
}
var defaultHeader = []string{"CHROM", "POS", "ID", "REF", "ALT", "QUAL", "FILTER", "INFO"}
func (s *ParseVcfLineSuite) TestBlankLineShouldReturnError() {
result, err := parseVcfLine("\t ", defaultHeader)
assert.Error(s.T(), err, "Line with only blanks should return empty and an error")
assert.Empty(s.T(), result, "Line with only blanks should return emptyand an error")
}
func (s *ParseVcfLineSuite) TestContinuousLineShouldReturnError() {
result, err := parseVcfLine("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc tellus ligula, faucibus sed nibh sed, fringilla viverra enim.", defaultHeader)
assert.Error(s.T(), err, "Line with continuous text should return empty and an error")
assert.Empty(s.T(), result, "Line with continuous text should return empty and an error")
}
func (s *ParseVcfLineSuite) TestEmptyFieldedLineShouldReturnError() {
result, err := parseVcfLine("\t\t\t\t\t", defaultHeader)
assert.Error(s.T(), err, "Line with empty fields should return empty and an error")
assert.Empty(s.T(), result, "Line with empty fields should return empty and an error")
}
func (s *ParseVcfLineSuite) TestWrongFormattedFieldedLineShouldReturnError() {
result, err := parseVcfLine("A\tB\tC\tD\tE\tF", defaultHeader)
assert.Error(s.T(), err, "Line with wrong formatted fields should return empty and an error")
assert.Empty(s.T(), result, "Line with wrong formatted fields should return empty and an error")
}
func (s *ParseVcfLineSuite) TestValidLineShouldReturnOneElementAndNoErrors() {
result, err := parseVcfLine("1\t847491\trs28407778\tGT\tA\t745.77\tPASS\tAC=1;AF=0.500;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 1, "Valid VCF should return a list with one element")
assert.Equal(s.T(), result[0].Chrom, "1", "result.Chrom should be 1")
assert.Equal(s.T(), result[0].Pos, 847490, "result.Pos should be 0-based to 847490")
assert.Equal(s.T(), result[0].Ref, "GT", "result.Ref should be GT")
assert.Equal(s.T(), result[0].Alt, "A", "result.Alt should be A")
}
func (s *ParseVcfLineSuite) TestValidLineWithChrShouldStripIt() {
result, err := parseVcfLine("chr1\t847491\trs28407778\tGT\tA\t745.77\tPASS\tAC=1;AF=0.500;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 1, "Valid VCF should return a list with one element")
assert.Equal(s.T(), result[0].Chrom, "1", "result.Chrom should be 1")
assert.Equal(s.T(), result[0].Pos, 847490, "result.Pos should be 0-based to 847490")
assert.Equal(s.T(), result[0].Ref, "GT", "result.Ref should be GT")
assert.Equal(s.T(), result[0].Alt, "A", "result.Alt should be A")
}
func (s *ParseVcfLineSuite) TestValidLineWithLowercaseRefAndAltShouldReturnOneElementAndNoErrors() {
result, err := parseVcfLine("1\t847491\trs28407778\tgt\ta\t745.77\tPASS\tAC=1;AF=0.500;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 1, "Valid VCF should return a list with one element")
assert.Equal(s.T(), result[0].Chrom, "1", "result.Chrom should be 1")
assert.Equal(s.T(), result[0].Pos, 847490, "result.Pos should be 0-based to 847490")
assert.Equal(s.T(), result[0].Ref, "GT", "result.Ref should be GT")
assert.Equal(s.T(), result[0].Alt, "A", "result.Alt should be A")
}
func (s *ParseVcfLineSuite) TestDotsShouldBeRemovedFromValidLineAlternative() {
result, err := parseVcfLine("1\t847491\trs28407778\tGTTTA\tG....\t745.77\tPASS\tAC=1;AF=0.500;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 1, "Valid VCF should return a list with one element")
assert.Equal(s.T(), result[0].Chrom, "1", "result.Chrom should be 1")
assert.Equal(s.T(), result[0].Pos, 847490, "result.Pos should be 0-based to 847490")
assert.Equal(s.T(), result[0].Ref, "GTTTA", "result.Ref should be GTTTA")
assert.Equal(s.T(), result[0].Alt, "G", "result.Alt should be G")
}
func (s *ParseVcfLineSuite) TestValidLineWithMultipleAlternativesShouldReturnThreeElementsAndNoErrors() {
result, err := parseVcfLine("1\t847491\trs28407778\tGT\tA,C,G\t745.77\tPASS\tAC=1;AF=0.300,0.300,0.400;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 3, "Valid VCF should return a list with one element")
assert.Equal(s.T(), result[0].Chrom, "1", "result[0].Chrom should be 1")
assert.Equal(s.T(), result[0].Pos, 847490, "result[0].Pos should be 0-based to 847490")
assert.Equal(s.T(), result[0].Ref, "GT", "result[0].Ref should be GT")
assert.Equal(s.T(), result[0].Alt, "A", "result[0].Alt should be A")
assert.Equal(s.T(), result[1].Chrom, "1", "result[1].Chrom should be 1")
assert.Equal(s.T(), result[1].Pos, 847490, "result[1].Pos should be 0-based to 847490")
assert.Equal(s.T(), result[1].Ref, "GT", "result[1].Ref should be GT")
assert.Equal(s.T(), result[1].Alt, "C", "result[1].Alt should be A")
assert.Equal(s.T(), result[2].Chrom, "1", "result[2].Chrom should be 1")
assert.Equal(s.T(), result[2].Pos, 847490, "result[2].Pos should be 0-based to 847490")
assert.Equal(s.T(), result[2].Ref, "GT", "result[2].Ref should be GT")
assert.Equal(s.T(), result[2].Alt, "G", "result[2].Alt should be A")
}
func (s *ParseVcfLineSuite) TestValidLineWithSampleGenotypeFields() {
result, err := parseVcfLine("1\t847491\trs28407778\tGTTTA\tG....\t745.77\tPASS\tAC=1;AF=0.500;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 1, "Valid VCF should return a list with one element")
samples := result[0].Samples
assert.NotNil(s.T(), samples, "Valid VCF should contain slice of sample maps")
assert.Exactly(s.T(), len(samples), 1, "Valid VCF should contain one sample")
sampleMap := samples[0]
assert.NotNil(s.T(), sampleMap, "Genotype field mapping should not return nil")
assert.Exactly(s.T(), len(sampleMap), 5, "Sample map should have as many keys as there are formats")
gt, ok := sampleMap["GT"]
assert.True(s.T(), ok, "GT key must be found")
assert.Equal(s.T(), gt, "0/1", "gt")
ad, ok := sampleMap["AD"]
assert.True(s.T(), ok, "AD key must be found")
assert.Equal(s.T(), ad, "16,25", "ad")
dp, ok := sampleMap["DP"]
assert.True(s.T(), ok, "AD key must be found")
assert.Equal(s.T(), dp, "41", "dp")
gq, ok := sampleMap["GQ"]
assert.True(s.T(), ok, "GQ key must be found")
assert.Equal(s.T(), gq, "99", "gq")
pl, ok := sampleMap["PL"]
assert.True(s.T(), ok, "PL key must be found")
assert.Equal(s.T(), pl, "774,0,434", "pl")
}
func (s *ParseVcfLineSuite) TestInfoFields() {
result, err := parseVcfLine("1\t847491\trs28407778\tG\tA,C\t745.77\tPASS\tAC=1,2;AF=0.500,0.335;AN=2;BQ=30.00;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;NS=27;H2;H3;SOMATIC;VALIDATED;1000G;MLEAC=1;MLEAF=0.500;END=847492;MQ=60.00;MQ0=0;SB=0.127;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;CIGAR=a;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 2, "Valid VCF should return a list with two elements")
info := result[0].Info
assert.NotNil(s.T(), info, "Valid VCF should contain info map")
assert.Exactly(s.T(), len(info), 28, "Info should contain 20 keys")
ac, ok := info["AC"]
assert.True(s.T(), ok, "AC key must be found")
assert.Equal(s.T(), ac, "1", "ac")
af, ok := info["AF"]
assert.True(s.T(), ok, "AF key must be found")
assert.Equal(s.T(), af, "0.500", "af")
af, ok = result[1].Info["AF"]
assert.True(s.T(), ok, "AF key must be found")
assert.Equal(s.T(), af, "0.335", "af")
db, ok := info["DB"]
assert.True(s.T(), ok, "DB key must be found")
booldb, isbool := db.(bool)
assert.True(s.T(), isbool, "DB value must be a boolean")
assert.True(s.T(), booldb)
_, ok = info["AA"]
assert.False(s.T(), ok, "AA key must not be found")
aa := result[0].AncestralAllele
assert.Nil(s.T(), aa, "No AA field")
dp := result[0].Depth
assert.NotNil(s.T(), dp, "Depth field of first element must be found")
assert.Equal(s.T(), *dp, 41)
dp = result[1].Depth
assert.NotNil(s.T(), dp, "Depth field of second element must be found")
assert.Equal(s.T(), *dp, 41)
freq := result[0].AlleleFrequency
assert.NotNil(s.T(), freq, "AlleleFrequency field must be found")
assert.Equal(s.T(), *freq, 0.500)
freq = result[1].AlleleFrequency
assert.NotNil(s.T(), freq, "AlleleFrequency field must be found")
assert.Equal(s.T(), *freq, 0.335)
count := result[0].AlleleCount
assert.NotNil(s.T(), count, "AlleleCount field must be found")
assert.Equal(s.T(), *count, 1)
count = result[1].AlleleCount
assert.NotNil(s.T(), count, "AlleleCount field must be found")
assert.Equal(s.T(), *count, 2)
total := result[0].TotalAlleles
assert.NotNil(s.T(), total, "TotalAlleles field must be found")
assert.Equal(s.T(), *total, 2)
end := result[0].End
assert.NotNil(s.T(), end, "End field must be found")
assert.Equal(s.T(), *end, 847492)
mapq0reads := result[0].MAPQ0Reads
assert.NotNil(s.T(), mapq0reads, "MAPQ0Reads field must be found")
assert.Equal(s.T(), *mapq0reads, 0)
numSamples := result[0].NumberOfSamples
assert.NotNil(s.T(), numSamples, "NumberOfSamples field must be found")
assert.Equal(s.T(), *numSamples, 27)
mq := result[0].MappingQuality
assert.NotNil(s.T(), mq, "MappingQuality field must be found")
assert.Equal(s.T(), *mq, 60.0)
cigar := result[0].Cigar
assert.NotNil(s.T(), cigar, "Cigar field must be found")
assert.Equal(s.T(), *cigar, "a")
dbsnp := result[0].InDBSNP
assert.NotNil(s.T(), dbsnp, "InDBSNP field must be found")
assert.True(s.T(), *dbsnp)
h2 := result[0].InHapmap2
assert.NotNil(s.T(), h2, "InHapmap2 field must be found")
assert.True(s.T(), *h2)
h3 := result[0].InHapmap3
assert.NotNil(s.T(), h3, "InHapmap3 field must be found")
assert.True(s.T(), *h3)
somatic := result[0].IsSomatic
assert.NotNil(s.T(), somatic, "IsSomatic field must be found")
assert.True(s.T(), *somatic)
validated := result[0].IsValidated
assert.NotNil(s.T(), validated, "IsValidated field must be found")
assert.True(s.T(), *validated)
thousand := result[0].In1000G
assert.NotNil(s.T(), thousand, "In1000G field must be found")
assert.True(s.T(), *thousand)
bq := result[0].BaseQuality
assert.NotNil(s.T(), bq, "BaseQuality field must be found")
assert.Equal(s.T(), *bq, 30.0)
strandBias := result[0].StrandBias
assert.NotNil(s.T(), strandBias, "StrandBias field must be found")
assert.Equal(s.T(), *strandBias, 0.127)
}
func (s *ParseVcfLineSuite) TestInfoWithoutFormat() {
result, err := parseVcfLine("1\t847491\trs28407778\tG\tA,C\t745.77\tPASS\tAC=1,2;AF=0.500,0.335;AN=2;BQ=30.00;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;DP=41;FS=0.000;NS=27;H2;H3;SOMATIC;VALIDATED;1000G;MLEAC=1;MLEAF=0.500;END=847492;MQ=60.00;MQ0=0;SB=0.127;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;CIGAR=a;culprit=FS;toxic\n", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 2, "Valid VCF should return a list with two elements")
info := result[0].Info
assert.NotNil(s.T(), info, "Valid VCF should contain info map")
assert.Exactly(s.T(), len(info), 28, "Info should contain 28 keys")
ac, ok := info["AC"]
assert.True(s.T(), ok, "AC key must be found")
assert.Equal(s.T(), ac, "1", "ac")
toxic, ok := info["toxic"]
assert.True(s.T(), ok, "toxic key must be found")
booltoxic, isbool := toxic.(bool)
assert.True(s.T(), isbool, "toxic value must be a boolean")
assert.True(s.T(), booltoxic)
}
func (s *ParseVcfLineSuite) TestAncestralAllele() {
result, _ := parseVcfLine("1\t847491\trs28407778\tG\tA,C\t745.77\tPASS\tAC=1;AF=0.500,0.335;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;AA=T;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
aa := result[0].AncestralAllele
assert.NotNil(s.T(), aa, "AncestralAllele field must be found")
assert.Equal(s.T(), *aa, "T")
}
func (s *ParseVcfLineSuite) TestAlternateFormatOptionalField() {
var result []*Variant
var err error
assert.NotPanics(s.T(), func() {
result, err = parseVcfLine("1\t847491\trs28407778\tG\tA\t745.77\tPASS\tSB=strong;AA\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
})
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
info := result[0].Info
assert.NotNil(s.T(), info, "Valid VCF should contain info map")
assert.Exactly(s.T(), len(info), 2, "Info should contain 2 keys")
sb, ok := info["SB"]
assert.True(s.T(), ok, "SB key must be found")
assert.Equal(s.T(), sb, "strong")
aa, ok := info["AA"]
assert.True(s.T(), ok, "AA key must be found")
boolaa, isbool := aa.(bool)
assert.True(s.T(), isbool, "AA value must be a boolean")
assert.True(s.T(), boolaa)
}
func (s *ParseVcfLineSuite) TestGenotype() {
result, _ := parseVcfLine("1\t847491\trs28407778\tG\tA,C\t745.77\tPASS\tAC=1;AF=0.500,0.335;AN=2;BaseQRankSum=0.842;ClippingRankSum=0.147;DB;AA=T;DP=41;FS=0.000;MLEAC=1;MLEAF=0.500;MQ=60.00;MQ0=0;MQRankSum=-1.109;QD=18.19;ReadPosRankSum=0.334;VQSLOD=2.70;culprit=FS;set=variant\tGT:AD:DP:GQ:PL\t0/1:16,25:41:99:774,0,434", defaultHeader)
samples := result[0].Samples
assert.NotNil(s.T(), samples, "Samples must be found")
assert.Len(s.T(), samples, 1, "There must be one sample")
sample := samples[0]
gt, found := sample["GT"]
assert.True(s.T(), found, "GT key must be found")
assert.Equal(s.T(), gt, "0/1")
}
func TestParseVcfLineSuite(t *testing.T) {
suite.Run(t, new(ParseVcfLineSuite))
}
func (s *ParseVcfLineSuite) TestValidCNVShouldReturnOneElementAndNoErrors() {
result, err := parseVcfLine("22\t16533236\tSI_BD_17525\tC\t<CN0>\t100\tPASS\tAC=125;AF=0.0249601;AN=5008;CIEND=-50,141;CIPOS=-141,50;CS=DEL_union;END=16536204;NS=2504;SVLEN=-2968;SVTYPE=DEL;DP=14570;EAS_AF=0;AMR_AF=0.0086;AFR_AF=0.09;EUR_AF=0;SAS_AF=0\tGT", defaultHeader)
assert.NoError(s.T(), err, "Valid VCF line should not return error")
assert.NotNil(s.T(), result, "Valid VCF line should not return nil")
assert.Exactly(s.T(), len(result), 1, "Valid VCF should return a list with one element")
assert.Equal(s.T(), result[0].Chrom, "22", "result.Chrom should be 2")
assert.Equal(s.T(), result[0].Pos, 16533235, "result.Pos should be 0-based to 16533235")
assert.Equal(s.T(), result[0].Ref, "C", "result.Ref should be C")
assert.Equal(s.T(), result[0].Alt, "<CN0>", "result.Alt should be A")
}
type FixSuffixSuite struct {
suite.Suite
}
func (s *FixSuffixSuite) TestNoSuffix() {
variant := Variant{
Ref: "T",
Alt: "C",
}
result := fixRefAltSuffix(&variant)
assert.Equal(s.T(), variant.Ref, result.Ref, "no suffix in common should return the same ref")
assert.Equal(s.T(), variant.Alt, result.Alt, "no suffix in common should return the same alt")
}
func (s *FixSuffixSuite) TestSmallSuffix() {
variant := Variant{
Ref: "GC",
Alt: "TC",
}
result := fixRefAltSuffix(&variant)
assert.Equal(s.T(), "G", result.Ref, "GC -> TC should become ref G")
assert.Equal(s.T(), "T", result.Alt, "GC -> TC should become alt T")
}
func (s *FixSuffixSuite) TestBigSuffix() {
variant := Variant{
Ref: "CGGCCACGTCCCCCTATGGAGGG",
Alt: "TGGCCACGTCCCCCTATGGAGGG",
}
result := fixRefAltSuffix(&variant)
assert.Equal(s.T(), "C", result.Ref, "CGGCCACGTCCCCCTATGGAGGG -> TGGCCACGTCCCCCTATGGAGGG should become ref C")
assert.Equal(s.T(), "T", result.Alt, "CGGCCACGTCCCCCTATGGAGGG -> TGGCCACGTCCCCCTATGGAGGG should become alt T")
}
func (s *FixSuffixSuite) TestBigSuffixWithBigResult() {
variant := Variant{
Ref: "CGGCCACGTCCCCCTATGGAGGG",
Alt: "CGGCCACGTCCCCCTATGGAGGGGGCCACGTCCCCCTATGGAGGG",
}
result := fixRefAltSuffix(&variant)
assert.Equal(s.T(), "C", result.Ref, "CGGCCACGTCCCCCTATGGAGGG -> CGGCCACGTCCCCCTATGGAGGGGGCCACGTCCCCCTATGGAGGG should become ref C")
assert.Equal(s.T(), "CGGCCACGTCCCCCTATGGAGGG", result.Alt, "CGGCCACGTCCCCCTATGGAGGG -> CGGCCACGTCCCCCTATGGAGGGGGCCACGTCCCCCTATGGAGGG should become alt T")
}
func TestFixSuffixSuite(t *testing.T) {
suite.Run(t, new(FixSuffixSuite))
}
type SplitVcfFieldsSuite struct {
suite.Suite
}
func (s *SplitVcfFieldsSuite) TestNewlineChomp() {
line := "X\t32632420\t.\tN\t<DEL>\t87.2\tPASS\tSVTYPE=DEL;END=32717410;EXPECTED=1071;OBSERVED=17;RATIO=0.0159;BF=87.2\tGT\t1/1\n"
vcfLine, err := splitVcfFields(line)
assert.NoError(s.T(), err, "split should not fail")
assert.NotNil(s.T(), vcfLine, "vcf line can't be nil")
assert.NotEmpty(s.T(), vcfLine.Samples, "samples can't be empty")
gt := vcfLine.Samples[0]["GT"]
assert.Equal(s.T(), "1/1", gt)
}
func TestSplitVcfFieldsSuite(t *testing.T) {
suite.Run(t, new(SplitVcfFieldsSuite))
}