export
methods for BSgenome objects. NOTE: The export
generic function and most of
its methods are defined and documented in the rtracklayer package.
This man page only documents the 2 export
methods define in the BSgenome package.
"export"(object, con, format, compress=FALSE, compression_level=NA, verbose=TRUE)
"export"(object, con, format, ...)
Alternatively con
can be a single string containing the
path to a FASTA or twoBit file, in which case either the file extension
or the format
argument needs to be "fasta"
, "twoBit"
,
or "2bit"
.
Also note that in this case, the export
method
that is called is either the method with signature
c("ANY", "character", "missing")
or the method with signature
c("ANY", "character", "character")
, both defined in the
rtracklayer package. If object
is a BSgenome object
and the file extension or the format
argument is
"fasta"
, "twoBit"
, or "2bit"
, then the flow
eventually reaches one of 2 methods documented here.
"fasta"
, "twoBit"
, or
"2bit"
(case insensitive for "twoBit"
and "2bit"
).
writeXStringSet
.
See ?writeXStringSet
for the details.
TRUE
by default.
bsapply
.
export
generic, and
FastaFile and TwoBitFile
objects in the rtracklayer package.
library(BSgenome.Celegans.UCSC.ce2)
genome <- BSgenome.Celegans.UCSC.ce2
## Export as FASTA file.
out1_file <- file.path(tempdir(), "Celegans.fasta")
export(genome, out1_file)
## Export as twoBit file.
out2_file <- file.path(tempdir(), "Celegans.2bit")
export(genome, out2_file)
## Sanity checks:
dna0 <- DNAStringSet(as.list(genome))
system.time(dna1 <- import(out1_file))
stopifnot(identical(names(dna0), names(dna1)) && all(dna0 == dna1))
system.time(dna2 <- import(out2_file)) # importing twoBit is 10-20x
# faster than importing non
# compressed FASTA
stopifnot(identical(names(dna0), names(dna2)) && all(dna0 == dna2))
Run the code above in your browser using DataLab