proef 0.2.0__py3-none-any.whl
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.
- proef/__init__.py +25 -0
- proef/acquisition.py +244 -0
- proef/ad.py +159 -0
- proef/adapters/__init__.py +0 -0
- proef/adapters/admet.py +196 -0
- proef/adapters/bio/__init__.py +0 -0
- proef/adapters/bio/rdkit_ops.py +52 -0
- proef/adapters/bio/safety_rules.json +146 -0
- proef/adapters/bio/seq_alerts.py +79 -0
- proef/adapters/bio/structure_score.py +85 -0
- proef/adapters/bio/tox_alerts.py +99 -0
- proef/adapters/data/__init__.py +0 -0
- proef/adapters/data/admet.py +62 -0
- proef/adapters/data/chembl.py +110 -0
- proef/adapters/data/frozen/admet/MANIFEST.json +48 -0
- proef/adapters/data/frozen/admet/bbb_martins/test.csv +407 -0
- proef/adapters/data/frozen/admet/bbb_martins/train_val.csv +1625 -0
- proef/adapters/data/frozen/admet/caco2_wang/test.csv +183 -0
- proef/adapters/data/frozen/admet/caco2_wang/train_val.csv +729 -0
- proef/adapters/data/frozen/admet/hia_hou/test.csv +118 -0
- proef/adapters/data/frozen/admet/hia_hou/train_val.csv +462 -0
- proef/adapters/data/moleculenet.py +60 -0
- proef/adapters/databases/__init__.py +0 -0
- proef/adapters/databases/chembl_gates.py +121 -0
- proef/adapters/databases/chembl_lookup.py +35 -0
- proef/adapters/databases/open_targets.py +102 -0
- proef/adapters/databases/pubmed.py +94 -0
- proef/adapters/devices/__init__.py +0 -0
- proef/adapters/devices/ezo_ph.py +251 -0
- proef/adapters/devices/hcs_microscope.py +143 -0
- proef/adapters/devices/lcms.py +123 -0
- proef/adapters/devices/scheduler.py +84 -0
- proef/adapters/devices/sila2.py +134 -0
- proef/adapters/genomics/alphagenome.py +146 -0
- proef/adapters/lab/__init__.py +0 -0
- proef/adapters/lab/bioprocess.py +32 -0
- proef/adapters/lab/devices.py +170 -0
- proef/adapters/lab/imaging.py +226 -0
- proef/adapters/lab/mhs_driver.py +124 -0
- proef/adapters/lab/opentrons.py +222 -0
- proef/adapters/lab/ot2_sim.py +174 -0
- proef/adapters/lab/plate_reader_share.py +108 -0
- proef/adapters/lab/protein_design.py +199 -0
- proef/adapters/lab/recording.py +119 -0
- proef/adapters/lab/replay.py +107 -0
- proef/adapters/lab/simulator.py +282 -0
- proef/adapters/lab/synthesis.py +92 -0
- proef/adapters/models/__init__.py +0 -0
- proef/adapters/models/anthropic_provider.py +157 -0
- proef/adapters/models/assayloop_ranker.py +67 -0
- proef/adapters/models/from_env.py +93 -0
- proef/adapters/models/gp_policy.py +93 -0
- proef/adapters/models/gp_policy_gp.py +36 -0
- proef/adapters/models/llm_policy.py +187 -0
- proef/adapters/models/openai_compat.py +150 -0
- proef/adapters/models/sklearn_policy.py +65 -0
- proef/adapters/retrosynthesis.py +247 -0
- proef/adapters/sandbox/__init__.py +20 -0
- proef/adapters/sandbox/agentenv.py +145 -0
- proef/adapters/sandbox/docker.py +217 -0
- proef/adapters/sandbox/local.py +164 -0
- proef/adapters/sandbox/opensandbox.py +122 -0
- proef/adapters/store/__init__.py +0 -0
- proef/adapters/store/sqlite.py +207 -0
- proef/adaptive.py +108 -0
- proef/advisory.py +76 -0
- proef/analysis_profiles/__init__.py +8 -0
- proef/analysis_profiles/measurements.py +266 -0
- proef/analysis_profiles/plate_assay.py +316 -0
- proef/analysis_report.py +195 -0
- proef/analysis_store.py +183 -0
- proef/anchor.py +154 -0
- proef/api/app.py +107 -0
- proef/api/launch.py +170 -0
- proef/api/v1/__init__.py +29 -0
- proef/api/v1/analyses.py +367 -0
- proef/api/v1/campaigns.py +802 -0
- proef/api/v1/deps.py +10 -0
- proef/api/v1/evals.py +16 -0
- proef/api/v1/evidence.py +132 -0
- proef/api/v1/governance.py +35 -0
- proef/api/v1/inbox.py +119 -0
- proef/api/v1/lab.py +110 -0
- proef/api/v1/pauses.py +77 -0
- proef/api/v1/programs.py +397 -0
- proef/api/v1/results.py +147 -0
- proef/api/v1/schemas.py +932 -0
- proef/api/v1/system.py +79 -0
- proef/api/v1/trees.py +216 -0
- proef/api/wizard_sessions.py +253 -0
- proef/approvals.py +102 -0
- proef/assays/__init__.py +15 -0
- proef/assays/dls.py +114 -0
- proef/assays/dsf.py +81 -0
- proef/assays/elisa.py +58 -0
- proef/assays/properties.py +65 -0
- proef/assays/simulate.py +157 -0
- proef/audit.py +152 -0
- proef/autoloop.py +1620 -0
- proef/benchmark.py +442 -0
- proef/campaign_fsm.py +151 -0
- proef/citations.py +141 -0
- proef/cli.py +1249 -0
- proef/connect.py +74 -0
- proef/core/__init__.py +0 -0
- proef/core/contracts/__init__.py +35 -0
- proef/core/contracts/analysis.py +100 -0
- proef/core/contracts/models.py +395 -0
- proef/core/device_card.py +125 -0
- proef/core/hypothesis.py +720 -0
- proef/core/interfaces.py +164 -0
- proef/core/registry.py +123 -0
- proef/core/safety.py +324 -0
- proef/core/workflow.py +159 -0
- proef/critic.py +62 -0
- proef/demo.py +164 -0
- proef/derivation.py +128 -0
- proef/diary.py +301 -0
- proef/eln.py +87 -0
- proef/evals/__init__.py +1 -0
- proef/evals/hallucination.py +86 -0
- proef/evals/harness.py +358 -0
- proef/evals/orchestration.py +254 -0
- proef/evals/tasks.py +1010 -0
- proef/evals/toolcalls.py +425 -0
- proef/experiment.py +172 -0
- proef/experiment_analysis.py +114 -0
- proef/experiments/__init__.py +0 -0
- proef/experiments/grounding_exp.py +689 -0
- proef/figures.py +218 -0
- proef/fitting.py +309 -0
- proef/fixtures.py +140 -0
- proef/flywheel.py +125 -0
- proef/followup.py +126 -0
- proef/governance.py +290 -0
- proef/groundedness.py +361 -0
- proef/grounding.py +202 -0
- proef/hypothesis_agent.py +369 -0
- proef/ingest.py +157 -0
- proef/instruments.json +173 -0
- proef/interpret.py +95 -0
- proef/kinetic.py +102 -0
- proef/labread/__init__.py +45 -0
- proef/labread/analysis.py +428 -0
- proef/labread/common.py +153 -0
- proef/labread/formats.py +190 -0
- proef/labread/layout.py +168 -0
- proef/labread/pubchem.py +179 -0
- proef/labselect.py +431 -0
- proef/materials.py +140 -0
- proef/mcp_instrument.py +396 -0
- proef/mcp_server.py +283 -0
- proef/modality.py +111 -0
- proef/model_guard.py +245 -0
- proef/output_blocks.py +183 -0
- proef/paths.py +32 -0
- proef/physfail.py +55 -0
- proef/plan.py +160 -0
- proef/plots.py +123 -0
- proef/predictors.py +217 -0
- proef/probes.py +79 -0
- proef/problem_tree.py +581 -0
- proef/program.py +308 -0
- proef/protocol_design.py +42 -0
- proef/proxy.py +78 -0
- proef/readiness.py +259 -0
- proef/reliability.py +49 -0
- proef/report.py +117 -0
- proef/reproduce.py +310 -0
- proef/reviewer.py +254 -0
- proef/sandbox_session.py +247 -0
- proef/sandboxd.py +109 -0
- proef/scaffold.py +195 -0
- proef/series.py +327 -0
- proef/skills.py +203 -0
- proef/sweep.py +83 -0
- proef/taste.py +177 -0
- proef/templates/confirmatory-followup.json +34 -0
- proef/templates/dose-response-screen.json +39 -0
- proef/templates/sar-exploration.json +38 -0
- proef/templates.py +124 -0
- proef/toolkit.py +433 -0
- proef/toolloop.py +133 -0
- proef/tools.py +441 -0
- proef/tpp.py +185 -0
- proef/views/__init__.py +14 -0
- proef/views/counts.py +102 -0
- proef/views/experiment.py +154 -0
- proef/views/ids.py +49 -0
- proef/views/narrative.py +294 -0
- proef/views/pipeline.py +370 -0
- proef/vision.py +165 -0
- proef/watch.py +790 -0
- proef/wizard_chain.py +25 -0
- proef/wizard_store.py +373 -0
- proef-0.2.0.dist-info/METADATA +662 -0
- proef-0.2.0.dist-info/RECORD +200 -0
- proef-0.2.0.dist-info/WHEEL +4 -0
- proef-0.2.0.dist-info/entry_points.txt +14 -0
- proef-0.2.0.dist-info/licenses/LICENSE +202 -0
proef/instruments.json
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"updated": "2026-10-11",
|
|
4
|
+
"attribution": "labmcp-* entries reference K-Dense LabMCP servers (Apache-2.0, github.com/K-Dense-AI/lab-instrument-mcps); profiles here are Proef-side mappings of their declared result fields",
|
|
5
|
+
"instruments": [
|
|
6
|
+
{
|
|
7
|
+
"id": "proef-virtual-lab",
|
|
8
|
+
"kind": "simulator",
|
|
9
|
+
"name": "Virtual lab (dose–response simulator)",
|
|
10
|
+
"vendor": "Proef",
|
|
11
|
+
"simulated": true,
|
|
12
|
+
"hardware_validated": false,
|
|
13
|
+
"assay_types": [
|
|
14
|
+
"binding",
|
|
15
|
+
"enzymatic",
|
|
16
|
+
"cytotoxicity",
|
|
17
|
+
"counterscreen",
|
|
18
|
+
"adme",
|
|
19
|
+
"pcr",
|
|
20
|
+
"elisa",
|
|
21
|
+
"dsf",
|
|
22
|
+
"custom"
|
|
23
|
+
],
|
|
24
|
+
"options": {
|
|
25
|
+
"seed": 42
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "ezo-ph-reference-mcp",
|
|
30
|
+
"kind": "mcp",
|
|
31
|
+
"name": "EZO pH probe (Proef reference MCP server)",
|
|
32
|
+
"vendor": "Atlas Scientific grammar; simulator stands in for labmcp_atlas_ezo",
|
|
33
|
+
"command": [
|
|
34
|
+
"{python}",
|
|
35
|
+
"-m",
|
|
36
|
+
"proef.mcp_instrument"
|
|
37
|
+
],
|
|
38
|
+
"simulated": true,
|
|
39
|
+
"hardware_validated": false,
|
|
40
|
+
"assay_types": [
|
|
41
|
+
"sensor"
|
|
42
|
+
],
|
|
43
|
+
"readouts": [
|
|
44
|
+
"read_ph"
|
|
45
|
+
],
|
|
46
|
+
"profile": {
|
|
47
|
+
"read_tool": "read_ph",
|
|
48
|
+
"value_field": "ph",
|
|
49
|
+
"unit": "pH",
|
|
50
|
+
"uncertainty_field": "uncertainty_ph",
|
|
51
|
+
"cal_field": "cal_state",
|
|
52
|
+
"stable_field": null
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "labmcp-mettler-toledo",
|
|
57
|
+
"kind": "mcp",
|
|
58
|
+
"name": "Mettler Toledo balance (LabMCP)",
|
|
59
|
+
"vendor": "K-Dense LabMCP (Apache-2.0)",
|
|
60
|
+
"command": [
|
|
61
|
+
"labmcp-mettler-toledo"
|
|
62
|
+
],
|
|
63
|
+
"availability_executable": "labmcp-mettler-toledo",
|
|
64
|
+
"homepage": "https://github.com/K-Dense-AI/lab-instrument-mcps",
|
|
65
|
+
"simulated_by_default": true,
|
|
66
|
+
"hardware_validated": false,
|
|
67
|
+
"assay_types": [],
|
|
68
|
+
"readouts": [
|
|
69
|
+
"read_weight",
|
|
70
|
+
"get_tare",
|
|
71
|
+
"read_temperature"
|
|
72
|
+
],
|
|
73
|
+
"profile": {
|
|
74
|
+
"read_tool": "read_weight",
|
|
75
|
+
"value_field": "value",
|
|
76
|
+
"unit": null,
|
|
77
|
+
"uncertainty_field": null,
|
|
78
|
+
"cal_field": null,
|
|
79
|
+
"stable_field": "stable"
|
|
80
|
+
},
|
|
81
|
+
"config_schema": [
|
|
82
|
+
{
|
|
83
|
+
"key": "simulate",
|
|
84
|
+
"type": "bool",
|
|
85
|
+
"default": true,
|
|
86
|
+
"description": "practice mode — no hardware contacted"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"key": "address",
|
|
90
|
+
"type": "string",
|
|
91
|
+
"default": null,
|
|
92
|
+
"description": "COM3 / /dev/ttyUSB0 / tcp://ip:port (from `labmcp ports`)"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"id": "labmcp-ika",
|
|
98
|
+
"kind": "mcp",
|
|
99
|
+
"name": "IKA hotplate/stirrer (LabMCP)",
|
|
100
|
+
"vendor": "K-Dense LabMCP (Apache-2.0)",
|
|
101
|
+
"command": [
|
|
102
|
+
"labmcp-ika"
|
|
103
|
+
],
|
|
104
|
+
"availability_executable": "labmcp-ika",
|
|
105
|
+
"homepage": "https://github.com/K-Dense-AI/lab-instrument-mcps",
|
|
106
|
+
"simulated_by_default": true,
|
|
107
|
+
"hardware_validated": false,
|
|
108
|
+
"assay_types": [],
|
|
109
|
+
"readouts": [
|
|
110
|
+
"get_status",
|
|
111
|
+
"wait_for_temperature"
|
|
112
|
+
],
|
|
113
|
+
"profile": {
|
|
114
|
+
"read_tool": "get_status",
|
|
115
|
+
"value_field": "hotplate_temperature_c",
|
|
116
|
+
"unit": "°C",
|
|
117
|
+
"uncertainty_field": null,
|
|
118
|
+
"cal_field": null,
|
|
119
|
+
"stable_field": null
|
|
120
|
+
},
|
|
121
|
+
"config_schema": [
|
|
122
|
+
{
|
|
123
|
+
"key": "simulate",
|
|
124
|
+
"type": "bool",
|
|
125
|
+
"default": true,
|
|
126
|
+
"description": "practice mode — no hardware contacted"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"key": "address",
|
|
130
|
+
"type": "string",
|
|
131
|
+
"default": null,
|
|
132
|
+
"description": "serial/virtual-COM address of the hotplate"
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"id": "opentrons-reference-driver",
|
|
138
|
+
"kind": "adapter",
|
|
139
|
+
"name": "Opentrons OT-2/Flex driver (contract-pinned)",
|
|
140
|
+
"vendor": "Opentrons HTTP API v3",
|
|
141
|
+
"adapter": "proef.adapters.lab.opentrons:OpentronsLab",
|
|
142
|
+
"simulated": false,
|
|
143
|
+
"hardware_validated": false,
|
|
144
|
+
"requires_network": true,
|
|
145
|
+
"assay_types": [
|
|
146
|
+
"make"
|
|
147
|
+
],
|
|
148
|
+
"note": "CI-verified against a spec-conformant simulated robot; physical confirmation pending (S-T4)"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"id": "lcms-simulator",
|
|
152
|
+
"kind": "adapter",
|
|
153
|
+
"name": "LC-MS ratiometric proteomics (simulator only)",
|
|
154
|
+
"vendor": "none (S-T4: no .raw/vendor API yet)",
|
|
155
|
+
"adapter": "proef.adapters.devices.lcms:LCMSAdapter",
|
|
156
|
+
"simulated": true,
|
|
157
|
+
"hardware_validated": false,
|
|
158
|
+
"requires_network": false,
|
|
159
|
+
"note": "SIMULATOR ONLY: supplies the edited-fraction denominator in virtual campaigns; simulator=False refuses"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"id": "hcs-microscope-simulator",
|
|
163
|
+
"kind": "adapter",
|
|
164
|
+
"name": "High-content imaging microscope (simulator only)",
|
|
165
|
+
"vendor": "none (S-T4: Micro-Manager binding pending)",
|
|
166
|
+
"adapter": "proef.adapters.devices.hcs_microscope:HCSMicroscopeAdapter",
|
|
167
|
+
"simulated": true,
|
|
168
|
+
"hardware_validated": false,
|
|
169
|
+
"requires_network": false,
|
|
170
|
+
"note": "SIMULATOR ONLY: all per-cell output is synthetic; simulator=False refuses"
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
proef/interpret.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""Prediction attribution — "why" beside every model number.
|
|
2
|
+
|
|
3
|
+
Per-instance explanations for the built-in policies:
|
|
4
|
+
- CharRidgePolicy: exact — each n-gram's (count × slot weight) contribution;
|
|
5
|
+
hashed slots can collide, and the output says so.
|
|
6
|
+
- MorganFingerprintRF: importance-weighted presence — global mean-decrease-
|
|
7
|
+
impurity × bits active in THIS molecule; folded bits are hashed indices,
|
|
8
|
+
not named substructures, and the output says so too.
|
|
9
|
+
|
|
10
|
+
Honesty rule: an explanation that overstates itself is worse than none.
|
|
11
|
+
"""
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
import math
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def explain_prediction(policy, smiles: str) -> dict:
|
|
18
|
+
name = getattr(policy, "name", type(policy).__name__)
|
|
19
|
+
|
|
20
|
+
# --- char n-gram ridge: exact per-n-gram contributions -----------------
|
|
21
|
+
if hasattr(policy, "w") and hasattr(policy, "_featurize"):
|
|
22
|
+
n = getattr(policy, "ngram", 3)
|
|
23
|
+
grams = [smiles[k:k + n] for k in
|
|
24
|
+
range(max(0, len(smiles) - n + 1))]
|
|
25
|
+
counts: dict[int, float] = {}
|
|
26
|
+
for g in grams:
|
|
27
|
+
h = int(_md5(g)[:8], 16) % policy.dim
|
|
28
|
+
counts[h] = counts.get(h, 0.0) + 1.0
|
|
29
|
+
count_norm = math.sqrt(sum(c * c for c in counts.values())) or 1.0
|
|
30
|
+
raw: dict[str, float] = {}
|
|
31
|
+
for g in grams:
|
|
32
|
+
h = int(_md5(g)[:8], 16) % policy.dim
|
|
33
|
+
raw[g] = raw.get(g, 0.0) + policy.w[h] / count_norm
|
|
34
|
+
contrib = sorted(raw.items(), key=lambda t: -abs(t[1]))
|
|
35
|
+
pred = policy.predict(smiles)
|
|
36
|
+
return {
|
|
37
|
+
"policy": name, "method": "ngram-contributions",
|
|
38
|
+
"prediction": round(pred, 3),
|
|
39
|
+
"baseline_mean": round(getattr(policy, "mean", 0.0), 3),
|
|
40
|
+
"top_positive": [(g, round(w, 3)) for g, w in contrib if w > 0][:5],
|
|
41
|
+
"top_negative": [(g, round(w, 3)) for g, w in contrib if w < 0][-5:],
|
|
42
|
+
"caveat": "hashed slots: an n-gram's weight may include collisions",
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# --- random forest over folded Morgan bits: importance × presence ------
|
|
46
|
+
if hasattr(policy, "model") and hasattr(policy, "_fp"):
|
|
47
|
+
try:
|
|
48
|
+
import numpy as np
|
|
49
|
+
x = np.asarray(policy._fp(smiles))
|
|
50
|
+
imp = np.asarray(policy.model.feature_importances_)
|
|
51
|
+
active = np.nonzero(x)[0]
|
|
52
|
+
ranked = sorted(active, key=lambda b: -imp[b] * x[b])
|
|
53
|
+
pred = policy.predict(smiles)
|
|
54
|
+
return {
|
|
55
|
+
"policy": name, "method": "importance-weighted-bits",
|
|
56
|
+
"prediction": round(float(pred), 3),
|
|
57
|
+
"top_bits": [(int(b), round(float(imp[b]), 4))
|
|
58
|
+
for b in ranked[:8]],
|
|
59
|
+
"n_active_bits": int(len(active)),
|
|
60
|
+
"caveat": "folded Morgan bits are hashed indices, not named "
|
|
61
|
+
"substructures; map via fingerprint back-mapping "
|
|
62
|
+
"for chemistry-readable reasons",
|
|
63
|
+
}
|
|
64
|
+
except ImportError:
|
|
65
|
+
pass
|
|
66
|
+
|
|
67
|
+
return {"policy": name, "method": "none",
|
|
68
|
+
"caveat": "this policy exposes no per-instance attribution"}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _md5(s: str) -> str:
|
|
72
|
+
import hashlib
|
|
73
|
+
return hashlib.md5(s.encode()).hexdigest() # noqa: S324
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def explain_admet(summary: dict) -> dict:
|
|
77
|
+
"""Rule-based ADMET: the 'why' is the triggered rules themselves."""
|
|
78
|
+
reasons = []
|
|
79
|
+
if summary.get("lipinski_violations"):
|
|
80
|
+
reasons.append(f"Lipinski: {summary['lipinski_violations']} violation(s)")
|
|
81
|
+
if summary.get("pains_alerts"):
|
|
82
|
+
reasons.append(f"PAINS: {', '.join(summary['pains_alerts'])}")
|
|
83
|
+
if summary.get("mw_da", 0) and summary["mw_da"] > 500:
|
|
84
|
+
reasons.append(f"MW {summary['mw_da']} Da > 500")
|
|
85
|
+
return {"method": "triggered-rules", "reasons": reasons or ["no flags"],
|
|
86
|
+
"prediction": None}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def explain_variant(impact) -> dict:
|
|
90
|
+
"""AlphaGenome AVI: feature attributions come with the score."""
|
|
91
|
+
return {"method": "avi-feature-attributions",
|
|
92
|
+
"prediction": impact.avi_score,
|
|
93
|
+
"top_drivers": dict(sorted(impact.attributions.items(),
|
|
94
|
+
key=lambda kv: -kv[1])[:3]),
|
|
95
|
+
"caveat": "attribution categories, not per-feature gradients"}
|
proef/kinetic.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""Kinetic matching for multi-step biochemical assembly (split inteins, etc.).
|
|
2
|
+
|
|
3
|
+
From the protein editing literature (Hua et al., Science 2025): when two
|
|
4
|
+
sequential splicing reactions run at mismatched rates, the reaction partitions
|
|
5
|
+
between a concerted pathway and a stepwise one, and hemi-spliced intermediates
|
|
6
|
+
accumulate. Deliberately slowing one component (e.g. mut-Cfa) restores
|
|
7
|
+
synchronisation.
|
|
8
|
+
|
|
9
|
+
This module encodes that principle as a reusable check for any experiment
|
|
10
|
+
involving multi-step biochemical assembly.
|
|
11
|
+
"""
|
|
12
|
+
from __future__ import annotations
|
|
13
|
+
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
from pydantic import BaseModel, Field
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass
|
|
21
|
+
class KineticProfile:
|
|
22
|
+
"""Rate constants for one component of a multi-step reaction."""
|
|
23
|
+
component_name: str
|
|
24
|
+
splicing_rate_per_sec: float | None = None # k_splice
|
|
25
|
+
association_rate_per_molar_sec: float | None = None # k_on
|
|
26
|
+
dissociation_constant_nM: float | None = None # K_D
|
|
27
|
+
half_life_sec: float | None = None
|
|
28
|
+
source: str = "" # where this data comes from (paper, measurement, estimate)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class KineticMatchResult:
|
|
33
|
+
compatible: bool
|
|
34
|
+
rate_ratio: float # faster_rate / slower_rate
|
|
35
|
+
interpretation: str
|
|
36
|
+
details: str
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def check_kinetic_match(
|
|
40
|
+
a: KineticProfile,
|
|
41
|
+
b: KineticProfile,
|
|
42
|
+
max_ratio: float = 10.0,
|
|
43
|
+
) -> KineticMatchResult:
|
|
44
|
+
"""Check whether two components' splicing rates are matched.
|
|
45
|
+
|
|
46
|
+
Rule (from Hua et al.): if the ratio of the two rate constants exceeds
|
|
47
|
+
~10x, the slower step becomes rate-limiting and hemi-spliced intermediates
|
|
48
|
+
accumulate. The fix is to slow the faster component (e.g. M75L/M81L
|
|
49
|
+
mutations) so both clocks keep time.
|
|
50
|
+
|
|
51
|
+
Returns compatible=False when the ratio exceeds max_ratio.
|
|
52
|
+
"""
|
|
53
|
+
if a.splicing_rate_per_sec is None or b.splicing_rate_per_sec is None:
|
|
54
|
+
return KineticMatchResult(
|
|
55
|
+
compatible=True, rate_ratio=1.0,
|
|
56
|
+
interpretation="rate data not available; cannot check",
|
|
57
|
+
details="no splicing rates provided — skipping kinetic match check")
|
|
58
|
+
|
|
59
|
+
fast = max(a.splicing_rate_per_sec, b.splicing_rate_per_sec)
|
|
60
|
+
slow = min(a.splicing_rate_per_sec, b.splicing_rate_per_sec)
|
|
61
|
+
if slow <= 0:
|
|
62
|
+
return KineticMatchResult(
|
|
63
|
+
compatible=True, rate_ratio=float("inf"),
|
|
64
|
+
interpretation="invalid rate (zero or negative)",
|
|
65
|
+
details=f"non-positive rate: {slow}")
|
|
66
|
+
|
|
67
|
+
ratio = fast / slow
|
|
68
|
+
if ratio <= max_ratio:
|
|
69
|
+
return KineticMatchResult(
|
|
70
|
+
compatible=True, rate_ratio=round(ratio, 2),
|
|
71
|
+
interpretation="matched",
|
|
72
|
+
details=f"rate ratio {ratio:.2f}x (limit {max_ratio}x)")
|
|
73
|
+
return KineticMatchResult(
|
|
74
|
+
compatible=False, rate_ratio=round(ratio, 2),
|
|
75
|
+
interpretation=f"mismatched by {ratio:.0f}x — expect intermediate accumulation",
|
|
76
|
+
details=f"{a.component_name} k={a.splicing_rate_per_sec} vs "
|
|
77
|
+
f"{b.component_name} k={b.splicing_rate_per_sec}; "
|
|
78
|
+
f"ratio {ratio:.1f}x exceeds limit {max_ratio}x")
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class InteinPairConfig(BaseModel):
|
|
82
|
+
"""Declared intein pair for a protein-editing experiment."""
|
|
83
|
+
n_intein: str
|
|
84
|
+
c_intein: str
|
|
85
|
+
n_splicing_rate: float | None = None
|
|
86
|
+
c_splicing_rate: float | None = None
|
|
87
|
+
is_engineered_slow_variant: bool = False
|
|
88
|
+
notes: str = ""
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def check_intein_pair(pair: InteinPairConfig) -> KineticMatchResult:
|
|
92
|
+
"""Check a declared intein pair for kinetic compatibility."""
|
|
93
|
+
if pair.n_splicing_rate is None or pair.c_splicing_rate is None:
|
|
94
|
+
return KineticMatchResult(
|
|
95
|
+
compatible=True, rate_ratio=1.0,
|
|
96
|
+
interpretation="rates not declared; cannot check",
|
|
97
|
+
details="no splicing rates provided for either intein domain")
|
|
98
|
+
a = KineticProfile(component_name=pair.n_intein,
|
|
99
|
+
splicing_rate_per_sec=pair.n_splicing_rate)
|
|
100
|
+
b = KineticProfile(component_name=pair.c_intein,
|
|
101
|
+
splicing_rate_per_sec=pair.c_splicing_rate)
|
|
102
|
+
return check_kinetic_match(a, b, max_ratio=10.0)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""labread — automatic instrument-result ingestion (scientist-facing, stable).
|
|
2
|
+
|
|
3
|
+
The point of the library: devices and labs produce files; Proef reads them.
|
|
4
|
+
`read_plate(path)` auto-detects the export format, standardizes it, fits
|
|
5
|
+
dose-response IC50s, and computes assay QC (Z' factor) — zero configuration.
|
|
6
|
+
|
|
7
|
+
Supported today:
|
|
8
|
+
- long-format CSV/TSV exports (any column order, header synonyms:
|
|
9
|
+
well/position, sample/compound, conc/concentration, value/RFU/OD/...)
|
|
10
|
+
- plate-grid exports (rows A-H, columns 1-12 numeric grid, e.g. Biotek/Synergy
|
|
11
|
+
style text exports), with metadata header lines skipped automatically
|
|
12
|
+
- vendor kinetic tables (Tecan i-control CSV/XLSX, BioTek KC1 flat CSV,
|
|
13
|
+
Gen5-style tab text): time/cycle rows x well columns, multi-channel,
|
|
14
|
+
'?????' missing tokens and Windows-1252 bytes tolerated; endpoint
|
|
15
|
+
reduction via cycles='last'|'first'|'mean'
|
|
16
|
+
- optional plate-layout join (well -> sample/conc) so bare grids get
|
|
17
|
+
dose-response fits: read_plate(path, layout=...)
|
|
18
|
+
- instrument identity metadata (reader, device, firmware, date) extracted
|
|
19
|
+
from the preamble for honest provenance: PlateResult.instrument
|
|
20
|
+
- native PubChem deposited tables (two dialects: meta-row dose ladders and
|
|
21
|
+
header-embedded doses; %inhibition or %Activity polarity, flips
|
|
22
|
+
disclosed) — with a REGIME GATE: the normalization frame is fingerprinted
|
|
23
|
+
and only externally-validated frames assert verdicts (CS05 validated
|
|
24
|
+
external-reference; self-normalized qHTS tables refuse the surface, per
|
|
25
|
+
CS06's published negative result). Records always stay standardized.
|
|
26
|
+
- Proef imaging evidence (.npy well images via the imaging lab)
|
|
27
|
+
- Excel (.xlsx) via the optional openpyxl extra
|
|
28
|
+
|
|
29
|
+
Control wells are auto-recognized by id: ctrl, control, blank, neg, vehicle,
|
|
30
|
+
ntc, standard.
|
|
31
|
+
"""
|
|
32
|
+
from __future__ import annotations
|
|
33
|
+
|
|
34
|
+
# curve models / statistics live in fitting.py; re-exported for callers
|
|
35
|
+
from proef.fitting import (GRID_CEIL_UM, GRID_FLOOR_UM, GRID_LOG_HI, GRID_LOG_LO, _hill_fit_ic50, _hill_sse, _spearman, classify_curve, fit_ic50, fit_ic50_ci, hill_response, replicate_ci, std_dev) # noqa: F401
|
|
36
|
+
from proef.labread.common import ( # noqa: F401
|
|
37
|
+
CONTROL_IDS, MISSING_TOKENS, POS_CONTROL_IDS, QC_ZPRIME_FLOOR, SYNONYMS, WELL_RE, _CHANNEL_RE, _channel_from_cell, _header_score, _is_missing, _is_number, _rows_from_csv, _well_columns, control_class, is_control, sanitize_label)
|
|
38
|
+
from proef.labread.formats import ( # noqa: F401
|
|
39
|
+
_META_KEY, _parse_grid, _parse_kinetic, _parse_long, detect_format, extract_instrument_meta)
|
|
40
|
+
from proef.labread.pubchem import ( # noqa: F401
|
|
41
|
+
_ASCENDING, _DESCENDING, _DOSE_NAME, _parse_pubchem, _pubchem_frame, _scale_of, tag_row_unit)
|
|
42
|
+
from proef.labread.layout import ( # noqa: F401
|
|
43
|
+
_layout_qc, _layout_sections, bind_layout)
|
|
44
|
+
from proef.labread.analysis import ( # noqa: F401
|
|
45
|
+
PlateResult, analyze_records, read_plate, to_pct_inhibition)
|