ancestry-array-ingest

Parse an AncestryDNA raw export, record chip metadata and hashes, and convert it to a sorted, bgzipped GRCh37 VCF (tabix-indexed with bcftools) with correct ploidy, PAR handling and REF orientation. U

SKILL.md

GitHub

AncestryDNA array ingest

Trigger

A new or re-downloaded AncestryDNA ancestryDNA.txt, or a request to regenerate the GRCh37 VCF used by imputation.

Inputs and outputs

  • Input: the raw export (owner copy at vault/genome/ancestry_dna/ancestryDNA.txt) and, for imputation-ready output, a local uncompressed GRCh37 FASTA (GENOME_REFERENCE_ROOT).
  • Output (gitignored scratch): people/robert_clark_jr/vcf_output/*.vcf.gz, .tbi, *.conversion_summary.json, *.unconverted_rows.tsv. Archive reviewed outputs under vault/genome/converted/ on private only.

Privacy classification

Raw rows and VCFs are direct identifiers: R4 / do_not_share. Never copy them into tests, examples, logs, prompts or public branches.

Preconditions

  • Record the export's sha256 before reading it; keep the original bytes unchanged.
  • bcftools (BCFTOOLS_PATH) sorts, compresses and indexes; with --no-bcftools the converter writes a sorted BGZF file without a tabix index.

Procedure

  1. Convert with an explicit --sample-sex; male writes non-PAR X and Y as haploid.
  2. Use --reference-fasta to orient REF/ALT; unresolved rows go to unconverted_rows.tsv.
  3. Keep the legacy header fields (##aave_sample_sex, AAVE_REF_UNKNOWN) so outputs stay diffable with earlier VCFs.

Stop conditions

Stop when the hash differs from the manifest, the build is not GRCh37, or the reference FASTA naming does not match (1..22, X, Y, MT).

Failure handling

Malformed rows are counted and listed, never guessed. A missing FASTA yields an inspection-only VCF that is clearly labeled as not imputation-ready.

Validation

tests/test_convert_ancestry_vcf.py, test_genome_header.py, test_genome_orientation.py.

Example (synthetic)

.\.venv\Scripts\python.exe scripts\convert_ancestry_vcf.py `
  --input tests\fixtures\synthetic\ancestry_raw_synthetic.txt `
  --output-dir out\synthetic-vcf --sample-id synthetic --sample-sex male --no-bcftools

Cannot support

Strand and orientation are inferred from the reference, not from the array; a converted call is still an array call, not sequencing.