just_dna_enricher.pharmvar_build¶
just_dna_enricher.pharmvar_build ¶
Build the PharmVar snapshot ([dev]) — operator-built, inject-only, never published (RM38).
This one is not like the other two, and the difference is the whole entry. ClinPGx and CPIC
snapshots may be built once and published, so a deployment fetches bytes somebody else took. PharmVar's
cannot. Its API key is personal and non-transferable under terms §2, and no axis SourceTerms records
covers passing on bulk data pulled under one — redistribution=True is about the CC BY-SA grant over
the content, not about a clause on the account. An unestablished permission is never a permission
(None ≠ False, the same rule as share_alike/commercial_use), so there is deliberately no
download.ensure_pharmvar_snapshot, no pharmvar publish command, and no HF repo. An operator builds
their own with their own key, and locations.resolve_pharmvar_reference finds it.
One request builds the whole thing. /genes?exclude-sub-alleles=true returns all fifteen genes
with their alleles and defining variants in a single ~5 MB response (1,173 core alleles, 12,925 variant
rows, probed 2026-08-07). At 2 rps that is the difference between one call and fifteen, and it is why
this builder needs no pacing beyond the client's own gate.
The assembly filter is load-bearing here specifically. PharmVar publishes each variant against both
GRCh37 and GRCh38 and lists GRCh37 first; a snapshot is where a wrong coordinate stops being latent and
starts being a written number. pharmvar.PHARMVAR_GENOME_BUILD documents the probe — 451 of 739
rsID-keyed defining variants would have carried a GRCh37 position — and the parquet records the build
it kept, so a reader can check rather than assume.
Builder-only: polars is a guarded [dev] import; the runtime reads the parquet through DuckDB.
build_snapshot ¶
build_snapshot(
out_dir: Path,
*,
client: PharmVarClient | None = None,
include_sub_alleles: bool = False,
) -> PharmVarBuildResult
Fetch PharmVar whole and write data/*.parquet + release.json under out_dir.
Raises PharmVarError when no key is configured — unlike the runtime pass, where an absent key is
a skip. Building is an explicit act with an explicit output, so failing to build has to be an
error rather than an empty snapshot that later reads as "PharmVar defines nothing".
Source code in enricher/src/just_dna_enricher/pharmvar_build.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 | |