kelatte commited on
Commit
eeaa10a
·
0 Parent(s):

TwinLab-Bench release

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +0 -0
  2. .gitignore +7 -0
  3. README.md +123 -0
  4. assets/readme-dataset-badge.svg +1 -0
  5. assets/readme-leaderboard-badge.svg +1 -0
  6. assets/readme-paper-badge.svg +1 -0
  7. assets/readme-project-page-badge.svg +1 -0
  8. assets/readme-task-dashboard-badge.svg +1 -0
  9. assets/twinlab-bench-logo-dark.png +3 -0
  10. assets/twinlab-bench-logo-light.png +3 -0
  11. cases/001-coral-lcm-porites-03/assets/calculators.py +1673 -0
  12. cases/001-coral-lcm-porites-03/assets/env_knowledge/research_notes_distilled.md +103 -0
  13. cases/001-coral-lcm-porites-03/assets/env_knowledge/research_notes_precomputed.md +282 -0
  14. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION1_AREA1_TUBE11_OE_1.jpeg +3 -0
  15. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION1_AREA1_TUBE12_OG_1.jpeg +3 -0
  16. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION5_AREA2.jpeg +3 -0
  17. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION5_AREA2_TUBE2_OG_2.jpeg +3 -0
  18. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__Slide1_OV_5X.jpg +3 -0
  19. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__Slide2_OV_5X.jpg +3 -0
  20. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA1_TUBE17_OE_1.jpeg +3 -0
  21. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA1_TUBE18_OG_1.jpeg +3 -0
  22. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA2_TUBE17_OE_2.jpeg +3 -0
  23. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA2_TUBE18_OG_2.jpeg +3 -0
  24. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE2_SECTION2_AREA1_TUBE14_OE_1_POST.jpeg +3 -0
  25. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE2_SECTION2_AREA1_TUBE15_OG_1.jpeg +3 -0
  26. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__Slide1_OV_5x.jpg +3 -0
  27. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__Slide2_OV_5x.jpg +3 -0
  28. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260511__SLIDE3_AREA1_SECTION5_TUBE34_PK_BULK.jpg +3 -0
  29. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260511__slide3fail.jpg +3 -0
  30. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__POR_R72_C2_Slide1.jpg +3 -0
  31. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__POR_R72_C2_Slide2_Nostain_5x_OV.jpg +3 -0
  32. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA1_TUBE60_OE_1.jpeg +3 -0
  33. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA1_TUBE61_OG_1.jpeg +3 -0
  34. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA4_TUBE60_OE_4.jpeg +3 -0
  35. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA4_TUBE61_OG_4.jpeg +3 -0
  36. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area3_Tube51_OE_3.jpeg +3 -0
  37. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area3_Tube52_OG_3.jpeg +3 -0
  38. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area5_Tube51_OE_5.jpeg +3 -0
  39. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area5_Tube52_OG_5.jpeg +3 -0
  40. cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Tube53_BULK.jpeg +3 -0
  41. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-08-AM.png +3 -0
  42. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-08-PM.png +3 -0
  43. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-13.png +3 -0
  44. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-14.png +3 -0
  45. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_13.png +3 -0
  46. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_34.png +3 -0
  47. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_61.png +3 -0
  48. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_D5000.png +3 -0
  49. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_13.png +3 -0
  50. cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_34.png +3 -0
.gitattributes ADDED
The diff for this file is too large to render. See raw diff
 
