Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ worker from the wheel the Lab installs, and the drops added in the lab
set the dose (two 50 µL drops of 10 µM paclitaxel in 5.1 mL give
0.196 µM). Graphics presets from Low (older laptops, 30 fps) to Ultra.

**Four more experiments in the lab.** A dose–response curve: a
micropipette (2–200 µL, a fresh tip for every solution), a 6-well plate
whose wells are each their own engine run, and a plate reader that gives
viability against the untreated wells and the IC50 (paclitaxel on A549
at 72 h: about 40 nM). Counting cells: trypsin, trypan blue and a
Neubauer hemocytometer, the count checked against the engine's dish,
scaled from the simulated patch to a 60 mm dish. Mitosis in a root tip
(acid, toluidine blue, squash, name the stage of each cell) and osmosis
in red onion cells (a simple osmotic model), both drawn, not simulated.

**Finding and handling things.** F finds anything by name, typos and
all, outlines it through walls and points the way. The thing you aim at
is outlined; a ring shows where a held item will go, red if something
is in the way. Walking speeds up and slows down, slides along benches,
and bobs and sounds with each step. Glassware has real wall thickness,
and sound effects are made in code. Shared-material parts are merged
and shadows redraw only when something moves, so the room costs about
600 draw calls.

**The repository is now `Rockman6/CellSim`**, and the site moved with it
to <https://rockman6.github.io/CellSim/>. GitHub forwards links to the
old repository name; links to the old site address no longer work.

## 1.7.0 — a CDK4/6 inhibitor, and Rb as the mechanism

**Palbociclib** (`mechanism = "cdk46"`): blocks cyclin D–CDK4/6, so Rb
Expand Down
329 changes: 174 additions & 155 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packaging/conda-forge/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test:
- python {{ python_min }}

about:
home: https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator
home: https://github.com/Rockman6/CellSim
summary: Mechanistic simulator of cultured cells under drug, with measured errors
description: |
CellSim simulates cultured cancer cells responding to a drug, from the
Expand All @@ -82,8 +82,8 @@ about:
license: MIT
license_family: MIT
license_file: LICENSE
doc_url: https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator/blob/main/docs/VALIDATION.md
dev_url: https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator
doc_url: https://github.com/Rockman6/CellSim/blob/main/docs/VALIDATION.md
dev_url: https://github.com/Rockman6/CellSim

extra:
recipe-maintainers:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ dependencies = ["numpy>=1.24", "scipy>=1.10"]
plots = ["matplotlib>=3.7"] # cellsim.cell.viewer only

[project.urls]
Homepage = "https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator"
Changelog = "https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator/blob/main/CHANGELOG.md"
Homepage = "https://github.com/Rockman6/CellSim"
Changelog = "https://github.com/Rockman6/CellSim/blob/main/CHANGELOG.md"

[project.scripts]
cellsim = "cellsim.cli:main"
Expand Down
14 changes: 7 additions & 7 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ <h1>CellSim</h1>
<a class="hero" href="lab3d/">
<img src="lab3d/screenshot.jpg" alt="The 3D lab: a microscope bench and an incubator, with daylight through the windows" width="1400" height="860">
<b>Walk into the lab →</b>
<span>A biology lab you explore in first person. Prepare onion, cheek and
pondweed slides and focus the microscope on them, or treat living cancer cells
with a drug, incubate them and compare them with an untreated dish. Those cells
are simulated by this engine, in your browser. Use a computer with a keyboard and
<span>A biology lab you explore in first person. Prepare onion, cheek, pondweed and
red onion slides, squash a root tip to find mitosis, or work with living cancer
cells: treat a dish, pipette a dose–response plate, or count cells in a
hemocytometer. Those cells are simulated by this engine, in your browser. Use a computer with a keyboard and
mouse; the first culture dish takes about half a minute to start the engine.</span></a>

