/usr/lib/R/site-library/IRanges/unitTests/test_intra-range-methods.R is in r-bioc-iranges 2.12.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | test_shift_Ranges <- function() {
ir0 <- IRanges(0, 0)
ir1 <- shift(ir0, .Machine$integer.max)
checkTrue(validObject(ir1))
checkIdentical(.Machine$integer.max, start(ir1))
checkIdentical(.Machine$integer.max, end(ir1))
checkIdentical(1L, width(ir1))
checkIdentical(ir1, shift(ir1))
checkIdentical(ir1, shift(shift(ir1, -10), 10))
ir2 <- shift(ir0, -.Machine$integer.max)
checkTrue(validObject(ir2))
checkIdentical(-.Machine$integer.max, start(ir2))
checkIdentical(-.Machine$integer.max, end(ir2))
checkIdentical(1L, width(ir2))
checkIdentical(ir2, shift(ir2))
checkIdentical(ir2, shift(shift(ir2, 10), -10))
## shift() would produce an object with ranges that are not within the
## [-.Machine$integer.max, .Machine$integer.max] range.
checkException(suppressWarnings(shift(ir1, 1)), silent=TRUE)
checkException(suppressWarnings(shift(ir2, -1)), silent=TRUE)
ir3 <- IRanges(1999222000, width=1000)
checkException(suppressWarnings(shift(ir3, 188222000)), silent=TRUE)
ir4 <- IRanges(1:20, width=222000000)
checkException(suppressWarnings(shift(ir4, 1:20 * 99000000L)), silent=TRUE)
}
test_narrow_Ranges <- function() {
ir1 <- IRanges(c(2,5,1), c(3,7,3))
checkIdentical(narrow(ir1, start=1, end=2),
IRanges(c(2, 5, 1), c(3, 6, 2)))
checkException(narrow(ir1, start=10, end=20), silent = TRUE)
}
test_narrow_RangesList <- function() {
range1 <- IRanges(start=c(2,5), end=c(3,7))
range2 <- IRanges(start=1, end=3)
for (compress in c(TRUE, FALSE)) {
collection <- IRangesList(range1, range2, compress = compress)
checkIdentical(narrow(collection, start=1, end=2),
IRangesList(IRanges(c(2, 5), c(3, 6)), IRanges(1, 2),
compress = compress))
checkException(narrow(collection, start=10, end=20), silent = TRUE)
}
}
test_resize_Ranges <- function() {
ir1 <- IRanges(c(2,5,1), c(3,7,3))
checkIdentical(resize(ir1, width=10),
IRanges(c(2, 5, 1), width=10))
checkIdentical(resize(ir1, width=10, fix="end"),
IRanges(c(-6, -2, -6), width=10))
checkIdentical(resize(ir1, width=10, fix="center"),
IRanges(c(-2, 1, -3), width=10))
checkIdentical(resize(ir1, width=10, fix=c("start", "end", "center")),
IRanges(c(2, -2, -3), width=10))
checkException(resize(ir1, -1), silent = TRUE)
}
test_resize_RangesList <- function() {
range1 <- IRanges(start=c(2,5), end=c(3,7))
range2 <- IRanges(start=1, end=3)
for (compress in c(TRUE, FALSE)) {
collection <- IRangesList(range1, range2, compress = compress)
checkIdentical(resize(collection, width=10),
IRangesList(IRanges(c(2, 5), width=10), IRanges(1, width=10),
compress = compress))
checkIdentical(resize(collection, width=10, fix="end"),
IRangesList(IRanges(c(-6, -2), width=10), IRanges(-6, width=10),
compress = compress))
checkIdentical(resize(collection, width=10, fix="center"),
IRangesList(IRanges(c(-2, 1), width=10), IRanges(-3, width=10),
compress = compress))
checkIdentical(resize(collection, width=10,
fix=CharacterList(c("start", "end"), "center")),
IRangesList(IRanges(c(2, -2), width=10), IRanges(-3, width=10),
compress = compress))
checkException(resize(collection, -1), silent = TRUE)
}
}
test_flank_Ranges <- function() {
checkIdentical(flank(IRanges(), 2), IRanges())
ir1 <- IRanges(c(2, 5, 1), c(3, 7, 3))
checkIdentical(flank(ir1, 2), IRanges(c(0, 3, -1), c(1, 4, 0)))
checkIdentical(flank(ir1, 2, FALSE), IRanges(c(4, 8, 4), c(5, 9, 5)))
checkIdentical(flank(ir1, 2, c(FALSE, TRUE, FALSE)),
IRanges(c(4, 3, 4), c(5, 4, 5)))
checkIdentical(flank(ir1, c(2, -2, 2)), IRanges(c(0, 5, -1), c(1, 6, 0)))
checkIdentical(flank(ir1, 2, both = TRUE), IRanges(c(0, 3, -1), c(3, 6, 2)))
checkIdentical(flank(ir1, 2, FALSE, TRUE), IRanges(c(2, 6, 2), c(5, 9, 5)))
checkIdentical(flank(ir1, -2, FALSE, TRUE), IRanges(c(2, 6, 2), c(5, 9, 5)))
checkException(flank(ir1, 2, both = c(TRUE, FALSE, TRUE)),
silent = TRUE) # not vectorized
checkException(flank(ir1, 2, c(FALSE, TRUE, NA)), silent = TRUE)
checkException(flank(ir1, NA), silent = TRUE)
}
test_flank_RangesList <- function() {
range1 <- IRanges(start=c(2,5), end=c(3,7))
range2 <- IRanges(start=1, end=3)
for (compress in c(TRUE, FALSE)) {
collection <- IRangesList(range1, range2, compress = compress)
checkIdentical(flank(collection, 2),
IRangesList(IRanges(c(0, 3), c(1, 4)), IRanges(-1, 0),
compress = compress))
checkIdentical(flank(collection, 2, FALSE),
IRangesList(IRanges(c(4, 8), c(5, 9)), IRanges(4, 5),
compress = compress))
checkIdentical(flank(collection, 2, LogicalList(c(FALSE, TRUE), FALSE)),
IRangesList(IRanges(c(4, 3), c(5, 4)), IRanges(4, 5),
compress = compress))
checkIdentical(flank(collection, IntegerList(c(2, -2), 2)),
IRangesList(IRanges(c(0, 5), c(1, 6)), IRanges(-1, 0),
compress = compress))
checkIdentical(flank(collection, 2, both = TRUE),
IRangesList(IRanges(c(0, 3), c(3, 6)), IRanges(-1, 2),
compress = compress))
checkIdentical(flank(collection, 2, FALSE, TRUE),
IRangesList(IRanges(c(2, 6), c(5, 9)), IRanges(2, 5),
compress = compress))
checkIdentical(flank(collection, -2, FALSE, TRUE),
IRangesList(IRanges(c(2, 6), c(5, 9)),
IRanges(2, 5), compress = compress))
checkException(flank(collection, 2, both = c(TRUE, FALSE, TRUE)),
silent = TRUE) # not vectorized
checkException(flank(collection, 2, LogicalList(c(FALSE, TRUE), NA)),
silent = TRUE)
checkException(flank(collection, NA), silent = TRUE)
}
}
test_promoters <- function() {
ir <- IRanges(c(10, 10), width=c(0, 1))
checkIdentical(width(promoters(ir, 0, 0)), c(0L, 0L))
checkIdentical(width(promoters(ir, 1, 0)), c(1L, 1L))
checkIdentical(start(promoters(ir, 1, 0)), c(9L, 9L))
checkIdentical(width(promoters(ir, 0, 1)), c(1L, 1L))
checkIdentical(start(promoters(ir, 0, 1)), c(10L, 10L))
ir <- IRanges(c(5, 2, 20), width=1)
checkIdentical(start(promoters(ir, 5, 2)), c(0L, -3L, 15L))
rl <- RangesList("A"=IRanges(5:7, width=1), "B"=IRanges(10:12, width=5))
current <- promoters(rl, 0, 0)
checkIdentical(names(current), names(rl))
checkIdentical(start(current), start(rl))
current <- promoters(rl, 2, 0)
checkIdentical(unique(unlist(width(current))), 2L)
library(XVector)
subject <- XInteger(10, 3:-6)
view <- Views(subject, start=4:2, end=4:6)
current <- promoters(view, 0, 0)
checkIdentical(start(current), start(view))
current <- promoters(view, 2, 0)
checkIdentical(unique(width(current)), 2L)
cmp <- IRangesList("A"=IRanges(5:7, width=1), "B"=IRanges(10:12, width=5))
current <- promoters(rl, 0, 0)
checkIdentical(names(current), names(rl))
checkIdentical(start(current), start(rl))
current <- promoters(rl, 2, 0)
checkIdentical(unique(unlist(width(current))), 2L)
}
test_reflect_Ranges <- function() {
ir1 <- IRanges(c(2,5,1), c(3,7,3))
bounds <- IRanges(c(0, 5, 3), c(10, 6, 9))
checkIdentical(reflect(ir1, bounds),
IRanges(c(7, 4, 9), c(8, 6, 11)))
checkException(reflect(ir1, IRanges()), silent = TRUE)
}
test_restrict_Ranges <- function() {
ir1 <- IRanges(c(2,5,1), c(3,7,3))
checkIdentical(restrict(ir1, start=2, end=5),
IRanges(c(2, 5, 2), c(3, 5, 3)))
checkIdentical(restrict(ir1, start=1, end=2),
IRanges(c(2, 1), c(2, 2)))
checkIdentical(restrict(ir1, start=1, end=2, keep.all.ranges=TRUE),
IRanges(c(2, 3, 1), c(2, 2, 2)))
}
test_restrict_RangesList <- function() {
range1 <- IRanges(start=c(2,5), end=c(3,7))
range2 <- IRanges(start=1, end=3)
for (compress in c(TRUE, FALSE)) {
collection <- IRangesList(range1, range2, compress = compress)
checkIdentical(restrict(collection, start=2, end=5),
IRangesList(IRanges(c(2, 5), c(3, 5)), IRanges(2, 3),
compress = compress))
checkIdentical(restrict(collection, start=1, end=2),
IRangesList(IRanges(2, 2), IRanges(1, 2),
compress = compress))
checkIdentical(restrict(collection, start=1, end=2, keep.all.ranges=TRUE),
IRangesList(IRanges(c(2, 3), c(2, 2)), IRanges(1, 2),
compress = compress))
}
}
test_zoom_Ranges <- function() {
ir <- IRanges(c(1,5), c(3,10))
checkIdentical(ir*1, ir)
checkIdentical(ir*c(1,2), IRanges(c(1,6), c(3, 8)))
checkIdentical(ir*-2, IRanges(c(-1,2), c(4, 13)))
checkException(ir*NA_integer_, silent = TRUE)
checkException(ir*numeric(), silent = TRUE)
checkException(ir*c(1,2,1), silent = TRUE)
checkException(ir[rep(1,3)]*c(1,2), silent = TRUE)
}
|