.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ /cases/
2
+ /runs/
3
+ /tmp/
4
+ /machine.yaml
5
+ __pycache__/
6
+ *.pyc
7
+ .cache/
README.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: TwinLab-Bench
3
+ language:
4
+ - en
5
+ tags:
6
+ - agents
7
+ - ai-scientist
8
+ - benchmark
9
+ - science
10
+ ---
11
+
12
+ <h1 align="center">TwinLab-Bench: Evaluating AI Scientists in Agentic Twins of Real Labs</h1>
13
+
14
+ <br>
15
+
16
+ <p align="center">
17
+ <picture>
18
+ <source media="(prefers-color-scheme: dark)" srcset="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/assets/twinlab-bench-logo-dark.png">
19
+ <img src="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/assets/twinlab-bench-logo-light.png" alt="TwinLab-Bench" width="315">
20
+ </picture>
21
+ <br>
22
+ <br>
23
+ </p>
24
+
25
+ <p align="center">
26
+ <a href="https://arxiv.org/abs/2611.26248"><img alt="Paper" src="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/assets/readme-paper-badge.svg"></a>
27
+ <a href="https://twinlab-bench.github.io/"><img alt="Project Page" src="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/assets/readme-project-page-badge.svg"></a>
28
+ <a href="https://huggingface.co/spaces/ZJUSCL/TwinLab-Bench_Leaderboard"><img alt="Leaderboard" src="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/assets/readme-leaderboard-badge.svg"></a>
29
+ <a href="https://twinlab-bench.github.io/#all"><img alt="Task Dashboard" src="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/assets/readme-task-dashboard-badge.svg"></a>
30
+ <a href="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench"><img alt="Dataset" src="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/assets/readme-dataset-badge.svg"></a>
31
+ </p>
32
+
33
+ ## Overview
34
+
35
+ [TwinLab-Bench](https://twinlab-bench.github.io/) is a benchmark that evaluates AI scientists on experiments that they design themselves. Each task comes from the records of a real laboratory. The agent receives the notebooks, raw data, and interim conclusions that the laboratory had at one point of its work, requests the experiments that it designs within a budget, and submits a report. The report is scored by comparison with a hidden answer taken from what the laboratory later found.
36
+
37
+ Each task has its own TwinLab agent, which serves as the environment and executes the experiments that the tested agent designs. The TwinLab agent returns the recorded result for an experiment that the laboratory performed, and runs calculators built from the records of the laboratory for the other experiments.
38
+
39
+ These tasks remain hard for frontier models, and the strongest model, Claude Fable 5.2, averages a score of 45.0 out of 100. Compare models on the [leaderboard](https://huggingface.co/spaces/ZJUSCL/TwinLab-Bench_Leaderboard), browse every task and one run of it on the [task dashboard](https://twinlab-bench.github.io/#all), and download the tasks from [Hugging Face](https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench). To report a problem with a task, [open an issue](https://github.com/ZJUSCL/TwinLab-Bench/issues).
40
+
41
+ ## Task Coverage
42
+
43
+ TwinLab-Bench contains **52** tasks from laboratories in the physical sciences (20 tasks), the life sciences (20 tasks), and engineering (12 tasks). The [task dashboard](https://twinlab-bench.github.io/#all) lists all of them.
44
+
45
+ <p align="center">
46
+ <img src="https://huggingface.co/datasets/ZJUSCL/TwinLab-Bench/resolve/main/figures/tasks.png" width="900" alt="The 52 tasks of TwinLab-Bench by division and department, with four example tasks">
47
+ </p>
48
+
49
+ ## Running the Benchmark
50
+
51
+ ### Setup
52
+
53
+ You need Linux with [bubblewrap](https://github.com/containers/bubblewrap), Python 3.11 or later, Claude Code, and a DeepSeek API key. Claude Code needs to be signed in only when a Claude model is the actor. Codex is needed only for GPT actors. `machine.example.yaml` lists the Claude Code and Codex versions that we tested.
54
+
55
+ ```bash
56
+ pip install -U huggingface_hub
57
+ hf download ZJUSCL/TwinLab-Bench --repo-type dataset --local-dir TwinLab-Bench
58
+ cd TwinLab-Bench
59
+ pip install -r requirements.txt
60
+ cp machine.example.yaml machine.yaml # edit the paths in this file
61
+ mkdir -p ~/.config/twinlab/claude-ds
62
+ ```
63
+
64
+ DeepSeek-flash serves as the TwinLab agent and the judge agent through Claude Code. By default Claude Code calls DeepSeek's Anthropic-format API at `https://api.deepseek.com/anthropic` (set `DEEPSEEK_BASE_URL_ANTHROPIC` for another endpoint).
65
+
66
+ ```bash
67
+ export DEEPSEEK_API_KEY=sk-...
68
+ ```
69
+
70
+ (Optional) For an endpoint that accepts only the OpenAI format, set `DEEPSEEK_BASE_URL_OPENAI` and start the local proxy, which converts the requests.
71
+
72
+ ```bash
73
+ export DEEPSEEK_BASE_URL_OPENAI=https://api.deepseek.com
74
+ python scripts/llm_proxy.py write-config --model deepseek-flash --upstream-model deepseek-flash \
75
+ --api-base $DEEPSEEK_BASE_URL_OPENAI --key-env DEEPSEEK_API_KEY \
76
+ --master-key sk-local-twinlab --config ~/.config/twinlab/litellm.yaml
77
+ python scripts/llm_proxy.py start --config ~/.config/twinlab/litellm.yaml --port 4001 --workers 32
78
+ ```
79
+
80
+ ### Run
81
+
82
+ Run one task.
83
+
84
+ ```bash
85
+ python scripts/run_case.py --case cases/029-die-attach-release-01/case.yaml --n-runs 1 \
86
+ --actor-agent claude-code --actor-model claude-opus-5-5 --actor-effort high \
87
+ --env-model deepseek-flash --judge-model deepseek-flash \
88
+ --actor-timeout-s 10800 --checkpoints case --out runs
89
+ ```
90
+
91
+ Run all 52 tasks. The script prints a table of scores and writes each run to `runs/<task>/<time>/run_0/`, where `result.json` holds the score.
92
+
93
+ ```bash
94
+ python scripts/run_batch.py --cases cases/*/case.yaml --n-runs 1 \
95
+ --actor-agent claude-code --actor-model claude-opus-5-5 --actor-effort high \
96
+ --env-model deepseek-flash --judge-model deepseek-flash \
97
+ --actor-timeout-s 10800 --checkpoints case --jobs 52 --out runs \
98
+ --env-check-scratch /tmp/twinlab_env_check
99
+ ```
100
+
101
+ A run that stops on an error continues with `python scripts/resume_run.py --run-dir <run dir>`. To test another model, use `--actor-agent codex` for GPT models, or add the model to `model_backends` in `machine.yaml` and keep `--actor-agent claude-code`.
102
+
103
+ ## Citation
104
+
105
+ If you find this work useful, please cite it.
106
+
107
+ ```bibtex
108
+ @article{wan2026twinlabbench,
109
+ title = {{TwinLab-Bench}: Evaluating {AI} Scientists in Agentic Twins of Real Labs},
110
+ author = {Wan, Yang and Zhu, Linchao},
111
+ journal = {arXiv preprint arXiv:2611.26248},
112
+ year = {2026},
113
+ url = {https://twinlab-bench.github.io/}
114
+ }
115
+ ```
116
+
117
+ ## Contact
118
+
119
+ For questions and feedback, contact [wanyang@zju.edu.cn](mailto:wanyang@zju.edu.cn).
120
+
121
+ ## Acknowledgements
122
+
123
+ TwinLab-Bench is built on the records of real laboratories. We thank the researchers who published the lab notebooks, raw data, and papers that the tasks come from, and the data providers who answered our emails and allowed us to reuse their records. Every task uses its source records under the terms of their licenses. The task table in the appendix of our paper lists the source records and papers of every task, and the bibliography of the paper gives their full references. If you use a task, please also cite its sources from this bibliography.
assets/readme-dataset-badge.svg ADDED
assets/readme-leaderboard-badge.svg ADDED
assets/readme-paper-badge.svg ADDED
assets/readme-project-page-badge.svg ADDED
assets/readme-task-dashboard-badge.svg ADDED
assets/twinlab-bench-logo-dark.png ADDED

Git LFS Details

  • SHA256: a3032d33c3f81b59920f1506366c37262e31787b925c194e9a19f43c94940d79
  • Pointer size: 130 Bytes
  • Size of remote file: 86.6 kB
assets/twinlab-bench-logo-light.png ADDED

Git LFS Details

  • SHA256: 88af361709897c594efdbc5d69173091938f5395d9cd86ce9ef126919d74cb31
  • Pointer size: 130 Bytes
  • Size of remote file: 85.5 kB
cases/001-coral-lcm-porites-03/assets/calculators.py ADDED
@@ -0,0 +1,1673 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Deterministic numbers for 001-coral-lcm-porites-01/-02/-03 (run by the environment agent, cwd = env_ws).
3
+
4
+ Every number the lab reports comes from this script. Recorded conditions return the recorded values the first time
5
+ they are run on the matching material; everything else follows the model below, calibrated on the record (case
6
+ quantitative_model) and on published instrument specifications. All state lives in calc_state/<run>.json; use ONE
7
+ run id for the whole session (e.g. --run s1). Output is JSON. Keys starting with "_" are ENV-ONLY bookkeeping and
8
+ must never be shown to the actor. Every command ends with "charge" (action keys of case.yaml) and, where material is
9
+ used up, "consumed".
10
+
11
+ MODEL (all areas um2, RNA pg; "section" = one 10 um cryosection)
12
+ Tissue pools per section before any wash (Porites): oral epidermis OE 150,000, oral gastrodermis OG 250,000, deep
13
+ lattice tissue 2,500,000 (x block area factor, per-section CV 12 %). Pocillopora: OE 200,000, OG 300,000, aboral
14
+ 300,000. RNA per 1,000 um2 at 10 um, 15 min RT PK, Microprep: oral layers 2.42 (2.9 at 15 min 56 C, tubes 215/216),
15
+ Porites deep lattice x0.27 (bulk tube 219 vs layer tubes 215/216 on the same slide), x block density factor,
16
+ x thickness/10. One whole prewashed R72_C2 section then holds 2.33 ng (record 2A: 2.36 ng).
17
+ Washes keep a fraction of the tissue (RET table: OCT-removal class x block fragility); frayed outer layer is no
18
+ longer dissectable as intact epidermis but stays on the slide (pool "frayed").
19
+ LCM: tissue in a layer ROI = ROI x fraction (FRAC table, CV 18 %); bulk ROI fraction = 0.31/sqrt(ROI mm2), clipped
20
+ 0.17-0.70. Dissections are capped by the tissue left on the slide.
21
+ Extraction: pg = sum(tissue x density) x thickness/10 x digestion yield x kit x buffer x extraction CV 12 %.
22
+ DV200 = material base (sections 70.2, curls 72.0, fresh 81.6) + block offset + digestion delta + wash penalty.
23
+ TapeStation HS RNA: reading = true conc x lognormal (CV 0.07 + 0.30 exp(-c/150): 35 % at 10 pg/uL, 8 % at 500)
24
+ + baseline 2-9 pg/uL; DV200/RINe only at readings >= 100 pg/uL (flagged below 500); RINe = 1 + 0.112 x (DV200 - 30).
25
+ Bioanalyzer Pico: qualitative from 50 pg/uL, concentration estimate from 200 pg/uL. Qubit RNA HS: 5-100 ng in tube.
26
+ RT-qPCR: Ct = ref - 1.037 x log2(template pg / 100) (E = 95 %), template = RNA in RT x target share x integrity;
27
+ 3:5 assay (oligo-dT RT): 5-prime template = 3-prime template / (1.5 exp(0.065 (90 - DV200))).
28
+ NEB low-input library: cDNA plateau ~75 ng at 20 cycles from >= ~100 pg; final library saturates near 20 ng/uL.
29
+
30
+ COMMANDS (python3 calculators.py <cmd> --run s1 --spec '<json>'; every key shown is REQUIRED unless marked opt)
31
+ status --spec '{}' all slides, tubes, eluates, anchors left (env only)
32
+ section {"block": "POR_4", "slides": [{"label": "slide 1", "thickness_um": 10,
33
+ "cryostat_step": "100EtOH|70EtOH|none", "n_sections": 5, "trim_oct": false}]}
34
+ stain {"slide": "POR_4-S1", "warmup": "direct|slow|open", "wash": <WASH>, "stain": <STAIN>,
35
+ "rnase_inhibitor": false}
36
+ WASH: ethanol_only | prewash_100rinse | standard | brief_water | dropwise_water | water_dips_60s |
37
+ trough_dunks | graded_aqueous
38
+ STAIN: cresyl_1min | cresyl_30s | cresyl_dilute | none | aqueous_HE | ethanolic_other | aqueous_other
39
+ "wash" may also be a list with one WASH per section and "stain" a list with one STAIN per section
40
+ (the series put on each section separately as drops, the slide held flat): each section gets its own
41
+ retention, OCT, outer layer, cutting and traceable perimeter (printed per section); tubes cut from
42
+ several sections take the most water-exposed one. On a slide already through a series, "untouched"
43
+ in the wash list (stain "none" for that section) leaves the section exactly as it is.
44
+ lcm {"slide": "POR_4-S1", "measure_tissue": false, "tubes": [{"id": "21", "target":
45
+ "oral_epidermis|oral_gastrodermis|bulk", "buffer": "PK|Shield|RNA_lysis", "clean_only": false,
46
+ "amount": {"lab_default": true} | {"n_dissections": 5} | {"roi_um2": 150000} |
47
+ {"tissue_um2": 100000} | {"all": true}, "sections": [1, 2] (opt)}]}
48
+ scrape {"slide": "POR_R72_C2-S3", "tubes": [{"id": "2A", "sections": [1], "buffer": "PK"}]} whole sections
49
+ curls {"block": "POR_4", "tubes": [{"id": "C1", "n_curls": 5, "thickness_um": 20, "buffer": "PK",
50
+ "trim_oct": true}]} curls cut from the block face (no slide used)
51
+ blank {"tubes": [{"id": "BL1", "buffer": "PK"}]} collection buffer only
52
+ spike {"tube": "BL1", "source": "synthetic" | "eluate:<id>", "rna_pg": 1000} RNA added before extraction
53
+ extract {"columns": [{"id": "E21", "tubes": ["21"], "digestion": <DIG>|"recorded", "kit": <KIT>,
54
+ "elution_ul": 8}]} DIG: 15minRT 30minRT 15min56C 1h52C 1h56C 3h56C overnight56C
55
+ KIT: microprep miniprep picopure rneasy_micro
56
+ fresh {"extractions": [{"id": "1A", "shield_ul": 150, "digestion": "15minRT", "kit": "microprep",
57
+ "elution_ul": 15}]} fresh unfixed fragment in DNA/RNA Shield
58
+ tapestation {"eluates": ["E21"], "ul": 2, "integrity": false, "reanalyze": false}
59
+ bioanalyzer {"eluates": ["E21"], "ul": 1}
60
+ qubit {"eluates": ["E21"], "ul": 2}
61
+ qpcr {"reactions": [{"eluate": "E21", "ul_rna": 1, "dilution": 1}], "targets": ["host", "symbiont", "spike",
62
+ "host_3prime", "host_5prime"], "replicates": 2, "no_rt": true, "ntc": true} (3prime/5prime:
63
+ oligo-dT RT 3:5 integrity assay, one extra RT of the same RNA volume)
64
+ library {"prep_id": "L1", "samples": [{"eluate": "13", "ul": 6}], "cdna_cycles": 20, "final_cycles": 8,
65
+ "qubit_dsdna": false} max 3 samples per prep
66
+ a sample may carry its own "cdna_cycles" / "final_cycles" (one prep, one library_preps);
67
+ opt "final_cycles_rule": {"cdna_ng_above": 5, "cycles": 10} = samples whose printed cDNA total is
68
+ above 5 ng get 10 final cycles, the others their final_cycles
69
+ concentrate {"eluate": "E21", "final_ul": 4, "new_id": "E21c"}
70
+ combine {"eluates": ["E21", "E22"], "new_id": "P1"}
71
+ split {"tubes": ["2A", "2B"], "parts": [{"id": "A1", "tissue_um2": 1000000}, {"id": "A2", "fraction": 0.5}],
72
+ "rest_id": "2R" | null} pool unextracted scrape or lcm lysates of one block (same buffer) and split
73
+ them by traced tissue or fraction; the rest stays in rest_id (null: discarded)
74
+ measure_tissue {"tubes": ["21", "2A", "C1"]} FIJI tracing: LCM ROI images, sections before scraping,
75
+ block-face photo of curls
76
+ inspect {"slide": "POR_3-S2"} | {"tube": "13"} re-describe existing material
77
+ decline {"what": "interpret|not_recorded|people|sequencing|new_blocks|special_slides|carrier_rna|reelution|
78
+ glass_histology|cdna_other_qc|not_offered"} prints REFUSED / UNAVAILABLE / NOT OFFERED and the reason
79
+ in_folder {"file": "records/<file>" | "protocols/<file>"} the answer is in a file of the actor's folder
80
+ quote {"actions": ["library_prep", ...]} lab days per step (action keys), nothing done
81
+
82
+ 001-03 (clean conversion of 001-02): the measurement model and every command above `decline` are unchanged; the
83
+ lab's history is in the actor's records/, and declines, folder pointers and quotes print fixed text.
84
+ """
85
+ import argparse
86
+ import hashlib
87
+ import json
88
+ import math
89
+ import random
90
+ from pathlib import Path
91
+
92
+ STATE = Path("calc_state")
93
+
94
+ # ---------------- blocks and tissue ----------------
95
+ BLOCKS = { # group = fragility class; density/area relative to R72_C2; dv = DV200 offset (design)
96
+ "POR_3": {"group": "std", "density": 1.10, "area": 1.00, "dv": 0.0, "genus": "Porites"},
97
+ "POR_4": {"group": "std", "density": 1.00, "area": 0.95, "dv": -1.0, "genus": "Porites"},
98
+ "POR_R72_C2": {"group": "std", "density": 1.00, "area": 1.00, "dv": 0.0, "genus": "Porites"},
99
+ "POR_R72_H1": {"group": "R72H1", "density": 0.90, "area": 0.90, "dv": -2.0, "genus": "Porites"},
100
+ "POR_R3_H1": {"group": "R3H1", "density": 1.05, "area": 1.00, "dv": 1.0, "genus": "Porites"},
101
+ "POC_R3_C2": {"group": "POC", "density": 1.00, "area": 1.00, "dv": 2.0, "genus": "Pocillopora"},
102
+ }
103
+ SLIDES_PER_BLOCK = 4
104
+ POOLS = {"Porites": {"OE": 150000.0, "OG": 250000.0, "deep": 2500000.0},
105
+ "Pocillopora": {"OE": 200000.0, "OG": 300000.0, "deep": 300000.0}}
106
+ DENSITY = {"Porites": {"OE": 1.0, "OG": 1.0, "deep": 0.27, "frayed": 1.0},
107
+ "Pocillopora": {"OE": 1.0, "OG": 1.0, "deep": 1.0, "frayed": 1.0}}
108
+ SYM = {"Porites": {"OE": 0.03, "OG": 0.45, "deep": 0.12, "frayed": 0.03}, # symbiont share of RNA (design)
109
+ "Pocillopora": {"OE": 0.03, "OG": 0.40, "deep": 0.15, "frayed": 0.03}}
110
+ D_RT = 2.42 / 1000.0 # pg per um2 of oral-layer tissue, 10 um, 15 min RT, Microprep, R72_C2
111
+ SECTION_CV = 0.12
112
+
113
+ # ---------------- staining / washes ----------------
114
+ WASHES = ["ethanol_only", "prewash_100rinse", "standard", "brief_water", "dropwise_water", "water_dips_60s",
115
+ "trough_dunks", "graded_aqueous"] # ordered by water exposure
116
+ RET = { # fraction of the tissue that stays on the membrane: std (POR_3, POR_4, R72_C2), R3H1, R72H1, POC
117
+ "ethanol_only": {"std": 0.95, "R3H1": 0.95, "R72H1": 0.93, "POC": 0.97},
118
+ "prewash_100rinse": {"std": 0.875, "R3H1": 0.85, "R72H1": 0.78, "POC": 0.95},
119
+ "standard": {"std": 0.85, "R3H1": 0.75, "R72H1": 0.62, "POC": 0.95},
120
+ "brief_water": {"std": 0.85, "R3H1": 0.75, "R72H1": 0.62, "POC": 0.95},
121
+ "dropwise_water": {"std": 0.80, "R3H1": 0.68, "R72H1": 0.50, "POC": 0.93},
122
+ "water_dips_60s": {"std": 0.55, "R3H1": 0.45, "R72H1": 0.15, "POC": 0.85},
123
+ "trough_dunks": {"std": 0.40, "R3H1": 0.40, "R72H1": 0.02, "POC": 0.75},
124
+ "graded_aqueous": {"std": 0.20, "R3H1": 0.15, "R72H1": 0.02, "POC": 0.50},
125
+ }
126
+ OUTER = {"ethanol_only": ("intact", 0.95), "prewash_100rinse": ("less_intact", 0.60),
127
+ "standard": ("frayed_in_places", 0.75), "brief_water": ("frayed_in_places", 0.75),
128
+ "dropwise_water": ("frayed_in_places", 0.72), "water_dips_60s": ("largely_missing", 0.40),
129
+ "trough_dunks": ("largely_missing", 0.15), "graded_aqueous": ("gone", 0.05)}
130
+ OCT = {"ethanol_only": "sheets_folds", "prewash_100rinse": "thin_film_gaps", "standard": "purple_gaps",
131
+ "brief_water": "little_in_gaps", "dropwise_water": "little_in_gaps", "water_dips_60s": "mostly_removed",
132
+ "trough_dunks": "mostly_removed", "graded_aqueous": "mostly_removed"}
133
+ OCT_ORDER = ["sheets_folds", "purple_gaps", "thin_film_gaps", "little_in_gaps", "mostly_removed"]
134
+ CUT = {"ethanol_only": "hampered", "prewash_100rinse": "easy", "standard": "ok", "brief_water": "ok",
135
+ "dropwise_water": "ok", "water_dips_60s": "easy", "trough_dunks": "easy", "graded_aqueous": "easy"}
136
+ TRACE = {"ethanol_only": 0.22, "prewash_100rinse": 0.30, "standard": 0.20, "brief_water": 0.33,
137
+ "dropwise_water": 0.33, "water_dips_60s": 0.15, "trough_dunks": 0.05, "graded_aqueous": 0.0}
138
+ TRACE_POC = 0.85
139
+ DV_PENALTY = {"ethanol_only": 0.0, "prewash_100rinse": 0.0, "standard": 0.5, "brief_water": 0.5,
140
+ "dropwise_water": 1.0, "water_dips_60s": 2.0, "trough_dunks": 3.0, "graded_aqueous": 5.0}
141
+ STAINS = {"cresyl_1min": 1.0, "cresyl_30s": 1.0, "cresyl_dilute": 0.95, "none": 0.75, "aqueous_HE": 1.1,
142
+ "ethanolic_other": 0.9, "aqueous_other": 1.0} # layer-contrast factor
143
+ STAIN_ESCALATE = {"aqueous_HE": "graded_aqueous", "aqueous_other": "water_dips_60s"} # aqueous stains add water
144
+ CRYO_BONUS = {"Porites": 0.02, "Pocillopora": -0.01} # ethanol at the cryostat: marginally better / worse
145
+
146
+ # ---------------- LCM ----------------
147
+ FRAC = {"oral_epidermis": {"ethanol_only": 0.25, "prewash_100rinse": 0.19, "standard": 0.23, "brief_water": 0.23,
148
+ "dropwise_water": 0.22, "water_dips_60s": 0.20, "trough_dunks": 0.18,
149
+ "graded_aqueous": 0.15},
150
+ "oral_gastrodermis": {"ethanol_only": 0.52, "prewash_100rinse": 0.60, "standard": 0.55, "brief_water": 0.55,
151
+ "dropwise_water": 0.55, "water_dips_60s": 0.50, "trough_dunks": 0.45,
152
+ "graded_aqueous": 0.40}}
153
+ FRAC_POC = {"oral_epidermis": 0.70, "oral_gastrodermis": 0.75, "bulk": 0.65}
154
+ BULK_K, BULK_FMIN, BULK_FMAX = 0.31, 0.17, 0.70
155
+ FRAC_CV = 0.18
156
+ PIECE_ROI = {"oral_epidermis": 60000.0, "oral_gastrodermis": 45000.0, "bulk": 1000000.0}
157
+ PIECE_CV = 0.45
158
+ P_FAIL = {"sheets_folds": 0.08}
159
+ P_FAIL_DEFAULT = 0.04
160
+ TARGET_POOL = {"oral_epidermis": "OE", "oral_gastrodermis": "OG"}
161
+
162
+ # ---------------- extraction ----------------
163
+ DIGS = ["15minRT", "30minRT", "15min56C", "1h52C", "1h56C", "3h56C", "overnight56C"]
164
+ DIG_YIELD_SEC = {"15minRT": 1.0, "30minRT": 1.05, "15min56C": 1.216, "1h52C": 1.0, "1h56C": 0.847, "3h56C": 0.82,
165
+ "overnight56C": 0.80}
166
+ DIG_DV_SEC = {"15minRT": 0.0, "30minRT": -0.5, "15min56C": -1.9, "1h52C": -7.0, "1h56C": -12.9, "3h56C": -17.0,
167
+ "overnight56C": -22.0}
168
+ DIG_YIELD_FRESH = {"15minRT": 1.0, "30minRT": 1.08, "15min56C": 1.256, "1h52C": 1.20, "1h56C": 1.182,
169
+ "3h56C": 1.12, "overnight56C": 1.05}
170
+ DIG_DV_FRESH = {"15minRT": 0.0, "30minRT": -0.3, "15min56C": -0.6, "1h52C": -12.0, "1h56C": -26.6, "3h56C": -33.0,
171
+ "overnight56C": -40.0}
172
+ CURL_LYSIS = {"15minRT": 0.75, "30minRT": 0.82, "15min56C": 0.90, "1h52C": 0.95, "1h56C": 1.0, "3h56C": 1.0,
173
+ "overnight56C": 1.0}
174
+ CURL_OCT = {True: 0.95, False: 0.85} # untrimmed block faces carry more OCT into the lysate
175
+ KITS = {"microprep": {"yield": 1.0, "dv": 0.0, "min_ul": 6, "max_ul": 50},
176
+ "miniprep": {"yield": 0.70, "dv": -1.0, "min_ul": 30, "max_ul": 100},
177
+ "picopure": {"yield": 0.85, "dv": -3.0, "min_ul": 10, "max_ul": 30},
178
+ "rneasy_micro": {"yield": 0.95, "dv": 0.0, "min_ul": 10, "max_ul": 30}}
179
+ BUFFERS = {"PK": (1.0, 0.0), "Shield": (1.0, 0.0), "RNA_lysis": (0.95, 0.5)}
180
+ EXTRACT_CV = 0.12
181
+ DV_BASE = {"section": 70.2, "curl": 72.0, "fresh": 81.6, "synthetic": 96.0}
182
+ SPIKE_REC = (0.82, 40.0) # recovery = 0.82 * m / (m + 40 pg), m = RNA on the column
183
+ FRESH_FRAGMENTS = 10
184
+ FRESH_BASE = {"microprep": (56600.0, 150.0), "miniprep": (527000.0, 300.0),
185
+ "picopure": (47000.0, 150.0), "rneasy_micro": (52000.0, 150.0)} # pg per reference Shield uL
186
+ FRESH_KIT_DV = {"microprep": 0.0, "miniprep": -1.9, "picopure": -3.0, "rneasy_micro": 0.0}
187
+ FRESH_CV = 0.12
188
+
189
+ # ---------------- instruments ----------------
190
+ TS_LOD, TS_QLO, TS_QHI = 100.0, 500.0, 10000.0
191
+ TS_BASE = (2.0, 9.0)
192
+ TS_BASE_MEAN = 5.5
193
+ BIO_QUAL, BIO_QUANT = 50.0, 200.0
194
+ QUBIT_MIN_NG, QUBIT_MAX_NG = 5.0, 100.0
195
+ CT_REF = {"host": 30.2, "symbiont": 29.4, "spike": 23.5, # Ct for 100 pg of that template in the 20 uL RT
196
+ "host_3prime": 30.7, "host_5prime": 30.7} # oligo-dT RT, amplicons ~0.9 kb apart (3':5' assay)
197
+ DT_TARGETS = ("host_3prime", "host_5prime")
198
+
199
+
200
+ def ratio_3to5(dv200):
201
+ """3':5' template ratio after oligo-dT RT (design calibrated on the rat panel: 1.2-3.5 intact, 5-200 degraded):
202
+ 1.5 at DV200 90, 2.6 at 81.6, 5.6 at 70, 13 at 57."""
203
+ return 1.5 * math.exp(0.065 * (90.0 - dv200))
204
+ CT_PER_LOG2 = 1.0 / math.log2(1.95)
205
+ LIB_RNA_MAX_UL = 8.0
206
+ CDNA_PLAT, CDNA_GAIN, CDNA_ELUTE_UL = 75000.0, 2000.0, 26.0 # pg; pg cDNA per pg RNA at 20 cycles; uL
207
+ LIB_MAX, LIB_GAIN = 20.0, 5.0 # ng/uL plateau; ng/uL per ng cDNA at 8 cycles
208
+ LIBRARY_PREPS = 2
209
+ SAMPLES_PER_PREP = 3
210
+
211
+ # ---------------- recorded material ----------------
212
+ # recorded slides: matching key -> rendering, figures, the tubes the lab dissected (rows) and their extraction
213
+ REC_SLIDES = {
214
+ "rec_0506_s1": {"block": "POR_4", "thickness": 10, "cryostat": "100EtOH", "wash": "ethanol_only", "stained": True,
215
+ "rendering": "REC_0506_POR4",
216
+ "overview": ["figures/random__POR_LCM__20260506__Slide1_OV_5x.jpg"],
217
+ "lcm_figs": {"oral_epidermis": ["figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA1_TUBE17_OE_1.jpeg",
218
+ "figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA2_TUBE17_OE_2.jpeg"],
219
+ "oral_gastrodermis": ["figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA1_TUBE18_OG_1.jpeg",
220
+ "figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA2_TUBE18_OG_2.jpeg"]},
221
+ "rows": [("17", "oral_epidermis", "PK", 3, 234535, None, "1h52C", 33.0, 1),
222
+ ("21", "oral_epidermis", "PK", 5, 346744, None, "15minRT", 43.5, 1),
223
+ ("18", "oral_gastrodermis", "PK", 3, 183347, None, "1h52C", 33.9, 1),
224
+ ("22", "oral_gastrodermis", "PK", 6, 303230, None, "15minRT", 44.7, 1),
225
+ ("23", "bulk", "PK", 1, 830657, None, "1h52C", 33.1, 2),
226
+ ("24", "bulk", "PK", 1, 1002718, None, "15minRT", 38.3, 2)]},
227
+ "rec_0506_s2": {"block": "POR_4", "thickness": 10, "cryostat": "none", "wash": "ethanol_only", "stained": True,
228
+ "rendering": "REC_0506_POR4",
229
+ "overview": ["figures/random__POR_LCM__20260506__Slide2_OV_5x.jpg"],
230
+ "lcm_figs": {"oral_epidermis": ["figures/random__POR_LCM__20260506__SLIDE2_SECTION2_AREA1_TUBE14_OE_1_POST.jpeg"],
231
+ "oral_gastrodermis": ["figures/random__POR_LCM__20260506__SLIDE2_SECTION2_AREA1_TUBE15_OG_1.jpeg"]},
232
+ "rows": []},
233
+ "rec_0511_graded": {"block": "POR_4", "thickness": 10, "cryostat": "none", "wash": "graded_aqueous",
234
+ "stained": True, "rendering": "REC_0511_GRADED_POR4",
235
+ "overview": ["figures/random__POR_LCM__20260511__slide3fail.jpg"],
236
+ "lcm_figs": {"bulk": ["figures/random__POR_LCM__20260511__SLIDE3_AREA1_SECTION5_TUBE34_PK_BULK.jpg"]},
237
+ "rows": [("31", "bulk", "Shield", 1, 2401591, None, "15minRT", 46.3, 1),
238
+ ("32", "bulk", "Shield", 1, 2575547, None, "15min56C", 46.1, 2),
239
+ ("33", "bulk", "RNA_lysis", 1, 1861138, None, "15minRT", 48.4, 1),
240
+ ("34", "bulk", "PK", 1, 2534590, None, "15min56C", 65.9, 3)]},
241
+ "rec_0511_c2s1": {"block": "POR_R72_C2", "thickness": 10, "cryostat": "none", "wash": "ethanol_only",
242
+ "stained": True, "rendering": "REC_0511_R72C2_ETOH", "cut": "easy",
243
+ "overview": ["figures/random__POR_LCM__20260513__POR_R72_C2_Slide1.jpg"],
244
+ "lcm_figs": {"oral_epidermis": ["figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA1_TUBE60_OE_1.jpeg",
245
+ "figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA4_TUBE60_OE_4.jpeg"],
246
+ "oral_gastrodermis": ["figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA1_TUBE61_OG_1.jpeg",
247
+ "figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA4_TUBE61_OG_4.jpeg"]},
248
+ "rows": [("60", "oral_epidermis", "PK", 5, 343268, None, "1h56C", 35.4, 1),
249
+ ("61", "oral_gastrodermis", "PK", 5, 239654, None, "15min56C", 26.5, 2)]},
250
+ "rec_0513_c2s2": {"block": "POR_R72_C2", "thickness": 10, "cryostat": "none", "wash": "brief_water",
251
+ "stained": False, "rendering": "REC_0513_R72C2_NOSTAIN",
252
+ "overview": ["figures/random__POR_LCM__20260513__POR_R72_C2_Slide2_Nostain_5x_OV.jpg"],
253
+ "lcm_figs": {"oral_epidermis": ["figures/random__POR_LCM__20260513__Slide2_Section2_Area3_Tube51_OE_3.jpeg",
254
+ "figures/random__POR_LCM__20260513__Slide2_Section2_Area5_Tube51_OE_5.jpeg"],
255
+ "oral_gastrodermis": ["figures/random__POR_LCM__20260513__Slide2_Section2_Area3_Tube52_OG_3.jpeg",
256
+ "figures/random__POR_LCM__20260513__Slide2_Section2_Area5_Tube52_OG_5.jpeg"],
257
+ "bulk": ["figures/random__POR_LCM__20260513__Slide2_Section2_Tube53_BULK.jpeg"]},
258
+ "rows": [("51", "oral_epidermis", "PK", 5, 110765, None, "overnight56C", 31.4, 1),
259
+ ("55", "oral_epidermis", "PK", 6, 276815, None, "1h56C", 24.4, 2),
260
+ ("52", "oral_gastrodermis", "PK", 5, 84931, None, "1h56C", 27.1, 1)]},
261
+ "rec_0522am_R3H1": {"block": "POR_R3_H1", "thickness": 12, "cryostat": "none", "wash": "brief_water",
262
+ "stained": True, "rendering": "REC_0522AM_H1", "overview": [], "lcm_figs": {}, "rows": []},
263
+ "rec_0522am_R72H1": {"block": "POR_R72_H1", "thickness": 12, "cryostat": "none", "wash": "brief_water",
264
+ "stained": True, "rendering": "REC_0522AM_H1", "overview": [], "lcm_figs": {}, "rows": []},
265
+ "rec_0522pm_R3H1": {"block": "POR_R3_H1", "thickness": 12, "cryostat": "none", "wash": "trough_dunks",
266
+ "stained": True, "rendering": "REC_0522PM_R3H1", "overview": [], "lcm_figs": {}, "rows": []},
267
+ "rec_0522pm_R72H1": {"block": "POR_R72_H1", "thickness": 12, "cryostat": "none", "wash": "trough_dunks",
268
+ "stained": True, "rendering": "REC_0522PM_R72H1", "overview": [], "lcm_figs": {},
269
+ "rows": []},
270
+ "rec_0527_poc70": {"block": "POC_R3_C2", "thickness": 10, "cryostat": "70EtOH", "wash": "standard",
271
+ "stained": True, "rendering": "REC_0527_POC", "overview": [], "lcm_figs": {}, "rows": []},
272
+ "rec_0527_pocnone": {"block": "POC_R3_C2", "thickness": 10, "cryostat": "none", "wash": "standard",
273
+ "stained": True, "rendering": "REC_0527_POC", "overview": [], "lcm_figs": {}, "rows": []},
274
+ "rec_0529_prewash": {"block": "POR_R72_C2", "thickness": 10, "cryostat": "100EtOH", "wash": "prewash_100rinse",
275
+ "stained": True, "rendering": "REC_0529_PREWASH", "overview": [], "lcm_figs": {},
276
+ "rows": [("221", "oral_epidermis", "PK", 2, 177470, 29699, None, None, None),
277
+ ("222", "oral_gastrodermis", "PK", 2, 85555, 53941, None, None, None),
278
+ ("223", "bulk", "PK", 1, 1325972, 828061, None, None, None),
279
+ ("224", "bulk", "PK", 1, 1063735, 581598, None, None, None)]},
280
+ "rec_0529_noprewash": {"block": "POR_R72_C2", "thickness": 10, "cryostat": "100EtOH", "wash": "ethanol_only",
281
+ "stained": True, "rendering": "REC_0529_NOPREWASH", "overview": [], "lcm_figs": {},
282
+ "rows": [("215", "oral_epidermis", "PK", 6, 405830, 113703, "15min56C", 42.7, 2),
283
+ ("217", "oral_epidermis", "PK", 3, 213808, 45312, None, None, None),
284
+ ("216", "oral_gastrodermis", "PK", 7, 334040, 165866, "15min56C", 60.3, 2),
285
+ ("218", "oral_gastrodermis", "PK", 3, 160971, 86392, None, None, None),
286
+ ("219", "bulk", "PK", 2, 442544, 293360, "15min56C", 35.0, 1),
287
+ ("220", "bulk", "PK", 3, 425766, 311347, None, None, None)]},
288
+ }
289
+ WHOLE_SECTION_ANCHORS = {"15minRT": (157.0, 70.2, "2A"), "15min56C": (191.0, 68.3, "2B"),
290
+ "1h56C": (133.0, 57.3, "2C")} # one prewashed R72_C2 section, Microprep, 15 uL
291
+ FRESH_ANCHORS = [(150, "15minRT", "microprep", 15, 3770.0, 81.6, "1A"),
292
+ (150, "15min56C", "microprep", 15, 4740.0, 81.0, "1B"),
293
+ (150, "1h56C", "microprep", 15, 4460.0, 55.0, "1C"),
294
+ (300, "15minRT", "miniprep", 100, 5270.0, 79.7, "1D")]
295
+ # library anchors by recorded tube: cDNA ng/uL, cDNA peak bp, library ng/uL, library peak bp, figures
296
+ LIB_ANCHORS = {"13": (2.26, 720, 14.4, 296, ["figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_13.png",
297
+ "figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_13.png"]),
298
+ "34": (3.09, 1109, 22.4, 267, ["figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_34.png",
299
+ "figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_34.png"]),
300
+ "61": (3.05, 738, 22.8, 284, ["figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_61.png",
301
+ "figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_61.png"])}
302
+ LIB_ALL_FIGS = ["figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_D5000.png",
303
+ "figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_all.png"]
304
+ GELS = {"figures/tapestation__2026-05-08-AM.png": ["17", "18", "21"],
305
+ "figures/tapestation__2026-05-08-PM.png": ["22", "23", "24"],
306
+ "figures/tapestation__2026-05-13.png": ["1", "2", "9", "13", "31", "32", "33", "34"],
307
+ "figures/tapestation__2026-05-14.png": ["51", "52", "55", "60", "61"]}
308
+ # first run (4/27-4/28): POR_3 slides 1 and 2, standard protocol; tubes 1, 2, 9, 13 extracted, 8 uL, 2 uL on TS
309
+ INITIAL_TUBES = [("1", "oral_epidermis", 5, 160516, "15minRT", 44.6, 1),
310
+ ("2", "oral_gastrodermis", 5, 86158, "1h56C", 54.9, 1),
311
+ ("9", "bulk", 1, 3215616, "15minRT", 48.1, 2),
312
+ ("13", "bulk", 2, 6681317, "1h56C", 108.0, 3)]
313
+ INITIAL_FIGS = {"POR_3-S1": ["figures/random__POR_LCM__20260428__Slide1_OV_5X.jpg",
314
+ "figures/random__POR_LCM__20260428__SLIDE1_SECTION1_AREA1_TUBE11_OE_1.jpeg",
315
+ "figures/random__POR_LCM__20260428__SLIDE1_SECTION1_AREA1_TUBE12_OG_1.jpeg",
316
+ "figures/random__POR_LCM__20260428__SLIDE1_SECTION5_AREA2.jpeg",
317
+ "figures/random__POR_LCM__20260428__SLIDE1_SECTION5_AREA2_TUBE2_OG_2.jpeg"],
318
+ "POR_3-S2": ["figures/random__POR_LCM__20260428__Slide2_OV_5X.jpg"]}
319
+
320
+
321
+ # ---------------- helpers ----------------
322
+ def rng_for(*parts) -> random.Random:
323
+ return random.Random(int(hashlib.sha256("|".join(map(str, parts)).encode()).hexdigest()[:16], 16))
324
+
325
+
326
+ def ln(r: random.Random, cv: float) -> float:
327
+ """Mean-one lognormal factor with coefficient of variation ~cv."""
328
+ s = math.sqrt(math.log(1 + cv * cv))
329
+ return math.exp(r.gauss(0, s) - s * s / 2)
330
+
331
+
332
+ def need(d: dict, keys, where: str):
333
+ missing = [k for k in keys if k not in d]
334
+ assert not missing, f"{where}: missing required keys {missing} (see the docstring)"
335
+ extra = [k for k in d if k not in keys]
336
+ return extra
337
+
338
+
339
+ def strict(d: dict, keys, opt, where: str):
340
+ extra = [k for k in need(d, keys, where) if k not in opt]
341
+ assert not extra, f"{where}: unknown keys {extra}; allowed {list(keys) + list(opt)}"
342
+
343
+
344
+ def one_of(v, allowed, what):
345
+ assert v in allowed, f"{what} = {v!r} is not supported; allowed: {list(allowed)}"
346
+ return v
347
+
348
+
349
+ def state_path(run):
350
+ return STATE / f"{run}.json"
351
+
352
+
353
+ def load(run):
354
+ p = state_path(run)
355
+ if p.is_file():
356
+ return json.loads(p.read_text())
357
+ st = init_state(run)
358
+ save(run, st)
359
+ return st
360
+
361
+
362
+ def save(run, st):
363
+ STATE.mkdir(exist_ok=True)
364
+ state_path(run).write_text(json.dumps(st))
365
+
366
+
367
+ def out(obj):
368
+ print(json.dumps(obj, indent=1))
369
+
370
+
371
+ def genus(block):
372
+ return BLOCKS[block]["genus"]
373
+
374
+
375
+ def new_section_pools(run, block, sid, k, thickness):
376
+ g = genus(block)
377
+ r = rng_for(run, "section", sid, k)
378
+ f = BLOCKS[block]["area"] * ln(r, SECTION_CV) * (0.9 if thickness <= 8 and g == "Porites" else 1.0)
379
+ return {"OE": POOLS[g]["OE"] * f, "OG": POOLS[g]["OG"] * f, "deep": POOLS[g]["deep"] * f, "frayed": 0.0}
380
+
381
+
382
+ def init_state(run):
383
+ st = {"slides": {}, "tubes": {}, "eluates": {}, "used_rec": [], "used_rows": [], "used_ws": [],
384
+ "used_fresh": [], "fresh_used": 0, "library_preps": 0, "libraries": {}, "shown_figs": [], "used_lib": [],
385
+ "slides_cut": {b: 0 for b in BLOCKS}}
386
+ st["slides_cut"]["POR_3"] = 2
387
+ for k, (sid, ret, label) in enumerate([("POR_3-S1", 0.85, "slide 1"), ("POR_3-S2", 0.80, "slide 2")]):
388
+ secs = []
389
+ for j in range(5):
390
+ p = new_section_pools(run, "POR_3", sid, j, 10)
391
+ p = {q: v * ret for q, v in p.items()}
392
+ p["frayed"] = p["OE"] * (1 - OUTER["standard"][1])
393
+ p["OE"] *= OUTER["standard"][1]
394
+ secs.append(p)
395
+ st["slides"][sid] = {"block": "POR_3", "label": label, "thickness": 10, "cryostat": "100EtOH",
396
+ "n_sections": 5, "trim": False, "sections": secs, "scraped": [],
397
+ "stain": {"wash": "standard", "stain": "cresyl_1min", "warmup": "direct",
398
+ "inhibitor": False, "retention": ret, "oct": "purple_gaps",
399
+ "outer": "frayed_in_places", "trace": [0.20] * 5, "cut": "ok",
400
+ "condensation": False, "dv_pen": 0.5, "rendering": "REC_0428_POR3_" +
401
+ ("S1" if k == 0 else "S2")},
402
+ "rec": None, "initial": True}
403
+ s1 = st["slides"]["POR_3-S1"]
404
+ for tid, target, n, roi, dig, conc, rating in INITIAL_TUBES:
405
+ frac = tissue_fraction(run, "POR_3", "standard", target, roi, tid)
406
+ comp = take(s1, target, roi * frac, None, clean=False, trace=0.20)
407
+ st["tubes"][tid] = {"kind": "lcm", "slide": "POR_3-S1", "block": "POR_3", "target": target, "buffer": "PK",
408
+ "roi": roi, "tissue": roi * frac, "n_dis": n, "n_failed": 0, "comp": comp,
409
+ "thk": 1.0, "wash": "standard", "dv_pen": 0.5, "extracted": True, "anchor": tid,
410
+ "spike": []}
411
+ true = max(0.3 * conc, conc - TS_BASE_MEAN) * 8.0
412
+ st["eluates"][tid] = {"tubes": [tid], "kind": "section", "elution": 8.0, "vol": 6.0, "conc": true / 8.0,
413
+ "dv200": dv_section("POR_3", 0.5, False, dig, "microprep", "PK") +
414
+ rng_for(run, "dv", tid).gauss(0, 1.2),
415
+ "sym": sym_share(comp, "POR_3"), "spike_pg": 0.0, "digestion": dig, "kit": "microprep",
416
+ "anchor": {"row": tid, "conc": conc, "rating": rating},
417
+ "ts": {"conc": conc, "rating": rating, "integrity": None}, "block": "POR_3"}
418
+ return st
419
+
420
+
421
+ def get_slide(st, key):
422
+ if key in st["slides"]:
423
+ return key, st["slides"][key]
424
+ hits = [k for k, s in st["slides"].items() if s["label"] == key]
425
+ assert len(hits) == 1, f"unknown slide {key!r}; slides: {[(k, s['label']) for k, s in st['slides'].items()]}"
426
+ return hits[0], st["slides"][hits[0]]
427
+
428
+
429
+ def get_eluate(st, key):
430
+ assert key in st["eluates"], f"unknown eluate {key!r}; eluates: {list(st['eluates'])}"
431
+ return st["eluates"][key]
432
+
433
+
434
+ def get_tube(st, key):
435
+ assert key in st["tubes"], f"unknown tube {key!r}; tubes: {list(st['tubes'])}"
436
+ return st["tubes"][key]
437
+
438
+
439
+ def new_id_ok(st, key, kind):
440
+ assert key not in st["tubes"] and key not in st["eluates"], \
441
+ f"{kind} id {key!r} is already used in this session; append a suffix (e.g. {key}.b)"
442
+
443
+
444
+ # ---------------- model pieces ----------------
445
+ def tissue_fraction(run, block, wash, target, roi, tid):
446
+ g = genus(block)
447
+ r = rng_for(run, "frac", tid)
448
+ if g == "Pocillopora":
449
+ base = FRAC_POC[target]
450
+ elif target == "bulk":
451
+ base = min(BULK_FMAX, max(BULK_FMIN, BULK_K / math.sqrt(roi / 1e6)))
452
+ else:
453
+ base = FRAC[target][wash]
454
+ return min(0.9, base * ln(r, FRAC_CV))
455
+
456
+
457
+ def available(slide, target, secs, clean, trace):
458
+ if target == "bulk":
459
+ return sum(sum(slide["sections"][i].values()) for i in secs)
460
+ pool = TARGET_POOL[target]
461
+ return sum(slide["sections"][i][pool] * (trace[i] if clean else 1.0) for i in secs)
462
+
463
+
464
+ def take(slide, target, tissue, secs, clean, trace):
465
+ """Remove `tissue` um2 from the slide's pools; returns the composition {pool: um2}."""
466
+ secs = list(range(len(slide["sections"]))) if secs is None else secs
467
+ comp = {"OE": 0.0, "OG": 0.0, "deep": 0.0, "frayed": 0.0}
468
+ left = tissue
469
+ for i in sorted(secs, key=lambda i: -sum(slide["sections"][i].values())):
470
+ if left <= 0:
471
+ break
472
+ s = slide["sections"][i]
473
+ if target == "bulk":
474
+ tot = sum(s.values())
475
+ if tot <= 0:
476
+ continue
477
+ f = min(1.0, left / tot)
478
+ for q in list(s):
479
+ comp[q] += s[q] * f
480
+ s[q] -= s[q] * f
481
+ left -= tot * f
482
+ else:
483
+ pool = TARGET_POOL[target]
484
+ cap = s[pool] * (trace if isinstance(trace, float) else trace[i]) if clean else s[pool]
485
+ got = min(left, cap)
486
+ s[pool] -= got
487
+ comp[pool] += got
488
+ left -= got
489
+ return comp
490
+
491
+
492
+ def sym_share(comp, block):
493
+ g = genus(block)
494
+ w = {q: comp[q] * DENSITY[g][q] for q in comp}
495
+ tot = sum(w.values())
496
+ return sum(w[q] * SYM[g][q] for q in w) / tot if tot > 0 else 0.0
497
+
498
+
499
+ def rna_of(comp, block):
500
+ g = genus(block)
501
+ return sum(comp[q] * DENSITY[g][q] for q in comp) * D_RT * BLOCKS[block]["density"]
502
+
503
+
504
+ def dv_section(block, dv_pen, inhibitor, dig, kit, buffer):
505
+ return (DV_BASE["section"] + BLOCKS[block]["dv"] - dv_pen * (0.5 if inhibitor else 1.0) + DIG_DV_SEC[dig]
506
+ + KITS[kit]["dv"] + BUFFERS[buffer][1])
507
+
508
+
509
+ def rating_for(run, eid, reading, dv200):
510
+ r = rng_for(run, "rating", eid).random()
511
+ if reading >= 100:
512
+ return 3 if dv200 >= 50 else 2
513
+ if reading >= 70:
514
+ return 3 if r < 0.5 else 2
515
+ if reading >= 50:
516
+ return 1 if r < 0.3 else (2 if r < 0.75 else 3)
517
+ if reading >= 30:
518
+ return 1 if r < 0.55 else (2 if r < 0.95 else 3)
519
+ return 1 if r < 0.8 else 2
520
+
521
+
522
+ def rine(dv200, r):
523
+ return round(min(9.5, max(1.0, 1 + 0.112 * (dv200 - 30) + r.gauss(0, 0.15))), 1)
524
+
525
+
526
+ # ---------------- commands ----------------
527
+ def cmd_status(a, st, spec):
528
+ slides = {}
529
+ for k, s in st["slides"].items():
530
+ left = [{q: round(v) for q, v in sec.items()} for sec in s["sections"]]
531
+ slides[k] = {"label": s["label"], "block": s["block"], "thickness_um": s["thickness"],
532
+ "cryostat_step": s["cryostat"], "n_sections": s["n_sections"],
533
+ "stained": None if s["stain"] is None else {k2: s["stain"][k2] for k2 in
534
+ ("wash", "stain", "rendering")},
535
+ "_recorded_match": s["rec"], "_tissue_left_per_section_um2": left, "scraped": s["scraped"]}
536
+ tubes = {k: {"kind": t["kind"], "slide": t.get("slide"), "target": t.get("target"), "buffer": t["buffer"],
537
+ "roi_um2": t.get("roi"), "extracted": t["extracted"], "_anchor_row": t.get("anchor")}
538
+ for k, t in st["tubes"].items()}
539
+ els = {k: {"tubes": e["tubes"], "vol_ul_left": round(e["vol"], 1), "elution_ul": e["elution"],
540
+ "digestion": e["digestion"], "kit": e["kit"], "_anchor": e["anchor"]} for k, e in st["eluates"].items()}
541
+ out({"slides": slides, "tubes": tubes, "eluates": els, "slides_cut": st["slides_cut"],
542
+ "fresh_fragments_left": FRESH_FRAGMENTS - st["fresh_used"],
543
+ "library_preps_used": st["library_preps"], "charge": []})
544
+
545
+
546
+ def cmd_section(a, st, spec):
547
+ strict(spec, ["block", "slides"], [], "section")
548
+ block = one_of(spec["block"], BLOCKS, "block")
549
+ made = []
550
+ for sl in spec["slides"]:
551
+ strict(sl, ["label", "thickness_um", "cryostat_step", "n_sections", "trim_oct"], [], "section.slides[]")
552
+ t = float(sl["thickness_um"])
553
+ assert 6 <= t <= 25, f"thickness {t} um: the cryostat set-up for these blocks covers 6-25 um"
554
+ cryo = one_of(sl["cryostat_step"], ["100EtOH", "70EtOH", "none"], "cryostat_step")
555
+ n = int(sl["n_sections"])
556
+ assert 1 <= n <= 6, "a 4 um frame PEN slide holds 1-6 Porites sections"
557
+ assert st["slides_cut"][block] < SLIDES_PER_BLOCK, \
558
+ f"no slide left for {block}: {st['slides_cut'][block]} of {SLIDES_PER_BLOCK} already cut"
559
+ st["slides_cut"][block] += 1
560
+ sid = f"{block}-S{st['slides_cut'][block]}"
561
+ r = rng_for(a.run, "sectioning", sid)
562
+ notes = []
563
+ g = genus(block)
564
+ if g == "Porites" and t <= 8:
565
+ notes.append(f"sections crumble at the porous lattice; {1 + int(r.random() < 0.5)} of {n} incomplete")
566
+ elif g == "Porites" and t >= 18:
567
+ notes.append(f"sections curl strongly off the knife; {max(1, round(n * 0.5))} of {n} folded at one edge")
568
+ elif g == "Porites" and t >= 14:
569
+ notes.append(f"sections roll off the knife more than at 10 um; {1 + int(r.random() < 0.5)} of {n} "
570
+ f"needed re-flattening with a brush")
571
+ else:
572
+ notes.append("sections lay flat")
573
+ if sl["trim_oct"]:
574
+ notes.append("block trimmed to about 1 mm of OCT around the tissue before cutting")
575
+ secs = [new_section_pools(a.run, block, sid, j, t) for j in range(n)]
576
+ st["slides"][sid] = {"block": block, "label": sl["label"], "thickness": t, "cryostat": cryo, "n_sections": n,
577
+ "trim": bool(sl["trim_oct"]), "sections": secs, "scraped": [], "stain": None,
578
+ "rec": None, "initial": False}
579
+ made.append({"slide": sid, "label": sl["label"], "thickness_um": t, "cryostat_step": cryo,
580
+ "n_sections": n, "sectioning": notes})
581
+ out({"slides": made, "charge": ["section_slide"], "consumed": [{"item": f"slide:{block}", "n": len(made)}]})
582
+
583
+
584
+ def match_rec(st, slide, wash, stain):
585
+ for key, rec in REC_SLIDES.items():
586
+ if key in st["used_rec"]:
587
+ continue
588
+ if (rec["block"], rec["thickness"], rec["cryostat"], rec["wash"], rec["stained"]) == \
589
+ (slide["block"], slide["thickness"], slide["cryostat"], wash, stain != "none"):
590
+ return key
591
+ return None
592
+
593
+
594
+ def sec_view(stn, secs):
595
+ """2026-11-06: the stain record a tube from these sections sees (per-section washes: the most water-exposed)."""
596
+ if "wash_sec" not in stn:
597
+ return stn
598
+ j = max(secs, key=lambda i: WASHES.index(stn["wash_sec"][i]))
599
+ v = dict(stn)
600
+ for k in ("wash", "oct", "outer", "cut", "dv_pen"):
601
+ v[k] = stn[k + "_sec"][j]
602
+ return v
603
+
604
+
605
+ UNTOUCHED = "untouched" # 2026-11-06 (c): a section the series leaves as it is (slide already through a series)
606
+
607
+
608
+ def prev_sec(prev, k, j):
609
+ """2026-11-06 (c): section j's value of an earlier stain record (per-section or slide-level)."""
610
+ return prev[k + "_sec"][j] if k + "_sec" in prev else prev[k]
611
+
612
+
613
+ def stain_per_section(a, st, spec, sid, s, washes, stains):
614
+ """2026-11-06: the series put on each section separately (drops, slide held flat): one WASH class and one STAIN
615
+ per section; 2026-11-06 (c): "untouched" sections (slide already through a series, stain "none") keep their state."""
616
+ warm = one_of(spec["warmup"], ["direct", "slow", "open"], "warmup")
617
+ first = s["stain"] is None
618
+ prev = s["stain"]
619
+ keep = [w == UNTOUCHED for w in washes]
620
+ assert not (first and any(keep)), f"{sid}: 'untouched' needs an earlier series on this slide; it is unstained"
621
+ assert not all(keep), f"{sid}: every section untouched means no series; nothing to run"
622
+ for j, (k, x) in enumerate(zip(keep, stains)):
623
+ assert not k or x == "none", f"{sid}: section {j + 1} is untouched; give it stain none"
624
+ effs = [w if k else (STAIN_ESCALATE[x] if x in STAIN_ESCALATE and
625
+ WASHES.index(STAIN_ESCALATE[x]) > WASHES.index(w) else w)
626
+ for w, x, k in zip(washes, stains, keep)]
627
+ block, g, grp = s["block"], genus(s["block"]), BLOCKS[s["block"]]["group"]
628
+ r = rng_for(a.run, "stain", sid, len(s.get("stain_history", [])))
629
+ t = s["thickness"]
630
+ order = ["intact", "less_intact", "frayed_in_places", "largely_missing", "gone"]
631
+ per_ret, wash_sec, oct_sec, outer_sec, cut_sec, dv_sec, rend_sec = [], [], [], [], [], [], []
632
+ for j, (sec, eff, x) in enumerate(zip(s["sections"], effs, stains)):
633
+ if keep[j]:
634
+ per_ret.append(None)
635
+ wash_sec.append(prev_sec(prev, "wash", j))
636
+ oct_sec.append(prev_sec(prev, "oct", j))
637
+ outer_sec.append(prev_sec(prev, "outer", j))
638
+ cut_sec.append(prev_sec(prev, "cut", j))
639
+ dv_sec.append(prev_sec(prev, "dv_pen", j))
640
+ rend_sec.append(prev_sec(prev, "rendering", j))
641
+ continue
642
+ ret = RET[eff][grp] if (first or eff != "ethanol_only") else 0.97
643
+ if s["cryostat"] != "none" and first:
644
+ ret = min(0.99, ret + CRYO_BONUS[g])
645
+ if g == "Porites":
646
+ ret *= 0.92 if t >= 18 else (0.96 if t >= 14 else (0.93 if t <= 8 else 1.0))
647
+ if warm == "open":
648
+ ret *= 0.95
649
+ rr = min(0.99, max(0.0, ret + r.gauss(0, 0.04 if ret > 0.1 else 0.01)))
650
+ per_ret.append(rr)
651
+ for q in sec:
652
+ sec[q] *= rr
653
+ outer_tok, outer_f = OUTER[eff]
654
+ moved = sec["OE"] * (1 - outer_f)
655
+ sec["OE"] -= moved
656
+ sec["frayed"] += moved
657
+ oct_tok = OCT[eff] if g == "Porites" else "little_in_gaps"
658
+ dv = DV_PENALTY[eff] + (5.0 if warm == "open" else 0.0)
659
+ rend = ("POC_" if g == "Pocillopora" else "") + eff.upper() + ("_NOSTAIN" if x == "none" else "")
660
+ if not first:
661
+ p_oct = prev_sec(prev, "oct", j)
662
+ p_out = prev_sec(prev, "outer", j)
663
+ oct_tok = OCT_ORDER[max(OCT_ORDER.index(p_oct), OCT_ORDER.index(oct_tok))]
664
+ outer_tok = order[max(order.index(p_out), order.index(outer_tok))]
665
+ dv += prev_sec(prev, "dv_pen", j)
666
+ rend = "RESTAINED_" + rend
667
+ wash_sec.append(eff)
668
+ oct_sec.append(oct_tok)
669
+ outer_sec.append(outer_tok)
670
+ cut_sec.append(CUT[eff] if g == "Porites" else "easy")
671
+ dv_sec.append(dv)
672
+ rend_sec.append(rend)
673
+ trace = []
674
+ for j, (eff, x) in enumerate(zip(effs, stains)):
675
+ if keep[j]:
676
+ trace.append(prev["trace"][j])
677
+ continue
678
+ if g == "Pocillopora":
679
+ tr0 = TRACE_POC
680
+ else:
681
+ tr0 = TRACE[eff] * STAINS[x] * math.sqrt(RET[eff][grp] / RET[eff]["std"]) * (0.85 if t >= 16 else 1.0)
682
+ trace.append(round(min(0.95, tr0 * ln(r, 0.25)), 3))
683
+ laser_sec = []
684
+ for oct_tok, cut in zip(oct_sec, cut_sec):
685
+ laser = "one pass at standard power"
686
+ if t >= 16:
687
+ laser = "higher laser power needed; a second pass at some spots"
688
+ if oct_tok == "sheets_folds" and cut == "hampered":
689
+ laser = "cuts stall at OCT folds; repeated passes, pieces stay attached at folds"
690
+ laser_sec.append(laser)
691
+ w = max(range(len(wash_sec)), key=lambda i: WASHES.index(wash_sec[i]))
692
+ stain = stains[0] if len(set(stains)) == 1 else stains
693
+ done = [v for v in per_ret if v is not None]
694
+ s.setdefault("stain_history", []).append({"wash": washes, "stain": stain})
695
+ s["stain"] = {"wash": wash_sec[w], "stain": stain, "warmup": warm, "inhibitor": bool(spec["rnase_inhibitor"]),
696
+ "retention": sum(done) / len(done), "oct": oct_sec[w], "outer": outer_sec[w], "trace": trace,
697
+ "cut": cut_sec[w], "condensation": warm == "open", "dv_pen": dv_sec[w], "rendering": rend_sec[w],
698
+ "wash_sec": wash_sec, "oct_sec": oct_sec, "outer_sec": outer_sec, "cut_sec": cut_sec,
699
+ "dv_pen_sec": dv_sec, "rendering_sec": rend_sec}
700
+ res = {"slide": sid, "label": s["label"], "water_applied": "separately on each section, as drops",
701
+ "wash_class_per_section": [UNTOUCHED if k else e for k, e in zip(keep, effs)], "stain": stain,
702
+ "warmup": warm,
703
+ "retention_pct_per_section": [UNTOUCHED if v is None else round(100 * v) for v in per_ret],
704
+ "residual_oct_per_section": oct_sec, "outer_layer_per_section": outer_sec,
705
+ "layer_boundary_traceable_pct_per_section": [round(100 * x) for x in trace],
706
+ "laser_cutting_per_section": cut_sec, "laser_per_section": laser_sec,
707
+ "ice_on_slide": "graded_aqueous" in [e for e, k in zip(effs, keep) if not k], "condensation": warm == "open",
708
+ "rendering_per_section": rend_sec, "charge": ["stain_and_lcm"]}
709
+ save(a.run, st)
710
+ out(res)
711
+
712
+
713
+ def cmd_stain(a, st, spec):
714
+ strict(spec, ["slide", "warmup", "wash", "stain", "rnase_inhibitor"], [], "stain")
715
+ sid, s = get_slide(st, spec["slide"])
716
+ assert not s["scraped"], f"{sid}: sections {s['scraped']} were scraped off"
717
+ warm = one_of(spec["warmup"], ["direct", "slow", "open"], "warmup")
718
+ if isinstance(spec["wash"], list) or isinstance(spec["stain"], list): # 2026-11-06 (c): per section
719
+ n = len(s["sections"])
720
+ washes = spec["wash"] if isinstance(spec["wash"], list) else [spec["wash"]] * n
721
+ stains = spec["stain"] if isinstance(spec["stain"], list) else [spec["stain"]] * n
722
+ assert len(washes) == n, f"{sid}: wash list needs {n} classes, one per section"
723
+ assert len(stains) == n, f"{sid}: stain list needs {n} entries, one per section"
724
+ washes = [w if w == UNTOUCHED else one_of(w, WASHES, "wash") for w in washes]
725
+ stains = [one_of(x, STAINS, "stain") for x in stains]
726
+ if len(set(washes)) > 1 or len(set(stains)) > 1:
727
+ return stain_per_section(a, st, spec, sid, s, washes, stains)
728
+ assert washes[0] != UNTOUCHED, f"{sid}: every section untouched means no series; nothing to run"
729
+ spec = dict(spec, wash=washes[0], stain=stains[0])
730
+ wash = one_of(spec["wash"], WASHES, "wash")
731
+ stain = one_of(spec["stain"], STAINS, "stain")
732
+ eff = wash
733
+ if stain in STAIN_ESCALATE and WASHES.index(STAIN_ESCALATE[stain]) > WASHES.index(wash):
734
+ eff = STAIN_ESCALATE[stain]
735
+ block, g, grp = s["block"], genus(s["block"]), BLOCKS[s["block"]]["group"]
736
+ r = rng_for(a.run, "stain", sid, len(s.get("stain_history", [])))
737
+ first = s["stain"] is None
738
+ ret = RET[eff][grp] if (first or eff != "ethanol_only") else 0.97
739
+ if s["cryostat"] != "none" and first:
740
+ ret = min(0.99, ret + CRYO_BONUS[g])
741
+ t = s["thickness"]
742
+ if g == "Porites":
743
+ ret *= 0.92 if t >= 18 else (0.96 if t >= 14 else (0.93 if t <= 8 else 1.0))
744
+ if warm == "open":
745
+ ret *= 0.95
746
+ rec = match_rec(st, s, eff, stain) if first else None
747
+ outer_tok, outer_f = OUTER[eff]
748
+ per_ret = []
749
+ for sec in s["sections"]:
750
+ rr = min(0.99, max(0.0, ret + r.gauss(0, 0.04 if ret > 0.1 else 0.01)))
751
+ per_ret.append(rr)
752
+ for q in sec:
753
+ sec[q] *= rr
754
+ moved = sec["OE"] * (1 - outer_f)
755
+ sec["OE"] -= moved
756
+ sec["frayed"] += moved
757
+ if g == "Pocillopora":
758
+ tr0 = TRACE_POC
759
+ else:
760
+ tr0 = TRACE[eff] * STAINS[stain] * math.sqrt(RET[eff][grp] / RET[eff]["std"]) * (0.85 if t >= 16 else 1.0)
761
+ trace = [round(min(0.95, tr0 * ln(r, 0.25)), 3) for _ in s["sections"]]
762
+ oct_tok = OCT[eff] if g == "Porites" else "little_in_gaps"
763
+ cut = CUT[eff] if g == "Porites" else "easy"
764
+ if rec and "cut" in REC_SLIDES[rec]:
765
+ cut = REC_SLIDES[rec]["cut"]
766
+ if not first:
767
+ prev = s["stain"]
768
+ oct_tok = OCT_ORDER[max(OCT_ORDER.index(prev["oct"]), OCT_ORDER.index(oct_tok))]
769
+ order = ["intact", "less_intact", "frayed_in_places", "largely_missing", "gone"]
770
+ outer_tok = order[max(order.index(prev["outer"]), order.index(outer_tok))]
771
+ laser = "one pass at standard power"
772
+ if t >= 16:
773
+ laser = "higher laser power needed; a second pass at some spots"
774
+ if oct_tok == "sheets_folds" and cut == "hampered":
775
+ laser = "cuts stall at OCT folds; repeated passes, pieces stay attached at folds"
776
+ rendering = REC_SLIDES[rec]["rendering"] if rec else (("POC_" if g == "Pocillopora" else "") + eff.upper())
777
+ if stain == "none" and not rec:
778
+ rendering += "_NOSTAIN"
779
+ dv_pen = DV_PENALTY[eff] + (5.0 if warm == "open" else 0.0)
780
+ if not first:
781
+ dv_pen += s["stain"]["dv_pen"]
782
+ rendering = "RESTAINED_" + rendering
783
+ s.setdefault("stain_history", []).append({"wash": wash, "stain": stain})
784
+ s["stain"] = {"wash": eff, "stain": stain, "warmup": warm, "inhibitor": bool(spec["rnase_inhibitor"]),
785
+ "retention": sum(per_ret) / len(per_ret), "oct": oct_tok, "outer": outer_tok, "trace": trace,
786
+ "cut": cut, "condensation": warm == "open", "dv_pen": dv_pen, "rendering": rendering}
787
+ if rec:
788
+ st["used_rec"].append(rec)
789
+ s["rec"] = rec
790
+ res = {"slide": sid, "label": s["label"], "wash_class": eff, "stain": stain, "warmup": warm,
791
+ "retention_pct_per_section": [round(100 * x) for x in per_ret],
792
+ "residual_oct": oct_tok, "outer_layer": outer_tok,
793
+ "layer_boundary_traceable_pct_per_section": [round(100 * x) for x in trace],
794
+ "laser_cutting": cut, "laser": laser,
795
+ "ice_on_slide": eff == "graded_aqueous", "condensation": warm == "open",
796
+ "rendering": rendering, "charge": ["stain_and_lcm"]}
797
+ if rec:
798
+ rr = REC_SLIDES[rec]
799
+ res["figures_overview"] = rr["overview"]
800
+ res["_recorded_tube_plan"] = [{"target": x[1], "buffer": x[2]} for x in rr["rows"]]
801
+ save(a.run, st)
802
+ out(res)
803
+
804
+
805
+ def cmd_lcm(a, st, spec):
806
+ strict(spec, ["slide", "measure_tissue", "tubes"], [], "lcm")
807
+ sid, s = get_slide(st, spec["slide"])
808
+ assert s["stain"] is not None, f"{sid} has not been through a stain/wash series; run `stain` first"
809
+ stn = s["stain"]
810
+ rec = REC_SLIDES.get(s["rec"]) if s["rec"] else None
811
+ res_t, figs = [], []
812
+ for tb in spec["tubes"]:
813
+ strict(tb, ["id", "target", "buffer", "clean_only", "amount"], ["sections"], "lcm.tubes[]")
814
+ tid = str(tb["id"])
815
+ new_id_ok(st, tid, "tube")
816
+ target = one_of(tb["target"], ["oral_epidermis", "oral_gastrodermis", "bulk"], "target")
817
+ buf = one_of(tb["buffer"], BUFFERS, "buffer")
818
+ secs = [int(x) - 1 for x in tb["sections"]] if "sections" in tb else list(range(len(s["sections"])))
819
+ for i in secs:
820
+ assert 0 <= i < len(s["sections"]) and i not in s["scraped"], f"{sid}: section {i + 1} not available"
821
+ stn = sec_view(s["stain"], secs) # 2026-11-06 per-section washes
822
+ clean = bool(tb["clean_only"]) and target != "bulk"
823
+ amt = tb["amount"]
824
+ assert isinstance(amt, dict) and len(amt) == 1, f"{tid}: amount must be one of the documented forms"
825
+ (mode, val), = amt.items()
826
+ r = rng_for(a.run, "lcm", tid)
827
+ avail = available(s, target, secs, clean, stn["trace"])
828
+ anchor, tissue, recorded_tissue = None, None, False
829
+ if mode == "lab_default":
830
+ assert val is True, "lab_default must be true"
831
+ row = None
832
+ if rec:
833
+ row = next((x for x in rec["rows"] if x[0] not in st["used_rows"] and x[1] == target
834
+ and x[2] == buf), None)
835
+ if row:
836
+ anchor = row[0]
837
+ n_dis, roi = row[3], float(row[4])
838
+ if row[5] is not None:
839
+ tissue, recorded_tissue = float(row[5]), True
840
+ else:
841
+ n_dis = 5 if target != "bulk" else 1
842
+ roi = sum(PIECE_ROI[target] * ln(r, PIECE_CV) for _ in range(n_dis))
843
+ elif mode == "n_dissections":
844
+ n_dis = int(val)
845
+ assert 1 <= n_dis <= 60, "n_dissections 1-60 per tube"
846
+ roi = sum(PIECE_ROI[target] * ln(r, PIECE_CV) for _ in range(n_dis))
847
+ elif mode == "roi_um2":
848
+ roi = float(val)
849
+ n_dis = max(1, round(roi / PIECE_ROI[target]))
850
+ elif mode == "tissue_um2":
851
+ tissue = float(val)
852
+ roi = None
853
+ elif mode == "all":
854
+ assert val is True, "all must be true"
855
+ tissue, roi = avail, None
856
+ else:
857
+ raise AssertionError(f"{tid}: unknown amount form {mode!r}")
858
+ frac = tissue_fraction(a.run, s["block"], stn["wash"], target, roi if roi else 1e6, tid)
859
+ if roi is None:
860
+ roi = tissue / frac
861
+ n_dis = max(1, round(roi / PIECE_ROI[target]))
862
+ if tissue is None:
863
+ tissue = roi * frac
864
+ limited = False
865
+ if anchor: # recorded dissection: recorded ROI and tissue stand; the pools give what they hold
866
+ pass
867
+ elif tissue > avail * 1.0001:
868
+ limited = True
869
+ scale = avail / tissue if tissue > 0 else 0.0
870
+ tissue, roi = avail, roi * scale
871
+ n_dis = max(1 if avail > 0 else 0, round(n_dis * scale))
872
+ comp = take(s, target, tissue, secs, clean, stn["trace"])
873
+ if anchor and sum(comp.values()) > 0: # composition of what was taken, scaled to the recorded tissue
874
+ k = tissue / sum(comp.values())
875
+ comp = {q: v * k for q, v in comp.items()}
876
+ p_fail = P_FAIL.get(stn["oct"], P_FAIL_DEFAULT)
877
+ n_failed = 0 if anchor else sum(r.random() < p_fail for _ in range(n_dis))
878
+ tr = sum(stn["trace"][i] for i in secs) / len(secs)
879
+ if target != "bulk" and not clean: # without a visible boundary the tube carries the other layer
880
+ other = "OG" if target == "oral_epidermis" else "OE"
881
+ mine = TARGET_POOL[target]
882
+ p_mine = (0.6 + 0.4 * tr) if target == "oral_epidermis" else (0.8 + 0.2 * tr)
883
+ mix = comp[mine] * (1 - p_mine)
884
+ comp[mine] -= mix
885
+ comp[other] += mix
886
+ if anchor:
887
+ st["used_rows"].append(anchor)
888
+ new = [f for f in rec["lcm_figs"].get(target, []) if f not in st["shown_figs"]]
889
+ figs += new
890
+ st["shown_figs"] += new # each recorded dissection image belongs to one session tube
891
+ st["tubes"][tid] = {"kind": "lcm", "slide": sid, "block": s["block"], "target": target, "buffer": buf,
892
+ "roi": roi, "tissue": tissue, "n_dis": n_dis, "n_failed": n_failed, "comp": comp,
893
+ "thk": s["thickness"] / 10.0, "wash": stn["wash"], "dv_pen": stn["dv_pen"],
894
+ "inhibitor": stn["inhibitor"], "extracted": False, "anchor": anchor, "spike": []}
895
+ t_out = {"tube": tid, "target": target, "buffer": buf, "dissections_collected": int(n_dis),
896
+ "dissections_failed_not_in_cap": int(n_failed), "roi_um2": int(round(roi))}
897
+ if spec["measure_tissue"] or mode == "tissue_um2":
898
+ t_out["tissue_in_roi_um2"] = int(round(tissue))
899
+ if limited:
900
+ t_out["limited"] = (f"only {int(round(roi)):,} um2 of ROI ({int(round(tissue)):,} um2 tissue) of this "
901
+ f"target could be dissected on the sections used")
902
+ t_out["_tissue_um2"] = int(round(tissue))
903
+ t_out["_anchor_row"] = anchor
904
+ t_out["_recorded_tissue"] = recorded_tissue
905
+ res_t.append(t_out)
906
+ save(a.run, st)
907
+ out({"slide": sid, "laser_cutting": stn["cut"], "tubes": res_t, "figures_dissection": figs,
908
+ "charge": ["stain_and_lcm"]})
909
+
910
+
911
+ def cmd_scrape(a, st, spec):
912
+ strict(spec, ["slide", "tubes"], [], "scrape")
913
+ sid, s = get_slide(st, spec["slide"])
914
+ res = []
915
+ for tb in spec["tubes"]:
916
+ strict(tb, ["id", "sections", "buffer"], [], "scrape.tubes[]")
917
+ tid = str(tb["id"])
918
+ new_id_ok(st, tid, "tube")
919
+ buf = one_of(tb["buffer"], BUFFERS, "buffer")
920
+ comp = {"OE": 0.0, "OG": 0.0, "deep": 0.0, "frayed": 0.0}
921
+ for x in tb["sections"]:
922
+ i = int(x) - 1
923
+ assert 0 <= i < len(s["sections"]) and i not in s["scraped"], f"{sid}: section {x} not available"
924
+ for q, v in s["sections"][i].items():
925
+ comp[q] += v
926
+ s["sections"][i][q] = 0.0
927
+ s["scraped"].append(i)
928
+ stn = sec_view(s["stain"], [int(x) - 1 for x in tb["sections"]]) if s["stain"] else None
929
+ st["tubes"][tid] = {"kind": "scrape", "slide": sid, "block": s["block"], "target": "whole_section",
930
+ "buffer": buf, "roi": None, "tissue": sum(comp.values()), "n_sections": len(tb["sections"]),
931
+ "comp": comp, "thk": s["thickness"] / 10.0, "wash": stn["wash"] if stn else None,
932
+ "dv_pen": stn["dv_pen"] if stn else 0.0, "inhibitor": stn["inhibitor"] if stn else False,
933
+ "unwashed": stn is None, "extracted": False, "anchor": None, "spike": [],
934
+ "ws_eligible": s["rec"] == "rec_0529_prewash" and len(tb["sections"]) == 1 and buf == "PK"}
935
+ res.append({"tube": tid, "sections": tb["sections"], "buffer": buf,
936
+ "note": "unstained slide: OCT still on the sections goes into the tube" if stn is None else
937
+ "sections scraped off the membrane into the tube", "_tissue_um2": int(sum(comp.values()))})
938
+ save(a.run, st)
939
+ out({"slide": sid, "tubes": res, "charge": ["whole_section_extract (includes extraction and TapeStation)"]})
940
+
941
+
942
+ def cmd_curls(a, st, spec):
943
+ strict(spec, ["block", "tubes"], [], "curls")
944
+ block = one_of(spec["block"], BLOCKS, "block")
945
+ res = []
946
+ for tb in spec["tubes"]:
947
+ strict(tb, ["id", "n_curls", "thickness_um", "buffer", "trim_oct"], [], "curls.tubes[]")
948
+ tid = str(tb["id"])
949
+ new_id_ok(st, tid, "tube")
950
+ n, t = int(tb["n_curls"]), float(tb["thickness_um"])
951
+ assert 1 <= n <= 20 and 5 <= t <= 50, "1-20 curls of 5-50 um"
952
+ buf = one_of(tb["buffer"], BUFFERS, "buffer")
953
+ p = new_section_pools(a.run, block, "curl" + tid, 0, 10)
954
+ g = genus(block)
955
+ tear = "curls roll cleanly" if g == "Pocillopora" else \
956
+ "curls come off as a porous, lacy OCT/tissue ribbon and partly crumble"
957
+ st["tubes"][tid] = {"kind": "curl", "slide": None, "block": block, "target": "curls", "buffer": buf,
958
+ "roi": None, "tissue": sum(p.values()) * n * t / 10.0, "comp": p,
959
+ "thk": n * t / 10.0, "wash": None, "dv_pen": 0.0, "inhibitor": False,
960
+ "trim": bool(tb["trim_oct"]), "extracted": False, "anchor": None, "spike": []}
961
+ res.append({"tube": tid, "n_curls": n, "thickness_um": t, "buffer": buf, "cutting": tear,
962
+ "trim": "block trimmed to about 1 mm of OCT" if tb["trim_oct"] else "block face not trimmed"})
963
+ save(a.run, st)
964
+ out({"block": block, "tubes": res, "charge": ["other_bench_procedure (cutting curls)"], "consumed": []})
965
+
966
+
967
+ def cmd_blank(a, st, spec):
968
+ strict(spec, ["tubes"], [], "blank")
969
+ res = []
970
+ for tb in spec["tubes"]:
971
+ strict(tb, ["id", "buffer"], [], "blank.tubes[]")
972
+ tid = str(tb["id"])
973
+ new_id_ok(st, tid, "tube")
974
+ buf = one_of(tb["buffer"], BUFFERS, "buffer")
975
+ st["tubes"][tid] = {"kind": "blank", "slide": None, "block": None, "target": "blank", "buffer": buf,
976
+ "roi": None, "tissue": 0.0, "comp": {}, "thk": 1.0, "wash": None, "dv_pen": 0.0,
977
+ "inhibitor": False, "extracted": False, "anchor": None, "spike": []}
978
+ res.append({"tube": tid, "buffer": buf, "content": "collection buffer only"})
979
+ save(a.run, st)
980
+ out({"tubes": res, "charge": []})
981
+
982
+
983
+ def cmd_spike(a, st, spec):
984
+ strict(spec, ["tube", "source", "rna_pg"], [], "spike")
985
+ t = get_tube(st, str(spec["tube"]))
986
+ assert not t["extracted"], "tube already extracted"
987
+ pg = float(spec["rna_pg"])
988
+ assert 1 <= pg <= 1e6, "rna_pg 1 pg - 1 ug"
989
+ src = spec["source"]
990
+ if src == "synthetic":
991
+ t["spike"].append({"pg": pg, "type": "synthetic", "dv200": DV_BASE["synthetic"], "sym": 0.0})
992
+ note = f"{pg:g} pg synthetic RNA added"
993
+ else:
994
+ assert src.startswith("eluate:"), "source = synthetic or eluate:<id>"
995
+ e = get_eluate(st, src.split(":", 1)[1])
996
+ ul = pg / e["conc"]
997
+ assert ul <= e["vol"], f"needs {ul:.2f} uL of {src}, only {e['vol']:.1f} uL left"
998
+ e["vol"] -= ul
999
+ t["spike"].append({"pg": pg, "type": "rna", "dv200": e["dv200"], "sym": e["sym"]})
1000
+ note = f"{ul:.2f} uL of {src.split(':', 1)[1]} added ({pg:g} pg by its true content)"
1001
+ save(a.run, st)
1002
+ out({"tube": spec["tube"], "note": note, "charge": []})
1003
+
1004
+
1005
+ def extract_mass(a, t, tid, dig, kit, eid):
1006
+ """True pg and DV200 contributions of one tube on a column (before spike recovery)."""
1007
+ if t["kind"] == "blank":
1008
+ return 0.0, 0.0
1009
+ block = t["block"]
1010
+ buf_y, buf_dv = BUFFERS[t["buffer"]]
1011
+ r = rng_for(a.run, "extract", eid, tid)
1012
+ if t["kind"] == "curl":
1013
+ pg = rna_of(t["comp"], block) * t["thk"] * DIG_YIELD_SEC[dig] * CURL_LYSIS[dig] * CURL_OCT[t["trim"]]
1014
+ dv = DV_BASE["curl"] + BLOCKS[block]["dv"] + DIG_DV_SEC[dig] + KITS[kit]["dv"] + buf_dv
1015
+ else:
1016
+ pg = rna_of(t["comp"], block) * t["thk"] * DIG_YIELD_SEC[dig]
1017
+ if t.get("unwashed"):
1018
+ pg *= 0.9
1019
+ dv = dv_section(block, t["dv_pen"], t.get("inhibitor", False), dig, kit, t["buffer"])
1020
+ pg *= KITS[kit]["yield"] * buf_y * ln(r, EXTRACT_CV)
1021
+ return pg, dv + r.gauss(0, 1.2)
1022
+
1023
+
1024
+ def cmd_extract(a, st, spec):
1025
+ strict(spec, ["columns"], [], "extract")
1026
+ res = []
1027
+ for col in spec["columns"]:
1028
+ strict(col, ["id", "tubes", "digestion", "kit", "elution_ul"], [], "extract.columns[]")
1029
+ eid = str(col["id"])
1030
+ assert eid not in st["eluates"], f"eluate id {eid!r} already used; choose another"
1031
+ kit = one_of(col["kit"], KITS, "kit")
1032
+ el = float(col["elution_ul"])
1033
+ assert KITS[kit]["min_ul"] <= el <= KITS[kit]["max_ul"], \
1034
+ f"{kit} elution {el} uL outside {KITS[kit]['min_ul']}-{KITS[kit]['max_ul']} uL"
1035
+ tubes = [str(x) for x in col["tubes"]]
1036
+ ts = [get_tube(st, x) for x in tubes]
1037
+ for x, t in zip(tubes, ts):
1038
+ assert not t["extracted"], f"tube {x} was already extracted"
1039
+ dig = col["digestion"]
1040
+ if dig == "recorded":
1041
+ assert len(ts) == 1 and ts[0]["anchor"], "digestion 'recorded' only for one tube with a recorded row"
1042
+ row = next(rw for rec in REC_SLIDES.values() for rw in rec["rows"] if rw[0] == ts[0]["anchor"])
1043
+ assert row[6], f"the recorded row of tube {tubes[0]} has no extraction"
1044
+ dig = row[6]
1045
+ one_of(dig, DIGS, "digestion")
1046
+ mass, dvw, symw, spike_pg = 0.0, 0.0, 0.0, 0.0
1047
+ anchor = None
1048
+ for x, t in zip(tubes, ts):
1049
+ pg, dv = extract_mass(a, t, x, dig, kit, eid)
1050
+ if t["anchor"] and len(ts) == 1:
1051
+ row = next(rw for rec in REC_SLIDES.values() for rw in rec["rows"] if rw[0] == t["anchor"])
1052
+ if row[6] is not None:
1053
+ true_rec = max(0.3 * row[7], row[7] - TS_BASE_MEAN) * 8.0
1054
+ if row[6] == dig and kit == "microprep" and el == 8.0:
1055
+ pg = true_rec
1056
+ anchor = {"row": row[0], "conc": row[7], "rating": row[8]}
1057
+ else:
1058
+ pg = true_rec / DIG_YIELD_SEC[row[6]] * DIG_YIELD_SEC[dig] * KITS[kit]["yield"] * \
1059
+ BUFFERS[t["buffer"]][0] * ln(rng_for(a.run, "rescale", eid), 0.08)
1060
+ if t.get("ws_eligible") and kit == "microprep" and el == 15.0 and dig in WHOLE_SECTION_ANCHORS \
1061
+ and dig not in st["used_ws"] and len(ts) == 1:
1062
+ c, dvr, name = WHOLE_SECTION_ANCHORS[dig]
1063
+ pg, dv = c * 15.0, dvr
1064
+ anchor = {"row": name, "conc": c, "rating": None, "dv200": dvr}
1065
+ st["used_ws"].append(dig)
1066
+ sym = sym_share(t["comp"], t["block"]) if t["block"] else 0.0
1067
+ for sp in t["spike"]:
1068
+ spike_pg += sp["pg"]
1069
+ mass += pg
1070
+ dvw += pg * dv
1071
+ symw += pg * sym
1072
+ t["extracted"] = True
1073
+ on_col = mass + spike_pg
1074
+ rec_f = SPIKE_REC[0] * on_col / (on_col + SPIKE_REC[1]) if on_col > 0 else 0.0
1075
+ synth, dv_nat_w, nat = 0.0, dvw, mass
1076
+ for t in ts:
1077
+ for sp in t["spike"]:
1078
+ got = sp["pg"] * rec_f * ln(rng_for(a.run, "spikerec", eid, sp["pg"]), 0.08)
1079
+ dvw += got * sp["dv200"]
1080
+ if sp["type"] == "synthetic":
1081
+ synth += got
1082
+ else: # coral RNA from another eluate behaves like tissue RNA
1083
+ symw += got * sp["sym"]
1084
+ dv_nat_w += got * sp["dv200"]
1085
+ nat += got
1086
+ total = mass + synth + (nat - mass)
1087
+ spike_rec = synth
1088
+ block = next((t["block"] for t in ts if t["block"]), None)
1089
+ kind = "curl" if any(t["kind"] == "curl" for t in ts) else "section"
1090
+ st["eluates"][eid] = {"tubes": tubes, "kind": kind, "elution": el, "vol": el, "conc": total / el,
1091
+ "dv200": dvw / total if total > 0 else None, "sym": symw / nat if nat > 0 else 0.0,
1092
+ "dv_native": dv_nat_w / nat if nat > 0 else None,
1093
+ "spike_pg": spike_rec, "digestion": dig, "kit": kit, "anchor": anchor, "ts": None,
1094
+ "block": block}
1095
+ res.append({"eluate": eid, "tubes": tubes, "digestion": dig, "kit": kit, "elution_ul": el,
1096
+ "note": "pooled on one column" if len(tubes) > 1 else "", "_true_pg": round(total, 1),
1097
+ "_anchor": anchor})
1098
+ save(a.run, st)
1099
+ out({"eluates": res, "charge": ["extract_rna (not for whole_section_extract tubes)"]})
1100
+
1101
+
1102
+ def cmd_fresh(a, st, spec):
1103
+ strict(spec, ["extractions"], [], "fresh")
1104
+ res = []
1105
+ for ex in spec["extractions"]:
1106
+ strict(ex, ["id", "shield_ul", "digestion", "kit", "elution_ul"], [], "fresh.extractions[]")
1107
+ eid = str(ex["id"])
1108
+ new_id_ok(st, eid, "eluate")
1109
+ assert st["fresh_used"] < FRESH_FRAGMENTS, f"all {FRESH_FRAGMENTS} fresh fragments in Shield are used"
1110
+ st["fresh_used"] += 1
1111
+ sh, dig, kit, el = float(ex["shield_ul"]), one_of(ex["digestion"], DIGS, "digestion"), \
1112
+ one_of(ex["kit"], FRESH_BASE, "kit"), float(ex["elution_ul"])
1113
+ assert 50 <= sh <= 600, "Shield volume 50-600 uL per fragment tube"
1114
+ assert KITS[kit]["min_ul"] <= el <= KITS[kit]["max_ul"], f"{kit} elution outside its range"
1115
+ r = rng_for(a.run, "fresh", eid)
1116
+ anchor = None
1117
+ for row in FRESH_ANCHORS:
1118
+ if row[6] not in st["used_fresh"] and (row[0], row[1], row[2], row[3]) == (sh, dig, kit, el):
1119
+ anchor = row
1120
+ break
1121
+ if anchor:
1122
+ st["used_fresh"].append(anchor[6])
1123
+ total, dv = anchor[4] * el, anchor[5]
1124
+ anc = {"row": anchor[6], "conc": anchor[4], "rating": 3, "dv200": anchor[5]}
1125
+ else:
1126
+ base, ref = FRESH_BASE[kit]
1127
+ total = base * sh / ref * DIG_YIELD_FRESH[dig] * ln(r, FRESH_CV)
1128
+ dv = DV_BASE["fresh"] + DIG_DV_FRESH[dig] + FRESH_KIT_DV[kit] + r.gauss(0, 0.8)
1129
+ anc = None
1130
+ st["eluates"][eid] = {"tubes": [], "kind": "fresh", "elution": el, "vol": el, "conc": total / el,
1131
+ "dv200": dv, "sym": 0.18, "spike_pg": 0.0, "digestion": dig, "kit": kit,
1132
+ "anchor": anc, "ts": None, "block": "POR_R72_C2"}
1133
+ res.append({"eluate": eid, "input": f"fresh unfixed Porites fragment in {sh:g} uL DNA/RNA Shield",
1134
+ "digestion": dig, "kit": kit, "elution_ul": el, "_anchor": anc})
1135
+ save(a.run, st)
1136
+ out({"eluates": res, "charge": ["positive_control_fresh (includes extraction and TapeStation)"]})
1137
+
1138
+
1139
+ def ts_reading(a, e, eid):
1140
+ if e["anchor"] and e["anchor"].get("conc") is not None:
1141
+ return e["anchor"]["conc"]
1142
+ r = rng_for(a.run, "ts", eid)
1143
+ c = e["conc"]
1144
+ cv = 0.07 + 0.30 * math.exp(-c / 150.0) # ~35 % at 10 pg/uL, 22 % at 100, 15 % at 200, 8 % at 500
1145
+ return c * ln(r, cv) + r.uniform(*TS_BASE)
1146
+
1147
+
1148
+ def ts_trace(reading, dv):
1149
+ if reading < 25:
1150
+ return "HS_FLAT"
1151
+ if reading < TS_LOD:
1152
+ return "HS_FAINT"
1153
+ if reading < TS_QLO:
1154
+ return "HS_LOW_GOOD" if dv >= 65 else "HS_LOW_DEGRADED"
1155
+ return "HS_Q_GOOD" if dv >= 75 else ("HS_Q_MID" if dv >= 60 else "HS_Q_DEGRADED")
1156
+
1157
+
1158
+ def cmd_tapestation(a, st, spec):
1159
+ strict(spec, ["eluates", "ul", "integrity", "reanalyze"], [], "tapestation")
1160
+ ul = float(spec["ul"])
1161
+ assert ul in (1.0, 2.0), "HS RNA ScreenTape takes 2 uL sample (1 uL sample + 1 uL water allowed)"
1162
+ res, figs_done = [], []
1163
+ for eid in [str(x) for x in spec["eluates"]]:
1164
+ e = get_eluate(st, eid)
1165
+ if spec["reanalyze"]:
1166
+ assert e["ts"] is not None, f"{eid} was never run on the TapeStation; nothing to re-analyse"
1167
+ elif e["ts"] is None:
1168
+ assert e["vol"] >= ul - 1e-9, f"{eid}: only {e['vol']:.1f} uL left"
1169
+ e["vol"] -= ul
1170
+ reading = ts_reading(a, e, eid)
1171
+ if ul == 1.0 and not e["anchor"]:
1172
+ reading *= ln(rng_for(a.run, "ts1ul", eid), 0.10)
1173
+ dv_true = e["dv200"] if e["dv200"] is not None else 0.0
1174
+ rating = e["anchor"]["rating"] if e["anchor"] and e["anchor"].get("rating") else \
1175
+ rating_for(a.run, eid, reading, dv_true)
1176
+ e["ts"] = {"conc": round(reading, 1) if reading < 1000 else round(reading), "rating": rating,
1177
+ "integrity": None}
1178
+ else:
1179
+ assert e["vol"] >= ul - 1e-9, f"{eid}: only {e['vol']:.1f} uL left"
1180
+ e["vol"] -= ul # a repeat run on the same eluate reports the same values (session rule)
1181
+ rd = e["ts"]["conc"]
1182
+ o = {"eluate": eid, "conc_pg_per_ul": rd, "total_pg_in_elution": round(rd * e["elution"]),
1183
+ "elution_ul": e["elution"], "rating_1_to_3": e["ts"]["rating"],
1184
+ "flag": "red warning: outside quantitative range (500-10,000 pg/uL)" if rd < TS_QLO else
1185
+ ("above 10,000 pg/uL: dilute and re-run" if rd > TS_QHI else "none"),
1186
+ "ul_left": round(e["vol"], 1)}
1187
+ if spec["integrity"] or spec["reanalyze"]:
1188
+ if e["ts"]["integrity"] is None:
1189
+ r = rng_for(a.run, "tsint", eid)
1190
+ if rd >= TS_LOD and e["dv200"] is not None:
1191
+ if e["anchor"] and e["anchor"].get("dv200") is not None:
1192
+ dvm = e["anchor"]["dv200"]
1193
+ else:
1194
+ dvm = round(min(99.0, e["dv200"] + r.gauss(0, 1.0 if rd >= TS_QLO else 2.5)), 1)
1195
+ e["ts"]["integrity"] = {"DV200_pct": dvm, "RINe": rine(dvm, r),
1196
+ "integrity_flag": "computed below the RINe functional range "
1197
+ "(1,000 pg/uL)" if rd < 1000 else "none",
1198
+ "trace": ts_trace(rd, dvm)}
1199
+ else:
1200
+ e["ts"]["integrity"] = {"DV200_pct": "not computed (signal too low)", "RINe": "-",
1201
+ "trace": ts_trace(rd, 0.0)}
1202
+ o.update(e["ts"]["integrity"])
1203
+ res.append(o)
1204
+ figs = []
1205
+ if spec["integrity"] or spec["reanalyze"]:
1206
+ rows_here = {e2["anchor"]["row"] for e2 in st["eluates"].values()
1207
+ if e2["anchor"] and e2["ts"] and e2["ts"]["integrity"] is not None}
1208
+ for f, lanes in GELS.items():
1209
+ if set(lanes) <= rows_here:
1210
+ figs.append(f)
1211
+ save(a.run, st)
1212
+ out({"tapestation_hs_rna": res, "_recorded_gel_figures_complete": figs,
1213
+ "charge": [] if spec["reanalyze"] else
1214
+ ["tapestation_existing (not when part of positive_control_fresh / whole_section_extract)"]})
1215
+
1216
+
1217
+ def cmd_bioanalyzer(a, st, spec):
1218
+ strict(spec, ["eluates", "ul"], [], "bioanalyzer")
1219
+ assert float(spec["ul"]) == 1.0, "RNA 6000 Pico takes 1 uL per well"
1220
+ res = []
1221
+ for eid in [str(x) for x in spec["eluates"]]:
1222
+ e = get_eluate(st, eid)
1223
+ assert e["vol"] >= 1.0, f"{eid}: only {e['vol']:.1f} uL left"
1224
+ e["vol"] -= 1.0
1225
+ key = "bio"
1226
+ if key not in e:
1227
+ r = rng_for(a.run, "bio", eid)
1228
+ c = e["conc"]
1229
+ rd = c * ln(r, 0.35 if c < BIO_QUANT else 0.20) + r.uniform(0, 2)
1230
+ dv = e["dv200"] if e["dv200"] is not None else 0.0
1231
+ o = {"eluate": eid}
1232
+ if rd < 25:
1233
+ o.update({"conc": "not detected", "RIN": "N/A", "pct_gt_200nt": "not computed",
1234
+ "trace": "PICO_FLAT"})
1235
+ elif rd < BIO_QUAL:
1236
+ o.update({"conc_pg_per_ul": round(rd, 1), "flag": "below qualitative range (50 pg/uL)",
1237
+ "RIN": "N/A", "pct_gt_200nt": "not computed", "trace": "PICO_NOISY"})
1238
+ elif rd < BIO_QUANT:
1239
+ o.update({"conc_pg_per_ul": round(rd, 1), "flag": "below quantitative range (200 pg/uL)",
1240
+ "RIN": "N/A" if rd < 100 else rine(dv + r.gauss(0, 3), r),
1241
+ "pct_gt_200nt": round(dv + r.gauss(0, 3), 1), "trace": "PICO_WEAK"})
1242
+ else:
1243
+ o.update({"conc_pg_per_ul": round(rd), "flag": "none", "RIN": rine(dv + r.gauss(0, 1.5), r),
1244
+ "pct_gt_200nt": round(dv + r.gauss(0, 1.5), 1),
1245
+ "trace": "PICO_GOOD" if dv >= 70 else "PICO_DEGRADED"})
1246
+ e[key] = o
1247
+ res.append(dict(e[key], ul_left=round(e["vol"], 1)))
1248
+ save(a.run, st)
1249
+ out({"bioanalyzer_rna_6000_pico": res, "charge": ["qc_assay_other"]})
1250
+
1251
+
1252
+ def cmd_qubit(a, st, spec):
1253
+ strict(spec, ["eluates", "ul"], [], "qubit")
1254
+ ul = float(spec["ul"])
1255
+ assert 1 <= ul <= 20, "Qubit takes 1-20 uL sample"
1256
+ res = []
1257
+ for eid in [str(x) for x in spec["eluates"]]:
1258
+ e = get_eluate(st, eid)
1259
+ assert e["vol"] >= ul - 1e-9, f"{eid}: only {e['vol']:.1f} uL left"
1260
+ e["vol"] -= ul
1261
+ ng = e["conc"] * ul / 1000.0
1262
+ r = rng_for(a.run, "qubit", eid, ul)
1263
+ if ng < QUBIT_MIN_NG:
1264
+ o = {"eluate": eid, "reading": "Out of range: too low", "ul_used": ul}
1265
+ elif ng > QUBIT_MAX_NG:
1266
+ o = {"eluate": eid, "reading": "Out of range: too high", "ul_used": ul}
1267
+ else:
1268
+ v = ng * ln(r, 0.05) / ul
1269
+ o = {"eluate": eid, "ng_per_ul": round(v, 2), "ul_used": ul}
1270
+ o["ul_left"] = round(e["vol"], 1)
1271
+ res.append(o)
1272
+ save(a.run, st)
1273
+ out({"qubit_rna_hs": res, "charge": ["qc_assay_other"]})
1274
+
1275
+
1276
+ def ct_value(pg, ref, r, dv200):
1277
+ if pg <= 0:
1278
+ return None
1279
+ eff = pg * min(1.05, max(0.3, (dv200 or 0.0) / 80.0))
1280
+ ct = ref - CT_PER_LOG2 * math.log2(eff / 100.0)
1281
+ ct += r.gauss(0, 0.10 + 0.08 * max(0.0, ct - 30.0))
1282
+ if ct > 40 or (ct > 37 and r.random() < (ct - 37) / 3):
1283
+ return None
1284
+ return round(ct, 2)
1285
+
1286
+
1287
+ def cmd_qpcr(a, st, spec):
1288
+ strict(spec, ["reactions", "targets", "replicates", "no_rt", "ntc"], [], "qpcr")
1289
+ targets = [one_of(t, CT_REF, "target") for t in spec["targets"]]
1290
+ nrep = int(spec["replicates"])
1291
+ assert 1 <= nrep <= 4, "1-4 replicate wells"
1292
+ res = []
1293
+ for k, rx in enumerate(spec["reactions"]):
1294
+ strict(rx, ["eluate", "ul_rna", "dilution"], [], "qpcr.reactions[]")
1295
+ eid = str(rx["eluate"])
1296
+ e = get_eluate(st, eid)
1297
+ ul, dil = float(rx["ul_rna"]), float(rx["dilution"])
1298
+ assert 0.5 <= ul <= 10 and dil >= 1, "ul_rna 0.5-10 into a 20 uL RT; dilution >= 1"
1299
+ n_rt = int(any(t in DT_TARGETS for t in targets)) + int(any(t not in DT_TARGETS for t in targets))
1300
+ use = ul / dil * n_rt * (2 if spec["no_rt"] else 1)
1301
+ assert e["vol"] >= use - 1e-9, f"{eid}: needs {use:.2f} uL, only {e['vol']:.1f} uL left"
1302
+ e["vol"] -= use
1303
+ pg = e["conc"] * ul / dil
1304
+ row = {"eluate": eid, "ul_rna": ul, "dilution": dil}
1305
+ spk = e["spike_pg"] / e["elution"] * ul / dil
1306
+ for tgt in targets:
1307
+ dvn = e.get("dv_native", e["dv200"])
1308
+ if tgt == "host":
1309
+ tpl = (pg - spk) * (1 - e["sym"])
1310
+ elif tgt == "host_3prime":
1311
+ tpl = (pg - spk) * (1 - e["sym"])
1312
+ elif tgt == "host_5prime":
1313
+ tpl = (pg - spk) * (1 - e["sym"]) / ratio_3to5(dvn or 0.0)
1314
+ elif tgt == "symbiont":
1315
+ tpl = (pg - spk) * e["sym"]
1316
+ else:
1317
+ tpl = spk
1318
+ cts = []
1319
+ for j in range(nrep):
1320
+ r = rng_for(a.run, "qpcr", eid, k, tgt, j, ul, dil)
1321
+ c = ct_value(tpl, CT_REF[tgt], r, e.get("dv_native", e["dv200"]) if tgt != "spike" else 95.0)
1322
+ cts.append(c if c is not None else "Undetermined")
1323
+ row[f"Ct_{tgt}"] = cts
1324
+ if spec["no_rt"]:
1325
+ row[f"Ct_{tgt}_noRT"] = ["Undetermined"] * nrep
1326
+ row["_true_pg_in_rt"] = round(pg, 2)
1327
+ row["ul_left"] = round(e["vol"], 1)
1328
+ res.append(row)
1329
+ rt = []
1330
+ if any(t not in DT_TARGETS for t in targets):
1331
+ rt.append("random-primed RT, 20 uL")
1332
+ if any(t in DT_TARGETS for t in targets):
1333
+ rt.append("oligo-dT-primed RT, 20 uL, for the 3' and 5' host amplicons (separate RT, same RNA volume)")
1334
+ o = {"rt": "; ".join(rt) + "; SYBR qPCR on 2 uL cDNA per well; single melt peak per target",
1335
+ "wells": res, "charge": ["qc_assay_other"]}
1336
+ if spec["ntc"]:
1337
+ o["NTC"] = {t: ["Undetermined"] * nrep for t in targets}
1338
+ save(a.run, st)
1339
+ out(o)
1340
+
1341
+
1342
+ def cmd_library(a, st, spec):
1343
+ strict(spec, ["prep_id", "samples", "cdna_cycles", "final_cycles", "qubit_dsdna"], ["final_cycles_rule"],
1344
+ "library")
1345
+ assert 1 <= len(spec["samples"]) <= SAMPLES_PER_PREP, f"one prep takes 1-{SAMPLES_PER_PREP} samples"
1346
+ assert st["library_preps"] < LIBRARY_PREPS, f"all {LIBRARY_PREPS} library preps are used"
1347
+ pid = str(spec["prep_id"])
1348
+ assert pid not in st["libraries"], f"prep id {pid} already used"
1349
+ cc0, fc0 = int(spec["cdna_cycles"]), int(spec["final_cycles"])
1350
+ assert 12 <= cc0 <= 24 and 3 <= fc0 <= 14, "cDNA cycles 12-24, final library cycles 3-14"
1351
+ rule = spec.get("final_cycles_rule") # 2026-11-06 (c): {"cdna_ng_above": X, "cycles": Y}, per sample
1352
+ if rule is not None:
1353
+ strict(rule, ["cdna_ng_above", "cycles"], [], "library.final_cycles_rule")
1354
+ assert 3 <= int(rule["cycles"]) <= 14, "final library cycles 3-14"
1355
+ st["library_preps"] += 1
1356
+ res, figs = [], []
1357
+ for k, smp in enumerate(spec["samples"]):
1358
+ strict(smp, ["eluate", "ul"], ["cdna_cycles", "final_cycles"], "library.samples[]")
1359
+ cc = int(smp["cdna_cycles"]) if "cdna_cycles" in smp else cc0 # 2026-11-06 (c): per-sample cycles
1360
+ fc = int(smp["final_cycles"]) if "final_cycles" in smp else fc0
1361
+ assert 12 <= cc <= 24 and 3 <= fc <= 14, "cDNA cycles 12-24, final library cycles 3-14"
1362
+ eid, ul = str(smp["eluate"]), float(smp["ul"])
1363
+ r = rng_for(a.run, "lib", pid, eid, k)
1364
+ if eid == "NTC":
1365
+ pg, dv, anc = 0.0, 0.0, None
1366
+ else:
1367
+ e = get_eluate(st, eid)
1368
+ assert 0 < ul <= LIB_RNA_MAX_UL, f"low-input workflow takes up to {LIB_RNA_MAX_UL:g} uL RNA"
1369
+ assert e["vol"] >= ul - 1e-9, f"{eid}: only {e['vol']:.1f} uL left"
1370
+ e["vol"] -= ul
1371
+ pg, dv = e["conc"] * ul, e["dv200"] or 0.0
1372
+ row = e["anchor"]["row"] if e["anchor"] else None
1373
+ anc = LIB_ANCHORS.get(row) if (row in LIB_ANCHORS and cc == 20 and fc == 8 and
1374
+ row not in st.get("used_lib", [])) else None
1375
+ if anc:
1376
+ st.setdefault("used_lib", []).append(row)
1377
+ bg = 400.0 * 1.85 ** (cc - 18)
1378
+ if anc:
1379
+ cdna_conc, cpeak, lconc, lpeak, f = anc
1380
+ figs += f
1381
+ cdna = cdna_conc * CDNA_ELUTE_UL * 1000
1382
+ assert rule is None, "final_cycles_rule is not used with the recorded prep conditions (20 and 8 cycles)"
1383
+ else:
1384
+ plat = min(120000.0, CDNA_PLAT * 1.1 ** (cc - 20)) * ln(r, 0.15)
1385
+ u = pg * CDNA_GAIN * 1.85 ** (cc - 20)
1386
+ cdna = plat * (1 - math.exp(-u / plat)) if pg > 0 else 0.0
1387
+ cdna_conc = round((cdna + bg * 0.3) / CDNA_ELUTE_UL / 1000, 2)
1388
+ cpeak = round(900 * ln(r, 0.15) - 15 * max(0.0, 65 - dv)) if pg > 0 else 0
1389
+ ng = cdna / 1000
1390
+ if rule is not None and round(cdna_conc * CDNA_ELUTE_UL, 2) > float(rule["cdna_ng_above"]):
1391
+ fc = int(rule["cycles"]) # 2026-11-06 (c): the cDNA yield decides the final cycles
1392
+ lconc = round(LIB_MAX * ln(r, 0.15) * (1 - math.exp(-ng * LIB_GAIN * 1.9 ** (fc - 8) / LIB_MAX)), 1)
1393
+ lpeak = round(282 * ln(r, 0.04) - (12 if dv < 50 else 0)) if pg > 0 else 0
1394
+ if pg <= 0: # no template: only primer and adaptor-dimer products are amplified
1395
+ lconc, lpeak = round(1.5 * ln(r, 0.3), 1), 132
1396
+ low_mw = "none" if cdna >= 2000 else ("small peak ~80-150 bp" if cdna >= 300 else "dominant <150 bp products")
1397
+ dimer = "none" if cdna >= 1000 else "adaptor-dimer peak ~128-140 bp"
1398
+ hump = fc >= 10 and cdna >= 10000
1399
+ o = {"sample": eid, "rna_ul": ul, "cdna_cycles": cc, "final_cycles": fc,
1400
+ "cdna_ng_per_ul": cdna_conc, "cdna_total_ng_in_26_ul": round(cdna_conc * CDNA_ELUTE_UL, 2),
1401
+ "cdna_main_peak_bp": cpeak if cpeak else "no peak", "cdna_low_mw": low_mw,
1402
+ "library_ng_per_ul": lconc, "library_peak_bp": lpeak if lpeak else "no peak",
1403
+ "library_adaptor_dimer": dimer, "library_high_mw_hump": hump,
1404
+ "trace": "LIB_GOOD" if cdna >= 2000 else ("LIB_LOW" if pg > 0 else "LIB_NTC"),
1405
+ "_rna_input_pg_true": round(pg, 1), "_recorded_anchor": bool(anc)}
1406
+ if spec["qubit_dsdna"]:
1407
+ o["library_qubit_dsdna_ng_per_ul"] = round(lconc * 0.87 * ln(r, 0.06), 1)
1408
+ res.append(o)
1409
+ if len([s for s in res if s["_recorded_anchor"]]) == 3:
1410
+ figs += LIB_ALL_FIGS
1411
+ st["libraries"][pid] = res
1412
+ save(a.run, st)
1413
+ out({"library_prep": pid, "samples": res, "figures": figs,
1414
+ "charge": ["library_prep (includes cDNA and library D5000 QC)"] +
1415
+ (["qc_assay_other (Qubit dsDNA)"] if spec["qubit_dsdna"] else []),
1416
+ "consumed": [{"item": "library_preps", "n": 1}]})
1417
+
1418
+
1419
+ def cmd_concentrate(a, st, spec):
1420
+ strict(spec, ["eluate", "final_ul", "new_id"], [], "concentrate")
1421
+ e = get_eluate(st, str(spec["eluate"]))
1422
+ nid = str(spec["new_id"])
1423
+ new_id_ok(st, nid, "eluate")
1424
+ fv = float(spec["final_ul"])
1425
+ assert 1 <= fv < e["vol"], f"final volume must be below the {e['vol']:.1f} uL left"
1426
+ mass = e["conc"] * e["vol"] * 0.95
1427
+ st["eluates"][nid] = dict(e, tubes=list(e["tubes"]), vol=fv, elution=fv, conc=mass / fv, anchor=None, ts=None,
1428
+ spike_pg=e["spike_pg"] / e["elution"] * e["vol"] * 0.95)
1429
+ st["eluates"][nid].pop("bio", None)
1430
+ e["vol"] = 0.0
1431
+ save(a.run, st)
1432
+ out({"eluate": nid, "from": spec["eluate"], "final_ul": fv, "note": "vacuum-concentrated",
1433
+ "charge": ["other_bench_procedure"]})
1434
+
1435
+
1436
+ def cmd_combine(a, st, spec):
1437
+ strict(spec, ["eluates", "new_id"], [], "combine")
1438
+ nid = str(spec["new_id"])
1439
+ new_id_ok(st, nid, "eluate")
1440
+ es = [get_eluate(st, str(x)) for x in spec["eluates"]]
1441
+ vol = sum(e["vol"] for e in es)
1442
+ assert vol > 0, "nothing left to combine"
1443
+ mass = sum(e["conc"] * e["vol"] for e in es)
1444
+ dvs = [e["dv200"] for e in es if e["dv200"] is not None]
1445
+ dv = sum((e["dv200"] or 0) * e["conc"] * e["vol"] for e in es) / mass if mass > 0 and dvs else None
1446
+ sym = sum(e["sym"] * e["conc"] * e["vol"] for e in es) / mass if mass > 0 else 0.0
1447
+ sp = sum(e["spike_pg"] * e["vol"] / e["elution"] for e in es)
1448
+ st["eluates"][nid] = {"tubes": sum((e["tubes"] for e in es), []), "kind": es[0]["kind"], "elution": vol,
1449
+ "vol": vol, "conc": mass / vol, "dv200": dv, "dv_native": dv, "sym": sym, "spike_pg": sp,
1450
+ "digestion": "+".join(sorted({e["digestion"] for e in es})), "kit": es[0]["kit"],
1451
+ "anchor": None, "ts": None, "block": es[0]["block"]}
1452
+ for e in es:
1453
+ e["vol"] = 0.0
1454
+ save(a.run, st)
1455
+ out({"eluate": nid, "from": spec["eluates"], "volume_ul": round(vol, 1), "charge": []})
1456
+
1457
+
1458
+ def traced_um2(run, tid, t):
1459
+ """2026-11-06 (c): the FIJI tissue area the lab reports for an unextracted lysate tube (as `measure_tissue`)."""
1460
+ if "split_of" in t:
1461
+ return t["traced_um2"]
1462
+ if t["kind"] == "lcm":
1463
+ return t["tissue"]
1464
+ assert t["kind"] == "scrape", f"tube {tid}: only scraped or dissected lysates can be pooled and split"
1465
+ return t["tissue"] * ln(rng_for(run, "fiji", tid), 0.06)
1466
+
1467
+
1468
+ def cmd_split(a, st, spec):
1469
+ """2026-11-06 (c): pool unextracted lysates of one block and split them into parts by traced tissue or fraction."""
1470
+ strict(spec, ["tubes", "parts", "rest_id"], [], "split")
1471
+ srcs = [str(x) for x in spec["tubes"]]
1472
+ assert srcs and len(set(srcs)) == len(srcs), "tubes: one or more distinct tube ids"
1473
+ ts = [get_tube(st, x) for x in srcs]
1474
+ for x, t in zip(srcs, ts):
1475
+ assert not t["extracted"], f"tube {x} was already extracted, or pooled and split before"
1476
+ assert not t["spike"], f"tube {x}: add spike-ins to the parts after the split"
1477
+ for k in ("kind", "block", "buffer", "thk"):
1478
+ assert len({t[k] for t in ts}) == 1, \
1479
+ f"tubes {srcs} differ in {k}; only lysates of one kind, block, buffer and thickness are pooled"
1480
+ assert len({bool(t.get("unwashed")) for t in ts}) == 1, "scrapes of stained and unstained slides are not pooled"
1481
+ traced = sum(traced_um2(a.run, x, t) for x, t in zip(srcs, ts))
1482
+ assert traced > 0, "the pooled tubes hold no tissue"
1483
+ comp = {q: sum(t["comp"][q] for t in ts) for q in ts[0]["comp"]}
1484
+ true_tot = sum(t["tissue"] for t in ts)
1485
+ fr = []
1486
+ for p in spec["parts"]:
1487
+ strict(p, ["id"], ["fraction", "tissue_um2"], "split.parts[]")
1488
+ assert ("fraction" in p) != ("tissue_um2" in p), f"part {p['id']}: give fraction or tissue_um2"
1489
+ fr.append(float(p["fraction"]) if "fraction" in p else float(p["tissue_um2"]) / traced)
1490
+ assert fr and all(f > 0 for f in fr), "every part needs a positive amount"
1491
+ assert sum(fr) <= 1.0001, (f"the parts ask for {sum(fr) * traced:,.0f} um2 of tissue; the pooled lysate holds "
1492
+ f"{traced:,.0f} um2 by tracing")
1493
+ rest = max(0.0, 1.0 - sum(fr))
1494
+ named = [(str(p["id"]), f) for p, f in zip(spec["parts"], fr)]
1495
+ if spec["rest_id"] is not None and rest > 1e-4:
1496
+ named.append((str(spec["rest_id"]), rest))
1497
+ ids = [x for x, _ in named]
1498
+ assert len(set(ids)) == len(ids), "part ids must differ"
1499
+ for x in ids:
1500
+ new_id_ok(st, x, "tube")
1501
+ washes = [t["wash"] for t in ts if t["wash"] is not None]
1502
+ base = dict(ts[0], wash=max(washes, key=WASHES.index) if washes else None,
1503
+ dv_pen=max(t["dv_pen"] for t in ts), inhibitor=all(t.get("inhibitor", False) for t in ts),
1504
+ anchor=None, spike=[], extracted=False, ws_eligible=False, split_of=srcs)
1505
+ base.pop("split_into", None)
1506
+ parts = []
1507
+ for x, f in named:
1508
+ st["tubes"][x] = dict(base, comp={q: v * f for q, v in comp.items()}, tissue=true_tot * f,
1509
+ roi=sum(t["roi"] for t in ts) * f if base["kind"] == "lcm" else None,
1510
+ n_dis=None, fraction=f, traced_um2=traced * f)
1511
+ parts.append({"tube": x, "fraction_of_pool": round(f, 4), "tissue_um2_by_tracing": int(round(traced * f))})
1512
+ for t in ts:
1513
+ t["extracted"] = True # the source lysates are used up by the pool
1514
+ t["split_into"] = ids
1515
+ res = {"pooled": srcs, "pooled_tissue_um2_by_tracing": int(round(traced)), "buffer": base["buffer"],
1516
+ "parts": parts, "charge": []}
1517
+ if spec["rest_id"] is None and rest > 1e-4:
1518
+ res["rest_discarded_um2_by_tracing"] = int(round(traced * rest))
1519
+ save(a.run, st)
1520
+ out(res)
1521
+
1522
+
1523
+ def cmd_measure_tissue(a, st, spec):
1524
+ strict(spec, ["tubes"], [], "measure_tissue")
1525
+ res = []
1526
+ for tid in [str(x) for x in spec["tubes"]]:
1527
+ t = get_tube(st, tid)
1528
+ r = rng_for(a.run, "fiji", tid)
1529
+ if "split_of" in t: # 2026-11-06 (c): a part of a pooled lysate (tracing of its source tubes)
1530
+ res.append({"tube": tid, "split_of": t["split_of"], "fraction_of_pool": round(t["fraction"], 4),
1531
+ "tissue_um2": int(round(t["traced_um2"]))})
1532
+ elif t["kind"] == "lcm": # ROI images saved at dissection
1533
+ res.append({"tube": tid, "roi_um2": int(round(t["roi"])), "tissue_in_roi_um2": int(round(t["tissue"])),
1534
+ "ratio_roi_to_tissue": round(t["roi"] / t["tissue"], 2) if t["tissue"] > 0 else None})
1535
+ elif t["kind"] == "scrape": # overview image of the sections before they were scraped
1536
+ res.append({"tube": tid, "sections": t["n_sections"],
1537
+ "tissue_on_sections_um2": int(round(t["tissue"] * ln(r, 0.06)))})
1538
+ elif t["kind"] == "curl": # photo of the trimmed block face before cutting
1539
+ res.append({"tube": tid, "tissue_per_block_face_um2": int(round(sum(t["comp"].values()) * ln(r, 0.06))),
1540
+ "note": "single face photo; porous tissue edges traced approximately"})
1541
+ else:
1542
+ raise AssertionError(f"{tid}: nothing to trace for a {t['kind']} tube")
1543
+ out({"fiji_tissue_tracing": res, "charge": ["ask_observation (free)"]})
1544
+
1545
+
1546
+ def cmd_inspect(a, st, spec):
1547
+ assert len(spec) == 1 and next(iter(spec)) in ("slide", "tube"), 'spec = {"slide": id} or {"tube": id}'
1548
+ if "slide" in spec:
1549
+ sid, s = get_slide(st, spec["slide"])
1550
+ o = {"slide": sid, "label": s["label"], "block": s["block"], "thickness_um": s["thickness"],
1551
+ "cryostat_step": s["cryostat"], "n_sections": s["n_sections"], "scraped_sections": s["scraped"]}
1552
+ if s["stain"]:
1553
+ stn = s["stain"]
1554
+ o.update({"wash_class": stn["wash"], "stain": stn["stain"], "residual_oct": stn["oct"],
1555
+ "outer_layer": stn["outer"], "retention_pct": round(100 * stn["retention"]),
1556
+ "layer_boundary_traceable_pct_per_section": [round(100 * x) for x in stn["trace"]],
1557
+ "laser_cutting": stn["cut"], "rendering": stn["rendering"]})
1558
+ if "wash_sec" in stn: # 2026-11-06 per-section washes
1559
+ o.update({"wash_class_per_section": stn["wash_sec"], "residual_oct_per_section": stn["oct_sec"],
1560
+ "outer_layer_per_section": stn["outer_sec"], "laser_cutting_per_section": stn["cut_sec"],
1561
+ "rendering_per_section": stn["rendering_sec"]})
1562
+ for k in ("wash_class", "residual_oct", "outer_layer", "laser_cutting", "rendering"):
1563
+ o.pop(k) # slide-level summaries would hide the per-section state
1564
+ else:
1565
+ o["state"] = "sectioned, unstained, at -80 C"
1566
+ o["figures"] = INITIAL_FIGS.get(sid, [])
1567
+ lost = sum(1 for sec in s["sections"] if sum(sec.values()) < 1)
1568
+ o["sections_fully_used"] = lost
1569
+ else:
1570
+ t = get_tube(st, str(spec["tube"]))
1571
+ o = {"tube": spec["tube"], "kind": t["kind"], "target": t.get("target"), "buffer": t["buffer"],
1572
+ "roi_um2": int(round(t["roi"])) if t.get("roi") else None, "dissections": t.get("n_dis"),
1573
+ "extracted": t["extracted"]}
1574
+ out(dict(o, charge=["ask_observation (free)"]))
1575
+
1576
+
1577
+ # ---------------- 001-03: records, declines, quotes (no numbers of the measurement model) ----------------
1578
+ RECORD_FILES = ["records/README.md", "records/block_register.md", "records/2026-04-27_first_Porites_LCM_run.md",
1579
+ "records/Pacuta_LCM_pipeline.md", "protocols/2025-09-10-PFCE-Protocol.md",
1580
+ "protocols/2026-04-24-LCM-TS-Low-Input-RNA-Library-Prep.md", "protocols/2026-04-25-LCM-Protocol.md",
1581
+ "protocols/2026-05-08-LCM-RNA-Microprep.md"]
1582
+ DECLINES = { # key: (label, reason printed to the actor verbatim)
1583
+ "interpret": ("REFUSED", "That has to be tested. The lab reports measurements and observations; it does not say "
1584
+ "which cause or which option it is."),
1585
+ "not_recorded": ("UNAVAILABLE", "Not recorded. Everything the lab wrote down about these blocks, the first run "
1586
+ "and the P. acuta pipeline is in records/ and protocols/."),
1587
+ "people": ("UNAVAILABLE", "No one else in the lab has worked with these Porites blocks; the P. acuta work is "
1588
+ "summarised in records/Pacuta_LCM_pipeline.md."),
1589
+ "sequencing": ("UNAVAILABLE", "Libraries are sequenced together with the rest of the 48-sample project once the "
1590
+ "protocol is settled; test libraries are checked on the D5000 only."),
1591
+ "new_blocks": ("UNAVAILABLE", "No live coral and no further fixed material: new fixation, decalcification, OCT or "
1592
+ "paraffin embedding is not part of this round, which has the six OCT blocks of "
1593
+ "records/block_register.md."),
1594
+ "special_slides": ("UNAVAILABLE", "The lab has only PEN membrane frame slides for the LMD7; adhesive, coated, "
1595
+ "tape-transfer, hydrogel or PET slides are not in stock."),
1596
+ "carrier_rna": ("REFUSED", "The lab does not add carrier RNA to extractions that go into the low-input library "
1597
+ "prep."),
1598
+ "reelution": ("REFUSED", "Columns are discarded after the single elution of the protocol, and eluates are not "
1599
+ "re-purified."),
1600
+ "glass_histology": ("UNAVAILABLE", "The blocks are kept for PEN slides for LCM; the glass slides cut on 4/27 "
1601
+ "belong to another project."),
1602
+ "cdna_other_qc": ("REFUSED", "cDNA is quantified on the D5000 ScreenTape as part of the library prep; the lab runs "
1603
+ "no other cDNA assay."),
1604
+ "not_offered": ("NOT OFFERED", "The lab does not offer this."),
1605
+ }
1606
+ QUOTE = { # lab days per step = case.yaml actions (asserted by the 001-03 build script)
1607
+ "ask_observation": 0, "tapestation_existing": 0.5, "section_slide": 1, "stain_and_lcm": 1, "extract_rna": 0.5,
1608
+ "positive_control_fresh": 1, "whole_section_extract": 1, "library_prep": 1.5, "ask_expert_knowledge": 0,
1609
+ "qc_assay_other": 0.5, "other_bench_procedure": 1, "quote": 0,
1610
+ }
1611
+ QUOTE_TEXT = {
1612
+ "ask_observation": "looking at existing slides and tubes, re-analysing an earlier TapeStation run, FIJI tissue "
1613
+ "tracing",
1614
+ "tapestation_existing": "TapeStation HS RNA of existing eluates",
1615
+ "section_slide": "cutting PEN slides",
1616
+ "stain_and_lcm": "staining/wash series and LCM",
1617
+ "extract_rna": "RNA extraction",
1618
+ "positive_control_fresh": "fresh fragments in DNA/RNA Shield, extraction and TapeStation included",
1619
+ "whole_section_extract": "whole sections scraped, extraction and TapeStation included",
1620
+ "library_prep": "low-input library prep (1-3 samples per prep), cDNA and library D5000 included",
1621
+ "ask_expert_knowledge": "a general question",
1622
+ "qc_assay_other": "Qubit, Bioanalyzer or RT-qPCR",
1623
+ "other_bench_procedure": "another bench procedure (block curls, concentrating an eluate)",
1624
+ "quote": "a question about lab days only",
1625
+ }
1626
+
1627
+
1628
+ def cmd_decline(a, st, spec):
1629
+ strict(spec, ["what"], [], "decline")
1630
+ label, reason = DECLINES[one_of(spec["what"], DECLINES, "what")]
1631
+ print(f"{label}: {reason}")
1632
+ print("CHARGE: none")
1633
+
1634
+
1635
+ def cmd_in_folder(a, st, spec):
1636
+ strict(spec, ["file"], [], "in_folder")
1637
+ f = one_of(spec["file"], RECORD_FILES, "file")
1638
+ print(f"IN YOUR FOLDER: {f}")
1639
+ print("CHARGE: none")
1640
+
1641
+
1642
+ def cmd_quote(a, st, spec):
1643
+ strict(spec, ["actions"], [], "quote")
1644
+ for k in spec["actions"]:
1645
+ one_of(k, QUOTE, "action")
1646
+ print(f"QUOTE: {QUOTE_TEXT[k]}: {QUOTE[k]:g} lab days")
1647
+ print("CHARGE: quote (free)")
1648
+
1649
+
1650
+ CMDS = {"status": cmd_status, "section": cmd_section, "stain": cmd_stain, "lcm": cmd_lcm, "scrape": cmd_scrape,
1651
+ "curls": cmd_curls, "blank": cmd_blank, "spike": cmd_spike, "extract": cmd_extract, "fresh": cmd_fresh,
1652
+ "tapestation": cmd_tapestation, "bioanalyzer": cmd_bioanalyzer, "qubit": cmd_qubit, "qpcr": cmd_qpcr,
1653
+ "library": cmd_library, "concentrate": cmd_concentrate, "combine": cmd_combine,
1654
+ "measure_tissue": cmd_measure_tissue, "inspect": cmd_inspect, "split": cmd_split,
1655
+ "decline": cmd_decline, "in_folder": cmd_in_folder, "quote": cmd_quote}
1656
+
1657
+
1658
+ def main():
1659
+ ap = argparse.ArgumentParser()
1660
+ ap.add_argument("cmd", choices=sorted(CMDS))
1661
+ ap.add_argument("--run", required=True)
1662
+ ap.add_argument("--spec", required=True, help="JSON object, or a path to a JSON file")
1663
+ a = ap.parse_args()
1664
+ raw = a.spec.strip()
1665
+ spec = json.loads(raw) if raw.startswith("{") else json.loads(Path(raw).read_text())
1666
+ assert isinstance(spec, dict), "spec must be a JSON object"
1667
+ st = load(a.run)
1668
+ CMDS[a.cmd](a, st, spec)
1669
+ save(a.run, st)
1670
+
1671
+
1672
+ if __name__ == "__main__":
1673
+ main()
cases/001-coral-lcm-porites-03/assets/env_knowledge/research_notes_distilled.md ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Research notes (distilled): public knowledge for the coral LCM lab
2
+
3
+ Environment-only. Distilled 2026-10-11 from the two literature reviews in assets/research_raw/ (sources read there).
4
+ Use it only to answer general questions (rule 8) and to know what instruments report. Numbers for this lab's
5
+ samples come from calculators.py, never from here. Never quote this file or apply its facts to the actor's samples.
6
+
7
+ ## A. Instruments (manufacturer specifications)
8
+
9
+ - Agilent HS RNA ScreenTape (4200 TapeStation): 2 uL sample + 1 uL HS RNA sample buffer, 72 C 3 min. Sensitivity
10
+ 100 pg/uL (signal-to-noise > 3, single peak); quantitative range 500-10,000 pg/uL (accuracy +/-30 %, CV <= 15 %);
11
+ sizing 100-6,000 nt; RINe functional range 1,000-25,000 pg/uL (software 5.3 can display RINe from 100 pg/uL).
12
+ DV200 = percent of the signal above 200 nt (a region analysis, no separate minimum). Readings below the
13
+ quantitative range carry a warning flag. Agilent publishes no precision data below 500 pg/uL. Max sample buffer
14
+ 10 mM Tris / 1 mM EDTA.
15
+ - Agilent RNA 6000 Pico (2100 Bioanalyzer): 1 uL per well. Qualitative range 50-5,000 pg/uL in water (200 pg/uL in
16
+ TE); concentration estimates only for 200-5,000 pg/uL; CV 20 %, accuracy 30 %. Salt, fixation and tissue stain
17
+ affect results. At 0-200 pg/uL displayed RIN values scatter widely (one study: 0 to 7.8 for the same material).
18
+ - Qubit RNA HS: 1-20 uL sample in 200 uL; accurate for 5-100 ng in the tube (about 250 pg/uL-100 ng/uL in the
19
+ sample); below that the instrument shows "Out of range: too low".
20
+ - TapeStation D5000 / HS D5000: DNA sizing for cDNA and libraries; NEB low-input cDNA is a broad profile from
21
+ ~400 bp to several kb; final Illumina libraries peak ~250-350 bp; primers ~80 bp, adaptor dimer 128-140 bp.
22
+ - Leica LMD7: UV laser cutting, gravity collection into a tube cap holding 40 uL buffer; the cap is checked in
23
+ collector view after each cut; 4 um PEN frame slides are heavier than 2 um and drop more reliably; static can
24
+ deflect pieces. Typical section thickness 4-40 um; thicker sections need more laser energy and more passes,
25
+ lose cutting precision for small targets, curl and lift more easily.
26
+
27
+ ## B. Kits, reagents, handling
28
+
29
+ - Zymo Quick-RNA Microprep: elution >= 6 uL; column capacity 10 ug; retains RNA >= 17 nt; no carrier RNA; on-column
30
+ DNase I. Proteinase K for tissue in DNA/RNA Shield at room temperature (>= 30 min homogenized, 2-5 h for intact
31
+ tissue); 55 C 1 h then 65 C is prescribed only for crosslinked (formalin) samples. Quick-RNA Miniprep: larger
32
+ column, elution >= 50 uL. A synthetic RNA ladder spiked into Zymo Quick-RNA Mini kits was recovered >= 80 %
33
+ (plasma kit comparison); no published recovery for ~1 ng through a micro column.
34
+ - Arcturus PicoPure: extraction buffer 30 min at 42 C, elution ~11 uL, no PK step. Qiagen RNeasy Micro: elution
35
+ 14 uL; the handbook adds 20 ng poly-A carrier RNA for < 5,000 cells (carrier dominates any mass-based QC and is
36
+ captured by oligo-dT priming).
37
+ - Kit comparisons in mammalian LCM: RNeasy Micro and PicoPure give similar yield per area; RNeasy Micro higher RIN
38
+ (median 7.2 vs 6.0 in prostate LCM). No published LCM comparison includes the Zymo Microprep.
39
+ - DNA/RNA Shield inactivates nucleases; tissue and RNA are stable in it at room temperature.
40
+ - PAXgene Tissue: alcohol-based, non-crosslinking fixation followed by stabilizer; RNA quality close to frozen
41
+ tissue (paraffin PAXgene sections RIN ~7-9; after LCM ~6-7). No crosslink reversal is needed.
42
+ - Proteinase K time and heat (published, mostly formalin tissue): longer digestion raises yield of crosslinked
43
+ RNA; experts report that excessive digestion lowers DV200; for non-crosslinked material no time course with
44
+ DV200 is published. Longer/warmer lysis lowered RIN without yield gain in one mouse LCM kit comparison.
45
+ - OCT: water-soluble glycol/resin embedding medium. 100 % ethanol barely dissolves it, 70 % ethanol slowly, water
46
+ quickly. Excess OCT in a lysate lowers column yield and can distort electrophoresis. Trimming the block to about
47
+ 1 mm around the tissue reduces OCT transferred around the section; it cannot remove OCT inside tissue pores.
48
+ - Stains for LCM: ethanolic cresyl violet, eosin Y and methyl green lose < 1 RIN unit; unstained sections lose
49
+ < 1 RIN unit; aqueous stains (HistoGene, Nissl in water without inhibitor, hematoxylin) lower RIN or 28S/18S.
50
+ Cresyl violet is a basic dye and also stains residual OCT and matrix. RNase inhibitor in aqueous stains helped in
51
+ some studies and not in others (no gain with ethanolic cresyl violet).
52
+ - Water and humidity reactivate RNases in dried sections; aqueous steps can also loosen sections from the
53
+ hydrophobic PEN membrane. Published fully ethanolic protocols keep RNA stable for 90-120 min at RT.
54
+ - Condensation: let closed slide containers equilibrate stepwise (-20 C, 4 C, RT, 15-30 min each) before opening.
55
+ Very cold ethanol on a wet slide can freeze the water film; slides are worked on a rack above dry ice, not on it.
56
+ - Adhesion aids for membrane slides (Leica guide and bone LCM papers): UV-C >= 1 J, RNase decontamination, a brief
57
+ 70-100 % ethanol or ice-cold acetone step right after mounting, 15 min drying with desiccant (or 10 min at 40 C),
58
+ poly-L-lysine, tape-transfer systems (CryoJane, Kawamoto film), hydrogel slides. No published loss fractions.
59
+ - Dry dehydrated sections keep RNA quality for at least a month at -80 C; repeated block thawing lowers RIN.
60
+
61
+ ## C. Low-input RNA libraries
62
+
63
+ - NEBNext Single Cell/Low Input RNA (E6420): 2 pg-200 ng total RNA (spec for RIN >= 8), RNA in up to 8 uL.
64
+ Recommended cDNA PCR cycles: 2 pg 20-21, 10 pg 17-18, 100 pg 14-15, 1 ng 10-11, 10 ng 8-9, 100-200 ng 7-8; these
65
+ give 1-20 ng cDNA (mostly 5-15 ng). 100 pg-20 ng cDNA can go into library construction; 1-20 ng cDNA with 8 PCR
66
+ cycles typically gives 100 ng-1 ug of library; ~100 pg cDNA needs about 12 cycles; adaptor dimer is possible with
67
+ <= 1 ng input (clean up again if a 128-140 bp peak appears).
68
+ - Extra cycles beyond need raise cDNA mass toward a plateau, duplication and over-amplification products at high
69
+ molecular weight; template-switching libraries from partly degraded RNA are 3'-biased with shorter cDNA.
70
+ - Low-input benchmarks: duplication 11 % (750 pg) vs 16 % (130 pg) with SMARTer Ultra-Low; LCM-seq mapping ~90 %
71
+ from >= 10 cells, ~79 % from 1-2 cells; 50 pg total RNA did not compromise gene detection in a plant LCM study.
72
+
73
+ ## D. Corals (public)
74
+
75
+ - Porites has a perforate skeleton; tissue extends several mm into it (massive Porites mean ~5.4 mm); after
76
+ decalcification the tissue is a network of strands around former skeleton space. Symbiodiniaceae are
77
+ concentrated in the outer ~2 mm (about 5-fold denser than deeper tissue). Porites compressa in Hawaii carries
78
+ ~2.5 x 10^6 symbiont cells/cm2. Pocillopora is imperforate, with a thin tissue layer (~0.2 mm) on the skeleton.
79
+ - No published thickness of Porites oral epidermis or gastrodermis, and no tissue fraction of decalcified
80
+ sections, was found.
81
+ - Cnidarian 28S rRNA often has a hidden break and runs near 18S, so RIN/RINe algorithms trained on mammalian
82
+ profiles are less meaningful; DV200 is the usual integrity metric for such samples.
83
+ - Porites qPCR reference genes: RPL11, EIF3H, ND5 (Kenkel et al. 2011). Symbiodiniaceae genes (e.g. actin) are used
84
+ for symbiont qPCR. 3':5' assay: ratio of a 3' to a 5' amplicon after oligo-dT RT, ~1-3.5 for intact RNA and > 5-8
85
+ for degraded RNA (rat panel).
86
+ - Published Pocillopora acuta LCM pipeline (Dellaert & Putnam 2026, PLoS ONE 21:e0358454; this is lab history,
87
+ readable by anyone): PAXgene Tissue Fix 24 h RT, Stabilizer 24 h 4 C; 0.5 M EDTA pH 8.0 at 4 C with shaking,
88
+ changed daily, ~3.5 days; 15 % then 30 % sucrose; OCT; 10 um sections on 4 um PEN frame slides, 30 s 100 % EtOH,
89
+ 15 min desiccant; warm-up 30 min each -20 C, 4 C, RT; ice-cold 1 % cresyl violet in 100 % EtOH 1 min, ice-cold
90
+ 70 % EtOH rinse, 100 % EtOH 1 min, no water; LMD7 gravity collection into 40 uL PK digestion buffer; 6-11
91
+ dissections per sample, each ~2,000-33,000 um2; PK 15 min RT; Zymo Quick-DNA/RNA Microprep Plus; TapeStation HS
92
+ RNA 211-339 pg/uL (1.7-2.7 ng in 8 uL), RIN not computable, DV200 > 50 % required; E6420 with 17 cDNA cycles gave
93
+ 0.6-6.2 ng cDNA, 9-11 library cycles; >= 30 M reads, 81.7 % genome mapping.
94
+
95
+ ## E. General LCM literature (only when asked for typical values)
96
+
97
+ - Yield per dissected area in fresh-frozen mouse brain at 8 um: 13-21 ng/mm2 in cell-body layers, 0.8-1.7 ng/mm2
98
+ in cell-sparse layers. Replicate CV of matched LCM regions 12-35 %. About 10 % of dissected tissue failed to reach
99
+ the cap in one catapult study.
100
+ - Decalcification of unfixed bone in plain EDTA degraded RNA (RIN 1-2); EDTA in a stabilising medium at pH 5.2 kept
101
+ RIN 9-10. For PAXgene-fixed coral no duration series is published.
102
+ - Alternatives for fragile tissue: paraffin embedding of PAXgene-fixed tissue (LCM RIN ~7.2), tape transfer,
103
+ adhesive or hydrogel slides.
cases/001-coral-lcm-porites-03/assets/env_knowledge/research_notes_precomputed.md ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Precomputed environment knowledge: Porites LCM-RNA
2
+
3
+ Environment-only reference. It settles in advance every judgment past sessions had to make, so the session only
4
+ maps requests, runs calculators.py and renders. Never quote this file, its headings, ids or reasoning to the actor.
5
+ Where this file and calculators.py disagree on a number, the calculator wins; where it and the CASE-SPECIFIC
6
+ INSTRUCTIONS disagree on wording, the instructions win.
7
+
8
+ ## 0. Calculator conventions and mapping
9
+
10
+ - One run for the session: `python3 calculators.py <cmd> --run s1 --spec '<json>'`. All keys in the docstring are
11
+ required; an assertion message means the spec or the request is impossible as stated (fix the spec, or tell the
12
+ actor plainly what the lab can do). A failed command changes nothing.
13
+ - Existing at the start: POR_3-S1 ("POR_3 slide 1", standard protocol, dissected 4/28), POR_3-S2 ("POR_3 slide 2",
14
+ stained 4/28, not dissected), eluates 1, 2, 9, 13 (6 uL left each). Two POR_3 slides remain to be cut.
15
+ - Names. Slides: pass the actor's name as "label" and use it in the observation; the calculator id is
16
+ `<block>-S<n>`. Tubes: the actor's names; if the actor gives none, T1, T2, ... in order through the session (never
17
+ number tubes like the record). Eluate id = tube id for a one-tube column; a pooled column gets a new name.
18
+ - Section, stain and dissect in one request: `section`, then `stain`, then `lcm` (one stain_and_lcm charge).
19
+ - `stain` performs a wash series. To describe a stained slide again, use `inspect`; run `stain` on it again only
20
+ when the actor asks for another wash or stain series on that slide. Integrity of an eluate already run on the
21
+ TapeStation: `tapestation` with "reanalyze": true, not a new run.
22
+
23
+ ### Wash series -> `wash` (classify by water exposure; the order of ethanol steps decides only the two ethanol classes)
24
+
25
+ | Actor's series (key features) | wash |
26
+ |---|---|
27
+ | lab standard: cresyl 1 min, ice-cold 70 % EtOH rinse and cover, brief water only where OCT remains, 100 % EtOH | standard |
28
+ | any series without water in which 70-96 % EtOH follows the stain (with or without 70-75 % EtOH before it): e.g. 75 % 2 min, cresyl, 70 %, 100 %; 70 % 3 + 2 min, 96 %, 100 %, cresyl, 70 % 1 min + rinse, 96 %, 100 %; cresyl, 100 % rinse, 70 % several covers, 96 %, 100 %; 70 % 3 x 1 min, cresyl, 70 % rinse, 100 % | ethanol_only |
29
+ | no water; 70 % EtOH (about 30 s to 2 min) and/or 96 % before the stain, cresyl, stain rinsed off with 100 % EtOH only | prewash_100rinse |
30
+ | one ice-cold water dip or rinse of <= 15 s ("10 s where OCT remains") in an otherwise ethanolic series, stained or not | brief_water |
31
+ | water applied drop-wise, up to 2 x 15 s, or two dips of <= 15 s | dropwise_water |
32
+ | water dips or rinses totalling about 30-60 s (e.g. 2 x 30 s before the stain) | water_dips_60s |
33
+ | 5-6 dunks in water troughs, or more than 60 s of water | trough_dunks |
34
+ | graded 75/50/30 % EtOH with water steps (PAXgene-like), any series with two or more water steps of >= 30 s | graded_aqueous |
35
+
36
+ Different water exposures on different sections of one slide (water put on each section separately, e.g. no
37
+ water on section 1 and 15/30/60/120 s on sections 2-5): run it, never decline it. Pass "wash" as a list with one
38
+ class per section, each classified by the table above (no water: the ethanol class of the rest of the series).
39
+ The lab puts the whole series (ethanol, water, stain) on as drops on each section with the slide held flat, so it
40
+ can also reach chosen sections only: on a slide already through a series, sections the actor wants left as they
41
+ are get "untouched" in the wash list (and "none" in a stain list); e.g. a second series on sections 3-5 with
42
+ sections 1-2 kept is ["untouched", "untouched", <class>, <class>, <class>]. The stain may differ per section too:
43
+ "stain" as a list (e.g. cresyl 1 min on sections 1-4 and 30 s on section 5). Never answer that a series has to
44
+ cover the whole slide. Report each section with its own printed numbers and the rendering text of its own
45
+ rendering id (rendering_per_section); an untouched section keeps its earlier description.
46
+
47
+ Stain: cresyl 1 min -> cresyl_1min; 20-45 s -> cresyl_30s; diluted cresyl -> cresyl_dilute; washes only -> none;
48
+ H&E -> aqueous_HE; eosin Y or methyl green in ethanol -> ethanolic_other; toluidine blue or hematoxylin in water ->
49
+ aqueous_other. Warm-up: onto the dish over dry ice straight from -80 C -> direct; -20 C / 4 C / RT steps -> slow;
50
+ warmed or opened on the open bench -> open. RNase inhibitor in stain or water -> rnase_inhibitor true. Cryostat step:
51
+ any 100 % EtOH cover -> 100EtOH; 70 % EtOH cover -> 70EtOH; air or silica drying only -> none.
52
+
53
+ ### Dissection -> `lcm`
54
+
55
+ - target: outer layer / oral epidermis -> oral_epidermis; symbiont layer / oral gastrodermis -> oral_gastrodermis;
56
+ bulk, big pieces, all tissue -> bulk. buffer: PK / digestion buffer -> PK; DNA/RNA Shield -> Shield; kit RNA lysis
57
+ buffer -> RNA_lysis.
58
+ - clean_only true when the actor restricts to intact stretches, clearly separated layers or "avoid mixed regions".
59
+ - amount: left open ("several dissections per tube", "dissect epidermis and gastrodermis", "a few pieces") ->
60
+ {"lab_default": true}; a count -> n_dissections; an ROI target -> roi_um2; a tissue-area target ("100,000 um2 of
61
+ traced tissue", "equal tissue area per tube") -> tissue_um2; "all", "as much as possible" -> all.
62
+ - When `stain` printed `_recorded_tube_plan` and the actor leaves the number of tubes or buffers open, make one tube
63
+ per plan entry (same target and buffer, lab_default). If the actor specifies tubes, follow the actor.
64
+ - Report roi_um2 as the total dissection area, the number of dissections collected and any that did not reach the
65
+ cap. `limited` text goes into the observation as a physical limit. tissue_in_roi_um2 only when asked.
66
+
67
+ ### Extraction -> `extract`, `scrape`, `curls`, `blank`, `spike`, `fresh`
68
+
69
+ - digestion: 15 min RT -> 15minRT; 30 min RT -> 30minRT; 15 min 56 C (1400 rpm) -> 15min56C; 1 h 52 C (incubator,
70
+ gentle shaking) -> 1h52C; 1 h 56 C (1400 rpm) -> 1h56C; 2-4 h 56 C -> 3h56C; overnight 56 C -> overnight56C. A
71
+ time within x1.5 of a key at the same temperature uses that key (say the actor's time in the observation, note
72
+ the key in grounding); anything else is not simulatable for that tube.
73
+ - "recorded": use it for a tube that printed a non-null `_anchor_row` when the actor leaves the per-tube assignment
74
+ open ("half 15 min RT, half 1 h 52 C", "different digestions"); give the remaining tubes the requested conditions
75
+ in turn, in tube order.
76
+ - kit: Zymo Microprep -> microprep; Zymo Miniprep -> miniprep; PicoPure -> picopure; RNeasy Micro -> rneasy_micro
77
+ (no carrier RNA; if the actor wants carrier, `decline` carrier_rna, section 6).
78
+ - Several caps on one column = one column entry with several tubes.
79
+ - Pooling lysates and splitting them into arms ("pool the scraped tissue and split it into equal tissue
80
+ equivalents of 1,000,000 um2 per arm", "halve the lysate"): `split` after `scrape` or `lcm`, before `extract`;
81
+ parts by tissue_um2 (the traced area, as `measure_tissue` prints it) or by fraction; the rest stays in rest_id
82
+ (null only when the actor discards it). No charge of its own. Then one `extract` column per part. Never answer
83
+ that the smallest unit is one whole section.
84
+ - Whole sections without microdissection: `scrape` (one entry per tube, sections chosen), then `extract`, then
85
+ `tapestation`; charge whole_section_extract only. Block curls: `curls`, `extract`, `tapestation`. Extraction blank:
86
+ `blank`, `extract`. Spike-in: `blank` or an existing tube, then `spike` (synthetic, or RNA from a measured eluate),
87
+ then `extract`. Fresh tissue: `fresh`, then `tapestation` (charge positive_control_fresh only).
88
+
89
+ ### Measurements
90
+
91
+ - TapeStation HS RNA: `tapestation` ul 2 (1 if the actor says 1 uL). "integrity" true only for DV200, RIN/RINe,
92
+ integrity, degradation, gel, trace, electropherogram. DV200 of an earlier run asked later -> "reanalyze": true
93
+ (no volume, no charge). Repeat runs of one eluate return the same reading and use 2 uL each.
94
+ - Bioanalyzer Pico -> `bioanalyzer` ul 1. Qubit RNA HS -> `qubit` (ul as asked, default 2). RT-qPCR -> `qpcr`: target
95
+ host by default; add symbiont when the actor asks for Symbiodiniaceae or layer purity, spike when it asks for spike
96
+ recovery; a 3':5' (integrity) assay -> targets host_3prime and host_5prime (oligo-dT RT, one extra RT of the same
97
+ RNA volume); a standard curve is several reactions of one eluate with dilutions; report Cts as printed.
98
+ - Library prep -> `library`, 1-3 samples per prep; Qubit dsDNA of the final libraries -> qubit_dsdna true (extra
99
+ qc_assay_other). "NTC" as an eluate name = no-template control. Report cDNA and library values as printed.
100
+ Up to 3 samples in one request are ONE prep (one `library` call, one library_preps), also when the samples get
101
+ different cDNA or final cycles: give those per sample ("cdna_cycles" / "final_cycles" in samples[]). Final cycles
102
+ that depend on the cDNA yield ("11 cycles, 10 if the cDNA is above 5 ng") -> final_cycles 11 with
103
+ final_cycles_rule {"cdna_ng_above": 5, "cycles": 10}; report the cycles each sample got as printed.
104
+ - Report totals as printed (`total_pg_in_elution`) and the elution volume; never recompute pg per area for the
105
+ actor (the actor does its own arithmetic).
106
+
107
+ ## 1. Feasibility table
108
+
109
+ Default: a real lab can do it, so the environment performs it. Costs = case action keys.
110
+
111
+ | # | Operation | Action (cost) | How | Actor observes |
112
+ |---|---|---|---|---|
113
+ | 1 | Look at existing slides POR_3 1 and 2, existing tubes | ask_observation (0) | `inspect` | rendering text, printed figures |
114
+ | 2 | DV200/RINe of the first-run eluates 1, 2, 9, 13 | tapestation_existing (0.5) | `tapestation` integrity true | readings < 100 pg/uL: "DV200 not computed", RINe "-" |
115
+ | 3 | Re-analyse an earlier TapeStation run | ask_observation (0) | `tapestation` reanalyze true | integrity of that run |
116
+ | 4 | Cut PEN slides (6-25 um, cryostat step, trimming, 1-6 sections) | section_slide (1) | `section` | sectioning notes; slides at -80 C |
117
+ | 5 | Stain / wash series of any kind, stain or not, inhibitor | stain_and_lcm (1) | `stain` (section 0 mapping) | rendering text + retention %, OCT, traceable perimeter %, cutting |
118
+ | 6 | Wash an already stained slide again | stain_and_lcm (1) | `stain` again (second pass) | rendering RESTAINED_*, further loss |
119
+ | 7 | LCM: layers, bulk, clean stretches only, ROI or tissue targets, chosen sections, several buffers | stain_and_lcm (1) | `lcm` | dissections, ROI areas, failures, limits |
120
+ | 8 | Tissue area inside ROIs, block face, whole sections (FIJI) | ask_observation (0) | `measure_tissue` or measure_tissue true | traced tissue areas |
121
+ | 9 | RNA extraction, any kit, digestion, elution, pooled caps | extract_rna (0.5) | `extract` | eluate names and volumes (numbers come with QC) |
122
+ | 10 | Whole-section scrape and extraction | whole_section_extract (1) | `scrape`, `extract`, `tapestation` | TapeStation values |
123
+ | 11 | Block curls straight from a block | other_bench_procedure (1) + extract_rna (0.5) + tapestation_existing (0.5) | `curls`, `extract`, `tapestation` | curl handling note, TapeStation values |
124
+ | 12 | Fresh Porites fragment in Shield (any kit, digestion) | positive_control_fresh (1) | `fresh`, `tapestation` | TapeStation values; quantitative range |
125
+ | 13 | Extraction blank | extract_rna (0.5) (+ QC) | `blank`, `extract` | baseline reading, no peaks |
126
+ | 14 | Synthetic spike-in or fresh-RNA spike into a tube | extract_rna (0.5) (+ QC) | `spike` before `extract` | reading of the eluate; spike Ct by qPCR |
127
+ | 15 | TapeStation HS RNA | tapestation_existing (0.5) | `tapestation` | conc, total, rating, flag; integrity if asked |
128
+ | 16 | Bioanalyzer Pico, Qubit RNA HS | qc_assay_other (0.5) | `bioanalyzer`, `qubit` | instrument output |
129
+ | 17 | RT-qPCR host, symbiont, spike, 3':5' assay; standard curve; no-RT; NTC | qc_assay_other (0.5) | `qpcr` | Cts per well, melt single peak |
130
+ | 18 | Concentrate an eluate (vacuum) | other_bench_procedure (1) | `concentrate` | new volume |
131
+ | 19 | Combine eluates | none (part of the next step) | `combine` | new tube volume |
132
+ | 19b | Pool lysates (scraped or dissected, one block) and split them into arms | none (part of the extraction) | `split` | traced tissue per part |
133
+ | 20 | Low-input library prep, any cycles, NTC | library_prep (1.5), library_preps 1 per prep | `library` | cDNA and library D5000 values, figures if printed |
134
+ | 21 | Qubit dsDNA of libraries | qc_assay_other (0.5) | `library` qubit_dsdna true | ng/uL |
135
+ | 22 | Laser power, speed, passes | part of stain_and_lcm | printed `laser` text | operator notes only, no numbers |
136
+ | 23 | Questions on instruments, kits, coral biology | ask_expert_knowledge (0) | section 2 | short public answer |
137
+ | 24 | Questions on the lab's own history, inventory, the first run, the P. acuta pipeline | none | `in_folder` (file in section 2 "Lab history"), else `decline` not_recorded | "IN YOUR FOLDER: <file>" or the decline text |
138
+ | 25 | Sequencing the libraries, new blocks, special slides, carrier RNA, re-elution, glass-slide histology, other cDNA QC, other people, interpretation | - | `decline` (section 6) | the printed reason |
139
+ | 26 | How many lab days a step costs | quote (0) | `quote` | "QUOTE: " lines |
140
+
141
+ Physical limits (state as observations, not refusals): 4 PEN slides per block in total; 1-6 sections per slide;
142
+ 10 fresh fragments in Shield; 2 library preps of up to 3 samples; eluate volume as printed; no live coral, no
143
+ fresh Pocillopora tissue in the inventory.
144
+
145
+ ## 2. Expert-knowledge answers
146
+
147
+ Answer only the literal question, briefly, from this section and research_notes_distilled.md. Never connect a
148
+ general fact to the actor's samples, never list "likely causes" for this case, never rank the actor's options.
149
+ Questions of the form "what limits my yield / which change should I prioritise / is it the kit / is the RNA really
150
+ there" are `decline --what interpret`. A general textbook question inside such a request may be answered in one or
151
+ two neutral sentences.
152
+
153
+ | Question | Answer |
154
+ |---|---|
155
+ | HS RNA ScreenTape range, LOD, RINe floor | distilled A (100 pg/uL detection, 500-10,000 quantitative, RINe from 1,000; 2 uL sample) |
156
+ | Bioanalyzer Pico / Qubit RNA HS ranges | distilled A |
157
+ | What does a blank eluate read | instrument behaviour from distilled A; whether the lab ran one before: `decline` not_recorded |
158
+ | PK conditions recommended by Zymo | distilled B (RT >= 30 min for Shield samples; 55 C only for crosslinked samples) |
159
+ | Microprep minimum elution, capacity, carrier | distilled B |
160
+ | Do ethanolic stains or RNase inhibitor affect RNA | distilled B (stains paragraph) |
161
+ | How to keep sections attached on PEN | distilled B (adhesion aids) |
162
+ | OCT solubility and removal options | distilled B (OCT) |
163
+ | NEB kit input range and cycle table | distilled C |
164
+ | Porites vs Pocillopora tissue | distilled D |
165
+ | Coral reference genes, symbiont genes | distilled D |
166
+ | Typical LCM yield per area | distilled E (only when asked for typical values) |
167
+ | Published P. acuta protocol details | `in_folder` records/Pacuta_LCM_pipeline.md (the paper is also public) |
168
+ | Lab-day cost of each step | `quote` |
169
+ | What parameter options the lab supports | the actor-visible catalog values only (never the hidden menu entries) |
170
+
171
+ Lab history (rule 8; facts up to 4/28 only). Everything is in the actor's own folder; answer with `in_folder` and the
172
+ file, never by repeating or interpreting it. A history question these files do not answer: `decline` not_recorded.
173
+ - records/README.md: list of the records; freezer and kit inventory (blocks, 4 PEN slides per block and 2 left of
174
+ POR_3, POR_3 slide 2 and eluates 1, 2, 9, 13 with 6 uL each, 10 Shield fragments of the same colonies, no live
175
+ coral or fresh Pocillopora, PEN frame slides, QC reagents and kits, NEB kit for 2 preps of up to 3 samples).
176
+ - records/block_register.md: species and fixation of each block (POR_3 and POR_4 the 3/10/26 PAXgene batch; the
177
+ three POR_R blocks the time-series set, another batch; POC_R3_C2 P. acuta, same pipeline), PFCE processing, days in
178
+ EDTA not logged, PEN slides cut so far.
179
+ - records/2026-04-27_first_Porites_LCM_run.md: the first run (4/27 sectioning steps, 3 glass slides for another
180
+ project; 4/28 staining straight from -80 C with the standard series, observations, slide 1 dissected into PK
181
+ buffer, slide 2 not dissected; Microprep 8 uL; table of tubes 1, 2, 9, 13 with dissections, areas, digestions,
182
+ TapeStation rating, concentration, pg in 8 uL).
183
+ - records/Pacuta_LCM_pipeline.md: the published P. acuta pipeline (fixation, decalcification, sections, warm-up,
184
+ stain without water, LCM, PK 15 min RT, extraction, QC with DV200 > 50 % for library prep, E6420 cycles,
185
+ sequencing depth and mapping).
186
+ - protocols/: the PFCE, LCM, Microprep and low-input library protocols as used for the first run.
187
+
188
+ ## 3. Non-numeric renderings
189
+
190
+ Slides (rendering id printed by `stain`/`inspect`). Add the printed numbers: retention %, traceable perimeter %,
191
+ laser text. "16-20 um" sections: tissue darker, strands overlap, layers harder to follow.
192
+
193
+ | Rendering | Observation text (phenomena only) |
194
+ |---|---|
195
+ | REC_0428_POR3_S1 / STANDARD | Purple-stained OCT fills many tissue gaps; tissue overall acceptable on the PEN membrane; oral epidermis and oral gastrodermis hard to tell apart. |
196
+ | REC_0428_POR3_S2 | As slide 1, with more purple OCT and less distinct tissue; looks worse than slide 1. |
197
+ | REC_0506_POR4 / ETHANOL_ONLY | A lot of OCT remains as sheets and folds over and between the sections, only lightly purple; folds lie across tissue edges and get in the way of the cuts; tissue well retained, outer margin continuous; layers can be followed only where the sheet is thin. If both POR_4 slides of that day are seen: the one with ethanol at the cryostat has marginally better tissue, same OCT. |
198
+ | REC_0511_R72C2_ETOH | Very much OCT, more than on the first-run slides; very dark purple; tissues hard to see and to tell apart; laser cutting surprisingly easy. |
199
+ | REC_0529_NOPREWASH | A lot of OCT left with cracking through it; difficult to cut because of the OCT; outer tissue layers look intact. |
200
+ | REC_0529_PREWASH / PREWASH_100RINSE | Easier to cut; outer tissue layers look less intact (thinned or frayed along much of the margin); a thin pale OCT film stays in many gaps, no thick sheets. |
201
+ | BRIEF_WATER, DROPWISE_WATER | OCT mostly gone from the membrane, a little left in tissue gaps; small fragments came off at margins and section ends during the water step; outer layer frayed in places; layers can be followed where the margin is intact. |
202
+ | REC_0513_R72C2_NOSTAIN / *_NOSTAIN | Unstained: looks acceptable; tissue structure visible, layer boundaries faint (stain would help a little); some tissue loss and small bare membrane patches after the water step. |
203
+ | REC_0522AM_H1 | Does not look good: tissue patchy and broken up, outer tissue frayed or missing in parts, OCT left in some gaps, weak contrast, layers distinguishable only in scattered areas. |
204
+ | WATER_DIPS_60S | Fragments lift off section edges during the dips; about half of each outline left bare; OCT largely removed, gaps clean; outer band missing along most of the perimeter; stain lighter. |
205
+ | TROUGH_DUNKS / REC_0522PM_R3H1 | Tissue comes off during the dunks; much tissue lost; what remains is fragmented with broken edges; OCT largely removed; layers cannot be reliably told apart. |
206
+ | REC_0522PM_R72H1 (and TROUGH_DUNKS on R72_H1) | Essentially all tissue came off the membrane during the dunks; only scattered small fragments remain. |
207
+ | REC_0511_GRADED_POR4 / GRADED_AQUEOUS | Severe tissue loss; tissue layers cannot be distinguished; ice formed in parts of the slide where cold water met very cold 100 % EtOH; OCT gone. |
208
+ | REC_0527_POC / POC_* | Pocillopora sections look good: tissue intact and flat, little OCT, oral epidermis and gastrodermis clearly distinguishable, clean cuts. If both cryostat variants are seen: the one without ethanol at the cryostat looks marginally better. |
209
+ | RESTAINED_* | Second series on a stained slide: stain paler, further tissue loss as printed, OCT state as printed. |
210
+
211
+ Colours: cresyl violet = violet tissue, OCT pale lilac to purple; H&E = blue nuclei, pink cytoplasm; unstained =
212
+ grey-brown tissue with golden-brown round symbiont cells in the gastrodermis. Symbiont cells are visible in all
213
+ Porites gastrodermis at 20x. Condensation (warmup open): droplets on the slide when the tube is opened.
214
+
215
+ TapeStation HS RNA traces (`trace`, integrity requests only):
216
+ - HS_FLAT: lower marker only, flat baseline, no bands, red warning, RINe "-".
217
+ - HS_FAINT: lower marker, faint smear, at most faint bands near 1,000 and 2,000 nt, red warning, RINe "-".
218
+ - HS_LOW_GOOD: two visible bands near 1,000 and 2,000 nt over a low smear; red warning (below quantitative range).
219
+ - HS_LOW_DEGRADED: weaker bands, smear shifted to shorter sizes, extra fragment bands between 200 and 1,000 nt,
220
+ more signal from 25 to 200 nt.
221
+ - HS_Q_GOOD: strong ribosomal bands, little smear below 200 nt. HS_Q_MID: bands clear, moderate smear below 500 nt.
222
+ HS_Q_DEGRADED: bands reduced, broad smear toward low sizes.
223
+ Bioanalyzer: PICO_FLAT no peaks above the marker; PICO_NOISY noisy baseline, no ribosomal peaks; PICO_WEAK small
224
+ peaks 1.5-3x above baseline; PICO_GOOD clear ribosomal peaks; PICO_DEGRADED peaks lower, smear to low sizes.
225
+ Libraries: LIB_GOOD cDNA broad multi-humped profile ~400-3,500 bp, final library single main peak 200-600 bp with a
226
+ tail to 1,500-2,000 bp; LIB_LOW smaller signal, more low-MW products; LIB_NTC only primer/adaptor-dimer peaks below
227
+ 150 bp. A high-MW hump (printed true) = second broad peak above 1,000 bp. Curl cutting and sectioning: printed notes.
228
+
229
+ Figures: attach exactly what the calculator printed for this request (first matching use only). Index:
230
+ 4/28 POR_3 slides (Slide1/Slide2 OV 5X, slide 1 dissection images); 5/6 POR_4 slides 1 and 2 (OV 5x, tubes 17/18
231
+ and 14/15 dissection images); 5/11 POR_4 graded slide (slide3fail, bulk tube 34 image); 5/13 R72_C2 slides 1 and 2
232
+ (overviews, tubes 60/61 and 51/52/53 images); TapeStation gels of 5/8 AM/PM, 5/13, 5/14 (only when every lane is a
233
+ recorded eluate of this session measured with integrity); cDNA and library D5000 traces of the three recorded
234
+ library samples. No figures exist for any other condition: describe in words.
235
+
236
+ ## 4. Bookkeeping rules (from past inconsistency flags)
237
+
238
+ 1. Every number comes from one calculator call for that material. Never copy a recorded row to a new tube, block or
239
+ repeat (past runs returned tube 1's values for an R72_C2 tube). Same material re-measured = same printed value.
240
+ 2. Volumes: copy `ul_left`. TapeStation uses 2 uL per run, Bioanalyzer 1 uL, qPCR the RNA put into RT (twice with a
241
+ no-RT control), libraries up to 8 uL. Do not invent qPCR or QC volumes the actor did not ask for; use the defaults
242
+ in section 5 and state them.
243
+ 3. Whole sections and LCM come from the same tissue model in the calculator; never quote a tissue area or per-area
244
+ yield that the calculator did not print.
245
+ 4. Charges: TapeStation runs outside composites are tapestation_existing (also when done in the same request as an
246
+ extraction). A dissection on a slide stained in an earlier request is charged stain_and_lcm again in that
247
+ request. One library prep covers up to 3 samples. Composite actions include their own extraction and QC.
248
+ 5. If the actor only asks again for results already produced, repeat them from session_record.md, charge nothing,
249
+ and do not rerun calculator commands (that would consume material).
250
+ 6. Never volunteer DV200, RINe, traces or tissue areas that were not requested. Never add unrequested assays.
251
+ 7. Do not attach figures for model-derived conditions; say nothing about "no image file".
252
+ 8. Keep slide and tube names stable for the whole session; status shows them with labels.
253
+ 9. When the actor's request contradicts the material state (slide already scraped, tube already extracted, no
254
+ volume left), report the physical state as an observation.
255
+
256
+ ## 5. Lab defaults (for anything the actor leaves open; state the values used)
257
+
258
+ - Sectioning: 10 um, 5 sections per PEN slide, ice-cold 100 % EtOH 2 min at the cryostat (1 min RT dry before,
259
+ 15 min desiccant after), block not trimmed.
260
+ - Staining: slow warm-up (protocol), wash standard, cresyl_1min, no inhibitor, dish on a rack over dry ice.
261
+ - LCM: PK collection buffer (40 uL in the cap), lab_default amount, clean_only false, measure_tissue false.
262
+ - Extraction: 15 min RT PK, Zymo Microprep; elution 8 uL for LCM tubes and blanks (lab practice: the whole eluate
263
+ fits the 8 uL library input), 15 uL for whole sections, curls and fresh tissue with the Microprep, 100 uL with the
264
+ Miniprep. Fresh fragment: 150 uL Shield (Microprep) or 300 uL (Miniprep). Curls: 5 x 20 um, PK, not trimmed.
265
+ - QC: TapeStation 2 uL; Bioanalyzer 1 uL; Qubit 2 uL; qPCR 1 uL RNA, no dilution, 2 replicate wells, no-RT and NTC.
266
+ - Library: all remaining eluate up to 8 uL, 17 cDNA cycles and 8 library cycles (lab protocol), no Qubit dsDNA.
267
+
268
+ ## 6. Declines (`decline --what <key>`; nothing consumed or charged; the printed reason goes to the actor verbatim)
269
+
270
+ | Request | key |
271
+ |---|---|
272
+ | "What limits my yield", "is it the kit", "which change should I prioritise", "is the RNA really there", "explain this result" | interpret |
273
+ | Lab history not in records/ or protocols/ (decalcification days per block, colony or time point behind a code, cryostat temperature of the first run, earlier blanks or spike-ins, LMD7 cap times); NOT the traces or DV200 of an earlier TapeStation run, which is `tapestation` reanalyze (row 3) | not_recorded |
274
+ | Asking another person (PI, a colleague, the P. acuta authors) | people |
275
+ | Sequencing the libraries (reads, mapping, duplication) | sequencing |
276
+ | New blocks: re-fixation, decalcifying or embedding new material (OCT or paraffin), blocks from the Shield fragments | new_blocks |
277
+ | Adhesive, coated (e.g. poly-L-lysine), tape-transfer, hydrogel or PET slides | special_slides |
278
+ | Carrier RNA in any extraction | carrier_rna |
279
+ | Second elution of a column, re-purification or clean-up of an eluate | reelution |
280
+ | Glass-slide H&E, confocal or other morphology slides | glass_histology |
281
+ | Bioanalyzer HS DNA, Qubit or any other assay of cDNA (the D5000 cDNA values come with `library`) | cdna_other_qc |
282
+ | Anything else the lab cannot do and no row above covers | not_offered |
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION1_AREA1_TUBE11_OE_1.jpeg ADDED

Git LFS Details

  • SHA256: 592699fc3e189078e4a5f0a06396d010744a7df02c10d4450c7bd93c7e841886
  • Pointer size: 131 Bytes
  • Size of remote file: 946 kB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION1_AREA1_TUBE12_OG_1.jpeg ADDED

Git LFS Details

  • SHA256: ab0099ab3cbfcaf14829797ea77a308f8d2474b1816fbed6ecff26b38ecc3a77
  • Pointer size: 131 Bytes
  • Size of remote file: 848 kB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION5_AREA2.jpeg ADDED

Git LFS Details

  • SHA256: afc2832d7fbc47287249282963a2719e490591abe899d6c5ca0c2c5fda81214c
  • Pointer size: 132 Bytes
  • Size of remote file: 1.07 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__SLIDE1_SECTION5_AREA2_TUBE2_OG_2.jpeg ADDED

Git LFS Details

  • SHA256: ca27d65b5ac1e612f6ff70dc65a8ea275da34ee61f9f8976dff8f2d6e4e1eb2f
  • Pointer size: 131 Bytes
  • Size of remote file: 924 kB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__Slide1_OV_5X.jpg ADDED

Git LFS Details

  • SHA256: c076ef9e12196836cc2cfaca4770b6498ab0e4154fb0006a1036086607635fee
  • Pointer size: 132 Bytes
  • Size of remote file: 3.99 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260428__Slide2_OV_5X.jpg ADDED

Git LFS Details

  • SHA256: 7089699213228446e8cc25cc7ec8a2825d33423c02b90187a30e5facca1e28a8
  • Pointer size: 132 Bytes
  • Size of remote file: 4.33 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA1_TUBE17_OE_1.jpeg ADDED

Git LFS Details

  • SHA256: 39edde58211d78864d911173bdba67ae470939f232bacfb00d95ceb5c91fa291
  • Pointer size: 132 Bytes
  • Size of remote file: 1.39 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA1_TUBE18_OG_1.jpeg ADDED

Git LFS Details

  • SHA256: b7cbe15e9d89f7092dca566d658059c740e89f840ec00e5498df619b8f8ffbcb
  • Pointer size: 132 Bytes
  • Size of remote file: 1.32 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA2_TUBE17_OE_2.jpeg ADDED

Git LFS Details

  • SHA256: 30a0051aed514c11131c703c124c12c58d3dc140a3d855ba1db1443f9c262461
  • Pointer size: 132 Bytes
  • Size of remote file: 1.39 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE1_SECTION1_AREA2_TUBE18_OG_2.jpeg ADDED

Git LFS Details

  • SHA256: 86856cf27d983029bf56d01f4bf460d123164dea22f9a118881d2e9ce2a6e261
  • Pointer size: 132 Bytes
  • Size of remote file: 1.33 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE2_SECTION2_AREA1_TUBE14_OE_1_POST.jpeg ADDED

Git LFS Details

  • SHA256: cbec85aa93855a58420d2867d8ddc9b0c5d380e7d126c1d4fb8f3c7f58ad5c8b
  • Pointer size: 132 Bytes
  • Size of remote file: 1.02 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__SLIDE2_SECTION2_AREA1_TUBE15_OG_1.jpeg ADDED

Git LFS Details

  • SHA256: c88d37536f179334417857f92dae3ea7ce790859aeacd9df1b613537a8816233
  • Pointer size: 132 Bytes
  • Size of remote file: 1.01 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__Slide1_OV_5x.jpg ADDED

Git LFS Details

  • SHA256: 94ce837724b447efb3e06ee5ac0e94adb0464600bea718fe39bb3a902f8673d3
  • Pointer size: 132 Bytes
  • Size of remote file: 4.3 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260506__Slide2_OV_5x.jpg ADDED

Git LFS Details

  • SHA256: 718fb9cf7ed18c6ab7f0719c65a29f99a31884bb5a0ab86ebdbf7ef667e81dc4
  • Pointer size: 132 Bytes
  • Size of remote file: 4.33 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260511__SLIDE3_AREA1_SECTION5_TUBE34_PK_BULK.jpg ADDED

Git LFS Details

  • SHA256: aa54b9ee4d9c3a7bbd64710e023bb5503b91083c4112c45a0cec9af8317bc157
  • Pointer size: 132 Bytes
  • Size of remote file: 1.02 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260511__slide3fail.jpg ADDED

Git LFS Details

  • SHA256: d46c0473414d5b79a49d1e37a6876d18a4dd95961acd50b035018366670f04f8
  • Pointer size: 132 Bytes
  • Size of remote file: 3.74 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__POR_R72_C2_Slide1.jpg ADDED

Git LFS Details

  • SHA256: 60c3b0c705fb378baab2dce6adeb5fbb9e53b935b88ee2bfaf49c2b89768d612
  • Pointer size: 132 Bytes
  • Size of remote file: 4.16 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__POR_R72_C2_Slide2_Nostain_5x_OV.jpg ADDED

Git LFS Details

  • SHA256: 886d4a4a8767141a4e1fb1cb307fdfd3e5b116ec64f12847d3a2b7ce716c0686
  • Pointer size: 132 Bytes
  • Size of remote file: 4.05 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA1_TUBE60_OE_1.jpeg ADDED

Git LFS Details

  • SHA256: 44788dfb53b2749a18185b61c9709c147298f02f7f48cd163a7c7931f2a8c0ff
  • Pointer size: 132 Bytes
  • Size of remote file: 1.17 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA1_TUBE61_OG_1.jpeg ADDED

Git LFS Details

  • SHA256: fc6c04e8011d00667fd1cfbd169f51cf8022861b1ec622598635b7622945aa2f
  • Pointer size: 131 Bytes
  • Size of remote file: 906 kB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA4_TUBE60_OE_4.jpeg ADDED

Git LFS Details

  • SHA256: 04b04c35a3fb5c8cccbbd2063c0a9baac70d519a41f583249eb6646d9e0e2137
  • Pointer size: 132 Bytes
  • Size of remote file: 1.15 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__SLIDE1_SECTION2_AREA4_TUBE61_OG_4.jpeg ADDED

Git LFS Details

  • SHA256: 52e29ccebb4560658b35a3f49759fe19f3f5c5b2ec7fe6815d1cf47b93de9f32
  • Pointer size: 131 Bytes
  • Size of remote file: 838 kB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area3_Tube51_OE_3.jpeg ADDED

Git LFS Details

  • SHA256: 47d7fe41dcb330e5092556d3c425ce30cb34eeb5043a19a814e930fb49a66e89
  • Pointer size: 132 Bytes
  • Size of remote file: 1.03 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area3_Tube52_OG_3.jpeg ADDED

Git LFS Details

  • SHA256: ea8d2873e090a9e50832f4e06c984157de350e4b002b81bbc4bd1289d85c20a9
  • Pointer size: 131 Bytes
  • Size of remote file: 995 kB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area5_Tube51_OE_5.jpeg ADDED

Git LFS Details

  • SHA256: 14b93a120914c602155415adc95313e39b2fb752485edc8f31847b9aec4de3f1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.1 MB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Area5_Tube52_OG_5.jpeg ADDED

Git LFS Details

  • SHA256: ce1c306c611f95f2b6ac6cdacb9432a19c72518dda9b148a0d9a9f290cadafdd
  • Pointer size: 131 Bytes
  • Size of remote file: 972 kB
cases/001-coral-lcm-porites-03/assets/figures/random__POR_LCM__20260513__Slide2_Section2_Tube53_BULK.jpeg ADDED

Git LFS Details

  • SHA256: 678437757b1b76ae61dcf4f981e255395d8ed4f389aac153a569184a5afacd32
  • Pointer size: 132 Bytes
  • Size of remote file: 1.21 MB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-08-AM.png ADDED

Git LFS Details

  • SHA256: 2e3b42ba7b223b78002d58e379ab00d173d07ec9360b778dac17daf065788a49
  • Pointer size: 130 Bytes
  • Size of remote file: 71.8 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-08-PM.png ADDED

Git LFS Details

  • SHA256: e206a2befd45eb1d1fdb4bc040f7f9ebbbbe6a3ca690c9a379c713f8bcb4d0b6
  • Pointer size: 130 Bytes
  • Size of remote file: 72.1 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-13.png ADDED

Git LFS Details

  • SHA256: 39e9b059ff4ca42ec3bbf9e0142b27ebcbf605c7214539b9ed49ebf754301940
  • Pointer size: 131 Bytes
  • Size of remote file: 112 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-14.png ADDED

Git LFS Details

  • SHA256: d0f9ddf9eca8807b05ef539cc3ccf3bd1cf0e9bddc1377f271ae5dcd849b3b2f
  • Pointer size: 130 Bytes
  • Size of remote file: 90.2 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_13.png ADDED

Git LFS Details

  • SHA256: 826aa01fd33ed49d563e2cc7679c291295f77d612efb6e092c5ad4ef9c6614fb
  • Pointer size: 131 Bytes
  • Size of remote file: 204 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_34.png ADDED

Git LFS Details

  • SHA256: 00865d06c4af6be8902e3e50f0d2fc59898f61a2fd486848c2751447e3ac7361
  • Pointer size: 131 Bytes
  • Size of remote file: 212 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_61.png ADDED

Git LFS Details

  • SHA256: 8e8ab82ee89b4feebc5eee6044a493c038661c78f4ffeae287b83c804a348a33
  • Pointer size: 131 Bytes
  • Size of remote file: 204 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-cDNA-D5000__cDNA_D5000.png ADDED

Git LFS Details

  • SHA256: c3f4fa5f577d9ed8873f9f023aa5579774c73e13bd94d0b567009dc88f88ac35
  • Pointer size: 130 Bytes
  • Size of remote file: 85 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_13.png ADDED

Git LFS Details

  • SHA256: 1e36158038b37f5f79eba339047bf363b2f5640e2792a29955c67e0bb10cd549
  • Pointer size: 131 Bytes
  • Size of remote file: 213 kB
cases/001-coral-lcm-porites-03/assets/figures/tapestation__2026-05-15-NEB-lib-D5000__Lib_34.png ADDED

Git LFS Details

  • SHA256: 4ef6911246009b172f93a88a72ba060c3fa8139277352a595303d9040461ea50
  • Pointer size: 131 Bytes
  • Size of remote file: 216 kB