Skip to content
Prev 3928 / 21312 Next

[Bioc-devel] Reading FASTQ/BAM from open file handle?

On 12/04/2012 03:17 PM, Ryan C. Thompson wrote:
Well, playing around a little I did this in one terminal

~$ mkfifo myfifo
~$ cat tmp/bam/ex1.bam > myfifo

And then in R

   library(Rsamtools)
   scanBam("~/myfifo")  # or, e.g., readBamGappedAlignments("~/myfifo")

so I guess there are hacks. The way to iterate through a bam file is with BamFile

   bf = BamFile("myfifo", yieldSize=100000L)

but it's requiring an index when opened

 > open(bf)
Error in open.BamFile(bf) : failed to load BAM index
   file: myfifo
In addition: Warning message:
In open.BamFile(bf) : [bam_index_load] fail to load BAM index.

so you'd be stuck parsing the whole file...

Martin