/usr/lib/R/site-library/ShortRead/unitTests/test_coverage.R is in r-bioc-shortread 1.36.0-1.
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 | .width <- 10
.mkAln <- function(position, width, strand)
{
n <- length(position)
AlignedRead(sread=DNAStringSet(rep(polyn("A", width), n)),
chromosome=rep("ChrA", n),
position=as.integer(position),
strand=strand)
}
test_coverage_leftmost_plus <- function()
{
## 'leftmost'
## 1 2
## 8 7 2
## ++++++++++-----
## ....|....|....|....|....|
aln <- .mkAln(8L, .width, strand("+"))
cvg <- coverage(aln, width=c(ChrA=25L), extend=5L)
checkIdentical(c(7L, 15L, 3L), runLength(cvg[[1]]))
}
test_coverage_leftmost_minus <- function()
{
## ....|....|....|....|
## -----++++++++++
## 3 8 1
## 7
aln <- .mkAln(8L, .width, strand("-"))
cvg <- coverage(aln, width=c(ChrA=20L), extend=5L)
checkIdentical(c(2L,15L,3L), runLength(cvg[[1]]))
}
test_coverage_fiveprime_plus <- function()
{
## 5'
## 1 2
## 8 7 2
## ++++++++++-----
## ....|....|....|....|....|
aln <- .mkAln(8L, .width, strand("+"))
cvg <- coverage(aln, width=c(ChrA=25L), coords="fiveprime", extend=5L)
checkIdentical(c(7L, 15L, 3L), runLength(cvg[[1]]))
}
test_coverage_fiveprime_minus <- function()
{
## ....|....|....|....|....|
## -----++++++++++
## 3 8 1
## 7
aln <- .mkAln(17L, .width, strand("-"))
cvg <- coverage(aln, width=c(ChrA=25L), coords="fiveprime", extend=5L)
checkIdentical(c(2L, 15L, 8L), runLength(cvg[[1]]))
}
test_coverage_width_names <- function()
{
aln <- .mkAln(1, 10, strand("+"))
checkTrue(validObject(coverage(aln)))
checkTrue(validObject(coverage(aln, width=c(ChrA=20L))))
## no names on width
checkException(coverage(aln, width=100), silent=TRUE)
## wrong name on width
checkException(coverage(aln, width=c(ChrB=100)), silent=TRUE)
## extra width element -- ok
checkTrue(validObject(coverage(aln, width=c(ChrA=20L, ChrB=20L))))
}
|