just_dna_enricher.cli.civic_commands¶
just_dna_enricher.cli.civic_commands ¶
The civic group: build, citations, publish and reproduce (RM260 split this out of the former
single-file cli.py).
civic_build_ ¶
civic_build_(
release: str | None = typer.Option(
None,
"--release",
help="Dated CIViC release to download, e.g. 01-Aug-2026. A DATED release, never the nightly: a snapshot that cannot name its input is one nothing can reproduce.",
),
evidence: Path | None = typer.Option(
None,
"--evidence",
exists=True,
dir_okay=False,
help="Local ClinicalEvidenceSummaries.tsv. Use instead of --release to build offline.",
),
variants: Path | None = typer.Option(
None,
"--variants",
exists=True,
dir_okay=False,
help="Local VariantSummaries.tsv.",
),
profiles: Path | None = typer.Option(
None,
"--profiles",
exists=True,
dir_okay=False,
help="Local MolecularProfileSummaries.tsv.",
),
out: Path = typer.Option(
repro_out("civic"),
"--out",
file_okay=False,
help="Output snapshot directory (writes data/civic.parquet + release.json).",
),
submitted: bool = typer.Option(
False,
"--submitted",
help="Also read the release's civic_accepted_and_submitted.vcf, so evidence a curator entered but no editor signed off joins the snapshot. Over 01-Aug-2026 that widens the direction corpus from 507 rows on 270 variants to 1149 on 397, adding 642 submitted rows and 127 variants, and every row carries the status CIViC gave it. Dated and pinnable like the TSVs, so the build stays reproducible.",
),
vcf: Path | None = typer.Option(
None,
"--vcf",
exists=True,
dir_okay=False,
help="Local civic_accepted_and_submitted.vcf. Use with the local TSV flags to build offline.",
),
) -> None
Reduce a dated CIViC release to the parquet snapshot the direction-axis drafter reads.
The bulk release, not the GraphQL API, and the two are not interchangeable. Every row of
ClinicalEvidenceSummaries.tsv is status accepted; the API defaults to NON_REJECTED and
serves roughly 2.35x as many evidence items. A snapshot has to be reproducible from a pinned
input, so this reads the dated files and records the basis in release.json.
--submitted widens that basis without leaving the dated release (RM169). CIViC publishes
<date>-civic_accepted_and_submitted.vcf beside the TSVs, so unreviewed evidence is pinnable too
and no API read is needed. The TSVs stay primary — the VCF cannot carry a variant with no GRCh37
coordinate, which is exactly the class whose identity had to be read out of its name — and the VCF
supplies the curation status, the submitted evidence, and the identity for the 112 variants
VariantSummaries.tsv (itself accepted-only) does not describe. Those rows are stamped
identity_derivation="vcf_csq", and nothing is placed from the VCF's own GRCh37 position.
There is no --use flag. CIViC is CC0 on every axis, so a declared-use gate would permit
every build unconditionally, and a flag feeding a gate that never gates is a flag that does
nothing (@acquisition-gate-is-not-a-read-gate).
Source code in enricher/src/just_dna_enricher/cli/civic_commands.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 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 | |
civic_citations_ ¶
civic_citations_(
spec: Path = typer.Argument(
...,
exists=True,
file_okay=False,
help="Module spec directory.",
),
snapshot: Path | None = typer.Option(
None,
"--snapshot",
exists=True,
file_okay=False,
help="CIViC snapshot to map authored rows through. Default: the provisioned cache.",
),
variant_id: list[int] = typer.Option(
[],
"--variant-id",
help="Ask about a CIViC variant id directly, repeatable. Its citations ground the MODULE rather than a variant, which is the only route to a record CIViC publishes no identity for — variant 1955 is the case this exists for.",
),
offline: bool = typer.Option(
False,
"--offline",
help="Do not fetch. Every subject is recorded as not-asked; no row is written.",
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Report what would be appended, write nothing.",
),
) -> None
Append the citations a CIViC variant carries that the dated bulk release cannot reach (RM160).
Why this is not part of civic build. The builder reads a dated release and is byte-
reproducible from it; civic reproduce proves it by building twice. The wider basis RM169 adopted
comes from a VCF, and a VCF record needs a POS — so submitted evidence attached to a variant with
no GRCh37 coordinate is published on exactly one surface, the GraphQL API, which has no release to
pin. The read is also one request per variant by construction, because evidenceItems takes a
single variantId. Batching it into the builder is the first repair anyone proposes and it is
exactly the reproducibility bargain this shape refused.
A recovered citation lands in studies.csv; literature.csv is derived from those PMIDs by the
literature command, and an article row nothing cites is dropped from the artifact. CIViC's own
curation status rides in confidence/confidence_unit, unconverted, so an accepted row and a
submitted row are not the same row. Appending only — a second run over an unchanged API adds
nothing — and enrich re-asks later and reports what has moved since.
CIViC is CC0, so there is no --use flag: a declared-use gate would permit every call
unconditionally, and a flag feeding a gate that never gates is a flag that does nothing.
Source code in enricher/src/just_dna_enricher/cli/civic_commands.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 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 | |
civic_publish_ ¶
civic_publish_(
snapshot_dir: Path = typer.Argument(
...,
exists=True,
file_okay=False,
help="Built snapshot directory (data/civic.parquet + release.json).",
),
repo_id: str | None = typer.Option(
None,
"--repo",
help=f"Target HF dataset (owner/name). Default: {DEFAULT_CIVIC_REPO_ID}.",
),
commit_message: str | None = typer.Option(
None, "--message", "-m", help="Commit message."
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Show what would be uploaded, after the checks the publish runs. Reads the repo's file list; uploads nothing.",
),
) -> None
Upload a built CIViC snapshot to a HuggingFace dataset repo (publisher/dev).
This one does not refuse, and the contrast with pubmind publish is the point. CIViC's content
is CC0 1.0 — a public-domain dedication with no share-alike, no bar on sale and attribution
requested rather than required — so there is no permission to establish before passing the bytes
on. PubMind's command exists in order to say no because NoDerivatives bars sharing its snapshot;
PharmVar's cache is unpublishable because its terms forbid it. Nothing here is in either position.
What the snapshot carries is a derivation of CIViC's release, not a copy of it: the germline
direction rows, placed on GRCh38 through identifiers CIViC itself publishes. release.json records
which dated release it came from and the accepted status basis, so a consumer can tell what they
are looking at without re-deriving it.
The ClinGen Allele Registry's answers are NOT in here, and that is deliberate rather than an oversight: the registry states no terms, and a lookup performed at draft time is a read, while baking its responses into a published file would be redistribution of bytes nobody has established we may pass on. The snapshot carries the CAID; resolving it stays the consumer's own fetch.
Source code in enricher/src/just_dna_enricher/cli/civic_commands.py
civic_reproduce_ ¶
civic_reproduce_(
release: str = typer.Option(
"01-Aug-2026",
"--release",
help="Dated CIViC release to reproduce, e.g. 01-Aug-2026.",
),
out: Path = typer.Option(
repro_out("civic_reproduce"),
"--out",
file_okay=False,
help="Working directory. The release files and two independent builds land here. The default is under data/, which this workspace git-ignores wholesale.",
),
keep: bool = typer.Option(
False,
"--keep",
help="Leave the downloaded release files in place for inspection.",
),
offline: bool = typer.Option(
False,
"--offline",
help="Skip the reference cross-check. The build and determinism checks still run.",
),
submitted: bool = typer.Option(
False,
"--submitted",
help="Reproduce the wider basis: also download the release's civic_accepted_and_submitted.vcf and build with it, so the submitted rows and their coordinates go through every check below rather than only the accepted ones.",
),
) -> None
Build the CIViC snapshot from a dated release and check it, end to end.
Five checks, and the third is the one worth the network. The first two are about us; the third is about whether the coordinates we produced are real.
- The release downloads and its bytes are recorded — a sha256 per file, so a rerun that disagrees is a finding about the source rather than a mystery.
- Two independent builds are byte-identical (Principle 7). A parquet has no inherent row order, so this is the check that the sort is doing its job.
- Every placed coordinate is cross-checked against the GRCh38 reference sequence. This is the external validation: the snapshot's positions come from RefSeq accessions inside ClinVar HGVS, and this asks an unrelated service (refget/seqrepo) whether the reference base at each of those positions is what we wrote. A wrong-build or off-by-one placement fails here and nowhere else.
- The drop registry closes — every input row kept or counted, an equality over a walked set.
- The published file list is exactly what the publisher would upload.
Exits non-zero if any check fails, so it is usable in CI.
Source code in enricher/src/just_dna_enricher/cli/civic_commands.py
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 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | |