Skip to main content

clinvar-proto

Generates clinvar_proto — a typed Python package for parsing NCBI ClinVar VCV XML into protobuf and pydantic models — from the ClinVar VCV XSD.

This repository is the generator, not the package. It holds the inputs (ClinVar_VCV_2.6.xsd, clinvar_transforms.yaml) and drives xsd-former (the xsdformer CLI) to emit the clinvar_proto source tree, which is then built into a wheel and published to PyPI. The generated tree (generated/) and build outputs (dist/) are gitignored — only the inputs are version-controlled.

Sibling to pubmed-proto; same generate-on-demand model.

Consuming clinvar_proto

Depend on the published wheel, not this repo:

pip install clinvar_proto      # or: uv add clinvar_proto
from lxml import etree
from clinvar_proto import xml_converter, pydantic_converter, models

tree = etree.parse('clinvar_release.xml')
archive_el = tree.getroot().find('VariationArchive')

proto = xml_converter.VariationArchiveType(archive_el)  # XML -> protobuf
model = pydantic_converter.VariationArchiveType_from_proto(proto)  # protobuf -> pydantic
json_str = model.model_dump_json()  # pydantic -> JSON

The converters take any ElementTree-like element, so lxml is the consumer's choice, not a dependency of the wheel (clinvar_proto needs only protobuf and pydantic). Release files are large, so consumers normally stream them with lxml.etree.iterparse on VariationArchive and convert one element at a time. Use lxml >= 6.1 if you do: earlier releases resolve external entities by default in iterparse (CVE-2026-41066).

The package exposes four modules (all typed; ships py.typed):

module purpose
clinvar_pb2 compiled protobuf messages (VariationArchiveType, …)
models pydantic models mirroring the protobuf schema
xml_converter ClinVar XML → protobuf (per-message factory funcs)
pydantic_converter protobuf ↔ pydantic (X_from_proto / X_to_proto)

Developing the generator

Requires uv.

make generate   # XSD + transforms -> generated/clinvar_proto/
make build      # generate, then build the wheel into dist/
make clean      # remove generated/ and dist/
uv run --group test pytest   # round-trip gate over real ClinVar records

Shaping the output is done in clinvar_transforms.yaml — inlining single- child wrappers, flattening list wrappers, and attaching documentation comments to the generated messages and fields. See the xsd-former docs for the transform reference.

Provenance & attribution

ClinVar_VCV_2.6.xsd is the NCBI ClinVar VCV XSD, version 2.6 (dated 2026-02-26):

https://ftp.ncbi.nlm.nih.gov/pub/clinvar/xsd_public/ClinVar_VCV_2.6.xsd

The vendored file is byte-identical to upstream (MD5 a7b65e5a166dc5f36a7eea9127d56f4e, matching NCBI's published ClinVar_VCV_2.6.xsd.md5). NCBI ClinVar data and schemas are U.S. Government works and public domain in the United States; the MIT LICENSE in this repo covers CPG's own files (transforms, generator wiring, tests), not the NCBI XSD.

Courtesy of the U.S. National Library of Medicine. NLM/NCBI does not endorse this package. The vendored XSD and the ClinVar records under tests/records/ are pinned snapshots and do not necessarily reflect the most current data available from NCBI — fetch from NCBI directly for current data.

The XSD is vendored deliberately, not fetched at build time: pinning the exact bytes keeps the generated schema reproducible, and NCBI's XSD version is bumped in place under a new filename rather than being immutable per release. When NCBI publishes a new version, re-vendor the file from https://ftp.ncbi.nlm.nih.gov/pub/clinvar/xsd_public/, point the Makefile and tests at it, regenerate, and run the round-trip gate.

Releasing

The published version is build.version in clinvar_transforms.yaml (what xsdformer stamps into the wheel). To release:

  1. Bump build.version in clinvar_transforms.yaml.
  2. Publish a GitHub Release tagged vX.Y.Z matching that version.

The release workflow generates, builds, and publishes to PyPI via Trusted Publishing (OIDC). It fails if the tag and build.version disagree.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clinvar_proto-0.1.0.tar.gz (106.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

clinvar_proto-0.1.0-py3-none-any.whl (110.1 kB view details)

Uploaded Python 3

File details

Details for the file clinvar_proto-0.1.0.tar.gz.

File metadata

  • Download URL: clinvar_proto-0.1.0.tar.gz
  • Upload date:
  • Size: 106.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for clinvar_proto-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b1780881f1bd3a06a33966f957236ac8945485de7a90f2d1a82b33adca096bf1
MD5 875e45cbe8796903d0a84aea3397f62e
BLAKE2b-256 a22dd748a9b375d53a9b07dccba1274700f63dd1b79d1354ca95ea0f73b68ed3

See more details on using hashes here.

Provenance

The following attestation bundles were made for clinvar_proto-0.1.0.tar.gz:

Publisher: release.yml on populationgenomics/clinvar-proto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clinvar_proto-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clinvar_proto-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 110.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for clinvar_proto-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5e83761729b7e255d42a19ac709e331e04f549cda1769f683728d5b27ac9fe9
MD5 c9d242e4b1f78e8d0934cb10215bbbb2
BLAKE2b-256 98f023c0f7220a0d7ab4f0229ad37386188924d6de0bbace80b7e4b17751de2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for clinvar_proto-0.1.0-py3-none-any.whl:

Publisher: release.yml on populationgenomics/clinvar-proto

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page