fas <- system.file("extdata", "Bacteria_175seqs.fas", package="DECIPHER")
dna <- as.character(readDNAStringSet(fas)) # aligned sequences
object.size(dna)
# compression
system.time(x <- Codec(dna, compression="auto"))
object.size(x)/sum(nchar(dna)) # bytes per position
system.time(g <- Codec(dna, compression="gzip"))
object.size(g)/sum(nchar(dna)) # bytes per position
# decompression
system.time(y <- Codec(x))
stopifnot(dna==y)
system.time(z <- Codec(g))
stopifnot(dna==z)
Run the code above in your browser using DataLab