Expand description
VCF/BCF header representation and manipulation.
This module provides the Header struct, which wraps an htslib bcf_hdr_t
pointer and provides safe access to header metadata including sample names,
INFO/FORMAT field definitions, and header modification.
§Ownership
Header owns its underlying bcf_hdr_t* via duplication. This ensures
correct lifetime management and thread safety - the header can outlive the
reader it was created from.
§Caching
Sample names and tag ID-to-name mappings are cached at construction time for O(1) lookups during variant processing.
§Example
use htsvcf_core::header::Header;
use rust_htslib::bcf::{self, Read};
let reader = bcf::Reader::from_path("input.vcf.gz").unwrap();
let header = unsafe { Header::new(reader.header().inner) };
// Access sample information
println!("Samples: {:?}", header.sample_names());
// Look up INFO field type
if let Some((ty, len)) = header.info_type(b"DP") {
println!("DP is {:?} with length {:?}", ty, len);
}Structs§
- Header
- A VCF/BCF header with metadata and sample information.
- Header
Field - Represents a field definition from the VCF header (INFO, FORMAT, or FILTER).