@biolibs/bionet-tools 0.1.1 → 0.1.2

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 (78) hide show
  1. package/README.md +146 -4
  2. package/dist/digest-bench.d.ts +76 -0
  3. package/dist/digest-bench.d.ts.map +1 -0
  4. package/dist/digest-bench.js +127 -0
  5. package/dist/digest-bench.js.map +1 -0
  6. package/dist/digest-working.d.ts +155 -0
  7. package/dist/digest-working.d.ts.map +1 -0
  8. package/dist/digest-working.js +216 -0
  9. package/dist/digest-working.js.map +1 -0
  10. package/dist/index.d.ts +20 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +20 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/ligate-bench.d.ts +92 -0
  15. package/dist/ligate-bench.d.ts.map +1 -0
  16. package/dist/ligate-bench.js +139 -0
  17. package/dist/ligate-bench.js.map +1 -0
  18. package/dist/ligate-working.d.ts +96 -0
  19. package/dist/ligate-working.d.ts.map +1 -0
  20. package/dist/ligate-working.js +145 -0
  21. package/dist/ligate-working.js.map +1 -0
  22. package/dist/ligate.d.ts +152 -0
  23. package/dist/ligate.d.ts.map +1 -0
  24. package/dist/ligate.js +161 -0
  25. package/dist/ligate.js.map +1 -0
  26. package/dist/map.d.ts +69 -0
  27. package/dist/map.d.ts.map +1 -0
  28. package/dist/map.js +80 -0
  29. package/dist/map.js.map +1 -0
  30. package/dist/pcr-bench.d.ts +9 -0
  31. package/dist/pcr-bench.d.ts.map +1 -1
  32. package/dist/pcr-bench.js +26 -2
  33. package/dist/pcr-bench.js.map +1 -1
  34. package/dist/pcr-scene.d.ts +2 -0
  35. package/dist/pcr-scene.d.ts.map +1 -1
  36. package/dist/pcr-scene.js +8 -8
  37. package/dist/pcr-scene.js.map +1 -1
  38. package/dist/pcr-working.d.ts +126 -0
  39. package/dist/pcr-working.d.ts.map +1 -0
  40. package/dist/pcr-working.js +175 -0
  41. package/dist/pcr-working.js.map +1 -0
  42. package/dist/run.d.ts +101 -6
  43. package/dist/run.d.ts.map +1 -1
  44. package/dist/run.js +127 -11
  45. package/dist/run.js.map +1 -1
  46. package/dist/sequence-file.d.ts +108 -0
  47. package/dist/sequence-file.d.ts.map +1 -0
  48. package/dist/sequence-file.js +145 -0
  49. package/dist/sequence-file.js.map +1 -0
  50. package/dist/sequences-tool.d.ts +13 -0
  51. package/dist/sequences-tool.d.ts.map +1 -0
  52. package/dist/sequences-tool.js +61 -0
  53. package/dist/sequences-tool.js.map +1 -0
  54. package/dist/tools.d.ts +2 -2
  55. package/dist/tools.d.ts.map +1 -1
  56. package/dist/tools.js +9 -4
  57. package/dist/tools.js.map +1 -1
  58. package/dist/working.d.ts +58 -0
  59. package/dist/working.d.ts.map +1 -0
  60. package/dist/working.js +55 -0
  61. package/dist/working.js.map +1 -0
  62. package/package.json +5 -2
  63. package/src/digest-bench.tsx +307 -0
  64. package/src/digest-working.ts +288 -0
  65. package/src/index.ts +20 -0
  66. package/src/ligate-bench.tsx +293 -0
  67. package/src/ligate-working.ts +182 -0
  68. package/src/ligate.ts +243 -0
  69. package/src/map.tsx +170 -0
  70. package/src/pcr-bench.tsx +54 -1
  71. package/src/pcr-scene.ts +10 -8
  72. package/src/pcr-working.ts +228 -0
  73. package/src/run.ts +179 -14
  74. package/src/sequence-file.ts +172 -0
  75. package/src/sequences-tool.tsx +109 -0
  76. package/src/tools.tsx +13 -8
  77. package/src/working.tsx +96 -0
  78. package/tools.css +54 -0
@@ -0,0 +1,216 @@
1
+ import { bandPosition } from "@biolibs/gel";
2
+ import { enzymes } from "@biolibs/restriction";
3
+ import { carryFeatures } from "./sequence-file.js";
4
+ const count = (value) => value.toLocaleString("en-US");
5
+ const clean = (bases) => bases.replace(/\s+/g, "").toUpperCase();
6
+ const PAIR = { A: "T", T: "A", G: "C", C: "G", N: "N", R: "Y", Y: "R", K: "M", M: "K", S: "S", W: "W", B: "V", V: "B", D: "H", H: "D" };
7
+ const IUPAC = { A: "A", C: "C", G: "G", T: "T", N: "[ACGT]", R: "[AG]", Y: "[CT]", K: "[GT]", M: "[AC]", S: "[CG]", W: "[AT]", B: "[CGT]", D: "[AGT]", H: "[ACT]", V: "[ACG]" };
8
+ const across = (bases) => [...bases].map((base) => PAIR[base] ?? "N").join("");
9
+ const flipped = (bases) => [...bases].reverse().map((base) => PAIR[base] ?? "N").join("");
10
+ /**
11
+ * Every place one enzyme cuts, with the bases it recognised there.
12
+ *
13
+ * The cut positions come from the restriction engine. This finds the site behind each one by
14
+ * looking for the enzyme's sequence itself, on both strands, and keeps only sites whose cut the
15
+ * engine also found, so each position is explained and none is invented.
16
+ *
17
+ * @param part - The molecule.
18
+ * @param cutter - The enzyme and where it cuts, from `cutsOf`.
19
+ * @returns The sites, in order along the molecule. A cut whose site cannot be found is left out.
20
+ */
21
+ export function cutSites(part, cutter) {
22
+ const enzyme = Object.hasOwn(enzymes, cutter.name) ? enzymes[cutter.name] : undefined;
23
+ const bases = clean(part.sequence);
24
+ const length = bases.length;
25
+ if (enzyme === undefined || enzyme.fst5 === null || enzyme.ovhg === null || length === 0)
26
+ return [];
27
+ const [size, fst5, ovhg] = [enzyme.size, enzyme.fst5, enzyme.ovhg];
28
+ const site = clean(String(enzyme.site));
29
+ // A circle is searched once round and a little further, so a site across the origin is found.
30
+ const searched = part.circular ? bases + bases.slice(0, size - 1) : bases;
31
+ const wrap = (value) => ((value % length) + length) % length;
32
+ const base = (place) => (part.circular ? bases[wrap(place)] : bases[place] ?? "");
33
+ const found = [];
34
+ const look = (pattern, backwards) => {
35
+ const matcher = new RegExp(`(?=(${[...pattern].map((one) => IUPAC[one] ?? one).join("")}))`, "g");
36
+ for (const match of searched.matchAll(matcher)) {
37
+ const start = match.index;
38
+ // Forwards, the top strand is cut `fst5` into the site. Backwards the enzyme sits the other way
39
+ // up, so that is where it cuts the bottom strand, and the top is cut across from its other cut.
40
+ const [top, under] = backwards ? [start + size - fst5 + ovhg, start + size - fst5] : [start + fst5, start + fst5 - ovhg];
41
+ const at = part.circular ? wrap(top) : top;
42
+ if (!cutter.positions.includes(at) || found.some((one) => one.at === at))
43
+ continue;
44
+ const [low, high] = [Math.min(top, under), Math.max(top, under)];
45
+ const from = Math.min(start, low) - 4;
46
+ const to = Math.max(start + size, high) + 4;
47
+ const shown = Array.from({ length: to - from }, (_, index) => base(from + index)).join("");
48
+ found.push({
49
+ enzyme: cutter.name, recognises: site, at, bottom: part.circular ? wrap(under) : under, stagger: under - top, site: { start, end: start + size }, backwards,
50
+ overhang: ovhg === 0 ? "blunt" : top < under ? "5′" : "3′",
51
+ bases: Array.from({ length: high - low }, (_, index) => base(low + index)).join(""),
52
+ around: { from, top: shown, bottom: across(shown), site: [start - from, start + size - from], cutTop: top - from, cutBottom: under - from },
53
+ });
54
+ }
55
+ };
56
+ look(site, false);
57
+ if (flipped(site) !== site)
58
+ look(flipped(site), true);
59
+ return found.sort((a, b) => a.at - b.at);
60
+ }
61
+ /**
62
+ * The pieces a digest gives, each with what made its ends and what it carries.
63
+ *
64
+ * @param part - The molecule, with what is marked on it.
65
+ * @param sites - Every cut, from `cutSites` for each enzyme.
66
+ * @returns The pieces, longest first. Nothing if there are no cuts.
67
+ */
68
+ export function digestPieces(part, sites) {
69
+ const length = clean(part.sequence).length;
70
+ const cuts = [...new Map(sites.map((one) => [one.at, one])).values()].sort((a, b) => a.at - b.at);
71
+ if (cuts.length === 0)
72
+ return [];
73
+ const end = (site) => (site === undefined ? { enzyme: null, overhang: "end", bases: "" } : { enzyme: site.enzyme, overhang: site.overhang, bases: site.bases });
74
+ const features = part.features ?? [];
75
+ const bases = clean(part.sequence);
76
+ const piece = (from, to, left, right) => {
77
+ const span = to > from ? to - from : length - from + to;
78
+ // A strand cut further out than the other gives the piece bases beyond the top strand's cut.
79
+ const [before, after] = [Math.max(0, -(left?.stagger ?? 0)), Math.max(0, right?.stagger ?? 0)];
80
+ const read = (start, many) => Array.from({ length: many }, (_, index) => bases[(((start + index) % length) + length) % length]).join("");
81
+ return {
82
+ from, to, left: end(left), right: end(right), length: span,
83
+ sequence: read(from - before, before + span + after), ends: { left: left?.stagger ?? 0, right: right?.stagger ?? 0 },
84
+ // Through the origin, what is carried is what lies before it and then what lies after.
85
+ features: to > from ? carryFeatures(features, from, to, before) : [...carryFeatures(features, from, length, before), ...carryFeatures(features, 0, to, length - from + before)],
86
+ };
87
+ };
88
+ const pieces = [];
89
+ if (part.circular) {
90
+ cuts.forEach((cut, index) => { const next = cuts[(index + 1) % cuts.length]; pieces.push(piece(cut.at, next.at, cut, next)); });
91
+ // One cut opens a circle into a single piece: it runs from the cut right round to the cut again.
92
+ }
93
+ else {
94
+ const edges = [0, ...cuts.map((one) => one.at), length];
95
+ for (let index = 0; index + 1 < edges.length; index++) {
96
+ if (edges[index + 1] > edges[index])
97
+ pieces.push(piece(edges[index], edges[index + 1], cuts[index - 1], cuts[index]));
98
+ }
99
+ }
100
+ return pieces.sort((a, b) => b.length - a.length);
101
+ }
102
+ /**
103
+ * One cut, said as steps that can be checked against the bases.
104
+ *
105
+ * @param site - The cut, from `cutSites`.
106
+ * @returns The working.
107
+ */
108
+ export function siteWorking(site) {
109
+ const wide = Math.abs(site.at - site.bottom);
110
+ return {
111
+ of: `${site.enzyme} at base ${count(site.at)}`, kind: "exact",
112
+ comes: site.overhang === "blunt" ? "a blunt end" : `a ${wide}-base ${site.overhang} overhang, ${site.bases}`,
113
+ steps: [
114
+ `${site.enzyme} recognises ${site.recognises}. Those bases are at ${count(site.site.start + 1)} to ${count(site.site.end)}${site.backwards ? ", reading along the bottom strand" : ""}.`,
115
+ `It cuts the top strand after base ${count(site.at)} and the bottom strand after base ${count(site.bottom)}.`,
116
+ site.overhang === "blunt" ? "Both strands are cut at the same place, so the ends are blunt."
117
+ : `The cuts are ${wide} bases apart, so each piece is left with ${wide} unpaired bases at its ${site.overhang} end: ${site.bases} on one piece and its partner on the other.`,
118
+ ],
119
+ };
120
+ }
121
+ /**
122
+ * How long the pieces are, as differences between the cuts, with the check that they add up.
123
+ *
124
+ * @param part - How long the molecule is, and whether it is a circle.
125
+ * @param sites - Every cut.
126
+ * @param plan - The digest as the gel engine worked it out, to compare with.
127
+ * @returns The working.
128
+ */
129
+ export function piecesWorking(part, sites, plan) {
130
+ const cuts = [...new Set(sites.map((one) => one.at))].sort((a, b) => a - b);
131
+ const sizes = [];
132
+ const steps = [`The cuts, in order along the molecule: after base ${cuts.map(count).join(", ")}.`];
133
+ if (part.circular) {
134
+ cuts.forEach((cut, index) => {
135
+ const next = cuts[(index + 1) % cuts.length];
136
+ const size = cuts.length === 1 ? part.length : next > cut ? next - cut : part.length - cut + next;
137
+ sizes.push(size);
138
+ steps.push(cuts.length === 1 ? `One cut opens the circle into one piece, the whole ${count(part.length)}.`
139
+ : next > cut ? `From ${count(cut)} to ${count(next)}: ${count(next)} − ${count(cut)} = ${count(size)}.`
140
+ : `From ${count(cut)} through the origin to ${count(next)}: ${count(part.length)} − ${count(cut)} + ${count(next)} = ${count(size)}.`);
141
+ });
142
+ }
143
+ else {
144
+ const edges = [0, ...cuts, part.length];
145
+ for (let index = 0; index + 1 < edges.length; index++) {
146
+ const size = edges[index + 1] - edges[index];
147
+ if (size <= 0)
148
+ continue;
149
+ sizes.push(size);
150
+ steps.push(`From ${index === 0 ? "the start" : count(edges[index])} to ${index + 2 === edges.length ? "the end" : count(edges[index + 1])}: ${count(edges[index + 1])} − ${count(edges[index])} = ${count(size)}.`);
151
+ }
152
+ }
153
+ const total = sizes.reduce((sum, size) => sum + size, 0);
154
+ steps.push(`They add up to the whole molecule: ${sizes.map(count).join(" + ")} = ${count(total)}${total === part.length ? "." : `, which is not its ${count(part.length)}. Something is wrong.`}`);
155
+ if (plan !== undefined) {
156
+ const same = [...sizes].sort((a, b) => b - a).join(",") === [...plan.fragments].sort((a, b) => b - a).join(",");
157
+ steps.push(same ? "The gel engine, working the pieces out its own way, gives the same lengths." : `The gel engine gives ${plan.fragments.map(count).join(", ")}, which does not agree. Trust neither until that is understood.`);
158
+ }
159
+ return { of: "the pieces", comes: `${[...sizes].sort((a, b) => b - a).map(count).join(", ")} bp`, kind: "exact", steps };
160
+ }
161
+ /**
162
+ * Where a piece runs to on a gel, with the rule behind it.
163
+ *
164
+ * @param size - How long the piece is.
165
+ * @param gel - The gel.
166
+ * @returns The working. It is an estimate: the rule is a straight line that real gels only roughly follow.
167
+ */
168
+ export function migrationWorking(size, gel) {
169
+ const [high, low, own] = [Math.log10(gel.largest), Math.log10(gel.smallest), Math.log10(size)];
170
+ const round = (value) => String(Math.round(value * 100) / 100);
171
+ const position = bandPosition(size, gel);
172
+ const inside = size <= gel.largest && size >= gel.smallest;
173
+ return {
174
+ of: `how far ${count(size)} bp runs on ${gel.percent}% agarose`, comes: `${Math.round(position * 100)}% of the way down`, kind: "estimate",
175
+ steps: [
176
+ `This gel separates pieces from ${count(gel.largest)} bp, which barely leave the wells, down to ${count(gel.smallest)} bp, which reach the front.`,
177
+ `Distance goes with the logarithm of length: log₁₀ ${count(gel.largest)} = ${round(high)}, log₁₀ ${count(gel.smallest)} = ${round(low)}, log₁₀ ${count(size)} = ${round(own)}.`,
178
+ inside ? `(${round(high)} − ${round(own)}) ÷ (${round(high)} − ${round(low)}) = ${round(position)} of the way from the wells to the front.`
179
+ : `${count(size)} bp is ${size > gel.largest ? "longer" : "shorter"} than this gel separates, so it is drawn at the ${size > gel.largest ? "wells" : "front"}, with anything else of that kind.`,
180
+ ],
181
+ rests: "Small pieces thread through agarose faster than large ones, and over a gel's working range the distance is close to a straight line against the logarithm of length. Real distance also depends on voltage, time, buffer and the shape of the DNA, so read a piece's size against the ladder beside it, never off the distance alone.",
182
+ };
183
+ }
184
+ /**
185
+ * What a careful operator would ask of a digest, given the gel it is to be run on.
186
+ *
187
+ * Each may be wrong for a particular bench, and none stops a run.
188
+ *
189
+ * @param part - The molecule.
190
+ * @param plan - The digest, from `planDigest`.
191
+ * @param gel - The gel.
192
+ * @returns The checks that apply, the ones most likely to matter first.
193
+ */
194
+ export function digestChecks(part, plan, gel) {
195
+ const checks = [];
196
+ for (const one of plan.cutters.filter((cutter) => cutter.positions.length === 0)) {
197
+ checks.push({ weight: "look", says: `${one.name} does not cut this. It is in the tube and does nothing.`, because: `${one.site} is not in the sequence` });
198
+ }
199
+ for (const band of plan.bands.filter((one) => one.sizes.length > 1 && !one.unresolved)) {
200
+ checks.push({ weight: "stop", says: `${band.sizes.map(count).join(" and ")} bp are too close in size to tell apart. They will look like one band.`, because: `${count(band.sizes[0] - band.sizes.at(-1))} bp apart, under 3% of ${count(band.sizes[0])}` });
201
+ }
202
+ const small = plan.fragments.filter((size) => size < gel.smallest);
203
+ if (small.length > 0)
204
+ checks.push({ weight: "stop", says: `${small.map(count).join(", ")} bp ${small.length === 1 ? "is" : "are"} smaller than ${gel.percent}% agarose separates. ${small.length === 1 ? "It" : "They"} may run off the gel or be too faint to see. A higher percentage would hold ${small.length === 1 ? "it" : "them"}.`, because: `${count(Math.max(...small))} < ${count(gel.smallest)} bp` });
205
+ const large = plan.fragments.filter((size) => size > gel.largest);
206
+ if (large.length > 0)
207
+ checks.push({ weight: "look", says: `${large.map(count).join(", ")} bp ${large.length === 1 ? "is" : "are"} larger than ${gel.percent}% agarose separates, and will stay near the wells. A lower percentage would spread ${large.length === 1 ? "it" : "them"}.`, because: `${count(Math.min(...large))} > ${count(gel.largest)} bp` });
208
+ if (part.circular && plan.fragments.length === 1) {
209
+ checks.push({ weight: "look", says: "One cut opens the circle into one piece of its full length. The gel shows that it cut and how long the plasmid is, and nothing about what is where on it. Two cuts say more.", because: "1 cut, 1 piece" });
210
+ }
211
+ if (plan.cutters.some((one) => one.name === "DpnI" && one.positions.length > 0)) {
212
+ checks.push({ weight: "look", says: "DpnI only cuts DNA that is methylated, as it is when grown in most lab strains of E. coli. It will not cut a PCR product.", because: "DpnI needs methylated GATC" });
213
+ }
214
+ return checks.sort((a, b) => Number(b.weight === "stop") - Number(a.weight === "stop"));
215
+ }
216
+ //# sourceMappingURL=digest-working.js.map
@@ -0,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OAAO,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACnP,CAAC;IACD,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;QAChF,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,2HAA2H,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAC;IAC5M,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC;AAC1F,CAAC"}
package/dist/index.d.ts CHANGED
@@ -8,22 +8,42 @@
8
8
  * which run made it.
9
9
  *
10
10
  * - `pcr.ts` — what a PCR would make, worked out from sequences alone
11
+ * - `sequence-file.ts` — a sequence read from a SnapGene, GenBank, EMBL or FASTA file, and features carried onto a product
11
12
  * - `pcr-scene.ts` — a PCR as met at the machine: the programme it shows, the checks, and what is in the tube
12
13
  * - `digest.ts` — where enzymes cut, the pieces, and the gel they would give
13
14
  * - `run.ts` — a PCR as a lab does one: which tubes, and what to record
14
15
  * - `pcr-tool.tsx`, `digest-tool.tsx` — the tools
15
16
  * - `pcr-bench.tsx` — a PCR at the machine: what is beside the scene, and what the scene is told to show
17
+ * - `pcr-working.ts` — the working behind what the PCR tool says: each figure with the steps that give it
18
+ * - `ligate.ts` — pieces that have already been cut, joined where their ends fit
19
+ * - `ligate-working.ts` — a ligation's working: each join in its bases, the length, how much to put in
20
+ * - `ligate-bench.tsx` — a ligation at the heat block: what is shown beside it, and what the scene draws
21
+ * - `digest-working.ts` — a digest looked at closely: each cut in its bases, each piece with its ends, the working
22
+ * - `digest-bench.tsx` — a digest at the gel station: what is shown beside it, and what the scene is told to draw
23
+ * - `working.tsx` — the working drawn: a figure that opens to show its steps
24
+ * - `map.tsx` — a sequence's map: a circle or a line, with what is marked on it
25
+ * - `sequences-tool.tsx` — bringing sequences in from files, and reading a part as a map
16
26
  * - `tools.tsx` — getting to one: from an instrument, or from a list of them all
