-
Notifications
You must be signed in to change notification settings - Fork 1
/
granges_findOverlaps_test.go
98 lines (80 loc) · 2.68 KB
/
granges_findOverlaps_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
/* Copyright (C) 2016 Philipp Benner
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package gonetics
/* -------------------------------------------------------------------------- */
//import "fmt"
import "testing"
/* -------------------------------------------------------------------------- */
func TestOverlapsList(t *testing.T) {
s := NewEndPointList()
r1 := endPoint{100, nil, nil, 1, true}
r2 := endPoint{200, nil, nil, 1, true}
r3 := endPoint{300, nil, nil, 1, true}
r4 := endPoint{300, nil, nil, 1, true}
s.Append(r1)
s.Append(r2)
s.Append(r3)
s.Remove(r2)
if s[0] != r1 {
t.Error("TestOverlapsStack failed!")
}
if s[1] != r3 {
t.Error("TestOverlapsStack failed!")
}
if s[1] != r4 {
t.Error("TestOverlapsStack failed!")
}
}
func TestOverlaps1(t *testing.T) {
rSubjects := NewGRanges(
[]string{"chr4", "chr4", "chr4", "chr4"},
[]int{100, 200, 300, 400},
[]int{150, 250, 350, 450},
[]byte{})
rQuery := NewGRanges(
[]string{"chr1", "chr4", "chr4", "chr4", "chr4", "chr4"},
[]int{100, 110, 190, 340, 390, 450},
[]int{150, 120, 220, 360, 400, 500},
[]byte{})
queryHits, subjectHits := FindOverlaps(rQuery, rSubjects)
if len(queryHits) != 3 {
t.Error("TestOverlaps1 failed!")
}
if queryHits[0] != 1 || queryHits[1] != 2 || queryHits[2] != 3 ||
(subjectHits[0] != 0 || subjectHits[1] != 1 || subjectHits[2] != 2) {
t.Error("TestOverlaps1 failed!")
}
}
func TestOverlaps2(t *testing.T) {
rSubjects := NewGRanges(
[]string{"chr4", "chr4", "chr4", "chr4"},
[]int{100, 200, 300, 400},
[]int{900, 800, 700, 600},
[]byte{})
rQuery := NewGRanges(
[]string{"chr4", "chr4"},
[]int{600, 850},
[]int{950, 950},
[]byte{})
queryHits, subjectHits := FindOverlaps(rQuery, rSubjects)
if len(queryHits) != 4 {
t.Error("TestOverlaps1 failed!")
}
if queryHits[0] != 0 || queryHits[1] != 0 || queryHits[2] != 0 || queryHits[3] != 1 ||
(subjectHits[0] != 0 || subjectHits[1] != 1 || subjectHits[2] != 2 || subjectHits[3] != 0) {
t.Error("TestOverlaps2 failed!")
}
}