Deterministic pharmacogenomics infrastructure: CPIC-pinned phenotype engine, gene callers, and recommendation lookup.
Project description
anukriti-pgx-core
Deterministic pharmacogenomics infrastructure
Authoritative, CPIC-pinned, no LLMs, no randomness. Same inputs → same outputs.
What this is
The deterministic core extracted from
anukriti (PGx product) and
anukriti-swarm (research
platform), now shippable as a standalone library and (optionally) HTTP service.
Three stacked layers:
VCF variants (rsid → ref,alt,gt)
│
▼ Layer 1: calling/ ← VCFCaller.call(gene, variants)
Star alleles (*1, *17, *2/*17 …)
│
▼ Layer 2: phenotype/ ← PhenotypeEngine.infer(gene, a1, a2) ← PHASE 1
Phenotype (PM / IM / NM / RM / UM)
│
▼ Layer 3: recommendations/ ← RecommendationLookup.lookup(...)
CPIC recommendation
Each layer is independently usable. A consumer that already has star alleles (e.g. a swarm agent) uses Layer 2 directly. A consumer with VCF input (e.g. a clinical pipeline) uses Layer 1, which calls into Layer 2 internally.
Why this exists
Before the extraction, the same phenotype logic lived in two places:
anukriti-swarm/rules/phenotype_rules.py— star-allele level, 3 genesanukriti/src/*_caller.py(16 files) — VCF level, 16 genes, inconsistent signatures
That meant two truth sources for the same CPIC tables, and no way for a third party to consume just the deterministic core without pulling in a FastAPI product or a multi-agent research framework.
This package is the deterministic core. It has:
- Zero runtime dependencies (Phase 1)
- No LLMs, no randomness, no I/O side effects
- CPIC table versions pinned by filename (e.g.
CYP2C19_named_diplotypes_v2022.1.json) - An explicit upgrade rhythm: CPIC updates → new file → new test pin → review → bump
Phase status
| Phase | Scope | Status |
|---|---|---|
| 1 | Layer 2: PhenotypeEngine for CYP2D6 + CYP2C19 | ✅ this release |
| 2 | Layer 1: VCFCaller + 16 gene callers (normalized signatures) | planned |
| 3 | Layer 3: RecommendationLookup + optional HTTP service | planned |
| 4 | Swarm expansion to the 13 non-CYP2D6/2C19/HLA-B genes | planned |
Install
pip install anukriti-pgx-core==0.2.1
# Or locally while iterating:
pip install -e /path/to/anukriti-pgx-core
Quick use (Layer 2 — what Swarm consumes)
from anukriti_pgx_core import PhenotypeEngine
engine = PhenotypeEngine()
result = engine.infer("CYP2C19", "*1", "*17")
# -> PhenotypeInference(
# gene="CYP2C19",
# diplotype="*1/*17",
# activity_score=2.5,
# phenotype="Rapid Metabolizer", # per CPIC 2022 Table 2
# confidence=1.0,
# rule_version="cpic_activity_score_v2",
# source="CPIC named-diplotype table (CYP2C19)",
# cpic_table_version="CYP2C19_named_diplotypes_v2022.1",
# ...
# )
engine.supported_genes()
# -> ["CYP2C19", "CYP2D6"]
engine.cpic_table_version("CYP2C19")
# -> "CYP2C19_named_diplotypes_v2022.1"
Authoritative sources (pinned)
| Gene | Layer | Table file | Citation |
|---|---|---|---|
| CYP2D6 | activity-score → phenotype | CYP2D6_activity_v2019.10.json |
CPIC 2019 standardization (Caudle et al., PMID:31647186) |
| CYP2C19 | named diplotype → phenotype | CYP2C19_named_diplotypes_v2022.1.json |
CPIC 2022 clopidogrel guideline Table 2 (Lee et al., PMID:35034351; NCBI NBK84114) |
| CYP2C19 | allele function (activity score) | CYP2C19_activity_v2022.1.json |
CPIC 2022 allele functionality table |
Updating a pinned table = adding a new file + bumping the pin + adding/updating the regression case. Silent in-place edits are not allowed.
Tests
cd anukriti-pgx-core
pip install -e ".[dev]"
pytest
# Or standalone:
python -m tests.test_pinned_star_alleles
Integration with existing Anukriti projects
From anukriti-swarm
Swarm's rules/phenotype_rules.py is a thin re-export shim that delegates
here. All existing swarm code (agents/pharmacogene/base.py,
core/verification/safety.py, core/runtime/runtime.py) continues to work
unchanged. Migration to direct anukriti_pgx_core imports is opt-in per
call site.
From anukriti (FastAPI product)
Phase 2 will migrate the 16 gene callers in anukriti/src/ into
anukriti_pgx_core.calling. Until then, anukriti continues to use its
existing caller modules unchanged.
License
Apache 2.0. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anukriti_pgx_core-0.2.1.tar.gz.
File metadata
- Download URL: anukriti_pgx_core-0.2.1.tar.gz
- Upload date:
- Size: 65.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3eebbdccc45434a9e241441d2b3286c4f8b6df2c1388f0275f59400b5d8b5c4
|
|
| MD5 |
e2fa2eafdb569a84bd47fb0a1b3ed9d2
|
|
| BLAKE2b-256 |
6983d58ab7ddfb816e4e67d13b3fd0d4f9015e217dbd7140808a5479397243a2
|
Provenance
The following attestation bundles were made for anukriti_pgx_core-0.2.1.tar.gz:
Publisher:
release.yml on AnukritiAi-hq/anukriti-pgx-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anukriti_pgx_core-0.2.1.tar.gz -
Subject digest:
d3eebbdccc45434a9e241441d2b3286c4f8b6df2c1388f0275f59400b5d8b5c4 - Sigstore transparency entry: 1486409734
- Sigstore integration time:
-
Permalink:
AnukritiAi-hq/anukriti-pgx-core@f8b5e1fa47b7fd0b174fb8d249e40191e98b67d6 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/AnukritiAi-hq
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f8b5e1fa47b7fd0b174fb8d249e40191e98b67d6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file anukriti_pgx_core-0.2.1-py3-none-any.whl.
File metadata
- Download URL: anukriti_pgx_core-0.2.1-py3-none-any.whl
- Upload date:
- Size: 70.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7847c6d0c6cf7a5f8af01c5e005244b37d41c7c3c7733eb44ec9a3cb72ad98ae
|
|
| MD5 |
92d094c42a0f2bb8836f014a433eb4a5
|
|
| BLAKE2b-256 |
2d6ba9c4c06f4e9b29425113a367e54f719903af9aa276cf02a2274a476d244d
|
Provenance
The following attestation bundles were made for anukriti_pgx_core-0.2.1-py3-none-any.whl:
Publisher:
release.yml on AnukritiAi-hq/anukriti-pgx-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anukriti_pgx_core-0.2.1-py3-none-any.whl -
Subject digest:
7847c6d0c6cf7a5f8af01c5e005244b37d41c7c3c7733eb44ec9a3cb72ad98ae - Sigstore transparency entry: 1486409781
- Sigstore integration time:
-
Permalink:
AnukritiAi-hq/anukriti-pgx-core@f8b5e1fa47b7fd0b174fb8d249e40191e98b67d6 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/AnukritiAi-hq
-
Access:
internal
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@f8b5e1fa47b7fd0b174fb8d249e40191e98b67d6 -
Trigger Event:
push
-
Statement type: