This file is indexed.

/usr/lib/R/site-library/ShortRead/unitTests/test_functions.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
 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
## readFastq

test_readFastq_autoDetectType <- function() 
{
    src <- system.file("unitTests","cases", package="ShortRead")
    srq <- readFastq(file.path(src, "sanger.fastq"))
    checkTrue(class(quality(srq)) == "FastqQuality")
    srq <- readFastq(file.path(src, "solexa.fastq"))
    checkTrue(class(quality(srq)) == "SFastqQuality")
    srq <- readFastq(file.path(src, "solexa.fastq"),
                     qualityType="FastqQuality")
    checkTrue(class(quality(srq)) == "FastqQuality")
}

test_readFastq_withids <- function() {
    sp <- SolexaPath(system.file('extdata', package='ShortRead'))
    rfq <- readFastq(analysisPath(sp), pattern="s_1_sequence.txt")
    rfq1 <- readFastq(analysisPath(sp), pattern="s_1_sequence.txt",
                      withIds=FALSE)
    checkIdentical(as.character(sread(rfq)), as.character(sread(rfq1)))
    checkIdentical(as.character(quality(quality(rfq))),
                   as.character(quality(quality(rfq1))))
    checkIdentical(as.character(id(rfq1)), character(length(rfq1)))
}

test_readFastq_zerowidth <- function() {
    fl <- tempfile();
    writeLines("@ \n\n+\n", fl)
    fq <- readFastq(fl)
    checkTrue(validObject(fq))
    checkIdentical(0L, width(fq))
}

## alphabetByCycle

checkAlphabetByCycle <- function(obj) {
    abc <- alphabetByCycle(obj)
    validObject(abc)
    checkEquals(length(obj)*unique(width(obj)), sum(abc))
}

test_alphabetByCycle <- function() {
    sp <- SolexaPath(system.file('extdata', package="ShortRead"))
    sq <- readFastq(sp)

    checkAlphabetByCycle(sread(sq))
    checkAlphabetByCycle(quality(sq))

    obj <- alphabetByCycle(sq)
    validObject(obj)
    checkEquals(c(18, 94, 36), dim(obj))

    checkEqualsNumeric(alphabetByCycle(sread(sq)),
                       apply(obj, c(1, 3), sum))
    checkEqualsNumeric(alphabetByCycle(quality(sq)),
                       apply(obj, 2:3, sum))

    obj <- rowSums(alphabetByCycle(id(sq)))
    obj <- obj[obj != 0]
    exp <- table(unlist(strsplit(as.character(id(sq)), ""),
                        use.names=FALSE))
    checkTrue(setequal(names(obj), names(exp)))
    checkIdentical(as.numeric(exp[names(obj)]),
                   as.vector(obj))

    srq <- ShortReadQ(DNAStringSet(), FastqQuality())
    abc <- alphabetByCycle(srq)
    alf <- alphabet(sread(srq))
    qalf <- alphabet(quality(srq))
    checkIdentical(matrix(0L, nrow=length(alf), ncol=0,
                          dimnames=list(alphabet=alf,
                            cycle=character(0))),
                   alphabetByCycle(sread(srq)))
    checkIdentical(array(0L, dim=c(18, 94, 0),
                         dimnames=list(base=alf, quality=qalf,
                           cycle=character(0))),
                   alphabetByCycle(srq))
}

## countLines

test_countLines <- function() {
    sp <- SolexaPath(system.file('extdata', package="ShortRead"))
    nlines <- countLines(analysisPath(sp), "s_1_sequence.txt")
    exp <- 1024; names(exp) <- "s_1_sequence.txt"
    checkEquals(exp, nlines)
    dir <- tempfile()
    dir.create(dir)
    checkException(countLines(dir), silent=TRUE)
}

## sort / order

test_order_stats <- function()
{
    checkIdentical(integer(0), srrank(AlignedRead()))
    checkIdentical(integer(0), srorder(AlignedRead()))
    checkIdentical(logical(0), srduplicated(AlignedRead()))
}

test_alphabetOrder <- function() {
    ## setup
    oldc <- Sys.getlocale("LC_COLLATE")
    on.exit(Sys.setlocale("LC_COLLATE", oldc))
    Sys.setlocale("LC_COLLATE", "C")
    sp <- SolexaPath(system.file('extdata', package='ShortRead'))
    rfq <- readFastq(analysisPath(sp), pattern="s_1_sequence.txt")

    checkEquals(srorder(sread(rfq)),
                order(as.character(sread(rfq))))
    checkEquals(srorder(quality(rfq)),
                order(as.character(quality(quality(rfq)))))

    checkEquals(srduplicated(sread(rfq)),
                duplicated(as.character(sread(rfq))))
    checkEquals(srduplicated(quality(rfq)),
                duplicated(as.character(quality(quality(rfq)))))
}

## _mark_field (C code)

test_mark_field <- function() {
    fl <- tempfile()
    do <- function(s, fl) {
        doexp(s, strsplit(unlist(strsplit(s, "\n")), "\t"), fl)
    }
    doexp <- function(s, exp, fl) {
        writeChar(s, fl)
        res <- .Call("_mark_field_test", fl, "\t", c(2L, 3L),
                     PACKAGE="ShortRead")
        checkIdentical(exp, res)
    }

    do("a\tb\tc\nd\te\tf\n", fl)
    do("a\t\tc\nd\te\tf\n", fl)
    do("\tb\tc\nd\te\tf\n", fl)
    do("\t\tc\nd\te\tf\n", fl)

    ## trailing \t are problematic for strsplit
    doexp("a\tb\t\nd\te\tf\n",
          list(c("a","b",""), c("d","e","f")),
          fl)
    doexp("a\t\t\nd\te\tf\n",
          list(c("a","",""), c("d","e","f")),
          fl)

    writeChar("\n", fl)
    res <- .Call("_mark_field_test", fl, "\t", c(1L,1L),
                 PACKAGE="ShortRead")
    checkIdentical(list(""), res)
}