Module reader

Module reader 

Source
Expand description

VCF/BCF file reader with optional index support.

This module provides Reader, a unified interface for reading VCF/BCF files that automatically detects and uses tabix (.tbi) or CSI (.csi) indices when available.

§Index Detection

When opening a file, the reader checks for index files at {path}.tbi and {path}.csi. If found, region queries are enabled via Reader::query.

§Example

use htsvcf_core::reader::open_reader;

let mut reader = open_reader("input.vcf.gz").unwrap();

// Check if indexed
if reader.has_index() {
    // Query a specific region
    reader.query("chr1:1000-2000", None, None).unwrap();
}

// Iterate over records
while let Ok(Some(record)) = reader.next_record() {
    println!("pos = {}", record.pos());
}

§Types

  • Reader: Main reader interface
  • InnerReader: Enum wrapping indexed or unindexed htslib readers
  • open_reader: Constructor that auto-detects index availability

Structs§

Reader
A VCF/BCF file reader with automatic index detection.

Enums§

InnerReader
Internal enum wrapping indexed or unindexed htslib readers.

Functions§

open_reader
Open a VCF/BCF file for reading.