# Loading PE data.
bamFile <- system.file("exdata", "pet.bam", package="csaw")
xparam <- readParam(pe="both")
out <- windowCounts(bamFile, param=xparam, filter=1)
outBam <- dumpPE(bamFile, "whee", param=xparam)
out2 <- windowCounts(outBam, param=reform(xparam, fast.pe=TRUE), filter=1)
stopifnot(identical(assay(out), assay(out2)))
stopifnot(identical(out$totals, out2$totals))
unlink("whee.bam")
# Comparing it to a more complex scenario.
xparam <- readParam(pe="both", rescue.ext=200)
out <- windowCounts(bamFile, param=xparam, filter=1)
outBam <- dumpPE(bamFile, "whee", param=xparam)
out2 <- windowCounts(outBam, param=reform(xparam, fast.pe=TRUE), filter=1)
stopifnot(identical(assay(out), assay(out2)))
stopifnot(identical(out$totals, out2$totals))
# Looking at extracted reads.
last.reg <- rowRanges(out)[6]
reg1 <- extractReads(last.reg, bamFile, param=xparam)
reg2 <- extractReads(last.reg, outBam, param=reform(xparam, fast.pe=TRUE))
stopifnot(identical(sort(reg1), sort(reg2)))
unlink("whee.bam")
Run the code above in your browser using DataLab