17
27
  *
18
28
  * The tools are drawn with the styles of `@biolibs/bionet-panels` and belong inside its `LabWindow`.
19
29
  * Import `@biolibs/bionet-tools/tools.css` once.
20
30
  */
21
31
  export * from "./pcr.js";
32
+ export * from "./sequence-file.js";
22
33
  export * from "./pcr-scene.js";
23
34
  export * from "./digest.js";
24
35
  export * from "./run.js";
25
36
  export * from "./pcr-tool.js";
26
37
  export * from "./digest-tool.js";
38
+ export * from "./pcr-working.js";
39
+ export * from "./digest-working.js";
40
+ export * from "./ligate.js";
41
+ export * from "./ligate-working.js";
42
+ export * from "./ligate-bench.js";
43
+ export * from "./digest-bench.js";
44
+ export * from "./working.js";
45
+ export * from "./map.js";
46
+ export * from "./sequences-tool.js";
27
47
  export * from "./tools.js";
28
48
  export * from "./pcr-bench.js";
29
49
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -8,22 +8,42 @@
8
8
  * which run made it.
9
9
  *
10
10
  * - `pcr.ts` — what a PCR would make, worked out from sequences alone
11
+ * - `sequence-file.ts` — a sequence read from a SnapGene, GenBank, EMBL or FASTA file, and features carried onto a product
11
12
  * - `pcr-scene.ts` — a PCR as met at the machine: the programme it shows, the checks, and what is in the tube
12
13
  * - `digest.ts` — where enzymes cut, the pieces, and the gel they would give
13
14
  * - `run.ts` — a PCR as a lab does one: which tubes, and what to record
14
15
  * - `pcr-tool.tsx`, `digest-tool.tsx` — the tools
15
16
  * - `pcr-bench.tsx` — a PCR at the machine: what is beside the scene, and what the scene is told to show
17
+ * - `pcr-working.ts` — the working behind what the PCR tool says: each figure with the steps that give it
18
+ * - `ligate.ts` — pieces that have already been cut, joined where their ends fit
19
+ * - `ligate-working.ts` — a ligation's working: each join in its bases, the length, how much to put in
20
+ * - `ligate-bench.tsx` — a ligation at the heat block: what is shown beside it, and what the scene draws
21
+ * - `digest-working.ts` — a digest looked at closely: each cut in its bases, each piece with its ends, the working
22
+ * - `digest-bench.tsx` — a digest at the gel station: what is shown beside it, and what the scene is told to draw
23
+ * - `working.tsx` — the working drawn: a figure that opens to show its steps
24
+ * - `map.tsx` — a sequence's map: a circle or a line, with what is marked on it
25
+ * - `sequences-tool.tsx` — bringing sequences in from files, and reading a part as a map
16
26
  * - `tools.tsx` — getting to one: from an instrument, or from a list of them all
17
27
  *
18
28
  * The tools are drawn with the styles of `@biolibs/bionet-panels` and belong inside its `LabWindow`.
19
29
  * Import `@biolibs/bionet-tools/tools.css` once.
20
30
  */
21
31
  export * from "./pcr.js";
32
+ export * from "./sequence-file.js";
22
33
  export * from "./pcr-scene.js";
23
34
  export * from "./digest.js";
24
35
  export * from "./run.js";
25
36
  export * from "./pcr-tool.js";
26
37
  export * from "./digest-tool.js";
38
+ export * from "./pcr-working.js";
39
+ export * from "./digest-working.js";
40
+ export * from "./ligate.js";
41
+ export * from "./ligate-working.js";
42
+ export * from "./ligate-bench.js";
43
+ export * from "./digest-bench.js";
44
+ export * from "./working.js";
45
+ export * from "./map.js";
46
+ export * from "./sequences-tool.js";
27
47
  export * from "./tools.js";
28
48
  export * from "./pcr-bench.js";
