just_dna_enricher.mitomap_build¶
just_dna_enricher.mitomap_build ¶
Build the MITOMAP snapshot the miss lane joins against (RM171).
The acquire stage is a plain curl of https://mitomap.org/downloads/mitomap.dump.sql.gz. That is
worth stating because the web surface of the same host answers curl and the fetch tool with a
Cloudflare 403 — which is why this source's terms had to be read from a browser — while the data
surface has no interstitial at all. Two surfaces, two answers, and the negative belongs to the one it
was measured on (@two-surfaces-two-denominators).
The build keeps six tables out of a 6.76 M-line dump and throws the other hundred away: the two
curated variant tables, their two reference link tables, reference, and edit_date. Each variant
row carries its source columns verbatim beside the four derived ones — the split status, the mapped
clin_sig, the reason its alleles cannot be spelled as VCF where that applies, and the gene where
locus names exactly one.
The dataset label comes from inside the dump, which is what makes a local build comparable. The
dump carries edit_date, a per-table curation date (mMut, rtMut), and the label is both of them —
the same choice ClinVar makes with ##fileDate rather than with Last-Modified. The header and the
sha256 are recorded in release.json beside it, because provenance of the fetch is a different
question from identity of the content, and a build from --dump <file> has the second and not the
first.
DownloadedDump
dataclass
¶
Where the dump landed and what the server said about it.
MitomapBuildResult
dataclass
¶
MitomapBuildResult(
out_dir: Path,
parquet_files: list[Path],
rows: dict[str, int] = dict(),
edit_dates: dict[str, str | None] = dict(),
reference_rows: int = 0,
references_with_pmid: int = 0,
references_without_nlmid: int = 0,
references_not_a_pmid: int = 0,
citation_links: int = 0,
unmintable: dict[str, int] = dict(),
withheld_brackets: dict[str, int] = dict(),
dataset: str | None = None,
source_sha256: str | None = None,
source_last_modified: str | None = None,
)
What the snapshot holds and what it came from.
download_mitomap_dump ¶
Stream the MITOMAP dump to dest (atomic .part rename), hashing while streaming.
httpx's exceptions do not leave this function (@client-exception-contract): a Cloudflare
403 on a mistyped path has to reach the CLI as MITOMAP BUILD FAILED: … rather than as a raw
HTTPStatusError, and the half-written .part goes with it so a failed run leaves the directory
as it found it.
Source code in enricher/src/just_dna_enricher/mitomap_build.py
dataset_label ¶
mitomap_<mmutation date>+<rtmutation date> from the dump's own edit_date table.
In band, and that is the ClinVar precedent rather than a preference. ClinVar's dataset is
the ##fileDate its VCF states about itself, not the Last-Modified its server states about the
transfer — so the same label comes out whether the file was downloaded or handed over. The dump
has the same property in edit_date, and taking it there is what lets mitomap build --dump from
a copy on disk produce a snapshot that can be compared against a downloaded one. The header and
the sha256 are still recorded in release.json; they are provenance of the fetch, which is a
different question.
Two dates, because this lane adopts two tables and they are curated separately. A compound
artifact gets a compound label — the same shape the derived miss lane uses for its two parents.
Taking the later of the two would state that a rtmutation from August applies to an mmutation
from October, and None where either is missing, because half a label is not a shorter label: it
is one that cannot be compared.
Source code in enricher/src/just_dna_enricher/mitomap_build.py
build_snapshot ¶
build_snapshot(
dump: Path,
out_dir: Path,
*,
source_url: str = DEFAULT_MITOMAP_URL,
source_sha256: str | None = None,
source_last_modified: str | None = None,
) -> MitomapBuildResult
Turn a MITOMAP pg_dump into out_dir/data/*.parquet + release.json.
Rows are sorted by (start, ref, alt, record_id) per table so a rebuild from the same bytes is
byte-identical (Principle 7); release.json's built_at is the only per-run-varying byte and
lives outside the parquet.
A dump missing one of the six tables is refused, not built short. A snapshot silently lacking
rtmutation would make every later miss count a lie about a table nobody looked at, and the
single hardest thing to notice about a derived artifact is a denominator that changed.
Source code in enricher/src/just_dna_enricher/mitomap_build.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |