I would like to read iteratively the same BAM file twice using
My option is to use
sam_read1 as much as needed to read the file until EOF.
Is there a possibility to "rewind", and use
sam_read1 again from the beginning of the file, without closing the file, destroying the object, and opening it again?
My aim is group the reads by the barcode. The first pass would allocate the specific sizes first (the number of reads by barcode), then store the reads.
I know I could sort the reads first (using
samtools sort -t BX), but I would like to skip this step using pre-allocation.