This file is indexed.

/usr/lib/R/site-library/Rsamtools/unitTests/test_BcfFile.R is in r-bioc-rsamtools 1.30.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
fl <- system.file("extdata", "ex1.bcf", package="Rsamtools")

test_BcfFile_openclose <- function()
{
    .normalizePath <- Rsamtools:::.normalizePath
    bf <- BcfFile(fl, character(0))     # no index
    checkTrue(!isOpen(bf))
    open(bf)
    checkTrue(isOpen(bf))
    checkIdentical(.normalizePath(fl), path(bf))
    checkIdentical(character(0), index(bf, asNA=FALSE))
    checkIdentical(NA_character_, index(bf))
    close(bf)
    checkTrue(!isOpen(bf))
    checkException(close(bf), silent=TRUE)
    bf <- open(bf)                   # open a closed BcfFile
    checkTrue(isOpen(bf))
    bf1 <- open(bf)                  # (re)open BcfFile
    checkTrue(isOpen(bf1))
    checkTrue(identical(bf$.extptr, bf1$.extptr))

    checkTrue(isOpen(bf))
    checkIdentical(.normalizePath(fl), path(bf))
    ## checkIdentical(.normalizePath(fl), index(bf))
}

test_BcfFile_scanBcfHeader <- function()
{
    .chk <- function(h) {
        checkTrue(validObject(h))
        checkEquals(3L, length(h))
        checkEquals(2L, length(h[["Reference"]]))
        checkEquals("ex1.bam", h[["Sample"]])
        checkEquals(1L, length(h[["Header"]]))
        checkEquals(c(0, 0), dim(h[["Header"]][["META"]]))
    }
    bf <- open(BcfFile(fl, character(0)))
    .chk(scanBcfHeader(bf))
    bf <- BcfFile(fl, character(0))
    .chk(scanBcfHeader(bf))
    checkTrue(!isOpen(bf))

    header <-
        structure(list(Reference = character(0), Sample =
                       character(0), Header =
                       "##FORMAT=<ID=GD,Number=1,Type=Float,Description=\"alleles [0,2]\">"),
                       .Names = c("Reference", "Sample", "Header"))
    checkTrue(validObject(Rsamtools:::.bcfHeaderAsSimpleList(header)))
}

test_BcfFile_scanBcfHeader_no_SAMPLE_header <- function()
{
    fl <- system.file(package="Rsamtools", "unitTests", "cases",
                      "no_SAMPLE_header.vcf")
    bf <- open(BcfFile(fl, character(0)))
    on.exit(close(bf))
    sample <- scanBcfHeader(bf)[["Sample"]]
    exp <- c("NA00001", "NA00002", "NA00003")
    checkIdentical(exp, sample)
}

test_BcfFile_scanBcfHeader_remote <- function()
{
    if ("windows" == .Platform$OS.type) {
        DEACTIVATED("remote scanBcFHeader not supported on Windows")
        return(TRUE)
    }

    fl <- "ftp://ftp.1000genomes.ebi.ac.uk/vol1/ftp/release/20110521/ALL.chr22.phase1_release_v3.20101123.snps_indels_svs.genotypes.vcf.gz"
    file <- tryCatch({
        open(BcfFile(fl))
    }, warning=function(w) {
        message("'test_BcfFile_scanBcfHeader_remote' warning:\n  ",
                conditionMessage(w))
        TRUE
    })
    if (is.logical(file))
        return(file)

    obs <- .Call(Rsamtools:::.scan_bcf_header, Rsamtools:::.extptr(file))
    close(file)
    exp <- setNames(c(0L, 1092L, 29L), c("Reference", "Sample", "Header"))
    checkIdentical(exp, sapply(obs, length))
}

test_BcfFile_scanBcfHeader_no_header_line <- function()
{
    fl <- system.file(package="Rsamtools", "unitTests", "cases",
                      "no_header_line.vcf")
    msg <- NULL
    tryCatch(scanBcfHeader(fl), error=function(err) {
        msg <<- conditionMessage(err)
    })
    checkIdentical("no 'header' line \"#CHROM POS ID...\"?", msg)
}

test_BcfFile_scan_noindex <- function()
{
    bf <- open(BcfFile(fl, character(0)))
    checkTrue(isOpen(bf))

    p <- ScanBcfParam()
    res <- scanBcf(bf, param=p)
    checkEquals(11L, length(res))
    checkEquals(3065L, res[["RecordsPerRange"]])
    checkEquals(3065L, unique(sapply(res[1:9], length)))
    checkEquals(1, length(res[["GENO"]]))
    checkEquals(3065L, length(res[["GENO"]][["PL"]]))

    checkIdentical(res, scanBcf(bf))
}

test_BcfFile_scan_index <- function()
{
    bf <- open(BcfFile(fl))
    which <- RangesList(seq1=IRanges(c(1, 1000), width=10),
                        seq2=IRanges(c(100, 1000), width=10))
    p <- ScanBcfParam(which=which)
    res <- scanBcf(bf, param=p)
    checkEquals(11L, length(res))
    checkEquals(c(0, 10, 10, 20), res[["RecordsPerRange"]])
    checkEquals(30L, unique(sapply(res[1:9], length)))
    checkEquals(1, length(res[["GENO"]]))
    checkEquals(30L, length(res[["GENO"]][["PL"]]))
}