@biolibs/bionet-tools 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +50 -0
  2. package/dist/digest-bench.d.ts +1 -1
  3. package/dist/digest-bench.d.ts.map +1 -1
  4. package/dist/digest-bench.js +16 -1
  5. package/dist/digest-bench.js.map +1 -1
  6. package/dist/index.d.ts +6 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +6 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/ligate-bench.d.ts +1 -1
  11. package/dist/ligate-bench.d.ts.map +1 -1
  12. package/dist/ligate-bench.js +12 -1
  13. package/dist/ligate-bench.js.map +1 -1
  14. package/dist/pcr-bench.d.ts +1 -1
  15. package/dist/pcr-bench.d.ts.map +1 -1
  16. package/dist/pcr-bench.js +19 -0
  17. package/dist/pcr-bench.js.map +1 -1
  18. package/dist/primer-bench.d.ts +120 -0
  19. package/dist/primer-bench.d.ts.map +1 -0
  20. package/dist/primer-bench.js +285 -0
  21. package/dist/primer-bench.js.map +1 -0
  22. package/dist/primer-design.d.ts +273 -0
  23. package/dist/primer-design.d.ts.map +1 -0
  24. package/dist/primer-design.js +273 -0
  25. package/dist/primer-design.js.map +1 -0
  26. package/dist/primer-working.d.ts +154 -0
  27. package/dist/primer-working.d.ts.map +1 -0
  28. package/dist/primer-working.js +245 -0
  29. package/dist/primer-working.js.map +1 -0
  30. package/dist/tools.d.ts +8 -4
  31. package/dist/tools.d.ts.map +1 -1
  32. package/dist/tools.js +9 -4
  33. package/dist/tools.js.map +1 -1
  34. package/dist/working.d.ts +16 -0
  35. package/dist/working.d.ts.map +1 -1
  36. package/dist/working.js +21 -0
  37. package/dist/working.js.map +1 -1
  38. package/package.json +3 -2
  39. package/src/digest-bench.tsx +13 -2
  40. package/src/index.ts +6 -0
  41. package/src/ligate-bench.tsx +11 -2
  42. package/src/pcr-bench.tsx +14 -1
  43. package/src/primer-bench.tsx +500 -0
  44. package/src/primer-design.ts +406 -0
  45. package/src/primer-working.ts +289 -0
  46. package/src/tools.tsx +14 -6
  47. package/src/working.tsx +29 -0
  48. package/tools.css +49 -2
package/package.json CHANGED
@@ -10,7 +10,8 @@
10
10
  "@biolibs/dseq": "^1.0.0",
11
11
  "@biolibs/dseqrecord": "^1.1.1",
12
12
  "@biolibs/gel": "^1.0.0",
13
- "@biolibs/glossary-react": "^0.1.0",
13
+ "@biolibs/glossary-react": "^0.1.2",
14
+ "@biolibs/pcr": "^1.0.0",
14
15
  "@biolibs/restriction": "^1.0.0",
15
16
  "@biolibs/seq": "^1.0.0",
16
17
  "@biolibs/seqio": "^1.1.2",
@@ -62,5 +63,5 @@
62
63
  ],
63
64
  "type": "module",
64
65
  "types": "dist/index.d.ts",
65
- "version": "0.1.4"
66
+ "version": "0.1.6"
66
67
  }
@@ -9,7 +9,7 @@
9
9
  * then read off the gel against a ladder. So the views run the same way as a PCR's: the rig, the
10
10
  * gel in it, what the power supply says, then what is in the tube, and the gel once it has run.
11
11
  */
12
- import { useMemo, useState, type ReactNode } from "react";
12
+ import { useEffect, useMemo, useState, type ReactNode } from "react";
13
13
  import { GELS, LADDERS, gelById } from "@biolibs/gel";
14
14
  import { useAct, useLab } from "@biolibs/bionet-react";
15
15
  import { Glossed } from "@biolibs/glossary-react";
@@ -63,7 +63,7 @@ const endWords = (end: PieceEnd): ReactNode => (end.enzyme === null ? <span clas
63
63
  */
64
64
  export function useDigestBench({ instrument = null, onDone, start }: {
65
65
  instrument?: { id: string; name: string } | null; onDone?: () => void;
66
- /** What to open on: the view, the tube and enzymes already chosen, the pieces to keep, and how far the gel starts. Read once. */
66
+ /** What to show: the view, the tube and enzymes chosen, the pieces to keep, how far the gel starts. Followed whenever it changes. */
67
67
  start?: { view?: DigestView; tube?: string; enzymes?: readonly string[]; keep?: readonly number[]; ran?: number };
68
68
  } = {}): { stage: DigestStage; panel: ReactNode } {
69
69
  const lab = useLab()?.lab;
@@ -84,6 +84,17 @@ export function useDigestBench({ instrument = null, onDone, start }: {
84
84
  const [keep, setKeep] = useState<number[]>([...(start?.keep ?? [])]);
85
85
  const [amount, setAmount] = useState("20");
86
86
 
87
+ // A host driving the bench — a tour, or a link — says what to show by changing `start`. Following
88
+ // it rather than being mounted afresh is what lets the scene stay put and the camera travel.
89
+ const asked = JSON.stringify(start ?? null);
90
+ useEffect(() => {
91
+ if (start === undefined) return;
92
+ if (start.view !== undefined) setView(start.view);
93
+ if (start.tube !== undefined) setTube(start.tube);
94
+ if (start.enzymes !== undefined) setChosen([...start.enzymes]);
95
+ if (start.keep !== undefined) setKeep([...start.keep]);
96
+ }, [asked]);
97
+
87
98
  const tubes = useMemo(() => (lab === null || lab === undefined ? [] : digestTubes(lab)), [lab]);
88
99
  // Arriving at the gel finds it running, because that is what a gel does.
89
100
  const [ran, setRan, running] = useRunning(view === "result" && tube !== "", start?.ran ?? 0);
package/src/index.ts CHANGED
@@ -24,6 +24,9 @@
24
24
  * - `working.tsx` — the working drawn: a figure that opens to show its steps
25
25
  * - `map.tsx` — a sequence's map: a circle or a line, with what is marked on it
26
26
  * - `sequences-tool.tsx` — bringing sequences in from files, and reading a part as a map
27
+ * - `primer-design.ts` — a pair of primers designed for a stretch of a part, with every candidate that was weighed and what to warn of
28
+ * - `primer-working.ts` — the working behind a design: the melting temperature's sum, the GC count, the bases that pair
29
+ * - `primer-bench.tsx` — designing primers at a desk: the panel, and the template with the pair marked on it for a scene
27
30
  * - `tools.tsx` — getting to one: from an instrument, or from a list of them all
28
31
  *
29
32
  * The tools are drawn with the styles of `@biolibs/bionet-panels` and belong inside its `LabWindow`.
@@ -48,3 +51,6 @@ export * from "./map.js";
48
51
  export * from "./sequences-tool.js";
49
52
  export * from "./tools.js";
50
53
  export * from "./pcr-bench.js";
54
+ export * from "./primer-design.js";
55
+ export * from "./primer-working.js";
56
+ export * from "./primer-bench.js";
@@ -7,7 +7,7 @@
7
7
  * the tube and invisible: which ends found each other, which way round a piece went in, and whether
8
8
  * anything closed into a circle. So the machine's views are short and the pictured ones carry it.
9
9
  */
10
- import { useMemo, useState, type ReactNode } from "react";
10
+ import { useEffect, useMemo, useState, type ReactNode } from "react";
11
11
  import { useAct, useLab } from "@biolibs/bionet-react";
12
12
  import { amountOf } from "@biolibs/bionet-panels";
13
13
  import { Glossed } from "@biolibs/glossary-react";
@@ -65,7 +65,7 @@ const productWords = (product: LigationProduct): string =>
65
65
  */
66
66
  export function useLigationBench({ instrument = null, onDone, start }: {
67
67
  instrument?: { id: string; name: string } | null; onDone?: () => void;
68
- /** What to open on: the view, the pieces already in the tube, and how far along to be. Read once. */
68
+ /** What to show: the view, the pieces in the tube, and how far along to be. Followed whenever it changes. */
69
69
  start?: { view?: LigationView; tubes?: readonly string[]; joined?: number };
70
70
  } = {}): { stage: LigationStage; panel: ReactNode } {
71
71
  const lab = useLab()?.lab;
@@ -84,6 +84,15 @@ export function useLigationBench({ instrument = null, onDone, start }: {
84
84
  const [busy, setBusy] = useState(false);
85
85
  const [said, setSaid] = useState<string | null>(null);
86
86
 
87
+ // A host driving the bench — a tour, or a link — says what to show by changing `start`. Following
88
+ // it rather than being mounted afresh is what lets the scene stay put and the camera travel.
89
+ const asked = JSON.stringify(start ?? null);
90
+ useEffect(() => {
91
+ if (start === undefined) return;
92
+ if (start.view !== undefined) setView(start.view);
93
+ if (start.tubes !== undefined) setTubes([...start.tubes]);
94
+ }, [asked]);
95
+
87
96
  const offered = useMemo(() => (lab === null || lab === undefined ? [] : ligationTubes(lab)), [lab]);
88
97
  // Arriving at the tube finds the pieces closing, which is the whole of what is happening in it.
89
98
  const [joined, setJoined, closing] = useRunning(view === "tube" && tubes.length > 0, start?.joined ?? 0);
package/src/pcr-bench.tsx CHANGED
@@ -126,7 +126,7 @@ function Pick({ label, choices, value, onChange }: { label: string; choices: Tub
126
126
  */
127
127
  export function usePcrBench({ instrument = null, onDone, start }: {
128
128
  instrument?: { id: string; name: string } | null; onDone?: () => void;
129
- /** What to open on: the view, the tubes already chosen, and where in the programme to be. Read once. */
129
+ /** What to show: the view, the tubes chosen, and where in the programme to be. Followed whenever it changes. */
130
130
  start?: { view?: BenchView; template?: string; forward?: string; reverse?: string; step?: PcrStepName; cycle?: number };
131
131
  } = {}): { stage: BenchStage; panel: ReactNode } {
132
132
  const lab = useLab()?.lab;
@@ -147,6 +147,19 @@ export function usePcrBench({ instrument = null, onDone, start }: {
147
147
  const [running, setRunning] = useState(false);
148
148
  const [site, setSite] = useState<"top" | "bottom">("top");
149
149
 
150
+ // A host driving the bench — a tour, or a link — says what to show by changing `start`. Following
151
+ // it rather than being mounted afresh is what lets the scene stay put and the camera travel.
152
+ const asked = JSON.stringify(start ?? null);
153
+ useEffect(() => {
154
+ if (start === undefined) return;
155
+ if (start.view !== undefined) setView(start.view);
156
+ if (start.template !== undefined) setTemplate(start.template);
157
+ if (start.forward !== undefined) setForward(start.forward);
158
+ if (start.reverse !== undefined) setReverse(start.reverse);
159
+ if (start.step !== undefined) setStep(start.step);
160
+ if (start.cycle !== undefined) setCycle(start.cycle);
161
+ }, [asked]);
162
+
150
163
  const tubes = useMemo(() => (lab === null || lab === undefined ? { templates: [], primers: [] } : pcrTubes(lab)), [lab]);
151
164
  const partOf = (item: string) => [...tubes.templates, ...tubes.primers].find((one) => one.item === item)?.part;
152
165
  const [templatePart, forwardPart, reversePart] = [partOf(template), partOf(forward), partOf(reverse)];