Skip to content

Make VCF header-field matching data-driven (field as selector), aligning VCF with the SAM header_field design #237

Description

@NoopDog

Context

Surfaced during self-review of #221 (PR #234). match_vcf_header_pattern bakes the matched field into code, one canonical field per header type:

So a rule can only ever match the one hard-coded field per type. Matching a different ##contig subfield (e.g. species, md5) would require a code change.

The asymmetry

The SAM side is already data-driven — the field is a parameter and rules declare it:

match_sam_header_pattern(header, section, field, pattern)   # SAM: field is a PARAMETER (rules carry header_field: PL/SN/AS/...)
match_vcf_header_pattern(header, header_type, pattern)      # VCF: field baked in per type

Proposal

Make the VCF matched field declarative, mirroring SAM. Either a vcf_header_field key in the rule when (preferred, matches the SAM header_field convention) or a type.field selector form (e.g. ##contig.assembly). The engine's _match_vcf_header would pass the field through, and match_vcf_header_pattern would look it up instead of hard-coding it.

Interaction with #154 (READ BEFORE STARTING)

#154 (rules with fact-based antecedents: extractors + derivers + rules) is the umbrella this sits under. If #154 introduces extractors that emit named facts and rules that match facts, the entire regex-against-a-named-header-field mechanism — both today's and this proposal's — is subsumed: rules would match a reference_assembly fact, not a regex against ##contig.assembly.

Therefore:

Related deriver work: #236 (accession->assembly) is itself a #154-style deriver.

Definition of done

  • Decide the declarative form (vcf_header_field key vs type.field selector); prefer parity with SAM's header_field.
  • match_vcf_header_pattern looks up the declared field; engine _match_vcf_header passes it through.
  • Migrate the existing VCF header rules (contig/INFO/FORMAT/FILTER) to declare their field.
  • Rule schema/validation accepts and (where possible) validates the field.
  • Tests updated; make test-all, make lint, make format-check, make type pass.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions