BcfFile {Rsamtools} | R Documentation |
Manipulate BCF files.
Description
Use BcfFile()
to create a reference to a BCF (and optionally
its index). The reference remains open across calls to methods,
avoiding costly index re-loading.
BcfFileList()
provides a convenient way of managing a list of
BcfFile
instances.
Usage
## Constructors
BcfFile(file, index = file,
mode=ifelse(grepl("\\.bcf$", file), "rb", "r"))
BcfFileList(...)
## Opening / closing
## S3 method for class 'BcfFile'
open(con, ...)
## S3 method for class 'BcfFile'
close(con, ...)
## accessors; also path(), index()
## S4 method for signature 'BcfFile'
isOpen(con, rw="")
bcfMode(object)
## actions
## S4 method for signature 'BcfFile'
scanBcfHeader(file, ...)
## S4 method for signature 'BcfFile'
scanBcf(file, ..., param=ScanBcfParam())
## S4 method for signature 'BcfFile'
indexBcf(file, ...)
Arguments
con , object |
An instance of |
file |
A character(1) vector of the BCF file path or, (for
indexBcf) an instance of |
index |
A character(1) vector of the BCF index. |
mode |
A character(1) vector; |
param |
An optional |
... |
Additional arguments. For |
rw |
Mode of file; ignored. |
Objects from the Class
Objects are created by calls of the form BcfFile()
.
Fields
The BcfFile
class inherits fields from the
RsamtoolsFile
class.
Functions and methods
BcfFileList
inherits methods from
RsamtoolsFileList
and SimpleList
.
Opening / closing:
- open.BcfFile
Opens the (local or remote)
path
andindex
(ifbamIndex
is notcharacter(0)
), files. Returns aBcfFile
instance.- close.BcfFile
Closes the
BcfFile
con
; returning (invisibly) the updatedBcfFile
. The instance may be re-opened withopen.BcfFile
.
Accessors:
- path
Returns a character(1) vector of the BCF path name.
- index
Returns a character(1) vector of BCF index name.
- bcfMode
Returns a character(1) vector BCF mode.
Methods:
- scanBcf
Visit the path in
path(file)
, returning the result ofscanBcf
applied to the specified path.- show
Compactly display the object.
Author(s)
Martin Morgan
Examples
fl <- system.file("extdata", "ex1.bcf.gz", package="Rsamtools",
mustWork=TRUE)
bf <- BcfFile(fl) # implicit index
bf
identical(scanBcf(bf), scanBcf(fl))
rng <- GRanges(c("seq1", "seq2"), IRanges(1, c(1575, 1584)))
param <- ScanBcfParam(which=rng)
bcf <- scanBcf(bf, param=param) ## all ranges
## ranges one at a time 'bf'
open(bf)
sapply(seq_len(length(rng)), function(i, bcfFile, rng) {
param <- ScanBcfParam(which=rng)
bcf <- scanBcf(bcfFile, param=param)[[1]]
## do extensive work with bcf
isOpen(bf) ## file remains open
}, bf, rng)