<h2>Run an experiment in your browser</h2>
Expand Down Expand Up @@ -115,9 +115,9 @@ <h2>How far to trust it</h2>
development when re-measuring showed one rested on a single surviving lineage
and the other on one random seed.</p>
<ul>
<li><a href="https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator/blob/main/docs/VALIDATION.md">Validation page</a> — every number, with its reproducer and its caveat</li>
<li><a href="https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator/blob/main/docs/PLAN.md">Plan</a> — what is done, what is next, what is out of scope</li>
<li><a href="https://github.com/Rockman6/CellSim-3D-Multicellular-Biology-Drug-Testing-Simulator">Source</a> — MIT licensed</li>
<li><a href="https://github.com/Rockman6/CellSim/blob/main/docs/VALIDATION.md">Validation page</a> — every number, with its reproducer and its caveat</li>
<li><a href="https://github.com/Rockman6/CellSim/blob/main/docs/PLAN.md">Plan</a> — what is done, what is next, what is out of scope</li>
<li><a href="https://github.com/Rockman6/CellSim">Source</a> — MIT licensed</li>
</ul>

<footer>The viewer renders simulation output and runs no biology of its own.</footer>
Expand Down
32 changes: 21 additions & 11 deletions web/lab3d/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# CellSim Lab
# CellSim

A biology lab you walk into in first person. Prepare slides of onion skin, cheek cells or a pondweed leaf, then focus a microscope on them. Or grow living A549 lung cancer cells, treat them with a drug and incubate them. The living cells are simulated by the Cell Sim engine (`cellsim.cell.dish`), running in the browser.
A biology lab you walk into in first person. Prepare slides of onion skin, cheek cells, a pondweed leaf, a squashed root tip or red onion skin, then focus a microscope on them. Or grow living A549 lung cancer cells, treat them with a drug and incubate them. The living cells are simulated by the CellSim engine (`cellsim.cell.dish`), running in the browser.

## Run it

Browsers block 3D models and the engine on pages opened straight from a file, so serve the `web` folder:

```bash
cd "Cell Sim/web"
cd CellSim/web
python3 -m http.server 8000
```

Expand All @@ -16,7 +16,7 @@ Then open <http://localhost:8000/lab3d/>.
The engine uses the wheel in `../lab/wheel/` (the same one the Lab page uses). GitHub Pages builds it on every deploy. To build it locally:

