sp <- SolexaPath(system.file('extdata', package='ShortRead'))
fl <- file.path(analysisPath(sp), "s_1_sequence.txt")
f <- FastqFile(fl)
rfq <- readFastq(f)
close(f)
f <- FastqSampler(fl, 50)
yield(f) # sample of size n=50
yield(f) # independent sample of size 50
close(f)
## Return sample as ordered in original file
f <- FastqSampler(fl, 50, ordered=TRUE)
yield(f)
close(f)
f <- FastqStreamer(fl, 50)
yield(f) # records 1 to 50
yield(f) # records 51 to 100
close(f)
## iterating over an entire file
f <- FastqStreamer(fl, 50)
while (length(fq <- yield(f))) {
## do work here
print(length(fq))
}
close(f)
## iterating over IRanges
rng <- IRanges(c(50, 100, 200), width=10:8)
f <- FastqStreamer(fl, rng)
while (length(fq <- yield(f))) {
print(length(fq))
}
close(f)
## Internal fields, methods, and help; for developers
ShortRead:::.FastqSampler_g$methods()
ShortRead:::.FastqSampler_g$fields()
ShortRead:::.FastqSampler_g$help("yield")
Run the code above in your browser using DataLab