Expand description
VCF variant record representation and field access.
This module provides types and functions for working with VCF/BCF variant
records. The Variant struct wraps a bcf::Record and provides convenient
access to standard VCF fields (CHROM, POS, REF, ALT, etc.) as well as INFO
and FORMAT data.
§Value Types
InfoValue: Represents INFO field values (scalar, array, flag, or absent)FormatValue: Represents FORMAT field values (per-sample data)
§Standalone Functions
For cases where you have a borrowed bcf::Record reference (e.g., from a
GcCell in V8 bindings), standalone helper functions are provided:
record_info: Get INFO field from a borrowed recordrecord_format: Get FORMAT field from a borrowed recordrecord_sample: Get all FORMAT fields for a single samplerecord_samples: Get all FORMAT fields for multiple samplesrecord_to_string: Format record as VCF line
§Example
use htsvcf_core::variant::{Variant, InfoValue};
use htsvcf_core::header::Header;
use rust_htslib::bcf::{self, Read};
let mut reader = bcf::Reader::from_path("input.vcf.gz").unwrap();
let header = unsafe { Header::new(reader.header().inner) };
for result in reader.records() {
let record = result.unwrap();
let variant = Variant::from_record(record);
println!("{}:{}", variant.chrom(), variant.pos());
// Access INFO fields
match variant.info(&header, "DP") {
InfoValue::Int(dp) => println!("DP = {}", dp),
InfoValue::Absent => println!("No DP"),
_ => {}
}
}Structs§
- Variant
- A VCF/BCF variant record with convenient field accessors.
Enums§
- Format
Value - Represents a value from a FORMAT field in a VCF record.
- Info
Value - Represents a value from an INFO field in a VCF record.
Functions§
- format_
float_ missing - Get the missing value sentinel for FORMAT float fields.
- format_
int_ missing - Get the missing value sentinel for FORMAT integer fields.
- get_
format_ tag_ names - Get the list of FORMAT tag names present in a record.
- record_
clear_ format - Clear (remove) a FORMAT field from a record.
- record_
clear_ info - Clear an INFO field from a record.
- record_
format - Get a FORMAT field value from a record (per-sample).
- record_
info - Get an INFO field value from a record.
- record_
sample - Get sample data from a record for a single sample by name.
- record_
samples - Get sample data from a record for all samples or a subset.
- record_
set_ format_ float - Set a FORMAT float field on a record.
- record_
set_ format_ integer - Set a FORMAT integer field on a record.
- record_
set_ format_ string - Set a FORMAT string field on a record.
- record_
set_ info_ flag - Set an INFO flag value on a record.
- record_
set_ info_ float - Set an INFO float value on a record.
- record_
set_ info_ integer - Set an INFO integer value on a record.
- record_
set_ info_ string - Set an INFO string value on a record.
- record_
to_ string - Format a record as a VCF line string.