-
Notifications
You must be signed in to change notification settings - Fork 3
/
test-add_RFLP.R
76 lines (69 loc) · 2.29 KB
/
test-add_RFLP.R
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
context('RFLP')
test_that('RFLP matching considers both strands', {
enzymes <- iSTOP:::process_enzymes(recognizes = 'c')
enzymes <- enzymes[enzymes$enzyme == 'MnlI', ]
# The basic pattern should match if edited base is present
expect_equal(
iSTOP:::identify_RFLP_enzymes('CCTc', enzymes),
'MnlI'
)
# But should not match if no edited base is present
expect_equal(
iSTOP:::identify_RFLP_enzymes('CCTC', enzymes),
NA_character_
)
# If match on opposite strand then should match nothing and return an empty string
expect_equal(
iSTOP:::identify_RFLP_enzymes('GAGGCCTc', enzymes),
NA_character_
)
# If match two overlapping sites then should return nothing
expect_equal(
iSTOP:::identify_RFLP_enzymes('CCTCCTc', enzymes),
NA_character_
)
# If match two overlapping sites then should return nothing
expect_equal(
iSTOP:::identify_RFLP_enzymes('GGTcCAG', enzymes),
NA_character_
)
# Overlapping on opposite forward and reverse patterns should match either
expect_equal(
stringr::str_locate_all('GGTcCAG', regex('(?=GGTc)|(?=cCAG)', ignore_case = T)) %>% purrr::map_int(nrow),
2
)
})
test_that('RFLP matching works for gained cutsite with t recognition', {
enzymes <- iSTOP:::process_enzymes(recognizes = 't')
enzymes <- enzymes[enzymes$enzyme == 'MnlI', ]
# The basic pattern should match if edited base is present
expect_equal(
iSTOP:::identify_RFLP_enzymes('CCtC', enzymes),
'MnlI'
)
# But should not match if no edited base is present
expect_equal(
iSTOP:::identify_RFLP_enzymes('CCTC', enzymes),
NA_character_
)
# If match on opposite strand then should match nothing and return an empty string
expect_equal(
iSTOP:::identify_RFLP_enzymes('GAGGCCtC', enzymes),
NA_character_
)
# If match two overlapping sites then should return nothing
expect_equal(
iSTOP:::identify_RFLP_enzymes('CCTCCtC', enzymes),
NA_character_
)
# If match two overlapping sites then should return nothing
expect_equal(
iSTOP:::identify_RFLP_enzymes('GGTtCAG', enzymes),
NA_character_
)
# Overlapping on opposite forward and reverse patterns should match either
expect_equal(
stringr::str_locate_all('GGTtCAG', regex('(?=GGTt)|(?=tCAG)', ignore_case = T)) %>% purrr::map_int(nrow),
2
)
})