just_dna_enricher.opentargets¶
just_dna_enricher.opentargets ¶
opentargets enrich: fill the Open Targets lane's tables from the provisioned snapshot (0.8, RM333).
One pass, four writes, one licence row per write:
| table | grain | from the snapshot |
|---|---|---|
locus_to_gene.csv |
(study locus, gene, variant) | the L2G score of every GWAS credible set a module variant is a member of |
colocalisations.csv |
(study locus, right study locus, variant) | those credible sets' molecular-QTL colocalisations |
consequences.csv |
(variant, transcript) | every module variant's per-transcript VEP consequence (RM236) |
gwas_effects.csv |
(association) | RM239's posterior_probability and fine_mapping_method, filled on rows another pass wrote |
Coordinates in, from resolution.csv, like frequencies: a posterior and a consequence are per
allele, and the resolution table is where an rsID has already become chrom-pos-ref-alt, which is
exactly how the snapshot keys its variants (its alleles come from columns; its variantId is never
parsed). Open Targets is GRCh38-only, so a row on another build is skipped and counted.
The pass never fetches. It reads the snapshot opentargets build provisioned, and with none it
skips with a warning and writes nothing: nobody asked, which is not "Open Targets holds nothing"
(@unreachable-not-absent). There is no --offline flag for that reason: the off switch would be a
flag the pass never sees.
Members, not lead-only (RM333, decided 2026-11-04). A variant gets the L2G and coloc rows of every
GWAS credible set it sits in, whether or not it leads it: HFE C282Y (rs1800562) is in 82 sets of the
26.09 release and leads none, so a lead-only table would be empty for the module the lane exists for.
variant_key is the module variant asked about and is in both tables' keys; lead_variant_id still
names the source's lead, and the member's own weight in the set is its posterior on gwas_effects.csv.
The snapshot holds GWAS sets only (the builder filters on studyType), so a member of a molecular-QTL
set gets no row here; that side arrives as the right half of a colocalisation.
Three answers per question, kept apart. For each gwas_effects.csv row the posterior is filled
only when exactly one value answers; otherwise it is left empty and the reason is counted: the study
has no credible set in the release, the variant is not in the study's set, or the variant sits in
several of the study's sets with different values (@multiplicity-is-a-finding, never a winner).
A row with no ALT gets the release's allele, only when the release names exactly one (RM333, decided
2026-11-04). resolution.csv may hold an rsID at (chrom, start, ref) with alts empty (an authored
rsID-only row, apoe_epsilon's two). The pass then reads every allele of the release at that position and
its rsIds: an allele carrying the row's rsID (or its rsid_current) is a candidate on any REF, an
allele on the row's REF carrying none is a candidate too (unknown, never "not this one": at
6:26091590 G the release states rs773443949 on G>T and nothing on G>A, while dbSNP, through
ClinVar, names both), and an allele carrying only other rsIDs is not. Exactly one candidate, carrying
the rsID on the row's REF, supplies the ALT, and the key is named in allele_supplied; any other
non-empty set withholds the key (allele_unstated_withheld, never a pick:
@multiplicity-is-a-finding), as does a row whose rsID is itself the back-fill's pick
(status="ambiguous"); no candidate is the ordinary not-in-release answer. A row with no
rsID either is withheld (allele_unstated_no_rsid): a position alone is not an identity
(@rsid-not-per-allele). The supplied ALT is never written back to resolution.csv
(@enrichment-is-validation), and no derived row says which ALT it used: the named key lists and the
counts are the record. A snapshot built before the allele table carried rs_ids cannot answer the
question at all: those keys are nobody-asked (allele_unstated_unasked), and strict refuses.
Answered replaces, could-not-ask keeps (@rederive-never-shortens): a variant this run looked up
has its rows replaced by the snapshot's answer, and a variant it could not look up (off-build,
unresolved) keeps whatever rows it had.
An answer is only as complete as the parts it was read from (RM361). READS names the source
datasets each table and the posterior are read from, and read_is_complete asks the snapshot's
release.json whether every one of them was read whole: True only when parts_read equals
parts_total for each, False when one was partial, and None when the record cannot say (no
parts_total, a dataset missing from it, a count that is not a number). Anything but True means an
absent row may be a part nobody opened, so no key is answered for that table: rows the snapshot did
yield are merged in, and every existing row is kept. A key that did not join the allele table is then
not_read rather than not_in_release, and the posterior on gwas_effects.csv is left as it was.
strict refuses such a snapshot before anything is read.
OpenTargetsError ¶
Bases: RuntimeError
The Open Targets pass failed; its own type, so the CLI prints a diagnosis rather than a traceback.
PosteriorCounts
dataclass
¶
PosteriorCounts(
filled: int = 0,
no_study: int = 0,
not_looked_up: int = 0,
variant_not_in_release: int = 0,
study_without_credible_set: int = 0,
not_in_credible_set: int = 0,
contested: int = 0,
method_missing: int = 0,
not_read: int = 0,
allele_withheld: int = 0,
)
What happened to each gwas_effects.csv row the pass looked at. Every bucket is a different answer.
OpenTargetsResult
dataclass
¶
OpenTargetsResult(
skipped: str | None = None,
dataset: str | None = None,
locus_to_gene: list[LocusToGeneRow] = list(),
colocalisations: list[ColocalisationRow] = list(),
consequences: list[ConsequenceRow] = list(),
gwas_effects: list[GwasEffectRow] = list(),
posterior: PosteriorCounts = PosteriorCounts(),
asked: list[str] = list(),
not_in_release: list[str] = list(),
not_read: list[str] = list(),
off_build: list[str] = list(),
allele_ambiguous: list[str] = list(),
shared_allele_keys: list[str] = list(),
allele_supplied: list[str] = list(),
allele_unstated_withheld: list[str] = list(),
allele_unstated_no_rsid: list[str] = list(),
allele_unstated_unasked: list[str] = list(),
partial: dict[str, tuple[int, int]] = dict(),
)
Outcome of one pass. skipped names why nothing was read, when nothing was.
dataset_complete ¶
Whether the snapshot read every part of dataset: None when its record cannot say (RM361).
Source code in enricher/src/just_dna_enricher/opentargets.py
read_is_complete ¶
Kleene AND of dataset_complete over datasets: one partial dataset is False whatever the rest
say, and otherwise one the record cannot speak for is None (RM361).
Source code in enricher/src/just_dna_enricher/opentargets.py
enrich_opentargets ¶
enrich_opentargets(
spec_dir: Path,
*,
mode: str = "best_effort",
write: bool = True,
snapshot: Path | None = None,
declared_use: str = "unstated",
) -> OpenTargetsResult
Fill the three Open Targets tables and RM239's posterior from the provisioned snapshot.
mode="strict" refuses a partial snapshot (one built from some parts of a dataset), because an
absent coloc or L2G row from it may mean "not read" rather than "not published", and a strict run
owes an artifact holding everything the release says. best_effort writes and warns.
Source code in enricher/src/just_dna_enricher/opentargets.py
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 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | |
summarise ¶
The counts a CLI prints, JSON-ready.