just_dna_enricher.cli.pgx_commands¶
just_dna_enricher.cli.pgx_commands ¶
The pharmacogenomic sources: the clinpgx, cpic and pharmvar groups and draft-clinpgx (RM260
split this out of the former single-file cli.py).
clinpgx_build_ ¶
clinpgx_build_(
out_dir: Path = typer.Option(
repro_out("clinpgx"),
"--out",
file_okay=False,
help="Snapshot output directory.",
),
zip_path: Path | None = typer.Option(
None,
"--zip",
help=f"An existing {CURRENT_ARCHIVE.archive} (else downloaded).",
),
url: str = typer.Option(
DEFAULT_CLINPGX_URL,
"--url",
help="ClinPGx bulk download URL.",
),
use: str = typer.Option(
"unstated",
"--use",
help="Declared use: unstated | non-commercial | commercial.",
),
) -> None
Download + build the ClinPGx snapshot (dev surface; needs polars).
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
clinpgx_check_ ¶
clinpgx_check_(
spec_dir: Path = typer.Argument(
...,
exists=True,
file_okay=False,
help="Module spec directory",
),
snapshot: Path | None = typer.Option(
None,
"--snapshot",
help="Explicit ClinPGx snapshot dir. Omit it and the cache is used, or one is downloaded.",
),
offline: bool = typer.Option(
False,
"--offline",
help="Use a local snapshot only: never download one.",
),
strict: bool = typer.Option(
False,
"--strict/--best-effort",
help="Fail on a stale evidence level.",
),
use: str = typer.Option(
"unstated",
"--use",
help="Declared use: unstated | non-commercial | commercial.",
),
) -> None
Cross-check pharm_variants.csv against the ClinPGx snapshot.
The snapshot no longer has to be handed over by hand (RM38): explicit path → $JUST_DNA_CLINPGX_CACHE
/ the default cache → downloaded from HuggingFace. --offline stops at the second step.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
cpic_build_ ¶
cpic_build_(
out_dir: Path = typer.Option(
repro_out("cpic"),
"--out",
file_okay=False,
help="Snapshot output directory.",
),
endpoint: str = typer.Option(
DEFAULT_CPIC_ENDPOINT,
"--endpoint",
help="CPIC PostgREST base URL.",
),
use: str = typer.Option(
"unstated",
"--use",
help="Declared use: unstated | non-commercial | commercial.",
),
) -> None
Fetch CPIC whole into data/*.parquet + release.json (dev surface; needs polars).
No gene filter, deliberately: the whole database is ~120k narrow rows, and a snapshot covering only the genes the operator thought of answers "CPIC has nothing" for the next one.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
cpic_publish_ ¶
cpic_publish_(
snapshot_dir: Path = typer.Argument(
...,
exists=True,
file_okay=False,
help="Built snapshot directory (data/*.parquet + release.json).",
),
repo: str = typer.Option(
DEFAULT_CPIC_REPO_ID,
"--repo",
help="Target HuggingFace dataset repo (owner/name).",
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Show what would be uploaded; send nothing.",
),
commit_message: str | None = typer.Option(
None, "--message", "-m", help="Commit message."
),
) -> None
Create-or-update the dataset repo and upload the built CPIC snapshot (publisher/dev).
Publishable because CPIC's recorded terms permit redistribution — CC BY-SA grants sharing under
share-alike plus attribution, which sources.csv carries. PharmVar has no equivalent command, and
that is the design rather than an omission.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
clinpgx_publish_ ¶
clinpgx_publish_(
snapshot_dir: Path = typer.Argument(
...,
exists=True,
file_okay=False,
help="Built snapshot directory (data/*.parquet + release.json).",
),
repo: str = typer.Option(
DEFAULT_CLINPGX_REPO_ID,
"--repo",
help="Target HuggingFace dataset repo (owner/name).",
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Show what would be uploaded; send nothing.",
),
commit_message: str | None = typer.Option(
None, "--message", "-m", help="Commit message."
),
) -> None
Publish a built ClinPGx snapshot so clinpgx check can provision it (publisher/dev).
LICENSE.txt travels with the parquet — the terms ClinPGx ships inside its own archive are what
license_sha256 pins, and a published snapshot without them pins nothing for whoever downloads it.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
pharmvar_build_ ¶
pharmvar_build_(
out_dir: Path = typer.Option(
repro_out("pharmvar"),
"--out",
file_okay=False,
help="Snapshot output directory.",
),
use: str = typer.Option(
"unstated",
"--use",
help="Declared use: unstated | non-commercial | commercial.",
),
) -> None
Fetch PharmVar whole into data/*.parquet + release.json (dev surface; needs polars + a key).
There is no pharmvar publish, and there will not be. The data is pulled under a key
PharmVar's terms §2 make personal and non-transferable, and no axis SourceTerms records covers
passing that on — an unestablished permission is not a permission. Build your own; point at it with
$JUST_DNA_PHARMVAR_CACHE or --pharmvar-cache.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
draft_clinpgx_ ¶
draft_clinpgx_(
spec_dir: Path = typer.Argument(
...,
exists=True,
file_okay=False,
help="Module spec directory",
),
snapshot: Path = typer.Option(
...,
"--snapshot",
exists=True,
file_okay=False,
help="Built ClinPGx snapshot (see `clinpgx build`). Inject-only; nothing is downloaded.",
),
drug: list[str] = typer.Option(
[],
"--drug",
help="Only annotations naming this drug (repeatable).",
),
gene: list[str] = typer.Option(
[],
"--gene",
help="Only annotations naming this gene (repeatable).",
),
min_evidence_level: str | None = typer.Option(
None,
"--min-evidence-level",
help="Keep annotations at least this strong: 1A|1B|2A|2B|3|4.",
),
use: str = typer.Option(
"unstated",
"--use",
help="Declared use: unstated | non-commercial | commercial. ClinPGx forbids sale.",
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Report what would be added; write nothing.",
),
) -> None
Draft pharm_variants.csv rows from the ClinPGx snapshot — appends, never overwrites a row.
Narrow with --drug and re-run as the module grows. A row already in the file is reported, never
replaced: drift against ClinPGx is clinpgx check's finding, not this command's edit to make.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
clinpgx_build_labels_ ¶
clinpgx_build_labels_(
out_dir: Path = typer.Option(
repro_out("drug_labels"),
"--out",
file_okay=False,
help="Snapshot output directory.",
),
zip_path: Path | None = typer.Option(
None,
"--zip",
exists=True,
dir_okay=False,
help="A drugLabels.zip you already have. Without it the archive is downloaded.",
),
url: str = typer.Option(
DEFAULT_DRUG_LABELS_URL,
"--url",
help="ClinPGx bulk download URL.",
),
use: str = typer.Option(
"unstated",
"--use",
help=f"Declared use: one of {sorted(VALID_DECLARED_USE)}.",
),
) -> None
Download + build the regulator drug-label snapshot (dev surface; needs polars).
A second archive from a source this tier already adopted, with its own release.json: ClinPGx
publishes at least twelve downloads on this endpoint and they do not refresh in lockstep, so the
label snapshot is dated from its own CREATED_*.txt rather than from the annotation lane's.
There is no --offline: a builder's off-switch is passing --zip instead of downloading.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
clinpgx_check_labels_ ¶
clinpgx_check_labels_(
spec_dir: 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="Built drug-label snapshot directory (see `clinpgx build-labels`). Omit it and $JUST_DNA_DRUG_LABELS_CACHE (or the shared cache base) is used.",
),
strict: bool = typer.Option(
False,
"--strict/--best-effort",
help="Carried into the report. A label difference NEVER fails, in either mode.",
),
use: str = typer.Option(
"unstated",
"--use",
help=f"Declared use: one of {sorted(VALID_DECLARED_USE)}.",
),
) -> None
Compare a module's gene/allele/drug claims against the drug labels five regulators publish.
Two join tiers, reported apart, and the tier belongs to the question. What do the agencies say about this gene and this medicine is the gene-tier subject; …and this star allele or rsID is the allele-tier one. A label naming both answers both, because they are two questions rather than one asked twice, and a gene-level agreement is not an allele-level agreement.
Writes no authored cell and never fails on a difference. Five agencies genuinely disagree with
each other — clopidogrel and CYP2C19 is Actionable PGx at four of them and Informative PGx at
the EMA — and a compile that refused would make this format pick the winner. A blank Testing
Level is a third of the file and is reported as unknown, never as No Clinical PGx.
Source code in enricher/src/just_dna_enricher/cli/pgx_commands.py
clinpgx_publish_labels_ ¶
clinpgx_publish_labels_(
snapshot_dir: Path = typer.Argument(
...,
exists=True,
file_okay=False,
help="Built snapshot directory (data/drug_labels.parquet + LICENSE.txt + release.json).",
),
repo: str = typer.Option(
DEFAULT_DRUG_LABELS_REPO_ID,
"--repo",
help="Target HuggingFace dataset repo (owner/name).",
),
dry_run: bool = typer.Option(
False,
"--dry-run",
help="Show what would be uploaded; send nothing.",
),
commit_message: str | None = typer.Option(
None, "--message", "-m", help="Commit message."
),
) -> None
Publish a built drug-label snapshot so clinpgx check-labels can provision it (publisher/dev).
A second repo rather than a second table in just-dna-seq/clinpgx, for the reason the builder
already gives its own release.json: the two ClinPGx archives do not refresh in lockstep, and one
repo holding both would date the pair from whichever was published last.
Same grounds as clinpgx publish — CC BY-SA permits redistribution, forbids sale, and requires
attribution, which sources.csv carries. LICENSE.txt travels with the parquet: a share-alike
snapshot whose terms did not travel pins nothing for whoever downloads it.