pcrPrimer <- "GGACTACCVGGGTATCTAAT"
library(ShortRead)
X11.options(type="Xlib")


dirPath <- "../extdata/barcode"
rp <- RochePath(dirPath)
bar <- read454(rp, "1.*fna", "1.*qual")

## access
sread(bar)
quality(bar)

## subset
bar254 <- bar[width(bar) == 254]
m <- as(quality(bar254), "matrix")
plot(colMeans(m))

## summarize
abc <- alphabetByCycle(sread(bar254))
abc[1:4,100:110]

tbls <- tables(sread(bar254))
xyplot(nReads ~ nOccurrences,
       tbls[["distribution"]],
       scales=list(log=TRUE))

## trim
codes <- narrow(sread(bar), 1, 8)
(counts <- tables(codes)[["top"]])

aBar <- bar[as.character(codes)==names(counts)[[1]]]
noBar <- narrow(aBar, 11, width(aBar))
trimmed <- trimLRPatterns(pcrPrimer,
                          subject=noBar,
                          Lfixed=FALSE)
