Expand description
Extract byte ranges from BAM files and output as interleaved FASTQ or BAM.
This library provides efficient extraction of specific byte ranges from BAM (Binary Alignment/Map) files and outputs them as interleaved FASTQ or BAM. This enables parallel processing of large BAM files by splitting them into chunks that can be processed independently.
§Key Features
- Block-aligned extraction: Automatically aligns to BGZF block boundaries for valid data
- Paired-read aware: Ensures read pairs are kept together across chunk boundaries
- Interleaved FASTQ output: Compatible with
samtools fastqinterleaved format - BAM output: Raw-copies middle BGZF blocks, only recompressing at slice boundaries
- Barcode support: Preserves BC tags in FASTQ headers
§BGZF Block Format
BAM files use BGZF (Blocked GNU Zip Format) compression. Each block is independently compressed, allowing random access. This library scans for valid BGZF block headers using an 8-byte signature and validates blocks by decompressing and checking for valid BAM records.
§Implementation Notes
- Read pairs are kept together by reading one extra record past the end boundary if needed
Modules§
- fastp
- Merge multiple fastp JSON output files into a single aggregated result, as if fastp had been run on the entire dataset at once.
Enums§
- Output
Format - Output format for extracted reads.
Functions§
- process_
blocks - Process a byte range from a BAM file and output in the specified format.