import bio.std.hts.bam.reader, std.stdio; ... auto bam = new BamReader("file.bam"); auto refseq = bam["chr17"]; writeln(refseq.name, " - length ", refseq.length); foreach (read; refseq[1234 .. 5678]) if (read.cigar.length > 1) writeln(read.name, " ", read.cigarString());
Each BAM file contains reads aligned to different reference sequences.
These sequences have unique identifiers in BAM file, starting from 0. Unmapped reads are associated with id = -1.
If BAI file is available, fast region queries are available, that is, getting all reads that overlap given region. This is achieved via opSlice method.