struct HTS::Bam::Pileup::Column

Overview

A pileup column at a genomic position, as a zero-copy view over htslib's current pileup buffer. It holds only pointers and constructs Alignment values lazily, so iterating (#each / #[]) allocates nothing per read and matches the C mpileup hot-path cost.

BORROWING CONTRACT: a Column and any Alignment obtained from it are valid ONLY during the current iteration step (the current block invocation). To retain data across positions, read the copied-out scalars (Alignment#base, #base_qual, #query_pos) or call Alignment#record. Do not deref a Column after the iterator advances or the Pileup is closed.

This borrowed view intentionally does not include Enumerable: methods such as to_a or map would make short-lived C-backed entries look like ordinary retained Crystal values.

Defined in:

hts/bam/pileup.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(tid : Int32, pos : Int64, base : Pointer(LibHTS::BamPileup1T), count : Int32, header : Bam::Header) #

[View source]

Instance Method Detail

def [](index : Int32) : Alignment #

[View source]
def chrom : String #

Reference (chromosome) name for this position Returns empty string if tid is -1 (unmapped)


[View source]
def count : Int32 #

Number of reads covering this position.


[View source]
def count(& : Alignment -> Bool) : Int32 #

Count reads matching the block without materializing an Array.


[View source]
def depth : Int32 #

Depth equals number of alignments covering this position


[View source]
def each(& : Alignment -> ) : Nil #

Iterate the reads covering this position without allocating an Array.


[View source]
def pos : Int64 #

[View source]
def tid : Int32 #

[View source]