Skip to main content

parse_variants_by_contig

Function parse_variants_by_contig 

Source
pub fn parse_variants_by_contig(
    path: &Path,
    sample_name: Option<&str>,
    _dict: &SequenceDictionary,
) -> Result<ParsedVariants>
Expand description

Read every variant from a VCF in a single pass and partition by contig.

This is the one-pass replacement for the per-contig loader pattern that re-scanned the entire VCF for every contig. Mirrors crate::vcf::methylation::parse_methylation_vcf: read the file once before the contig loop, then look up per-contig records by name. Trades I/O for memory — every selected variant is held in the returned map until the caller drops it — which is the same trade-off the methylation loader already makes.

Ploidy is captured during this scan before the hom-ref/all-missing filter, so ParsedVariants::sample_ploidy reflects the true sample ploidy even on contigs (or whole samples) with no ALT calls.

§Arguments

  • path — Path to the VCF file (plain or BGZF; noodles autodetects).
  • sample_name — Sample to resolve genotypes for, or None to use the only sample in a single-sample VCF.
  • _dict — Sequence dictionary (reserved for future cross-validation against the reference).

§Errors

Returns an error if the VCF cannot be read, the sample is not found, or a GT field is malformed.