29
49
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * A ligation at the heat block: what is shown beside it, and what the scene is told to draw.
3
+ *
4
+ * A heat block shows one number, the temperature, and nothing else. Everything that matters is in
5
+ * the tube and invisible: which ends found each other, which way round a piece went in, and whether
6
+ * anything closed into a circle. So the machine's views are short and the pictured ones carry it.
7
+ */
8
+ import { type ReactNode } from "react";
9
+ import { type DrawnMolecule } from "./sequence-file.js";
10
+ /** The views of the heat block, by the names every instrument's stage uses. */
11
+ export type LigationView = "machine" | "block" | "screen" | "tube" | "result";
12
+ /** How each piece is coloured, in the theme's terms. The first is the one being cloned into. */
13
+ declare const TONES: readonly ["yours", "theirs", "held", "good", "found"];
14
+ /** What the scene is told to show. It is shaped to be spread onto `InstrumentStage`. */
15
+ export interface LigationStage {
16
+ model: "heat-block";
17
+ name: string;
18
+ view: LigationView;
19
+ onView: (view: LigationView) => void;
20
+ /** What the block's display says. */
21
+ screen: {
22
+ text: string;
23
+ lit?: boolean;
24
+ }[];
25
+ /** The well the tube is in. */
26
+ well?: {
27
+ row: number;
28
+ column: number;
29
+ };
30
+ /** The pieces being joined, for the view into the tube. */
31
+ joining?: {
32
+ pieces: {
33
+ name: string;
34
+ length: number;
35
+ flipped: boolean;
36
+ tone: (typeof TONES)[number];
37
+ }[];
38
+ joins: {
39
+ label: string;
40
+ }[];
41
+ circular: boolean;
42
+ joined: number;
43
+ };
44
+ /** What it makes, for the last view. */
45
+ molecule?: DrawnMolecule & {
46
+ marks: {
47
+ at: number;
48
+ label: string;
49
+ }[];
50
+ };
51
+ }
52
+ /**
53
+ * A ligation, at the heat block it is left in.
54
+ *
55
+ * @param options - `instrument` is the block it is set up at, if the lab has one; `onDone` adds a way to leave.
56
+ * @returns `stage`, to spread onto `InstrumentStage` from `@biolibs/bionet-scene`, and `panel`, to put inside it.
57
+ *
58
+ * @example
59
+ * ```tsx
60
+ * import { useLigationBench } from "@biolibs/bionet-tools";
61
+ *
62
+ * // `InstrumentStage` is the scene package's: it is handed what this gives and draws it.
63
+ * const bench = useLigationBench({ instrument });
64
+ * <InstrumentStage {...bench.stage}>{bench.panel}</InstrumentStage>
65
+ * ```
66
+ */
67
+ export declare function useLigationBench({ instrument, onDone }?: {
68
+ instrument?: {
69
+ id: string;
70
+ name: string;
71
+ } | null;
72
+ onDone?: () => void;
73
+ }): {
74
+ stage: LigationStage;
75
+ panel: ReactNode;
76
+ };
77
+ /**
78
+ * A ligation on its own, for a lab that has not drawn its room.
79
+ *
80
+ * It is the same thing without the scene, so it carries its own way of moving between the views.
81
+ *
82
+ * @param props - `instrument` is the block it is set up at, if the lab has one; `onDone` adds a way to leave.
83
+ */
84
+ export declare function LigationTool({ instrument, onDone }: {
85
+ instrument?: {
86
+ id: string;
87
+ name: string;
88
+ } | null;
89
+ onDone?: () => void;
90
+ }): import("react").JSX.Element;
91
+ export {};
92
+ //# sourceMappingURL=ligate-bench.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ligate-bench.d.ts","sourceRoot":"","sources":["../src/ligate-bench.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAQ1D,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGpE,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9E,gGAAgG;AAChG,QAAA,MAAM,KAAK,uDAAwD,CAAC;AAEpE,wFAAwF;AACxF,MAAM,WAAW,aAAa;IA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AE,CA6M1L;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAAE,UAAiB,EAAE,MAAM,EAAE,EAAE;IAAE,UAAU,CAAC,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,+BAcpI"}
@@ -0,0 +1,139 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ /**
4
+ * A ligation at the heat block: what is shown beside it, and what the scene is told to draw.
5
+ *
6
+ * A heat block shows one number, the temperature, and nothing else. Everything that matters is in
7
+ * the tube and invisible: which ends found each other, which way round a piece went in, and whether
8
+ * anything closed into a circle. So the machine's views are short and the pictured ones carry it.
9
+ */
10
+ import { useMemo, useState } from "react";
11
+ import { useAct, useLab } from "@biolibs/bionet-react";
12
+ import { amountOf } from "@biolibs/bionet-panels";
13
+ import { Glossed } from "@biolibs/glossary-react";
14
+ import { endBases } from "./ligate.js";
15
+ import { joinWorking, ligationChecks, ligationLengthWorking, ratioWorking } from "./ligate-working.js";
16
+ import { SequenceMap } from "./map.js";
17
+ import { ligationRun, ligationTubes } from "./run.js";
18
+ import { moleculeOf } from "./sequence-file.js";
19
+ import { JoinBases, ShowWorking } from "./working.js";
20
+ /** How each piece is coloured, in the theme's terms. The first is the one being cloned into. */
21
+ const TONES = ["yours", "theirs", "held", "good", "found"];
22
+ const count = (value) => value.toLocaleString("en-US");
23
+ const whole = (text) => (/^\d+$/.test(text.trim()) ? Number(text) : undefined);
24
+ /** How a product is said in one line. */
25
+ const productWords = (product) => `${count(product.length)} bp ${product.circular ? "circle" : "line"} · ${product.pieces.map((piece) => `${piece.name}${piece.flipped ? " ↺" : ""}`).join(" + ")}`;
26
+ /**
27
+ * A ligation, at the heat block it is left in.
28
+ *
29
+ * @param options - `instrument` is the block it is set up at, if the lab has one; `onDone` adds a way to leave.
30
+ * @returns `stage`, to spread onto `InstrumentStage` from `@biolibs/bionet-scene`, and `panel`, to put inside it.
31
+ *
32
+ * @example
33
+ * ```tsx
34
+ * import { useLigationBench } from "@biolibs/bionet-tools";
35
+ *
36
+ * // `InstrumentStage` is the scene package's: it is handed what this gives and draws it.
37
+ * const bench = useLigationBench({ instrument });
38
+ * <InstrumentStage {...bench.stage}>{bench.panel}</InstrumentStage>
39
+ * ```
40
+ */
41
+ export function useLigationBench({ instrument = null, onDone } = {}) {
42
+ const lab = useLab()?.lab;
43
+ const act = useAct();
44
+ const [view, setView] = useState("machine");
45
+ const [tubes, setTubes] = useState([]);
46
+ const [blunt, setBlunt] = useState(false);
47
+ const [linear, setLinear] = useState(false);
48
+ const [chosen, setChosen] = useState(0);
49
+ const [joined, setJoined] = useState(100);
50
+ const [celsius, setCelsius] = useState("16");
51
+ const [hours, setHours] = useState("16");
52
+ const [ratio, setRatio] = useState("3");
53
+ const [name, setName] = useState("");
54
+ const [amount, setAmount] = useState("20");
55
+ const [note, setNote] = useState("");
56
+ const [busy, setBusy] = useState(false);
57
+ const [said, setSaid] = useState(null);
58
+ const offered = useMemo(() => (lab === null || lab === undefined ? [] : ligationTubes(lab)), [lab]);
59
+ const run = useMemo(() => (lab === null || lab === undefined ? null : ligationRun(lab, {
60
+ tubes, blunt, linear, chosen, instrument: instrument?.id ?? null, name, note, ...(whole(amount) === undefined ? {} : { amount: whole(amount) }),
61
+ })), [lab, tubes, blunt, linear, chosen, instrument, name, note, amount]);
62
+ const plan = run?.plan ?? null;
63
+ const product = run?.product ?? null;
64
+ const pieces = run?.pieces ?? [];
65
+ // A piece made by a PCR has no phosphate at its ends, which the log already knows from the run that made it.
66
+ const fromPcr = useMemo(() => pieces.filter((piece) => {
67
+ const made = lab?.items.find((one) => one.item === piece.id)?.from;
68
+ return made !== undefined && lab?.runs.find((one) => one.run === made)?.kind === "pcr";
69
+ }).map((piece) => piece.id), [pieces, lab]);
70
+ const checks = plan === null ? [] : ligationChecks(pieces, plan, { fromPcr });
71
+ const toneOf = (id) => TONES[Math.max(0, pieces.findIndex((piece) => piece.id === id)) % TONES.length];
72
+ const stage = {
73
+ model: "heat-block", name: instrument?.name ?? "Heat block", view, onView: setView,
74
+ screen: [{ text: `${whole(celsius) ?? "—"} °C`, lit: true }, { text: `${whole(hours) ?? "—"} h` }],
75
+ ...(pieces.length === 0 ? {} : { well: { row: 0, column: 1 } }),
76
+ ...(product === null || view !== "tube" ? {} : { joining: {
77
+ circular: product.circular, joined: joined / 100,
78
+ pieces: product.pieces.map((piece) => ({ name: piece.name, length: piece.length, flipped: piece.flipped, tone: toneOf(piece.id) })),
79
+ joins: product.joins.map((join) => ({ label: join.kind === "blunt" ? "blunt" : join.bases })),
80
+ } }),
81
+ ...(product === null || view !== "result" ? {} : { molecule: {
82
+ ...moleculeOf({ name: run?.name ?? "product", length: product.length, circular: product.circular, features: product.features }),
83
+ marks: product.joins.map((join) => ({ at: join.at, label: join.kind === "blunt" ? "blunt" : join.bases })),
84
+ } }),
85
+ };
86
+ const pick = (item) => {
87
+ setTubes(tubes.includes(item) ? tubes.filter((one) => one !== item) : [...tubes, item]);
88
+ setChosen(0);
89
+ setSaid(null);
90
+ };
91
+ const record = async (what, done) => {
92
+ if (what === null)
93
+ return;
94
+ setBusy(true);
95
+ const answer = await act("recordRun", what);
96
+ setBusy(false);
97
+ if (answer.ok) {
98
+ setSaid(done);
99
+ setNote("");
100
+ setName("");
101
+ setTubes([]);
102
+ }
103
+ };
104
+ const panel = lab === null || lab === undefined ? null : (_jsxs("div", { className: "bionet benchpanel", children: [_jsxs("section", { className: "card", children: [_jsxs("div", { className: "toolhead", children: [_jsx("h2", { children: "Ligation" }), onDone !== undefined && _jsx("button", { type: "button", className: "quiet", onClick: onDone, children: "Back to the lab" })] }), offered.length === 0 ? _jsx("p", { className: "empty", children: "There are no cut pieces to join. Cut something at the gel station and keep a piece, or add a linear part on the Freezer tab." }) : (_jsxs("fieldset", { disabled: busy, className: "stack", children: [_jsx("p", { className: "label", children: "Pieces in the tube" }), _jsx("div", { className: "enzymes", children: offered.map((one) => {
105
+ const ends = endBases({ id: one.item, name: one.part.name, sequence: one.part.sequence, ends: one.part.ends ?? { left: 0, right: 0 } });
106
+ return (_jsxs("label", { className: "check", title: one.label, children: [_jsx("input", { type: "checkbox", checked: tubes.includes(one.item), onChange: () => pick(one.item) }), " ", one.part.name, _jsxs("span", { className: "dim small", children: [" ", count(one.part.length), " bp \u00B7 ", ends.left.kind === "blunt" ? "blunt" : ends.left.bases, " \u2026 ", ends.right.kind === "blunt" ? "blunt" : ends.right.bases] })] }, one.item));
107
+ }) }), _jsxs("div", { className: "row tight", children: [_jsxs("label", { className: "check small", children: [_jsx("input", { type: "checkbox", checked: blunt, onChange: (event) => { setBlunt(event.target.checked); setChosen(0); } }), " Let blunt ends join"] }), _jsxs("label", { className: "check small", children: [_jsx("input", { type: "checkbox", checked: linear, onChange: (event) => { setLinear(event.target.checked); setChosen(0); } }), " Show what does not close"] })] })] })), plan !== null && plan.problem !== null && tubes.length > 0 && _jsx("p", { className: "trouble", role: "status", children: plan.problem }), plan !== null && plan.products.length > 1 && (_jsxs("label", { children: ["What is being made", _jsx("select", { value: chosen, onChange: (event) => setChosen(Number(event.target.value)), "aria-label": "What is being made", children: plan.products.map((one, at) => _jsx("option", { value: at, children: productWords(one) }, at)) })] }))] }), view === "machine" && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "At the block" }), _jsx("p", { className: "small", children: _jsx(Glossed, { text: "Ligase joins the backbone of two pieces of DNA whose ends are held together, which is how cut pieces are made into one molecule again." }) }), _jsx("p", { className: "dim small", children: "A heat block holds the tube at one temperature and shows that temperature. It shows nothing else: whether anything joined is found out days later, by what grows. The last two views are what you are picturing while it sits there." })] })), view === "block" && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "The wells" }), _jsx("p", { className: "voice", children: "The machine" }), _jsx("p", { className: "small", children: "A metal block with holes for tubes, held at the temperature below. The tube is in the second hole." }), _jsx("p", { className: "voice", children: "This run" }), pieces.length === 0 ? _jsx("p", { className: "dim small", children: "Nothing is in the tube yet. Choose the pieces above." }) : (_jsxs("ul", { className: "plainlist small", children: [pieces.map((piece) => {
108
+ const held = lab.items.find((one) => one.item === piece.id);
109
+ return _jsxs("li", { children: [piece.name, " \u00B7 ", count(piece.sequence.length), " bp", held === undefined ? "" : ` · ${amountOf(held)} in the tube it came from`] }, piece.id);
110
+ }), _jsx("li", { className: "dim", children: "and ligase, with the buffer that carries the ATP it needs" })] }))] })), view === "screen" && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "The temperature" }), _jsx("p", { className: "voice", children: "The machine" }), _jsxs("fieldset", { disabled: busy, className: "programme", children: [_jsxs("label", { children: ["Hold at", _jsx("input", { type: "number", min: 0, max: 40, step: 1, value: celsius, onChange: (event) => setCelsius(event.target.value) }), " \u00B0C"] }), _jsxs("label", { children: ["for", _jsx("input", { type: "number", min: 1, max: 72, step: 1, value: hours, onChange: (event) => setHours(event.target.value) }), " h"] })] }), _jsx("p", { className: "voice", children: "What is going on" }), _jsx("p", { className: "small", children: "Two things are wanted at once and they want opposite temperatures. The ends have to stay stuck together long enough to be sealed, which is warmer the longer the overhang and colder the shorter it is; and ligase works faster the warmer it is. Sixteen degrees overnight is the usual answer to that, and an hour at room temperature often does for a sticky join." }), _jsx("p", { className: "dim small", children: "Nothing here works out what a given temperature and time will give. What is set is kept with the run." })] })), view === "tube" && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "In the tube" }), product === null ? _jsx("p", { className: "dim small", children: tubes.length === 0 ? "Choose the pieces to join." : "These pieces do not join into anything." }) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "voice", children: "This run" }), _jsxs("p", { children: [_jsxs("strong", { children: [product.pieces.length, " ", product.pieces.length === 1 ? "piece" : "pieces"] }), " ", _jsx("span", { className: "dim", children: product.circular ? "closing into a circle" : "end to end" })] }), _jsxs("label", { className: "small", children: ["How far along", _jsx("input", { type: "range", min: 0, max: 100, step: 1, value: joined, onChange: (event) => setJoined(Number(event.target.value)), "aria-label": "How far along the joining is" })] }), _jsx("p", { className: "dim small", children: "Drag it back to see the pieces apart, and forward to close them. Nothing in the tube can be seen while this is going on; this is the picture of it." }), _jsx("p", { className: "small", children: _jsx(Glossed, { text: "A sticky end holds to the end whose unpaired bases pair with it, and ligase seals the backbone on each strand. A blunt end has nothing to hold to, so the two ends must meet by chance." }) }), _jsx("p", { className: "voice", children: "The working" }), product.joins.map((join) => {
111
+ const from = pieces.find((piece) => piece.id === join.from);
112
+ const to = pieces.find((piece) => piece.id === join.to);
113
+ const placedFrom = product.pieces.find((piece) => piece.id === join.from);
114
+ const placedTo = product.pieces.find((piece) => piece.id === join.to);
115
+ const out = placedFrom.flipped ? endBases(from).left : endBases(from).right;
116
+ const into = placedTo.flipped ? endBases(to).right : endBases(to).left;
117
+ const working = joinWorking({ name: placedFrom.name, end: out }, { name: placedTo.name, end: into });
118
+ return _jsx(ShowWorking, { working: working, children: _jsx(JoinBases, { bases: working.bases }) }, `${join.from} ${join.to} ${join.at}`);
119
+ })] }))] })), view === "result" && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "What it makes" }), product === null ? _jsx("p", { className: "dim small", children: "Choose pieces that join into something." }) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "voice", children: "This run" }), _jsxs("p", { children: [_jsxs("strong", { children: [count(product.length), " bp"] }), " ", _jsx("span", { className: "dim", children: product.circular ? "circular" : "linear" })] }), _jsx(SequenceMap, { name: run?.name ?? "product", length: product.length, circular: product.circular, features: product.features, marks: product.joins.map((join) => ({ at: join.at, label: join.kind === "blunt" ? "blunt" : join.bases })) }), _jsx("p", { className: "dim small", children: product.features.length === 0 ? "Nothing was marked on the pieces, so nothing is marked on this." : "What was marked on each piece is marked where that piece now is." }), _jsx("p", { className: "voice", children: "Checks" }), checks.length === 0 ? _jsx("p", { className: "small good", children: "Nothing about this ligation looks wrong." })
120
+ : _jsx("ul", { className: "checks", children: checks.map((check) => _jsxs("li", { className: check.weight, children: [check.says, " ", _jsx("code", { className: "because", children: check.because })] }, check.says)) }), _jsx("p", { className: "voice", children: "The working" }), _jsx(ShowWorking, { working: ligationLengthWorking(product, pieces) }), product.pieces.length > 1 && (() => {
121
+ const longest = [...product.pieces].sort((a, b) => b.length - a.length)[0];
122
+ const other = product.pieces.find((piece) => piece.id !== longest.id);
123
+ return _jsx(ShowWorking, { working: ratioWorking({ name: longest.name, length: longest.length }, { name: other.name, length: other.length }, { ratio: whole(ratio) ?? 3 }), children: _jsxs("label", { className: "small", children: ["Molecules of insert to each of vector", _jsx("input", { type: "number", min: 1, max: 20, step: 1, value: ratio, onChange: (event) => setRatio(event.target.value), "aria-label": "Molar ratio" })] }) });
124
+ })(), _jsxs("fieldset", { disabled: busy, className: "stack", children: [_jsxs("label", { children: ["Call it", _jsx("input", { value: name, onChange: (event) => setName(event.target.value), placeholder: run?.name ?? "", maxLength: 200 })] }), _jsxs("label", { children: ["Amount, in \u00B5L", _jsx("input", { type: "number", min: 0, step: 1, value: amount, onChange: (event) => setAmount(event.target.value) })] }), _jsxs("label", { children: ["Note", _jsx("input", { value: note, onChange: (event) => setNote(event.target.value), placeholder: "Anything worth remembering", maxLength: 2000 })] }), _jsxs("div", { className: "row", children: [_jsx("button", { type: "button", onClick: () => void record(run?.worked ?? null, "Recorded: the ligation is in the freezer."), children: "It worked" }), _jsx("button", { type: "button", className: "quiet", onClick: () => void record(run?.failed ?? null, "Recorded: it gave nothing."), children: "It gave nothing" })] })] }), said !== null && _jsx("p", { className: "small", role: "status", children: said })] }))] }))] }));
125
+ return { stage, panel };
126
+ }
127
+ /**
128
+ * A ligation on its own, for a lab that has not drawn its room.
129
+ *
130
+ * It is the same thing without the scene, so it carries its own way of moving between the views.
131
+ *
132
+ * @param props - `instrument` is the block it is set up at, if the lab has one; `onDone` adds a way to leave.
133
+ */
134
+ export function LigationTool({ instrument = null, onDone }) {
135
+ const bench = useLigationBench({ instrument, ...(onDone === undefined ? {} : { onDone }) });
136
+ const names = [["machine", "The heat block"], ["block", "The wells"], ["screen", "The temperature"], ["tube", "In the tube"], ["result", "What it makes"]];
137
+ return (_jsxs("div", { className: "pcr", children: [_jsx("div", { className: "row tight pick", role: "tablist", "aria-label": `Views of ${bench.stage.name}`, children: names.map(([one, said]) => (_jsx("button", { type: "button", role: "tab", "aria-selected": one === bench.stage.view, className: one === bench.stage.view ? "" : "quiet", onClick: () => bench.stage.onView(one), children: said }, one))) }), bench.panel] }));
138
+ }
139
+ //# sourceMappingURL=ligate-bench.js.map