-
Notifications
You must be signed in to change notification settings - Fork 14
/
alleles_test.go
45 lines (40 loc) · 1.23 KB
/
alleles_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
/*
* alleles_test.go
* allhic
*
* Created by Haibao Tang on 06/28/19
* Copyright © 2019 Haibao Tang. All rights reserved.
*/
package allhic_test
import (
"path/filepath"
"testing"
"github.com/tanghaibao/allhic"
)
// setupAlleler reads in test.paf and return the object for testing
func setupAlleler() allhic.Alleler {
pafFile := filepath.Join("tests", "test.paf")
reFile := filepath.Join("tests", "test.counts_RE.txt")
alleler := allhic.Alleler{PafFile: pafFile, ReFile: reFile}
alleler.Run()
return alleler
}
func TestParsePafFile(t *testing.T) {
alleler := setupAlleler()
expectedNumRecords := 10
if len(alleler.Paf.Records) != expectedNumRecords {
t.Fatalf("Expected %d records, got %d", expectedNumRecords, len(alleler.Paf.Records))
}
cmValue, ok := alleler.Paf.Records[0].Tags["cm"].(int)
if !ok {
t.Fatal("Cannot find the cm tag in the first PAF record")
}
expectedCmValue := 5277
if cmValue != expectedCmValue {
t.Fatalf("The first record is expected to have cm %d, got %d", expectedCmValue, cmValue)
}
expectedLength := 135917
if gotLength := alleler.ReCounts.Records[0].Length; gotLength != expectedLength {
t.Fatalf("The first record is expected to have length %d, got %d", expectedLength, gotLength)
}
}