@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.
- package/README.md +146 -4
- package/dist/digest-bench.d.ts +76 -0
- package/dist/digest-bench.d.ts.map +1 -0
- package/dist/digest-bench.js +127 -0
- package/dist/digest-bench.js.map +1 -0
- package/dist/digest-working.d.ts +155 -0
- package/dist/digest-working.d.ts.map +1 -0
- package/dist/digest-working.js +216 -0
- package/dist/digest-working.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/ligate-bench.d.ts +92 -0
- package/dist/ligate-bench.d.ts.map +1 -0
- package/dist/ligate-bench.js +139 -0
- package/dist/ligate-bench.js.map +1 -0
- package/dist/ligate-working.d.ts +96 -0
- package/dist/ligate-working.d.ts.map +1 -0
- package/dist/ligate-working.js +145 -0
- package/dist/ligate-working.js.map +1 -0
- package/dist/ligate.d.ts +152 -0
- package/dist/ligate.d.ts.map +1 -0
- package/dist/ligate.js +161 -0
- package/dist/ligate.js.map +1 -0
- package/dist/map.d.ts +69 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/map.js +80 -0
- package/dist/map.js.map +1 -0
- package/dist/pcr-bench.d.ts +9 -0
- package/dist/pcr-bench.d.ts.map +1 -1
- package/dist/pcr-bench.js +26 -2
- package/dist/pcr-bench.js.map +1 -1
- package/dist/pcr-scene.d.ts +2 -0
- package/dist/pcr-scene.d.ts.map +1 -1
- package/dist/pcr-scene.js +8 -8
- package/dist/pcr-scene.js.map +1 -1
- package/dist/pcr-working.d.ts +126 -0
- package/dist/pcr-working.d.ts.map +1 -0
- package/dist/pcr-working.js +175 -0
- package/dist/pcr-working.js.map +1 -0
- package/dist/run.d.ts +101 -6
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +127 -11
- package/dist/run.js.map +1 -1
- package/dist/sequence-file.d.ts +108 -0
- package/dist/sequence-file.d.ts.map +1 -0
- package/dist/sequence-file.js +145 -0
- package/dist/sequence-file.js.map +1 -0
- package/dist/sequences-tool.d.ts +13 -0
- package/dist/sequences-tool.d.ts.map +1 -0
- package/dist/sequences-tool.js +61 -0
- package/dist/sequences-tool.js.map +1 -0
- package/dist/tools.d.ts +2 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +9 -4
- package/dist/tools.js.map +1 -1
- package/dist/working.d.ts +58 -0
- package/dist/working.d.ts.map +1 -0
- package/dist/working.js +55 -0
- package/dist/working.js.map +1 -0
- package/package.json +5 -2
- package/src/digest-bench.tsx +307 -0
- package/src/digest-working.ts +288 -0
- package/src/index.ts +20 -0
- package/src/ligate-bench.tsx +293 -0
- package/src/ligate-working.ts +182 -0
- package/src/ligate.ts +243 -0
- package/src/map.tsx +170 -0
- package/src/pcr-bench.tsx +54 -1
- package/src/pcr-scene.ts +10 -8
- package/src/pcr-working.ts +228 -0
- package/src/run.ts +179 -14
- package/src/sequence-file.ts +172 -0
- package/src/sequences-tool.tsx +109 -0
- package/src/tools.tsx +13 -8
- package/src/working.tsx +96 -0
- package/tools.css +54 -0
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.tsx"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIjD,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.tsx"],"names":[],"mappings":"AAEA,wFAAwF;AACxF,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIjD,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIjE,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAkE,CAAC;AAS7H;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,sCAiBvF;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,EAAE,IAAI,EAAE,KAAa,EAAE,KAAU,EAAE,EAAE;IAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAA;CAAE,sCAezI"}
|
package/dist/tools.js
CHANGED
|
@@ -6,11 +6,15 @@ import { useLab } from "@biolibs/bionet-react";
|
|
|
6
6
|
import { DigestTool } from "./digest-tool.js";
|
|
7
7
|
import { PcrTool } from "./pcr-tool.js";
|
|
8
8
|
import { instrumentFor, toolFor } from "./run.js";
|
|
9
|
+
import { LigationTool } from "./ligate-bench.js";
|
|
10
|
+
import { SequencesTool } from "./sequences-tool.js";
|
|
9
11
|
/** What each tool is called. */
|
|
10
|
-
export const TOOL_NAMES = { pcr: "PCR", digest: "Digest and gel" };
|
|
12
|
+
export const TOOL_NAMES = { pcr: "PCR", digest: "Digest and gel", ligation: "Ligation" };
|
|
11
13
|
function Tool({ tool, instrument, onDone }) {
|
|
12
14
|
const more = onDone === undefined ? {} : { onDone };
|
|
13
|
-
return tool === "pcr" ? _jsx(PcrTool, { instrument: instrument, ...more })
|
|
15
|
+
return tool === "pcr" ? _jsx(PcrTool, { instrument: instrument, ...more })
|
|
16
|
+
: tool === "ligation" ? _jsx(LigationTool, { instrument: instrument, ...more })
|
|
17
|
+
: _jsx(DigestTool, { instrument: instrument, ...more });
|
|
14
18
|
}
|
|
15
19
|
/**
|
|
16
20
|
* The tool an instrument opens.
|
|
@@ -32,7 +36,7 @@ export function InstrumentTool({ place, onDone }) {
|
|
|
32
36
|
*
|
|
33
37
|
* A run is still recorded as done at the instrument for that tool, if the lab has placed one.
|
|
34
38
|
*
|
|
35
|
-
* @param props - `tool` is which to open on; `views` lets a host show a tool its own way, such as
|
|
39
|
+
* @param props - `tool` is which to open on, `sequences` being the lab's sequences and their maps; `views` lets a host show a tool its own way, such as
|
|
36
40
|
* at its instrument in a scene, in place of the plain form.
|
|
37
41
|
*/
|
|
38
42
|
export function Tools({ tool: first = "pcr", views = {} }) {
|
|
@@ -40,6 +44,7 @@ export function Tools({ tool: first = "pcr", views = {} }) {
|
|
|
40
44
|
const [tool, setTool] = useState(first);
|
|
41
45
|
if (lab === null || lab === undefined)
|
|
42
46
|
return null;
|
|
43
|
-
|
|
47
|
+
const names = [["sequences", "Sequences"], ...Object.keys(TOOL_NAMES).map((one) => [one, TOOL_NAMES[one]])];
|
|
48
|
+
return (_jsxs("div", { className: "tools", children: [_jsx("div", { className: "row tight pick", role: "tablist", "aria-label": "Tools", children: names.map(([one, name]) => (_jsx("button", { type: "button", role: "tab", "aria-selected": one === tool, className: one === tool ? "" : "quiet", onClick: () => setTool(one), children: name }, one))) }), tool === "sequences" ? _jsx(SequencesTool, {}) : views[tool] ?? _jsx(Tool, { tool: tool, instrument: instrumentFor(lab, tool) }, tool)] }));
|
|
44
49
|
}
|
|
45
50
|
//# sourceMappingURL=tools.js.map
|
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,wFAAwF;AACxF,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,a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IAAI,CAAC,UAAU,CAAgB,CAAC,GAAG,CAAC,CAAC,GAAG,EAAsB,EAAE,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpL,OAAO,CACL,eAAK,SAAS,EAAC,OAAO,aACpB,cAAK,SAAS,EAAC,gBAAgB,EAAC,IAAI,EAAC,SAAS,gBAAY,OAAO,YAC9D,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAC1B,iBAAkB,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAC,KAAK,mBAAgB,GAAG,KAAK,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,YAAG,IAAI,IAArI,GAAG,CAA4I,CAC7J,CAAC,GACE,EACL,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,KAAC,aAAa,KAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,KAAC,IAAI,IAAY,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,IAAtD,IAAI,CAAsD,IAC5H,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The working, drawn: a figure that opens to show the steps that give it.
|
|
3
|
+
*
|
|
4
|
+
* It is shut until asked for, so a tool reads the same as before to somebody who trusts it, and
|
|
5
|
+
* opens to somebody who wants to follow it. Whether a figure is exact or an estimate is said on the
|
|
6
|
+
* outside, since that is worth knowing without opening anything.
|
|
7
|
+
*/
|
|
8
|
+
import type { ReactNode } from "react";
|
|
9
|
+
import type { CutSite } from "./digest-working.js";
|
|
10
|
+
import type { JoinOverhangs } from "./ligate-working.js";
|
|
11
|
+
import type { BindingWorking, Working } from "./pcr-working.js";
|
|
12
|
+
/**
|
|
13
|
+
* One figure and its working.
|
|
14
|
+
*
|
|
15
|
+
* @param props - `working` is the figure; `children` is drawn under the steps, for a table or a picture that goes with them.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* import { ShowWorking, tmWorking } from "@biolibs/bionet-tools";
|
|
20
|
+
*
|
|
21
|
+
* const working = tmWorking("fwd", "GGATCACAGTCTACACTG");
|
|
22
|
+
* {working !== null && <ShowWorking working={working} />}
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function ShowWorking({ working, children }: {
|
|
26
|
+
working: Working;
|
|
27
|
+
children?: ReactNode;
|
|
28
|
+
}): import("react").JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* A primer laid against the strand it binds, each base over the one it faces.
|
|
31
|
+
*
|
|
32
|
+
* The primer is written 5′ to 3′. A line joins each pair that holds. The bases at the 3′ end that
|
|
33
|
+
* must pair are underlined, and a tail that does not bind stands apart from the strand.
|
|
34
|
+
*
|
|
35
|
+
* @param props - `working` is from `bindingWorking`; `name` is what the primer is called.
|
|
36
|
+
*/
|
|
37
|
+
export declare function FacedBases({ working, name }: {
|
|
38
|
+
working: BindingWorking;
|
|
39
|
+
name: string;
|
|
40
|
+
}): import("react").JSX.Element;
|
|
41
|
+
/**
|
|
42
|
+
* A cut, drawn in the bases it is made in: both strands, the recognised bases marked, and a bar
|
|
43
|
+
* where each strand is cut.
|
|
44
|
+
*
|
|
45
|
+
* @param props - `site` is from `cutSites`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function CutBases({ site }: {
|
|
48
|
+
site: CutSite;
|
|
49
|
+
}): import("react").JSX.Element;
|
|
50
|
+
/**
|
|
51
|
+
* Two ends of a ligation written one over the other, so that the pairing can be read.
|
|
52
|
+
*
|
|
53
|
+
* @param props - `bases` is from `joinWorking`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function JoinBases({ bases }: {
|
|
56
|
+
bases: JoinOverhangs;
|
|
57
|
+
}): import("react").JSX.Element;
|
|
58
|
+
//# sourceMappingURL=working.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working.d.ts","sourceRoot":"","sources":["../src/working.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAa,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3E;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,+BAY5F;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAAE,OAAO,EAAE,cAAc,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,+BAUtF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,+BAYnD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,+BAW5D"}
|
package/dist/working.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* One figure and its working.
|
|
4
|
+
*
|
|
5
|
+
* @param props - `working` is the figure; `children` is drawn under the steps, for a table or a picture that goes with them.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { ShowWorking, tmWorking } from "@biolibs/bionet-tools";
|
|
10
|
+
*
|
|
11
|
+
* const working = tmWorking("fwd", "GGATCACAGTCTACACTG");
|
|
12
|
+
* {working !== null && <ShowWorking working={working} />}
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export function ShowWorking({ working, children }) {
|
|
16
|
+
return (_jsxs("details", { className: "working", children: [_jsxs("summary", { children: [_jsx("span", { className: "of", children: working.of }), " ", _jsx("strong", { children: working.comes }), _jsx("span", { className: `kind ${working.kind}`, title: working.kind === "exact" ? "This follows from the sequences alone." : "This rests on a rule of thumb. A different rule would give a different figure.", children: working.kind })] }), _jsx("ol", { children: working.steps.map((step) => _jsx("li", { children: step }, step)) }), children, working.rests !== undefined && _jsx("p", { className: "rests", children: working.rests })] }));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A primer laid against the strand it binds, each base over the one it faces.
|
|
20
|
+
*
|
|
21
|
+
* The primer is written 5′ to 3′. A line joins each pair that holds. The bases at the 3′ end that
|
|
22
|
+
* must pair are underlined, and a tail that does not bind stands apart from the strand.
|
|
23
|
+
*
|
|
24
|
+
* @param props - `working` is from `bindingWorking`; `name` is what the primer is called.
|
|
25
|
+
*/
|
|
26
|
+
export function FacedBases({ working, name }) {
|
|
27
|
+
const says = `${name}, 5′ to 3′, against the ${working.strand} strand: ${working.faced.filter((one) => one.pairs).length} of ${working.faced.length} bases pair.`;
|
|
28
|
+
const cell = (base, extra = "") => _jsx("span", { className: `base base-${base.toLowerCase() || "none"} ${extra}`, children: base || "·" });
|
|
29
|
+
return (_jsxs("div", { className: "faced", role: "img", "aria-label": says, children: [_jsxs("div", { className: "row", children: [_jsx("span", { className: "end", children: "5\u2032" }), working.faced.map((one, at) => _jsx("span", { children: cell(one.primer, one.needed ? "needed" : "") }, at)), _jsxs("span", { className: "end", children: ["3\u2032 ", name] })] }), _jsxs("div", { className: "row", children: [_jsx("span", { className: "end" }), working.faced.map((one, at) => _jsx("span", { className: one.pairs ? "bond" : "bond none", children: one.pairs ? "|" : " " }, at)), _jsx("span", { className: "end" })] }), _jsxs("div", { className: "row", children: [_jsx("span", { className: "end", children: "3\u2032" }), working.faced.map((one, at) => _jsx("span", { children: cell(one.faces) }, at)), _jsxs("span", { className: "end", children: ["5\u2032 ", working.strand, " strand"] })] })] }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A cut, drawn in the bases it is made in: both strands, the recognised bases marked, and a bar
|
|
33
|
+
* where each strand is cut.
|
|
34
|
+
*
|
|
35
|
+
* @param props - `site` is from `cutSites`.
|
|
36
|
+
*/
|
|
37
|
+
export function CutBases({ site }) {
|
|
38
|
+
const { top, bottom, site: [start, end], cutTop, cutBottom } = site.around;
|
|
39
|
+
const says = `${site.enzyme} at base ${site.at.toLocaleString("en-US")}: it recognises ${site.recognises} and leaves ${site.overhang === "blunt" ? "a blunt end" : `a ${site.overhang} overhang of ${site.bases}`}.`;
|
|
40
|
+
const row = (bases, cut) => [...bases].map((base, at) => (_jsx("span", { className: `base base-${base.toLowerCase()}${at >= start && at < end ? " site" : ""}${at === cut ? " cut" : ""}`, children: base }, at)));
|
|
41
|
+
return (_jsxs("div", { className: "faced cutbases", role: "img", "aria-label": says, children: [_jsxs("div", { className: "row", children: [_jsx("span", { className: "end", children: "5\u2032" }), row(top, cutTop), _jsx("span", { className: "end", children: "3\u2032 top" })] }), _jsxs("div", { className: "row", children: [_jsx("span", { className: "end", children: "3\u2032" }), row(bottom, cutBottom), _jsx("span", { className: "end", children: "5\u2032 bottom" })] })] }));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Two ends of a ligation written one over the other, so that the pairing can be read.
|
|
45
|
+
*
|
|
46
|
+
* @param props - `bases` is from `joinWorking`.
|
|
47
|
+
*/
|
|
48
|
+
export function JoinBases({ bases }) {
|
|
49
|
+
if (bases.kind === "blunt")
|
|
50
|
+
return _jsx("p", { className: "faced blunt", children: "Both ends are blunt, so there is nothing to pair: ligase seals them as they meet." });
|
|
51
|
+
const says = `${bases.from}'s ${bases.kind} overhang ${bases.left} against ${bases.to}'s ${bases.right}.`;
|
|
52
|
+
const row = (text) => [...text].map((base, at) => _jsx("span", { className: `base base-${base.toLowerCase()}`, children: base }, at));
|
|
53
|
+
return (_jsxs("div", { className: "faced", role: "img", "aria-label": says, children: [_jsxs("div", { className: "row", children: [_jsx("span", { className: "end", children: bases.from }), row(bases.left), _jsx("span", { className: "end" })] }), _jsxs("div", { className: "row", children: [_jsx("span", { className: "end" }), [...bases.left].map((base, at) => _jsx("span", { className: "bond", children: "|" }, at)), _jsx("span", { className: "end" })] }), _jsxs("div", { className: "row", children: [_jsx("span", { className: "end", children: bases.to }), row(bases.right), _jsx("span", { className: "end" })] })] }));
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=working.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"working.js","sourceRoot":"","sources":["../src/working.tsx"],"names":[],"mappings":";AAYA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,EAAE,OAAO,EAAE,QAAQ,EAA8C;IAC3F,OAAO,CACL,mBAAS,SAAS,EAAC,SAAS,aAC1B,8BACE,eAAM,SAAS,EAAC,IAAI,YAAE,OAAO,CAAC,EAAE,GAAQ,OAAC,2BAAS,OAAO,CAAC,KAAK,GAAU,EACzE,eAAM,SAAS,EAAE,QAAQ,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,gFAAgF,YAAG,OAAO,CAAC,IAAI,GAAQ,IACrN,EACV,uBAAK,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,uBAAgB,IAAI,IAAX,IAAI,CAAa,CAAC,GAAM,EACjE,QAAQ,EACR,OAAO,CAAC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ChD,eAAK,SAAS,EAAC,KAAK,aAAC,eAAM,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,IAAI,GAAQ,EAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAC,eAAM,SAAS,EAAC,KAAK,GAAG,IAAM,EAC7G,eAAK,SAAS,EAAC,KAAK,aAAC,eAAM,SAAS,EAAC,KAAK,GAAG,EAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,eAAe,SAAS,EAAC,MAAM,mBAApB,EAAE,CAA2B,CAAC,EAAC,eAAM,SAAS,EAAC,KAAK,GAAG,IAAM,EACxJ,eAAK,SAAS,EAAC,KAAK,aAAC,eAAM,SAAS,EAAC,KAAK,YAAE,KAAK,CAAC,EAAE,GAAQ,EAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC,eAAM,SAAS,EAAC,KAAK,GAAG,IAAM,IACxG,CACP,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
},
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@biolibs/assembly2": "^1.0.0",
|
|
7
|
-
"@biolibs/bionet": "^1.3.
|
|
7
|
+
"@biolibs/bionet": "^1.3.2",
|
|
8
8
|
"@biolibs/bionet-panels": "^0.3.1",
|
|
9
9
|
"@biolibs/bionet-react": "^0.2.0",
|
|
10
|
+
"@biolibs/dseq": "^1.0.0",
|
|
10
11
|
"@biolibs/dseqrecord": "^1.1.1",
|
|
11
12
|
"@biolibs/gel": "^1.0.0",
|
|
12
13
|
"@biolibs/glossary-react": "^0.1.0",
|
|
13
14
|
"@biolibs/restriction": "^1.0.0",
|
|
14
15
|
"@biolibs/seq": "^1.0.0",
|
|
16
|
+
"@biolibs/seqio": "^1.1.2",
|
|
17
|
+
"@biolibs/seqmap": "^1.0.0",
|
|
15
18
|
"@biolibs/seqtools": "^1.0.0"
|
|
16
19
|
},
|
|
17
20
|
"description": "The tools a lab uses at the bench, tied to its freezer: PCR and a check digest with its gel, run in silico from the tubes it holds and recorded, so what was used is taken and what was made becomes a tube",
|
|
@@ -59,5 +62,5 @@
|
|
|
59
62
|
],
|
|
60
63
|
"type": "module",
|
|
61
64
|
"types": "dist/index.d.ts",
|
|
62
|
-
"version": "0.1.
|
|
65
|
+
"version": "0.1.2"
|
|
63
66
|
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A digest and its gel at the gel station: what is shown beside the instrument, and what the scene
|
|
5
|
+
* is told to draw.
|
|
6
|
+
*
|
|
7
|
+
* A gel box and its power supply show a voltage, a current and a time. They show nothing of the
|
|
8
|
+
* DNA: where it was cut, how many pieces there are, how far each has run. That is pictured, and
|
|
9
|
+
* then read off the gel against a ladder. So the views run the same way as a PCR's: the rig, the
|
|
10
|
+
* gel in it, what the power supply says, then what is in the tube, and the gel once it has run.
|
|
11
|
+
*/
|
|
12
|
+
import { useMemo, useState, type ReactNode } from "react";
|
|
13
|
+
import { GELS, LADDERS, gelById } from "@biolibs/gel";
|
|
14
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
15
|
+
import { Glossed } from "@biolibs/glossary-react";
|
|
16
|
+
import { cutters, enzymeNamed } from "./digest.js";
|
|
17
|
+
import { Gel } from "./digest-tool.js";
|
|
18
|
+
import { cutSites, digestChecks, digestPieces, migrationWorking, piecesWorking, siteWorking, type PieceEnd } from "./digest-working.js";
|
|
19
|
+
import { SequenceMap } from "./map.js";
|
|
20
|
+
import { digestRun, digestTubes } from "./run.js";
|
|
21
|
+
import { moleculeOf, type DrawnMolecule } from "./sequence-file.js";
|
|
22
|
+
import { CutBases, ShowWorking } from "./working.js";
|
|
23
|
+
|
|
24
|
+
/** The views of the gel station, by the same names every instrument's stage uses. */
|
|
25
|
+
export type DigestView = "machine" | "block" | "screen" | "tube" | "result";
|
|
26
|
+
|
|
27
|
+
/** What the scene is told to show. It is shaped to be spread onto `InstrumentStage`. */
|
|
28
|
+
export interface DigestStage {
|
|
29
|
+
model: "gel-station";
|
|
30
|
+
name: string;
|
|
31
|
+
view: DigestView;
|
|
32
|
+
onView: (view: DigestView) => void;
|
|
33
|
+
/** What the power supply's display says. */
|
|
34
|
+
screen: { text: string; lit?: boolean }[];
|
|
35
|
+
/** The lane the digest is loaded in. */
|
|
36
|
+
well?: { row: number; column: number };
|
|
37
|
+
/** The molecule being cut, with the cuts marked, for the view into the tube. */
|
|
38
|
+
molecule?: DrawnMolecule & { marks: { at: number; label: string }[] };
|
|
39
|
+
/** The gel once run: the ladder and the digest, for the last view. */
|
|
40
|
+
gel?: { lanes: { name: string; tone: "dim" | "held"; bands: { position: number; intensity: number; label: string }[] }[]; ran: number };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const count = (value: number): string => value.toLocaleString("en-US");
|
|
44
|
+
const whole = (text: string): number | undefined => (/^\d+$/.test(text.trim()) ? Number(text) : undefined);
|
|
45
|
+
const endWords = (end: PieceEnd): ReactNode => (end.enzyme === null ? <span className="dim">the molecule's end</span>
|
|
46
|
+
: <>{end.enzyme} <span className="dim">{end.overhang === "blunt" ? "blunt" : `${end.overhang} `}</span>{end.overhang !== "blunt" && <code>{end.bases}</code>}</>);
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A digest and its gel, at the gel station.
|
|
50
|
+
*
|
|
51
|
+
* @param options - `instrument` is the gel station it is run at, if the lab has one; `onDone` adds a way to leave.
|
|
52
|
+
* @returns `stage`, to spread onto `InstrumentStage` from `@biolibs/bionet-scene`, and `panel`, to put inside it.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* import { useDigestBench } from "@biolibs/bionet-tools";
|
|
57
|
+
*
|
|
58
|
+
* // `InstrumentStage` is the scene package's: it is handed what this gives and draws it.
|
|
59
|
+
* const bench = useDigestBench({ instrument });
|
|
60
|
+
* <InstrumentStage {...bench.stage}>{bench.panel}</InstrumentStage>
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export function useDigestBench({ instrument = null, onDone }: { instrument?: { id: string; name: string } | null; onDone?: () => void } = {}): { stage: DigestStage; panel: ReactNode } {
|
|
64
|
+
const lab = useLab()?.lab;
|
|
65
|
+
const act = useAct();
|
|
66
|
+
const [view, setView] = useState<DigestView>("machine");
|
|
67
|
+
const [tube, setTube] = useState("");
|
|
68
|
+
const [chosen, setChosen] = useState<string[]>([]);
|
|
69
|
+
const [other, setOther] = useState("");
|
|
70
|
+
const [unknown, setUnknown] = useState<string | null>(null);
|
|
71
|
+
const [used, setUsed] = useState("1");
|
|
72
|
+
const [gel, setGel] = useState("1.0");
|
|
73
|
+
const [ladder, setLadder] = useState("1kb");
|
|
74
|
+
const [volts, setVolts] = useState("100");
|
|
75
|
+
const [minutes, setMinutes] = useState("45");
|
|
76
|
+
const [ran, setRan] = useState(100);
|
|
77
|
+
const [note, setNote] = useState("");
|
|
78
|
+
const [busy, setBusy] = useState(false);
|
|
79
|
+
const [said, setSaid] = useState<string | null>(null);
|
|
80
|
+
const [keep, setKeep] = useState<number[]>([]);
|
|
81
|
+
const [amount, setAmount] = useState("20");
|
|
82
|
+
|
|
83
|
+
const tubes = useMemo(() => (lab === null || lab === undefined ? [] : digestTubes(lab)), [lab]);
|
|
84
|
+
const part = tubes.find((one) => one.item === tube)?.part;
|
|
85
|
+
const offered = useMemo(() => (part === undefined ? [] : cutters(part)), [part]);
|
|
86
|
+
const run = useMemo(() => (lab === null || lab === undefined ? null : digestRun(lab, {
|
|
87
|
+
tube, enzymes: chosen, gel, ladder, instrument: instrument?.id ?? null, note, ...(whole(used) === undefined ? {} : { used: whole(used)! }),
|
|
88
|
+
...(whole(volts) === undefined ? {} : { volts: whole(volts)! }), ...(whole(minutes) === undefined ? {} : { minutes: whole(minutes)! }),
|
|
89
|
+
keep: keep.map((from) => ({ from, ...(whole(amount) === undefined ? {} : { amount: whole(amount)! }) })),
|
|
90
|
+
})), [lab, tube, chosen, gel, ladder, instrument, note, used, volts, minutes, keep, amount]);
|
|
91
|
+
const plan = run?.plan ?? null;
|
|
92
|
+
const good = plan !== null && plan.problem === null ? plan : null;
|
|
93
|
+
const sites = useMemo(() => (part === undefined || plan === null ? [] : plan.cutters.flatMap((one) => cutSites(part, one)).sort((a, b) => a.at - b.at)), [part, plan]);
|
|
94
|
+
const pieces = useMemo(() => (part === undefined ? [] : digestPieces(part, sites)), [part, sites]);
|
|
95
|
+
// A piece is known by where it starts, so a change of enzymes lets go of pieces that are no longer there.
|
|
96
|
+
const kept = pieces.filter((piece) => keep.includes(piece.from));
|
|
97
|
+
const gelType = useMemo(() => { try { return gelById(gel); } catch { return gelById("1.0"); } }, [gel]);
|
|
98
|
+
const checks = part === undefined || good === null ? [] : digestChecks(part, good, gelType);
|
|
99
|
+
|
|
100
|
+
const stage: DigestStage = {
|
|
101
|
+
model: "gel-station", name: instrument?.name ?? "Gel station", view, onView: setView,
|
|
102
|
+
screen: [{ text: `${whole(volts) ?? "—"} V`, lit: true }, { text: `${whole(minutes) ?? "—"}:00 min` }],
|
|
103
|
+
...(part === undefined ? {} : { well: { row: 0, column: 1 } }),
|
|
104
|
+
...(part === undefined || view !== "tube" ? {} : { molecule: (() => {
|
|
105
|
+
const drawn = moleculeOf(part);
|
|
106
|
+
// A piece being kept is drawn on the molecule, so what is taken can be seen against what is left.
|
|
107
|
+
const taken = kept.flatMap((piece) => (piece.to > piece.from ? [[piece.from, piece.to]] : [[piece.from, part.length], [0, piece.to]]).filter(([start, end]) => end! > start!)
|
|
108
|
+
.map(([start, end]) => ({ start: start!, end: end!, strand: 0 as const, tone: "found" as const, label: `kept · ${count(piece.length)} bp` })));
|
|
109
|
+
return { ...drawn, features: [...taken, ...drawn.features], marks: sites.map((one) => ({ at: one.at, label: one.enzyme })) };
|
|
110
|
+
})() }),
|
|
111
|
+
...(good === null ? {} : { gel: { ran: ran / 100, lanes: [
|
|
112
|
+
{ name: "ladder", tone: "dim" as const, bands: good.ladder.map((band) => ({ position: band.position, intensity: 0.6, label: count(band.size) })) },
|
|
113
|
+
{ name: part?.name ?? "digest", tone: "held" as const, bands: good.bands.map((band) => ({ position: band.position, intensity: band.intensity,
|
|
114
|
+
label: `${band.sizes.map(count).join(" + ")}${kept.some((piece) => band.sizes.includes(piece.length)) ? " · kept" : ""}` })) },
|
|
115
|
+
] } }),
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const toggle = (name: string): void => { setChosen(chosen.includes(name) ? chosen.filter((one) => one !== name) : [...chosen, name]); setSaid(null); setKeep([]); };
|
|
119
|
+
const record = async (what: Record<string, unknown> | null, done: string): Promise<void> => {
|
|
120
|
+
if (what === null) return;
|
|
121
|
+
setBusy(true);
|
|
122
|
+
const answer = await act("recordRun", what);
|
|
123
|
+
setBusy(false);
|
|
124
|
+
if (answer.ok) { setSaid(done); setNote(""); setKeep([]); }
|
|
125
|
+
};
|
|
126
|
+
const here = lab === null || lab === undefined ? [] : lab.runs.filter((one) => one.kind === "digest" && (instrument === null || one.instrument === instrument.id)).slice(-5).reverse();
|
|
127
|
+
const partName = (item: string | undefined): string => lab?.parts.find((one) => one.checksum === lab.items.find((each) => each.item === item)?.part)?.name ?? "a tube";
|
|
128
|
+
const checked = checks.length === 0 ? <p className="small good">Nothing about this digest looks wrong for this gel.</p>
|
|
129
|
+
: <ul className="checks">{checks.map((check) => <li key={check.says} className={check.weight}>{check.says} <code className="because">{check.because}</code></li>)}</ul>;
|
|
130
|
+
|
|
131
|
+
const panel = lab === null || lab === undefined ? null : (
|
|
132
|
+
<div className="bionet benchpanel">
|
|
133
|
+
<section className="card">
|
|
134
|
+
<div className="toolhead">
|
|
135
|
+
<h2>Digest and gel</h2>
|
|
136
|
+
{onDone !== undefined && <button type="button" className="quiet" onClick={onDone}>Back to the lab</button>}
|
|
137
|
+
</div>
|
|
138
|
+
{tubes.length === 0 ? <p className="empty">There are no tubes to digest. Add a part and a tube of it on the Freezer tab.</p> : (
|
|
139
|
+
<fieldset disabled={busy} className="stack">
|
|
140
|
+
<label>Tube
|
|
141
|
+
<select value={tube} onChange={(event) => { setTube(event.target.value); setChosen([]); setSaid(null); setKeep([]); }} aria-label="Tube">
|
|
142
|
+
<option value="">Choose a tube…</option>
|
|
143
|
+
{tubes.map((one) => <option key={one.item} value={one.item}>{one.label}</option>)}
|
|
144
|
+
</select>
|
|
145
|
+
</label>
|
|
146
|
+
{part !== undefined && (
|
|
147
|
+
<>
|
|
148
|
+
<p className="label">Enzymes{offered.length === 0 ? " · none of the usual ones cut this" : ""}</p>
|
|
149
|
+
<div className="enzymes">
|
|
150
|
+
{offered.map((one) => (
|
|
151
|
+
<label key={one.name} className="check" title={`${one.site} · cuts ${one.positions.length === 1 ? "once" : `${one.positions.length} times`}`}>
|
|
152
|
+
<input type="checkbox" checked={chosen.includes(one.name)} onChange={() => toggle(one.name)} /> {one.name} <span className="dim small">×{one.positions.length}</span>
|
|
153
|
+
</label>
|
|
154
|
+
))}
|
|
155
|
+
{chosen.filter((name) => !offered.some((one) => one.name === name)).map((name) => (
|
|
156
|
+
<label key={name} className="check"><input type="checkbox" checked onChange={() => toggle(name)} /> {name}</label>
|
|
157
|
+
))}
|
|
158
|
+
</div>
|
|
159
|
+
<form className="row tight" onSubmit={(event) => {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
const name = enzymeNamed(other);
|
|
162
|
+
setUnknown(name === null && other.trim() !== "" ? other.trim() : null);
|
|
163
|
+
if (name !== null && !chosen.includes(name)) setChosen([...chosen, name]);
|
|
164
|
+
if (name !== null) setOther("");
|
|
165
|
+
}}>
|
|
166
|
+
<input value={other} onChange={(event) => setOther(event.target.value)} placeholder="Another enzyme, by name" aria-label="Another enzyme" maxLength={40} spellCheck={false} />
|
|
167
|
+
<button type="submit" className="quiet">Add</button>
|
|
168
|
+
</form>
|
|
169
|
+
{unknown !== null && <p className="trouble small" role="status">There is no enzyme called {unknown} here.</p>}
|
|
170
|
+
</>
|
|
171
|
+
)}
|
|
172
|
+
</fieldset>
|
|
173
|
+
)}
|
|
174
|
+
{plan !== null && chosen.length > 0 && plan.problem !== null && <p className="trouble" role="status">{plan.problem}</p>}
|
|
175
|
+
</section>
|
|
176
|
+
|
|
177
|
+
{view === "machine" && (
|
|
178
|
+
<section className="card">
|
|
179
|
+
<h2>At the gel box</h2>
|
|
180
|
+
<p className="small"><Glossed text="A restriction enzyme cuts DNA wherever its site occurs, and gel electrophoresis sorts the pieces by size. A check digest cuts a plasmid with enzymes whose sites are known, to see that the pieces come out the lengths they should." /></p>
|
|
181
|
+
<p className="dim small">A gel box and its power supply show volts, current and time. They show nothing of the DNA. The first three views are what is there to see; the last two are what you picture, and then read off the gel.</p>
|
|
182
|
+
</section>
|
|
183
|
+
)}
|
|
184
|
+
|
|
185
|
+
{view === "block" && (
|
|
186
|
+
<section className="card">
|
|
187
|
+
<h2>The gel</h2>
|
|
188
|
+
<p className="voice">The machine</p>
|
|
189
|
+
<fieldset disabled={busy} className="programme">
|
|
190
|
+
<label>Gel<select value={gel} onChange={(event) => setGel(event.target.value)}>{GELS.map((one) => <option key={one.id} value={one.id}>{one.percent}% agarose</option>)}</select></label>
|
|
191
|
+
<label>Ladder<select value={ladder} onChange={(event) => setLadder(event.target.value)}>{LADDERS.map((one) => <option key={one.id} value={one.id}>{one.name}</option>)}</select></label>
|
|
192
|
+
</fieldset>
|
|
193
|
+
<p className="small"><Glossed text="A slab of agarose in buffer, with a row of wells at one end. The wells go at the negative end, since DNA runs towards the positive one." /></p>
|
|
194
|
+
<p className="voice">This run</p>
|
|
195
|
+
<p className="small">{part === undefined ? "Nothing is loaded yet. Choose a tube above." : `The ladder is in the first lane and ${part.name} in the second.`} This gel separates pieces from {count(gelType.largest)} down to {count(gelType.smallest)} bp.</p>
|
|
196
|
+
{good !== null && <><p className="voice">Checks</p>{checked}</>}
|
|
197
|
+
</section>
|
|
198
|
+
)}
|
|
199
|
+
|
|
200
|
+
{view === "screen" && (
|
|
201
|
+
<section className="card">
|
|
202
|
+
<h2>The power supply</h2>
|
|
203
|
+
<p className="voice">The machine</p>
|
|
204
|
+
<fieldset disabled={busy} className="programme">
|
|
205
|
+
<label>Run at<input type="number" min={10} max={300} step={5} value={volts} onChange={(event) => setVolts(event.target.value)} /> V</label>
|
|
206
|
+
<label>for<input type="number" min={1} max={600} step={5} value={minutes} onChange={(event) => setMinutes(event.target.value)} /> min</label>
|
|
207
|
+
</fieldset>
|
|
208
|
+
<p className="voice">What is going on</p>
|
|
209
|
+
<p className="small">DNA carries a negative charge all along its backbone, so in a field every piece is pulled towards the positive electrode. The agarose holds long pieces back more than short ones, and that is what sorts them.</p>
|
|
210
|
+
<p className="dim small">Nothing here works out how far a given voltage and time move the bands: that depends on the box, the buffer and the gel. What is set is kept with the run, and the gel is drawn as run until the smallest pieces it separates near the far end.</p>
|
|
211
|
+
</section>
|
|
212
|
+
)}
|
|
213
|
+
|
|
214
|
+
{view === "tube" && (
|
|
215
|
+
<section className="card">
|
|
216
|
+
<h2>In the tube</h2>
|
|
217
|
+
{part === undefined || good === null ? <p className="dim small">{part === undefined ? "Choose a tube and its enzymes to see where it is cut." : "Choose enzymes that cut this to see the pieces."}</p> : (
|
|
218
|
+
<>
|
|
219
|
+
<SequenceMap name={part.name} length={part.length} circular={part.circular} features={part.features} marks={sites.map((one) => ({ at: one.at, label: one.enzyme }))} />
|
|
220
|
+
<p className="voice">This run</p>
|
|
221
|
+
<p><strong>{pieces.length} {pieces.length === 1 ? "piece" : "pieces"}</strong> <span className="dim">from {sites.length} {sites.length === 1 ? "cut" : "cuts"}</span></p>
|
|
222
|
+
<table className="pieces">
|
|
223
|
+
<thead><tr><th>Keep</th><th>Length</th><th>From</th><th>One end</th><th>Other end</th><th>Carries</th></tr></thead>
|
|
224
|
+
<tbody>
|
|
225
|
+
{pieces.map((piece) => (
|
|
226
|
+
<tr key={`${piece.from} ${piece.to}`}>
|
|
227
|
+
<td><input type="checkbox" checked={keep.includes(piece.from)} aria-label={`Keep the ${count(piece.length)} bp piece`}
|
|
228
|
+
onChange={() => setKeep(keep.includes(piece.from) ? keep.filter((one) => one !== piece.from) : [...keep, piece.from])} /></td>
|
|
229
|
+
<td><strong>{count(piece.length)}</strong></td>
|
|
230
|
+
<td><code>{count(piece.from + 1)}..{count(piece.to)}</code></td>
|
|
231
|
+
<td>{endWords(piece.left)}</td>
|
|
232
|
+
<td>{endWords(piece.right)}</td>
|
|
233
|
+
<td className="dim">{piece.features.map((one) => one.label).join(", ") || "—"}</td>
|
|
234
|
+
</tr>
|
|
235
|
+
))}
|
|
236
|
+
</tbody>
|
|
237
|
+
</table>
|
|
238
|
+
<p className="small"><Glossed text="An end with unpaired bases is a sticky end, and will only join to an end whose unpaired bases pair with it. A blunt end has none." /></p>
|
|
239
|
+
<p className="dim small">Tick a piece to keep it. Cutting its band out of the gel and cleaning it up gives a tube of that piece, with these ends, once the gel has matched.</p>
|
|
240
|
+
<p className="voice">The working</p>
|
|
241
|
+
{sites.map((site) => <ShowWorking key={`${site.enzyme} ${site.at}`} working={siteWorking(site)}><CutBases site={site} /></ShowWorking>)}
|
|
242
|
+
<ShowWorking working={piecesWorking(part, sites, good)} />
|
|
243
|
+
</>
|
|
244
|
+
)}
|
|
245
|
+
</section>
|
|
246
|
+
)}
|
|
247
|
+
|
|
248
|
+
{view === "result" && (
|
|
249
|
+
<section className="card">
|
|
250
|
+
<h2>The gel, run</h2>
|
|
251
|
+
{part === undefined || good === null ? <p className="dim small">Choose a tube and enzymes that cut it to see the gel it should give.</p> : (
|
|
252
|
+
<>
|
|
253
|
+
<p className="voice">This run</p>
|
|
254
|
+
<Gel ladder={good.ladder} bands={good.bands} name={part.name} />
|
|
255
|
+
<label className="small">How far it has run
|
|
256
|
+
<input type="range" min={0} max={100} step={1} value={ran} onChange={(event) => setRan(Number(event.target.value))} aria-label="How far the gel has run" />
|
|
257
|
+
</label>
|
|
258
|
+
<p className="dim small">Drag it back to see the pieces start together in the well and draw apart as they run. The scene follows.</p>
|
|
259
|
+
{good.bands.some((band) => band.unresolved) && <p className="dim small">* outside what this gel separates.</p>}
|
|
260
|
+
<p className="voice">Checks</p>
|
|
261
|
+
{checked}
|
|
262
|
+
<p className="voice">The working</p>
|
|
263
|
+
{[...new Set(good.fragments)].map((size) => <ShowWorking key={size} working={migrationWorking(size, gelType)} />)}
|
|
264
|
+
<fieldset disabled={busy} className="stack">
|
|
265
|
+
<label>Used, from the tube<input type="number" min={0} step={1} value={used} onChange={(event) => setUsed(event.target.value)} aria-label="Amount used" /></label>
|
|
266
|
+
<label>Note<input value={note} onChange={(event) => setNote(event.target.value)} placeholder="Anything worth remembering about this gel" maxLength={2000} /></label>
|
|
267
|
+
{kept.length > 0 && (
|
|
268
|
+
<>
|
|
269
|
+
<p className="small">Keeping {kept.map((piece) => `${count(piece.length)} bp`).join(" and ")}: {kept.length === 1 ? "a new tube" : `${kept.length} new tubes`}, each a part with the ends the enzymes left.</p>
|
|
270
|
+
<label>Amount of each, in µL<input type="number" min={0} step={1} value={amount} onChange={(event) => setAmount(event.target.value)} aria-label="Amount of each kept piece" /></label>
|
|
271
|
+
</>
|
|
272
|
+
)}
|
|
273
|
+
<div className="row">
|
|
274
|
+
<button type="button" onClick={() => void record(run?.matched ?? null, kept.length === 0 ? "Recorded: the gel showed what was expected." : `Recorded: the gel matched, and ${kept.length === 1 ? "the piece is" : `${kept.length} pieces are`} in the freezer.`)}>
|
|
275
|
+
{kept.length === 0 ? "The gel matched" : `The gel matched · keep ${kept.length === 1 ? "the piece" : `${kept.length} pieces`}`}
|
|
276
|
+
</button>
|
|
277
|
+
<button type="button" className="quiet" onClick={() => void record(run?.differed ?? null, "Recorded: the gel did not show what was expected.")}>The gel did not match</button>
|
|
278
|
+
</div>
|
|
279
|
+
</fieldset>
|
|
280
|
+
{said !== null && <p className="small" role="status">{said}</p>}
|
|
281
|
+
</>
|
|
282
|
+
)}
|
|
283
|
+
</section>
|
|
284
|
+
)}
|
|
285
|
+
|
|
286
|
+
{here.length > 0 && view === "result" && (
|
|
287
|
+
<section className="card">
|
|
288
|
+
<h2>Recent digests{instrument === null ? "" : " here"}</h2>
|
|
289
|
+
<table>
|
|
290
|
+
<thead><tr><th>Tube</th><th>Enzymes</th><th>Expected</th><th>Gel</th></tr></thead>
|
|
291
|
+
<tbody>
|
|
292
|
+
{here.map((one) => (
|
|
293
|
+
<tr key={one.run}>
|
|
294
|
+
<td>{partName(one.inputs[0]?.item)}</td>
|
|
295
|
+
<td>{String(one.settings["enzymes"] ?? "").replace(/\+/g, " + ")}</td>
|
|
296
|
+
<td className="dim">{String(one.settings["expected"] ?? "")}</td>
|
|
297
|
+
<td>{one.outcome === "worked" ? "matched" : <span className="badge">did not match</span>}</td>
|
|
298
|
+
</tr>
|
|
299
|
+
))}
|
|
300
|
+
</tbody>
|
|
301
|
+
</table>
|
|
302
|
+
</section>
|
|
303
|
+
)}
|
|
304
|
+
</div>
|
|
305
|
+
);
|
|
306
|
+
return { stage, panel };
|
|
307
|
+
}
|