```bash
cd "Cell Sim"
cd CellSim
python -m pip wheel --no-deps --no-build-isolation -w web/lab/wheel .
cd web/lab/wheel && ls -t cellsim-*-py3-none-any.whl | head -1 > LATEST
```
Expand All @@ -35,6 +35,8 @@ The first time you look at a culture dish, the browser downloads Python (Pyodide
| Q | Put down the item in your hand |
| E | Inventory |
| J | Lab journal |
| F | Find anything: type its name, typos and all, and follow the blue marker; the thing is outlined, even through walls. F again stops |
| R | With the micropipette in your hand: set its volume (2–200 µL) |
| Space, Shift, Ctrl | Jump, sneak, sprint |
| Esc | Pause |
| F3 | Frame rate, draw calls and memory |
Expand All @@ -44,7 +46,11 @@ The first time you look at a culture dish, the browser downloads Python (Pyodide
- **Onion skin cells:** goggles, wash your hands, slide on the white tile, cut the onion with the scalpel, peel the skin with the forceps, one drop of iodine, cover slip, stage, then focus at 4×, 10× and 40×.
- **Your cheek cells:** swab your cheek, smear it on the slide, put the swab in the disinfectant, then add methylene blue.
- **Pondweed leaf cells:** a drop of water first, then one leaf from the tank. At 400× the chloroplasts stream around each cell.
- **Mitosis in a root tip:** cut the last 5 mm of a root from the onion by the windows, soften it in 1 M hydrochloric acid in the 60 °C water bath, stain it with toluidine blue, squash it under the cover slip with a paper towel, then click cells at 400× and name their stage. The journal works out the mitotic index.
- **Osmosis in red onion cells:** mount red onion skin in water, then draw salt solution under the cover slip with a paper towel: the protoplasts shrink from their walls. Draw water under and they swell back.
- **Living cancer cells:** take Dish A from the incubator and look at it, add drops of paclitaxel, doxorubicin or cisplatin, incubate, and compare with Dish B, the untreated control. The doses are real dilutions: two 50 µL drops of 10 µM paclitaxel in 5.1 mL of medium give 0.196 µM. The engine's cell counts appear in the journal.
- **Dose–response curve:** with the micropipette (a fresh tip for every well), put a different volume of one drug into each well of the 6-well plate, keep one well as the control, incubate 72 h and read the plate. The journal plots viability against dose and reads off the IC50. Each well is its own engine run.
- **Counting cells:** lift the cells off a dish with trypsin, mix 10 µL with 10 µL of trypan blue, load the hemocytometer and click every cell in the four corner squares. The count is checked against the engine's dish, scaled from the simulated patch to the whole 60 mm dish.

## Graphics and battery

Expand All @@ -57,36 +63,40 @@ Settings → Graphics: **Auto** picks a preset from the graphics chip.
| High | Sharper shadows, four lamps |
| Ultra | Full resolution, 4096 px shadows, all six lamps, no frame cap |

The game stops drawing when nothing moves, and the Cell Sim engine (about 150 MB of memory) only loads once a culture dish needs it.
The game stops drawing when nothing moves, the sun's shadows are redrawn only when something in the lab moves, and the CellSim engine (about 150 MB of memory) only loads once a culture dish needs it. Small parts that share a material are merged into one mesh, so the whole room is about 600 draw calls.

## What's where

| Path | |
|---|---|
| `index.html`, `css/game.css` | Screens and HUD |
| `js/main.js` | Game loop, input, inventory, the microscope stage, incubator and drawers |
| `js/main.js` | Game loop, input, inventory, the microscope stage, incubator, plate reader and drawers |
| `js/player.js`, `js/audio.js` | Walking (speeding up, slowing down, sliding along benches, head bob by stride) and the sound effects, made in code |
| `js/finder.js`, `js/outline.js` | Find anything (typo-tolerant search) and the outlines round what you aim at or look for |
| `js/room.js` | The room, furniture, lights and colliders |
| `js/items.js` | Every item and what left- and right-click do with it |
| `js/props.js` | Equipment built in code: slides, bottles, beakers, dishes, the pondweed tank, tools |
| `js/props.js` | Equipment built in code: glassware with real wall thickness, bottles, the micropipette, the 6-well plate, the hemocytometer, the water bath, tools |
| `js/liquids.js` | Volumes, colour mixing and drug dilution |
| `js/scope.js`, `js/specimens.js`, `js/culture.js` | The view through the eyepiece |
| `js/engine.js`, `js/engine-worker.js`, `js/lab_engine.py` | The Cell Sim engine, in a background worker |
| `js/engine.js`, `js/engine-worker.js`, `js/lab_engine.py` | The CellSim engine, in a background worker |
| `js/tasks.js`, `js/journal.js` | Experiments and the lab journal |
| `assets/` | Models, textures and lighting (`downloads/` holds the raw Sketchfab files and is not committed) |

## Honest notes

- The living cells are the engine's: positions, cell-cycle phase, p53, caspase-3 and DNA damage come from `run_dish_stream`. Only their outlines are drawn here.
- The onion, cheek and pondweed slides are drawn at measured cell sizes. They are not simulated.
- The onion, cheek, pondweed, root tip and red onion slides are drawn at measured cell sizes and, for the root tip, measured stage proportions (about 12 % of meristem cells dividing). They are not simulated.
- Osmosis follows a simple osmotic model (each cell's sap about 0.55 osmol/L, varying cell to cell; a protoplast shrinks to sap ÷ outside), sped up so it happens in seconds. It is not the CellSim engine.
- Softening the root tip takes 20 s here instead of 5 minutes.

## Credits

- **Cell engine:** Cell Sim (MIT), in the browser via Pyodide.
- **Cell engine:** CellSim (MIT), in the browser via Pyodide.
- **3D engine:** three.js r160 (MIT).
- **Poly Haven (CC0):** yellow onion, metal stool, steel shelves, fluorescent lights, drawer cabinet, clipboard, stationery, wall clock, magnifying glass, binder notebook, metal office desk, floor tiles, painted plaster, and the hospital room HDRI.
- **Sketchfab (CC Attribution 4.0):**
- [Chemistry Lab Table](https://sketchfab.com/3d-models/chemistry-lab-table-fc5951d8af674da4bf55aef0693ff1d0) by Jawahar Yokesh
- [lab bench](https://sketchfab.com/3d-models/lab-bench-1ac2a62c52a848bbaf746146dc7253f8) by Konstantin_Keller (the incubator)
- [Compound Microscope](https://sketchfab.com/3d-models/compound-microscope-8709be06c5b24549b19bba7a1988a56f) by kg007
- [Door Classroom](https://sketchfab.com/3d-models/door-classroom-9-mb-fcc87f41b47f49a8941d2b6847246909) by Mehdi Shahsavan
- **Built in code:** the room, slides, cover slips, bottles, beakers, culture dishes, the pondweed tank, the lab tools, the safety goggles, the hand sanitizer and the window blinds.
- **Built in code:** the room, slides, cover slips, bottles, beakers, culture dishes, the 6-well plate, the micropipette and tips, microtubes, the hemocytometer, the plate reader, the water bath, the pondweed tank, the lab tools, the safety goggles, the hand sanitizer, the window blinds and the sound effects.
43 changes: 43 additions & 0 deletions web/lab3d/css/game.css
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,46 @@ input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent);
.eyepiece { --ep: min(calc(100vw - 32px), 50vh); }
.scope-panel { flex: none; width: 100%; }
}

/* ---------- aiming ---------- */
.crosshair.on::before, .crosshair.on::after { background: var(--key); }
.crosshair.blocked::before, .crosshair.blocked::after { background: var(--bad); }
.prompt .p.blocked { color: var(--bad); }

/* ---------- find anything ---------- */
.finder { place-items: start center; padding-top: 12vh; background: rgba(6, 9, 11, 0.45); }
.find-panel { gap: 10px; }
.find-input { width: 100%; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.08); font: 500 18px/1.2 var(--font-body); user-select: text; -webkit-user-select: text; }
.find-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.find-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 50vh; overflow: auto; }
.find-results li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 12px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; }
.find-results li b { font: 600 15px/1.2 var(--font-display); }
.find-results li .where { grid-column: 1; color: var(--muted); font-size: 13px; }
.find-results li .dist { grid-row: 1 / span 2; grid-column: 2; align-self: center; font: 500 13px var(--font-mono); color: var(--muted); }
.find-results li[aria-selected="true"], .find-results li:hover { background: rgba(91, 140, 255, 0.16); border-color: rgba(91, 140, 255, 0.5); }
.find-results .empty, .find-results .sect { cursor: default; color: var(--muted); font-size: 13px; padding: 6px 12px; }
.find-results .sect { font: 600 11px/1.2 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; }
.find-hint { position: absolute; left: max(16px, env(safe-area-inset-left, 0px)); bottom: 22px; font-size: 13px; color: var(--muted); background: var(--glass); border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px; }
.track-marker { position: absolute; left: 0; top: 0; display: grid; justify-items: center; gap: 2px; margin: -14px 0 0 0; pointer-events: none; text-shadow: 0 1px 3px #000; will-change: transform; }
.track-marker > * { transform: translateX(-50%); position: relative; left: 0; }
.track-marker b { font: 600 14px/1.1 var(--font-display); color: #cfe0ff; white-space: nowrap; }
.track-marker span { font: 500 12px var(--font-mono); color: #cfe0ff; }
.track-marker .arrow { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(91, 140, 255, 0.3), 0 0 14px rgba(91, 140, 255, 0.8); animation: ping 1.4s ease-out infinite; }
.track-marker.edge .arrow { border-radius: 0; background: none; box-shadow: none; animation: none; width: 0; height: 0; border-left: 14px solid var(--accent); border-top: 9px solid transparent; border-bottom: 9px solid transparent; transform: translateX(-50%) rotate(var(--a, 0rad)); filter: drop-shadow(0 0 6px rgba(91, 140, 255, 0.9)); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(91, 140, 255, 0.6), 0 0 14px rgba(91, 140, 255, 0.8); } 100% { box-shadow: 0 0 0 14px rgba(91, 140, 255, 0), 0 0 14px rgba(91, 140, 255, 0.8); } }

/* ---------- micropipette ---------- */
.pip-readout { font: 600 48px/1 var(--font-mono); text-align: center; letter-spacing: 0.04em; }
.pip-readout output { color: var(--key); }
.pip-steps { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pip-steps .mbtn { min-width: 48px; text-align: center; }
#pipRange { width: 100%; }

/* ---------- microscope extras ---------- */
.seg.wells button { font-size: 14px; padding: 7px 4px; }
.readout.osmo { background: rgba(178, 40, 110, 0.18); border: 1px solid rgba(178, 40, 110, 0.45); border-radius: 6px; padding: 7px 10px; }
.stage-btns { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.stage-btns .mbtn { text-align: center; }
.count-t { border-collapse: collapse; font-size: 14px; }
.count-t th, .count-t td { padding: 4px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.count-t td { font-family: var(--font-mono); text-align: right; }
Loading
Loading