bionym 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bionym-0.1.0/LICENSE +21 -0
- bionym-0.1.0/PKG-INFO +181 -0
- bionym-0.1.0/README.md +162 -0
- bionym-0.1.0/pyproject.toml +30 -0
- bionym-0.1.0/setup.cfg +4 -0
- bionym-0.1.0/src/bionym/__init__.py +9 -0
- bionym-0.1.0/src/bionym/_static/components.css +63 -0
- bionym-0.1.0/src/bionym/_static/components.iife.js +1 -0
- bionym-0.1.0/src/bionym/_static/report.js +91 -0
- bionym-0.1.0/src/bionym/ask.py +157 -0
- bionym-0.1.0/src/bionym/cli.py +203 -0
- bionym-0.1.0/src/bionym/clients/__init__.py +1 -0
- bionym-0.1.0/src/bionym/clients/expression.py +249 -0
- bionym-0.1.0/src/bionym/clients/kegg.py +105 -0
- bionym-0.1.0/src/bionym/clients/ncbi.py +610 -0
- bionym-0.1.0/src/bionym/clients/oma.py +121 -0
- bionym-0.1.0/src/bionym/clients/uniprot.py +160 -0
- bionym-0.1.0/src/bionym/clients/veupathdb.py +473 -0
- bionym-0.1.0/src/bionym/evidence.py +24 -0
- bionym-0.1.0/src/bionym/graph.py +177 -0
- bionym-0.1.0/src/bionym/jev.py +222 -0
- bionym-0.1.0/src/bionym/llm.py +114 -0
- bionym-0.1.0/src/bionym/proposals.py +436 -0
- bionym-0.1.0/src/bionym/questions/__init__.py +8 -0
- bionym-0.1.0/src/bionym/questions/ask.py +244 -0
- bionym-0.1.0/src/bionym/questions/s0_classify.py +65 -0
- bionym-0.1.0/src/bionym/questions/s1_resolve.py +62 -0
- bionym-0.1.0/src/bionym/questions/s2_assemblies.py +134 -0
- bionym-0.1.0/src/bionym/questions/s3_orthologs.py +60 -0
- bionym-0.1.0/src/bionym/questions/s4_annotate.py +113 -0
- bionym-0.1.0/src/bionym/questions/s5_expression.py +56 -0
- bionym-0.1.0/src/bionym/questions/s6_remap.py +89 -0
- bionym-0.1.0/src/bionym/report.py +134 -0
- bionym-0.1.0/src/bionym/resolver.py +2308 -0
- bionym-0.1.0/src/bionym/species.py +37 -0
- bionym-0.1.0/src/bionym.egg-info/PKG-INFO +181 -0
- bionym-0.1.0/src/bionym.egg-info/SOURCES.txt +47 -0
- bionym-0.1.0/src/bionym.egg-info/dependency_links.txt +1 -0
- bionym-0.1.0/src/bionym.egg-info/entry_points.txt +2 -0
- bionym-0.1.0/src/bionym.egg-info/requires.txt +10 -0
- bionym-0.1.0/src/bionym.egg-info/top_level.txt +1 -0
- bionym-0.1.0/tests/test_ask.py +118 -0
- bionym-0.1.0/tests/test_backend.py +94 -0
- bionym-0.1.0/tests/test_classify.py +39 -0
- bionym-0.1.0/tests/test_clients.py +208 -0
- bionym-0.1.0/tests/test_graph.py +29 -0
- bionym-0.1.0/tests/test_proposals.py +23 -0
- bionym-0.1.0/tests/test_report.py +78 -0
- bionym-0.1.0/tests/test_resolver.py +658 -0
bionym-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Danielle Callan and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
bionym-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bionym
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Resolve bioinformatics identifiers into confidence-scored knowledge graphs with JEV.
|
|
5
|
+
License: MIT
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: httpx>=0.27
|
|
10
|
+
Requires-Dist: typer>=0.12
|
|
11
|
+
Requires-Dist: pydantic>=2.6
|
|
12
|
+
Requires-Dist: diskcache>=5.6
|
|
13
|
+
Requires-Dist: python-dotenv>=1.0
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-cov>=5; extra == "dev"
|
|
17
|
+
Requires-Dist: fastapi>=0.110; extra == "dev"
|
|
18
|
+
Dynamic: license-file
|
|
19
|
+
|
|
20
|
+
# BioNym
|
|
21
|
+
|
|
22
|
+
Resolve bioinformatics identifiers into confidence-scored knowledge graphs.
|
|
23
|
+
|
|
24
|
+
Given a gene identifier (any species — NCBI gene ID, symbol, VEuPathDB
|
|
25
|
+
locus tag, UniProt accession, Ensembl ID, ...), BioNym gathers evidence
|
|
26
|
+
from public APIs (NCBI, VEuPathDB, OMA, UniProt, GEO, Expression Atlas,
|
|
27
|
+
...), asks [JEV](https://typesafe.ai) (TypeSafe `systemone`) an ordered
|
|
28
|
+
workflow of typed questions, and emits a knowledge graph where every claim
|
|
29
|
+
carries a confidence score and a list of supporting evidence.
|
|
30
|
+
|
|
31
|
+
## Status
|
|
32
|
+
|
|
33
|
+
All pipeline stages implemented: S0 (ID classification), S1 (entity
|
|
34
|
+
resolution → organism + assembly), S2 (related & newer assemblies with
|
|
35
|
+
species-rank lineage normalization), S3 (orthologs via OMA), S4 (UniProt
|
|
36
|
+
annotation: GO evidence-code confidence, KEGG, InterPro/Pfam), S5
|
|
37
|
+
(expression: GEO + Expression Atlas, JEV-scored), S6 (cross-assembly
|
|
38
|
+
presence: `annotated_in` + JEV `likely_present`).
|
|
39
|
+
|
|
40
|
+
On top of the staged pipeline, two optional LLM passes propose claims that
|
|
41
|
+
JEV then verifies: text claims over publication/dataset metadata, and data
|
|
42
|
+
claims over per-gene measurements (VEuPathDB ExpressionGraphs, GEO GDS SOFT
|
|
43
|
+
files, GXA baseline/differential TSVs). A third pass can synthesize a
|
|
44
|
+
JEV-verified gene summary into `metadata.summary`.
|
|
45
|
+
|
|
46
|
+
Interfaces: CLI (`bionym resolve`, `bionym summarize`, `bionym ask`), FastAPI backend (`backend/`), static web frontend (`web/`, D3 multi-partite network).
|
|
47
|
+
|
|
48
|
+
`ask` answers a free-form question over a resolved graph: JEV first
|
|
49
|
+
classifies the question into graph categories, the matching subgraph
|
|
50
|
+
is sliced out, the LLM answers over that slice (citing node ids), and
|
|
51
|
+
JEV scores accuracy/completeness — deterministic citation fidelity
|
|
52
|
+
checked against the full graph on top.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
conda create -n bionym python=3.11 -y
|
|
58
|
+
conda activate bionym
|
|
59
|
+
pip install -e '.[dev]'
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configure
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cp .env.example .env # then edit
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `TYPESAFE_API_KEY` — required for real JEV calls.
|
|
69
|
+
- `NCBI_API_KEY` — optional, raises NCBI rate limit 3/s → 10/s.
|
|
70
|
+
- `VEUPATHDB_API_KEY` — optional, enables VEuPathDB lookups (release 71+).
|
|
71
|
+
- `BIONYM_CACHE_DIR` — optional response/JEV cache.
|
|
72
|
+
- `LLM_API_KEY` + `LLM_MODEL` — optional, enables the proposal passes
|
|
73
|
+
(claims, summary). Any OpenAI-compatible endpoint; `LLM_BASE_URL`
|
|
74
|
+
defaults to OpenRouter. Disabled when unset — the resolver runs fine
|
|
75
|
+
without them, you just get no proposed claims or summary.
|
|
76
|
+
- `BIONYM_PROPOSAL_MIN_SCORE` (default 0.5) — JEV triage score a
|
|
77
|
+
dataset/publication needs before the LLM spends a call on it.
|
|
78
|
+
- `BIONYM_PROPOSAL_CONCURRENCY` (default 8) — max simultaneous LLM calls.
|
|
79
|
+
- `JEV_BASE_URL` — optional; repoint the systemone endpoint at any
|
|
80
|
+
compatible backend (Laya, Kev, CLM all speak `POST /v1/systemone`).
|
|
81
|
+
- `JEV_MODEL` — optional (default `jev-latest`); model string sent in
|
|
82
|
+
the request — set it when pointing at a non-jev backend.
|
|
83
|
+
- `LLM_TIMEOUT` — optional, seconds (default 180); whole-graph asks
|
|
84
|
+
can exceed the old 60s on slow models.
|
|
85
|
+
- `BIONYM_ALLOW_MOCK` — server only; `=1` permits `mock_jev=true`
|
|
86
|
+
on API requests (offline dev/evals). Off by default.
|
|
87
|
+
|
|
88
|
+
## Usage
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
bionym resolve PF3D7_0710100 -o graph.json -v
|
|
92
|
+
bionym resolve 672 --depth 0 # classify only
|
|
93
|
+
bionym resolve 672 --report # + self-contained HTML report
|
|
94
|
+
bionym resolve 672 --min-confidence 0.7 # drop low-confidence edges
|
|
95
|
+
bionym resolve 672 --no-propose # quick scan: skip LLM claim passes
|
|
96
|
+
bionym resolve 672 --summarize # + JEV-verified summary in metadata
|
|
97
|
+
bionym resolve 672 --mock-jev # offline dev, no API key
|
|
98
|
+
|
|
99
|
+
bionym summarize graph.json # summary pass on an existing graph
|
|
100
|
+
bionym ask graph.json "what datasets are associated?"
|
|
101
|
+
# classify → slice → LLM answer → JEV scores
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> **`--mock-jev` is for development only.** It returns deterministic
|
|
105
|
+
> placeholder answers (first option / midpoint score / 0.5) instead of real
|
|
106
|
+
> JEV judgments, so the resulting graph **will not be biologically
|
|
107
|
+
> meaningful** — edges and confidences are arbitrary. It's a free way to
|
|
108
|
+
> exercise the full pipeline and surface *technical* bugs (crashes, parsing,
|
|
109
|
+
> wiring) without an API key or cost. Never interpret mock output as a
|
|
110
|
+
> result.
|
|
111
|
+
|
|
112
|
+
Output: a JSON knowledge graph — `nodes` (typed: Gene, Organism, Assembly,
|
|
113
|
+
IdType, ...; each with an external `url`), `edges` (claims with
|
|
114
|
+
`confidence`, `probabilities`, `jev_question_id`, `evidence[]`), and
|
|
115
|
+
`metadata` (`outcome`: `resolved|refused`, `stages` + `stage_times`,
|
|
116
|
+
`jev_usage` per-stage token counts, optional `summary`: JEV-verified
|
|
117
|
+
claim list with `claim`/`quote`/`confidence`).
|
|
118
|
+
|
|
119
|
+
## Web app
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# backend (needs the package installed + .env)
|
|
123
|
+
cd backend && uvicorn main:app --port 8001
|
|
124
|
+
|
|
125
|
+
# frontend (static; also works opened directly or from GH Pages)
|
|
126
|
+
cd web && python -m http.server 8080
|
|
127
|
+
# open http://localhost:8080 — backend URL is set in web/index.html (BACKEND const)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
The UI offers **Quick scan** (`propose=false` — deterministic stages + JEV
|
|
131
|
+
edge scoring only, seconds) vs **Full analysis** (`propose+summarize`,
|
|
132
|
+
minutes). The verified summary renders in a collapsible section above the
|
|
133
|
+
network. API: `GET /api/resolve?identifier=…&depth=…&propose=…&summarize=…`,
|
|
134
|
+
`POST /api/summarize` (summary pass over a previously returned graph),
|
|
135
|
+
and `POST /api/ask` (ask-the-graph over a previously returned graph —
|
|
136
|
+
powers the collapsible Q&A panel in the UI).
|
|
137
|
+
|
|
138
|
+
## Design rules
|
|
139
|
+
|
|
140
|
+
- JEV questions are Python-templated only — no LLM generates questions or
|
|
141
|
+
candidate options. `criteria` always come from API result sets; every
|
|
142
|
+
Choice question has a `none`/`other` escape. JEV judges, never enumerates.
|
|
143
|
+
- The one exception: *claims*. Free-text biological claims can't be
|
|
144
|
+
enumerated from an API result set, so the proposal passes (text claims,
|
|
145
|
+
data claims, summary) let the LLM propose candidates — the only place it
|
|
146
|
+
generates content. The asymmetry holds: every proposal is verified by JEV
|
|
147
|
+
against the serialized source (dataset metadata, per-sample values, or
|
|
148
|
+
the graph itself) before it lands. The LLM proposes, JEV disposes — it
|
|
149
|
+
never scores its own output.
|
|
150
|
+
- Every edge must carry ≥1 `Evidence` record (source, endpoint, timestamp,
|
|
151
|
+
payload) so "why" is always answerable.
|
|
152
|
+
- Unbounded API result sets are capped before JEV/LLM stages so a single
|
|
153
|
+
state can't overflow the model context or spend unbounded calls:
|
|
154
|
+
ortholog candidates keep the top 100 by OMA score (S3), and
|
|
155
|
+
datasets/publications keep the top 100 per kind by triage score
|
|
156
|
+
(`proposals.MAX_ITEMS_PER_KIND`). These are hard-coded for now — if a
|
|
157
|
+
use case needs deeper coverage they should become configurable.
|
|
158
|
+
|
|
159
|
+
## Layout
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
src/bionym/ core library + CLI (no web deps)
|
|
163
|
+
jev.py systemone client: batch questions, token logging,
|
|
164
|
+
mock mode, JEV_BASE_URL for Laya/Kev/CLM backends
|
|
165
|
+
llm.py proposal/summary/ask LLM client (mock mode for dev)
|
|
166
|
+
ask.py ask-the-graph orchestration (classify→slice→answer→score)
|
|
167
|
+
evidence.py Evidence records
|
|
168
|
+
graph.py KnowledgeGraph: nodes/edges/confidence, url + filtering
|
|
169
|
+
proposals.py LLM propose-then-JEV-verify: prompts, serializers, parsers
|
|
170
|
+
questions/ staged JEV question builders (s0–s6) + ask
|
|
171
|
+
classify/slice builders
|
|
172
|
+
clients/ one thin client per data source
|
|
173
|
+
resolver.py stage orchestration + proposal/summary passes
|
|
174
|
+
report.py self-contained HTML report (D3 network + tables)
|
|
175
|
+
backend/ FastAPI deployable
|
|
176
|
+
web/ static frontend (D3 multi-partite network)
|
|
177
|
+
evals/ corpus + runner + differ for real-ID eval runs
|
|
178
|
+
(see evals/README.md; results committed as JSONL)
|
|
179
|
+
tests/ pytest; JEV/LLM mocked or faked, backend via
|
|
180
|
+
TestClient
|
|
181
|
+
```
|
bionym-0.1.0/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# BioNym
|
|
2
|
+
|
|
3
|
+
Resolve bioinformatics identifiers into confidence-scored knowledge graphs.
|
|
4
|
+
|
|
5
|
+
Given a gene identifier (any species — NCBI gene ID, symbol, VEuPathDB
|
|
6
|
+
locus tag, UniProt accession, Ensembl ID, ...), BioNym gathers evidence
|
|
7
|
+
from public APIs (NCBI, VEuPathDB, OMA, UniProt, GEO, Expression Atlas,
|
|
8
|
+
...), asks [JEV](https://typesafe.ai) (TypeSafe `systemone`) an ordered
|
|
9
|
+
workflow of typed questions, and emits a knowledge graph where every claim
|
|
10
|
+
carries a confidence score and a list of supporting evidence.
|
|
11
|
+
|
|
12
|
+
## Status
|
|
13
|
+
|
|
14
|
+
All pipeline stages implemented: S0 (ID classification), S1 (entity
|
|
15
|
+
resolution → organism + assembly), S2 (related & newer assemblies with
|
|
16
|
+
species-rank lineage normalization), S3 (orthologs via OMA), S4 (UniProt
|
|
17
|
+
annotation: GO evidence-code confidence, KEGG, InterPro/Pfam), S5
|
|
18
|
+
(expression: GEO + Expression Atlas, JEV-scored), S6 (cross-assembly
|
|
19
|
+
presence: `annotated_in` + JEV `likely_present`).
|
|
20
|
+
|
|
21
|
+
On top of the staged pipeline, two optional LLM passes propose claims that
|
|
22
|
+
JEV then verifies: text claims over publication/dataset metadata, and data
|
|
23
|
+
claims over per-gene measurements (VEuPathDB ExpressionGraphs, GEO GDS SOFT
|
|
24
|
+
files, GXA baseline/differential TSVs). A third pass can synthesize a
|
|
25
|
+
JEV-verified gene summary into `metadata.summary`.
|
|
26
|
+
|
|
27
|
+
Interfaces: CLI (`bionym resolve`, `bionym summarize`, `bionym ask`), FastAPI backend (`backend/`), static web frontend (`web/`, D3 multi-partite network).
|
|
28
|
+
|
|
29
|
+
`ask` answers a free-form question over a resolved graph: JEV first
|
|
30
|
+
classifies the question into graph categories, the matching subgraph
|
|
31
|
+
is sliced out, the LLM answers over that slice (citing node ids), and
|
|
32
|
+
JEV scores accuracy/completeness — deterministic citation fidelity
|
|
33
|
+
checked against the full graph on top.
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
conda create -n bionym python=3.11 -y
|
|
39
|
+
conda activate bionym
|
|
40
|
+
pip install -e '.[dev]'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configure
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cp .env.example .env # then edit
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- `TYPESAFE_API_KEY` — required for real JEV calls.
|
|
50
|
+
- `NCBI_API_KEY` — optional, raises NCBI rate limit 3/s → 10/s.
|
|
51
|
+
- `VEUPATHDB_API_KEY` — optional, enables VEuPathDB lookups (release 71+).
|
|
52
|
+
- `BIONYM_CACHE_DIR` — optional response/JEV cache.
|
|
53
|
+
- `LLM_API_KEY` + `LLM_MODEL` — optional, enables the proposal passes
|
|
54
|
+
(claims, summary). Any OpenAI-compatible endpoint; `LLM_BASE_URL`
|
|
55
|
+
defaults to OpenRouter. Disabled when unset — the resolver runs fine
|
|
56
|
+
without them, you just get no proposed claims or summary.
|
|
57
|
+
- `BIONYM_PROPOSAL_MIN_SCORE` (default 0.5) — JEV triage score a
|
|
58
|
+
dataset/publication needs before the LLM spends a call on it.
|
|
59
|
+
- `BIONYM_PROPOSAL_CONCURRENCY` (default 8) — max simultaneous LLM calls.
|
|
60
|
+
- `JEV_BASE_URL` — optional; repoint the systemone endpoint at any
|
|
61
|
+
compatible backend (Laya, Kev, CLM all speak `POST /v1/systemone`).
|
|
62
|
+
- `JEV_MODEL` — optional (default `jev-latest`); model string sent in
|
|
63
|
+
the request — set it when pointing at a non-jev backend.
|
|
64
|
+
- `LLM_TIMEOUT` — optional, seconds (default 180); whole-graph asks
|
|
65
|
+
can exceed the old 60s on slow models.
|
|
66
|
+
- `BIONYM_ALLOW_MOCK` — server only; `=1` permits `mock_jev=true`
|
|
67
|
+
on API requests (offline dev/evals). Off by default.
|
|
68
|
+
|
|
69
|
+
## Usage
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
bionym resolve PF3D7_0710100 -o graph.json -v
|
|
73
|
+
bionym resolve 672 --depth 0 # classify only
|
|
74
|
+
bionym resolve 672 --report # + self-contained HTML report
|
|
75
|
+
bionym resolve 672 --min-confidence 0.7 # drop low-confidence edges
|
|
76
|
+
bionym resolve 672 --no-propose # quick scan: skip LLM claim passes
|
|
77
|
+
bionym resolve 672 --summarize # + JEV-verified summary in metadata
|
|
78
|
+
bionym resolve 672 --mock-jev # offline dev, no API key
|
|
79
|
+
|
|
80
|
+
bionym summarize graph.json # summary pass on an existing graph
|
|
81
|
+
bionym ask graph.json "what datasets are associated?"
|
|
82
|
+
# classify → slice → LLM answer → JEV scores
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
> **`--mock-jev` is for development only.** It returns deterministic
|
|
86
|
+
> placeholder answers (first option / midpoint score / 0.5) instead of real
|
|
87
|
+
> JEV judgments, so the resulting graph **will not be biologically
|
|
88
|
+
> meaningful** — edges and confidences are arbitrary. It's a free way to
|
|
89
|
+
> exercise the full pipeline and surface *technical* bugs (crashes, parsing,
|
|
90
|
+
> wiring) without an API key or cost. Never interpret mock output as a
|
|
91
|
+
> result.
|
|
92
|
+
|
|
93
|
+
Output: a JSON knowledge graph — `nodes` (typed: Gene, Organism, Assembly,
|
|
94
|
+
IdType, ...; each with an external `url`), `edges` (claims with
|
|
95
|
+
`confidence`, `probabilities`, `jev_question_id`, `evidence[]`), and
|
|
96
|
+
`metadata` (`outcome`: `resolved|refused`, `stages` + `stage_times`,
|
|
97
|
+
`jev_usage` per-stage token counts, optional `summary`: JEV-verified
|
|
98
|
+
claim list with `claim`/`quote`/`confidence`).
|
|
99
|
+
|
|
100
|
+
## Web app
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# backend (needs the package installed + .env)
|
|
104
|
+
cd backend && uvicorn main:app --port 8001
|
|
105
|
+
|
|
106
|
+
# frontend (static; also works opened directly or from GH Pages)
|
|
107
|
+
cd web && python -m http.server 8080
|
|
108
|
+
# open http://localhost:8080 — backend URL is set in web/index.html (BACKEND const)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The UI offers **Quick scan** (`propose=false` — deterministic stages + JEV
|
|
112
|
+
edge scoring only, seconds) vs **Full analysis** (`propose+summarize`,
|
|
113
|
+
minutes). The verified summary renders in a collapsible section above the
|
|
114
|
+
network. API: `GET /api/resolve?identifier=…&depth=…&propose=…&summarize=…`,
|
|
115
|
+
`POST /api/summarize` (summary pass over a previously returned graph),
|
|
116
|
+
and `POST /api/ask` (ask-the-graph over a previously returned graph —
|
|
117
|
+
powers the collapsible Q&A panel in the UI).
|
|
118
|
+
|
|
119
|
+
## Design rules
|
|
120
|
+
|
|
121
|
+
- JEV questions are Python-templated only — no LLM generates questions or
|
|
122
|
+
candidate options. `criteria` always come from API result sets; every
|
|
123
|
+
Choice question has a `none`/`other` escape. JEV judges, never enumerates.
|
|
124
|
+
- The one exception: *claims*. Free-text biological claims can't be
|
|
125
|
+
enumerated from an API result set, so the proposal passes (text claims,
|
|
126
|
+
data claims, summary) let the LLM propose candidates — the only place it
|
|
127
|
+
generates content. The asymmetry holds: every proposal is verified by JEV
|
|
128
|
+
against the serialized source (dataset metadata, per-sample values, or
|
|
129
|
+
the graph itself) before it lands. The LLM proposes, JEV disposes — it
|
|
130
|
+
never scores its own output.
|
|
131
|
+
- Every edge must carry ≥1 `Evidence` record (source, endpoint, timestamp,
|
|
132
|
+
payload) so "why" is always answerable.
|
|
133
|
+
- Unbounded API result sets are capped before JEV/LLM stages so a single
|
|
134
|
+
state can't overflow the model context or spend unbounded calls:
|
|
135
|
+
ortholog candidates keep the top 100 by OMA score (S3), and
|
|
136
|
+
datasets/publications keep the top 100 per kind by triage score
|
|
137
|
+
(`proposals.MAX_ITEMS_PER_KIND`). These are hard-coded for now — if a
|
|
138
|
+
use case needs deeper coverage they should become configurable.
|
|
139
|
+
|
|
140
|
+
## Layout
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
src/bionym/ core library + CLI (no web deps)
|
|
144
|
+
jev.py systemone client: batch questions, token logging,
|
|
145
|
+
mock mode, JEV_BASE_URL for Laya/Kev/CLM backends
|
|
146
|
+
llm.py proposal/summary/ask LLM client (mock mode for dev)
|
|
147
|
+
ask.py ask-the-graph orchestration (classify→slice→answer→score)
|
|
148
|
+
evidence.py Evidence records
|
|
149
|
+
graph.py KnowledgeGraph: nodes/edges/confidence, url + filtering
|
|
150
|
+
proposals.py LLM propose-then-JEV-verify: prompts, serializers, parsers
|
|
151
|
+
questions/ staged JEV question builders (s0–s6) + ask
|
|
152
|
+
classify/slice builders
|
|
153
|
+
clients/ one thin client per data source
|
|
154
|
+
resolver.py stage orchestration + proposal/summary passes
|
|
155
|
+
report.py self-contained HTML report (D3 network + tables)
|
|
156
|
+
backend/ FastAPI deployable
|
|
157
|
+
web/ static frontend (D3 multi-partite network)
|
|
158
|
+
evals/ corpus + runner + differ for real-ID eval runs
|
|
159
|
+
(see evals/README.md; results committed as JSONL)
|
|
160
|
+
tests/ pytest; JEV/LLM mocked or faked, backend via
|
|
161
|
+
TestClient
|
|
162
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "bionym"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Resolve bioinformatics identifiers into confidence-scored knowledge graphs with JEV."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
dependencies = [
|
|
13
|
+
"httpx>=0.27",
|
|
14
|
+
"typer>=0.12",
|
|
15
|
+
"pydantic>=2.6",
|
|
16
|
+
"diskcache>=5.6",
|
|
17
|
+
"python-dotenv>=1.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.optional-dependencies]
|
|
21
|
+
dev = ["pytest>=8", "pytest-cov>=5", "fastapi>=0.110"]
|
|
22
|
+
|
|
23
|
+
[project.scripts]
|
|
24
|
+
bionym = "bionym.cli:app"
|
|
25
|
+
|
|
26
|
+
[tool.setuptools.packages.find]
|
|
27
|
+
where = ["src"]
|
|
28
|
+
|
|
29
|
+
[tool.setuptools.package-data]
|
|
30
|
+
bionym = ["_static/*.js", "_static/*.css"]
|
bionym-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""bionym: bioinformatics ID -> confidence-scored knowledge graph via JEV."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("bionym")
|
|
7
|
+
except PackageNotFoundError:
|
|
8
|
+
# source tree without an install (tests set their own expectations)
|
|
9
|
+
__version__ = "0.0.0.dev0"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* @bionym/components — scoped component styles.
|
|
2
|
+
* All selectors are .bn-* namespaced; override freely or pass {colors}
|
|
3
|
+
* to components instead. CSS vars: --bn-ink, --bn-muted, --bn-line, --bn-bg. */
|
|
4
|
+
|
|
5
|
+
.bn-net-wrap, .bn-ov-wrap, .bn-detail {
|
|
6
|
+
--bn-ink: #1a202c; --bn-muted: #4a5568; --bn-line: #cbd5e0; --bn-bg: #f7fafc;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* ---- network ---------------------------------------------------------- */
|
|
10
|
+
.bn-net-wrap { position: relative; }
|
|
11
|
+
.bn-net { display: block; width: 100%; height: auto; cursor: grab; }
|
|
12
|
+
.bn-net:active { cursor: grabbing; }
|
|
13
|
+
|
|
14
|
+
.bn-net .node { stroke: #fff; stroke-width: 1px; cursor: default; }
|
|
15
|
+
.bn-net .nodelabel { font-size: 9px; pointer-events: none; opacity: 0; transition: opacity .1s; }
|
|
16
|
+
.bn-net .nodelabel.on { opacity: 1; }
|
|
17
|
+
.bn-net .link { fill: none; }
|
|
18
|
+
.bn-net .link.link-dim { stroke-opacity: .04; }
|
|
19
|
+
.bn-net .link.link-hi { stroke-opacity: .95; stroke: #2b6cb0; }
|
|
20
|
+
.bn-net .colhead { font-size: 11px; font-weight: 600; fill: var(--bn-muted); }
|
|
21
|
+
.bn-net .nodeg.dim { opacity: .12; }
|
|
22
|
+
.bn-net .nodeg:focus { outline: none; }
|
|
23
|
+
.bn-net .nodeg:focus .node { stroke: #2b6cb0; stroke-width: 2px; }
|
|
24
|
+
.bn-net .cluster { cursor: pointer; }
|
|
25
|
+
|
|
26
|
+
/* tooltip — absolutely positioned element inside the container */
|
|
27
|
+
.bn-tip {
|
|
28
|
+
position: fixed; z-index: 10; pointer-events: none;
|
|
29
|
+
background: #fff; border: 1px solid var(--bn-line); border-radius: 6px;
|
|
30
|
+
padding: .4rem .6rem; font-size: .78rem; max-width: 22rem;
|
|
31
|
+
box-shadow: 0 2px 8px rgba(0,0,0,.12); color: var(--bn-ink);
|
|
32
|
+
}
|
|
33
|
+
.bn-tip .bn-t-title { font-weight: 600; margin-bottom: .15rem; }
|
|
34
|
+
.bn-tip .bn-t-sub { color: var(--bn-muted); }
|
|
35
|
+
|
|
36
|
+
/* legend */
|
|
37
|
+
.bn-legend {
|
|
38
|
+
display: flex; flex-wrap: wrap; gap: .4rem 1rem;
|
|
39
|
+
padding: .4rem .2rem; font-size: .75rem; color: var(--bn-muted);
|
|
40
|
+
}
|
|
41
|
+
.bn-legend .leg { display: inline-flex; align-items: center; gap: .3rem; }
|
|
42
|
+
.bn-legend .leg i { width: .7rem; height: .7rem; border-radius: 50%; display: inline-block; }
|
|
43
|
+
|
|
44
|
+
/* ---- overview bar chart ------------------------------------------------ */
|
|
45
|
+
.bn-ov { display: block; width: 100%; height: auto; }
|
|
46
|
+
.bn-ov text { font-size: 9px; fill: var(--bn-muted); }
|
|
47
|
+
.bn-ov .seg { stroke: #fff; stroke-width: .5px; }
|
|
48
|
+
.bn-ov .bar:hover { opacity: .85; }
|
|
49
|
+
|
|
50
|
+
/* ---- detail panel -------------------------------------------------------
|
|
51
|
+
* Positioning is the consumer's — component only styles the box. Put it in
|
|
52
|
+
* an <aside> or wherever fits your layout. */
|
|
53
|
+
.bn-detail {
|
|
54
|
+
background: #fff; border: 1px solid var(--bn-line); border-radius: 8px;
|
|
55
|
+
padding: .7rem .9rem; font-size: .8rem; color: var(--bn-ink);
|
|
56
|
+
box-shadow: 0 4px 14px rgba(0,0,0,.15);
|
|
57
|
+
}
|
|
58
|
+
.bn-detail h3 { margin: 0 0 .3rem; font-size: .9rem; }
|
|
59
|
+
.bn-detail .bn-d-sub { color: var(--bn-muted); font-size: .72rem; word-break: break-all; }
|
|
60
|
+
.bn-detail ul { margin: .4rem 0 0; padding-left: 1.1rem; }
|
|
61
|
+
.bn-detail .bn-d-close { float: right; background: none; border: 0; color: var(--bn-muted); font-size: 1rem; padding: 0; cursor: pointer; }
|
|
62
|
+
.bn-detail .bn-d-actions a { margin-right: .8rem; font-size: .78rem; }
|
|
63
|
+
.bn-conf { color: var(--bn-muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
|