@biolibs/bionet-tools 0.0.0-stage → 0.1.0

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 CHANGED
@@ -1,3 +1,69 @@
1
- # Temporary Holding Version
1
+ # @biolibs/bionet-tools
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The tools a lab uses at the bench, tied to its freezer: PCR, and a check digest with its gel. For PCR, choose a template and two primers from the tubes the lab holds, see what they would make, and record the run. The template and primers drop by what was used, and the product becomes a new tube that knows which run made it.
4
+
5
+ ```
6
+ npm install @biolibs/bionet-tools @biolibs/bionet-panels @biolibs/bionet-react @biolibs/bionet-theme react
7
+ ```
8
+
9
+ ## What a PCR would make
10
+
11
+ ```ts
12
+ import { planPcr, primerTm } from "@biolibs/bionet-tools";
13
+
14
+ const template = "GGATCACAGTCTACACTGCTCACTCCAACCCCGGCCCCTGAGTCCGAGGAGAGGGTGCTTCAGAGTATGTATACC";
15
+ const plan = planPcr({ sequence: template, circular: false }, "GGATCACAGTCTACACTG", "GGTATACATACTCTGAAG");
16
+ plan.problem; // null
17
+ plan.products[0].length; // 75
18
+ primerTm("GGATCACAGTCTACACTG"); // 54
19
+ ```
20
+
21
+ `planPcr` takes sequences and returns sequences, using the engine in `@biolibs/assembly2` that the cloning plans use. The primers may be given in either order. If they do not make exactly one product, `problem` says why in words.
22
+
23
+ ## From the freezer to a recorded run
24
+
25
+ ```ts
26
+ import { pcrRun, pcrTubes } from "@biolibs/bionet-tools";
27
+
28
+ const { templates, primers } = pcrTubes(lab); // lab is the `lab` of a client's snapshot
29
+ const run = pcrRun(lab, { template: templates[0].item, forward: primers[0].item, reverse: primers[1].item });
30
+ run.plan?.products[0]?.length; // what it would make
31
+ if (run.worked !== null) await act("recordRun", run.worked);
32
+ ```
33
+
34
+ `pcrTubes` offers short linear parts as primers and the rest as templates. `pcrRun` works a choice out into what to hand the lab's `recordRun`: `worked` when there is exactly one product, and `failed` for a run that was done and gave nothing, which still used the tubes.
35
+
36
+ ## A digest and its gel
37
+
38
+ ```ts
39
+ import { cutters, digestRun, planDigest } from "@biolibs/bionet-tools";
40
+
41
+ const plan = planDigest({ sequence: "AAAAAAAAAAGAATTCAAAAAAAAAAAAAAAAAAAAGGATCCAAAAAAAAAA", circular: true }, ["EcoRI", "BamHI"]);
42
+ plan.fragments; // [ 26, 26 ]
43
+ plan.problem; // null
44
+
45
+ cutters(part); // the usual enzymes that cut a part, fewest cuts first
46
+ const run = digestRun(lab, { tube, enzymes: ["EcoRI"] }); // what to record, if the gel matched or did not
47
+ ```
48
+
49
+ `planDigest` gives the cuts, the pieces, and the bands they and a ladder would show on a gel, from
50
+ `@biolibs/restriction` and `@biolibs/gel`. A digest here is a check: recording it uses some of the
51
+ tube, makes nothing, and notes which enzymes, what was expected and whether the gel showed it.
52
+ Keeping a cut piece as a tube is not offered, because a part cannot yet say what ends it has.
53
+
54
+ ## The tool
55
+
56
+ ```tsx
57
+ import "@biolibs/bionet-tools/tools.css";
58
+ import { InstrumentTool, PcrTool } from "@biolibs/bionet-tools";
59
+
60
+ <InstrumentTool place={thermocyclerId} onDone={close} /> // the tool for whichever instrument that is
61
+ <Tools /> // every tool, for a lab that has not drawn its room
62
+ <PcrTool /> // or one tool on its own; DigestTool likewise
63
+ ```
64
+
65
+ The tools use the lab's hooks and are drawn with the panels' styles, so they go inside a `LabProvider` and a `LabWindow`. `InstrumentTool` opens PCR for a place whose `model` is `thermocycler` and digest and gel for a `gel-station`, and says so when there is no tool for an instrument yet. `Tools` lists them all, and still records a run at the lab's instrument for that tool if it has placed one.
66
+
67
+ ## License
68
+
69
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,30 @@
1
+ import type { Band } from "@biolibs/gel";
2
+ /**
3
+ * A gel, drawn: a ladder in one lane and the digest in the next.
4
+ *
5
+ * @param props - `ladder` and `bands` are what `planDigest` gave; `name` is what the sample is called.
6
+ */
7
+ export declare function Gel({ ladder, bands, name }: {
8
+ ladder: readonly Band[];
9
+ bands: readonly Band[];
10
+ name: string;
11
+ }): import("react").JSX.Element;
12
+ /**
13
+ * Cut a tube's molecule in silico, see the gel it should give, and record whether the real gel matched.
14
+ *
15
+ * Choose a tube and one or more enzymes. The enzymes usually on a shelf that cut it are offered,
16
+ * the ones that cut fewest times first, and any other can be named. The pieces are listed and drawn
17
+ * as a gel beside a ladder. Recording takes what was used from the tube and notes whether the gel
18
+ * showed what was expected; nothing is made.
19
+ *
20
+ * @param props - `instrument` is the gel station it is run at, if the lab has one; `onDone` adds a
21
+ * way to leave.
22
+ */
23
+ export declare function DigestTool({ instrument, onDone }: {
24
+ instrument?: {
25
+ id: string;
26
+ name: string;
27
+ } | null;
28
+ onDone?: () => void;
29
+ }): import("react").JSX.Element | null;
30
+ //# sourceMappingURL=digest-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digest-tool.d.ts","sourceRoot":"","sources":["../src/digest-tool.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAMzC;;;;GAIG;AACH,wBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IAAC,KAAK,EAAE,SAAS,IAAI,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,+BAwB7G;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,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,sCA4IlI"}
@@ -0,0 +1,83 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /**
4
+ * A check digest from the freezer, with the gel it should give.
5
+ *
6
+ * Like the PCR tool it holds only what has been chosen. The pieces and the gel come from
7
+ * `planDigest`, and recording is one thing asked of the lab.
8
+ */
9
+ import { useMemo, useState } from "react";
10
+ import { GELS, LADDERS } from "@biolibs/gel";
11
+ import { useAct, useLab } from "@biolibs/bionet-react";
12
+ import { cutters, enzymeNamed } from "./digest.js";
13
+ import { digestRun, digestTubes } from "./run.js";
14
+ /**
15
+ * A gel, drawn: a ladder in one lane and the digest in the next.
16
+ *
17
+ * @param props - `ladder` and `bands` are what `planDigest` gave; `name` is what the sample is called.
18
+ */
19
+ export function Gel({ ladder, bands, name }) {
20
+ const [top, height] = [26, 250];
21
+ const lane = (x, drawn, tone, labelled) => drawn.map((band, at) => {
22
+ const y = top + 10 + band.position * (height - 24);
23
+ return (_jsxs("g", { children: [_jsx("rect", { x: x, y: y - 1.6, width: 54, height: 3.2, rx: 1.2, fill: tone, opacity: 0.3 + 0.7 * band.intensity }), _jsxs("text", { x: labelled === "left" ? x - 6 : x + 60, y: y + 3.5, textAnchor: labelled === "left" ? "end" : "start", className: labelled === "left" ? "mark" : "size", children: [band.sizes.length > 1 ? `${band.sizes.join(" + ")}` : band.size, band.unresolved ? " *" : ""] })] }, `${x} ${at}`));
24
+ });
25
+ return (_jsxs("svg", { className: "gel", viewBox: "0 0 330 290", role: "img", "aria-label": `A gel: a ladder beside ${name}, cut into pieces of ${bands.flatMap((band) => band.sizes).join(", ")} base pairs`, children: [_jsx("rect", { x: 52, y: top, width: 176, height: height, rx: 6, className: "slab" }), _jsx("text", { x: 89, y: 16, textAnchor: "middle", className: "lane", children: "ladder" }), _jsx("text", { x: 177, y: 16, textAnchor: "middle", className: "lane", children: name.length > 16 ? `${name.slice(0, 15)}…` : name }), _jsx("rect", { x: 62, y: top + 4, width: 54, height: 4, className: "well" }), _jsx("rect", { x: 150, y: top + 4, width: 54, height: 4, className: "well" }), lane(62, ladder, "var(--bionet-dim)", "left"), lane(150, bands, "var(--bionet-held)", "right")] }));
26
+ }
27
+ /**
28
+ * Cut a tube's molecule in silico, see the gel it should give, and record whether the real gel matched.
29
+ *
30
+ * Choose a tube and one or more enzymes. The enzymes usually on a shelf that cut it are offered,
31
+ * the ones that cut fewest times first, and any other can be named. The pieces are listed and drawn
32
+ * as a gel beside a ladder. Recording takes what was used from the tube and notes whether the gel
33
+ * showed what was expected; nothing is made.
34
+ *
35
+ * @param props - `instrument` is the gel station it is run at, if the lab has one; `onDone` adds a
36
+ * way to leave.
37
+ */
38
+ export function DigestTool({ instrument = null, onDone }) {
39
+ const lab = useLab()?.lab;
40
+ const act = useAct();
41
+ const [tube, setTube] = useState("");
42
+ const [chosen, setChosen] = useState([]);
43
+ const [other, setOther] = useState("");
44
+ const [unknown, setUnknown] = useState(null);
45
+ const [used, setUsed] = useState("1");
46
+ const [gel, setGel] = useState("1.0");
47
+ const [ladder, setLadder] = useState("1kb");
48
+ const [note, setNote] = useState("");
49
+ const [busy, setBusy] = useState(false);
50
+ const [said, setSaid] = useState(null);
51
+ const tubes = useMemo(() => (lab === null || lab === undefined ? [] : digestTubes(lab)), [lab]);
52
+ const part = tubes.find((one) => one.item === tube)?.part;
53
+ const offered = useMemo(() => (part === undefined ? [] : cutters(part)), [part]);
54
+ const run = useMemo(() => (lab === null || lab === undefined ? null : digestRun(lab, {
55
+ tube, enzymes: chosen, gel, ladder, instrument: instrument?.id ?? null, note, ...(used.trim() === "" ? {} : { used: Number(used) }),
56
+ })), [lab, tube, chosen, gel, ladder, instrument, note, used]);
57
+ if (lab === null || lab === undefined || run === null)
58
+ return null;
59
+ const toggle = (name) => { setChosen(chosen.includes(name) ? chosen.filter((one) => one !== name) : [...chosen, name]); setSaid(null); };
60
+ const record = async (what, done) => {
61
+ if (what === null)
62
+ return;
63
+ setBusy(true);
64
+ const answer = await act("recordRun", what);
65
+ setBusy(false);
66
+ if (answer.ok) {
67
+ setSaid(done);
68
+ setNote("");
69
+ }
70
+ };
71
+ const here = lab.runs.filter((one) => one.kind === "digest" && (instrument === null || one.instrument === instrument.id)).slice(-5).reverse();
72
+ const partName = (item) => lab.parts.find((one) => one.checksum === lab.items.find((each) => each.item === item)?.part)?.name ?? "a tube";
73
+ return (_jsxs("div", { className: "pcr digest", children: [_jsxs("section", { className: "card", children: [_jsxs("div", { className: "toolhead", children: [_jsxs("div", { children: [_jsxs("h2", { children: ["Digest and gel", instrument === null ? "" : ` · ${instrument.name}`] }), _jsx("p", { className: "dim small", children: "Choose a tube and the enzymes to cut it with. The pieces are worked out from its sequence, and drawn as the gel they should give." })] }), onDone !== undefined && _jsx("button", { type: "button", className: "quiet", onClick: onDone, children: "Back to the lab" })] }), tubes.length === 0 ? _jsx("p", { className: "empty", children: "There are no tubes to digest. Add a part and a tube of it on the Freezer tab." }) : (_jsxs("fieldset", { disabled: busy, className: "choose", children: [_jsxs("div", { className: "tube", children: [_jsxs("label", { children: ["Tube", _jsxs("select", { value: tube, onChange: (event) => { setTube(event.target.value); setChosen([]); setSaid(null); }, "aria-label": "Tube", children: [_jsx("option", { value: "", children: "Choose a tube\u2026" }), tubes.map((one) => _jsx("option", { value: one.item, children: one.label }, one.item))] })] }), _jsxs("label", { className: "used", children: ["used", _jsx("input", { type: "number", min: 0, step: 1, value: used, onChange: (event) => setUsed(event.target.value), "aria-label": "Amount used" })] }), part !== undefined && _jsxs("p", { className: "dim small", children: [part.length, " bp", part.circular ? " · circular" : " · linear"] })] }), part !== undefined && (_jsxs("div", { children: [_jsxs("p", { className: "label", children: ["Enzymes", offered.length === 0 ? " · none of the usual ones cut this" : ""] }), _jsxs("div", { className: "enzymes", children: [offered.map((one) => (_jsxs("label", { className: "check", title: `${one.site} · cuts ${one.positions.length === 1 ? "once" : `${one.positions.length} times`}`, children: [_jsx("input", { type: "checkbox", checked: chosen.includes(one.name), onChange: () => toggle(one.name) }), " ", one.name, " ", _jsxs("span", { className: "dim small", children: ["\u00D7", one.positions.length] })] }, one.name))), chosen.filter((name) => !offered.some((one) => one.name === name)).map((name) => (_jsxs("label", { className: "check", children: [_jsx("input", { type: "checkbox", checked: true, onChange: () => toggle(name) }), " ", name] }, name)))] }), _jsxs("form", { className: "row tight", onSubmit: (event) => {
74
+ event.preventDefault();
75
+ const name = enzymeNamed(other);
76
+ setUnknown(name === null && other.trim() !== "" ? other.trim() : null);
77
+ if (name !== null && !chosen.includes(name))
78
+ setChosen([...chosen, name]);
79
+ if (name !== null)
80
+ setOther("");
81
+ }, children: [_jsx("input", { value: other, onChange: (event) => setOther(event.target.value), placeholder: "Another enzyme, by name", "aria-label": "Another enzyme", maxLength: 40, spellCheck: false }), _jsx("button", { type: "submit", className: "quiet", children: "Add" })] }), unknown !== null && _jsxs("p", { className: "trouble small", role: "status", children: ["There is no enzyme called ", unknown, " here."] })] }))] }))] }), run.plan !== null && chosen.length > 0 && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "What it gives" }), run.plan.problem !== null ? _jsx("p", { className: "trouble", role: "status", children: run.plan.problem }) : (_jsxs("div", { className: "result", children: [_jsx(Gel, { ladder: run.plan.ladder, bands: run.plan.bands, name: part?.name ?? "digest" }), _jsxs("div", { children: [_jsxs("p", { children: [_jsxs("strong", { children: [run.plan.fragments.length, " ", run.plan.fragments.length === 1 ? "piece" : "pieces"] }), " ", _jsxs("span", { className: "dim", children: [run.plan.fragments.join(", "), " bp"] })] }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Enzyme" }), _jsx("th", { children: "Site" }), _jsx("th", { children: "Cuts after base" })] }) }), _jsx("tbody", { children: run.plan.cutters.map((one) => _jsxs("tr", { children: [_jsx("td", { children: one.name }), _jsx("td", { children: _jsx("code", { children: one.site }) }), _jsx("td", { children: one.positions.length === 0 ? _jsx("span", { className: "dim", children: "does not cut" }) : one.positions.join(", ") })] }, one.name)) })] }), _jsxs("div", { className: "row tight", children: [_jsxs("label", { children: ["Gel", _jsx("select", { value: gel, onChange: (event) => setGel(event.target.value), children: GELS.map((one) => _jsxs("option", { value: one.id, children: [one.percent, "% agarose"] }, one.id)) })] }), _jsxs("label", { children: ["Ladder", _jsx("select", { value: ladder, onChange: (event) => setLadder(event.target.value), children: LADDERS.map((one) => _jsx("option", { value: one.id, children: one.name }, one.id)) })] })] }), run.plan.bands.some((band) => band.unresolved) && _jsx("p", { className: "dim small", children: "* outside what this gel separates. Try another concentration." }), run.plan.bands.some((band) => band.sizes.length > 1) && _jsx("p", { className: "dim small", children: "Pieces too close in size to tell apart run as one band." })] })] })), run.plan.problem === null && (_jsxs("fieldset", { disabled: busy, className: "stack", children: [_jsxs("label", { children: ["Note", _jsx("input", { value: note, onChange: (event) => setNote(event.target.value), placeholder: "Anything worth remembering about this gel", maxLength: 2000 })] }), _jsxs("div", { className: "row", children: [_jsx("button", { type: "button", onClick: () => void record(run.matched, "Recorded: the gel showed what was expected."), children: "The gel matched" }), _jsx("button", { type: "button", className: "quiet", onClick: () => void record(run.differed, "Recorded: the gel did not show what was expected."), children: "The gel did not match" })] })] })), said !== null && _jsx("p", { className: "small", role: "status", children: said })] })), here.length > 0 && (_jsxs("section", { className: "card", children: [_jsxs("h2", { children: ["Recent digests", instrument === null ? "" : " here"] }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Tube" }), _jsx("th", { children: "Enzymes" }), _jsx("th", { children: "Expected" }), _jsx("th", { children: "Gel" }), _jsx("th", { children: "Note" })] }) }), _jsx("tbody", { children: here.map((one) => (_jsxs("tr", { children: [_jsx("td", { children: partName(one.inputs[0]?.item) }), _jsx("td", { children: String(one.settings["enzymes"] ?? "").replace(/\+/g, " + ") }), _jsx("td", { className: "dim", children: String(one.settings["expected"] ?? "") }), _jsx("td", { children: one.outcome === "worked" ? "matched" : _jsx("span", { className: "badge", children: "did not match" }) }), _jsx("td", { className: "dim", children: one.note ?? "" })] }, one.run))) })] })] }))] }));
82
+ }
83
+ //# sourceMappingURL=digest-tool.js.map
@@ -0,0 +1 @@
1
+ {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AG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAM,EACtE,aAAI,SAAS,EAAC,KAAK,YAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,GAAM,EACjE,uBAAK,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,OAAO,8BAAqB,GAAM,EAC9F,aAAI,SAAS,EAAC,KAAK,YAAE,GAAG,CAAC,IAAI,IAAI,EAAE,GAAM,KALlC,GAAG,CAAC,GAAG,CAMX,CACN,CAAC,GACI,IACF,IACA,CACX,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * A restriction digest, and the gel it would give, worked out before either is run.
3
+ *
4
+ * Given a molecule and some enzymes this says where they cut, how long the pieces are, and where
5
+ * each piece would run on a gel beside a ladder. Like `pcr.ts` it knows sequences and nothing of
6
+ * the lab.
7
+ */
8
+ import { type Band } from "@biolibs/gel";
9
+ /** The enzymes offered first: the ones most often on a lab's shelf. Any other may be named. */
10
+ export declare const COMMON_ENZYMES: readonly string[];
11
+ /** The gel a digest is run on unless somebody says otherwise: 1% agarose. */
12
+ export declare const USUAL_GEL = "1.0";
13
+ /** The ladder run beside it unless somebody says otherwise. */
14
+ export declare const USUAL_LADDER = "1kb";
15
+ /** One enzyme and where it cuts a molecule. */
16
+ export interface Cutter {
17
+ /** The enzyme's name. */
18
+ name: string;
19
+ /** The sequence it recognises. */
20
+ site: string;
21
+ /** Where it cuts, counted from the start of the molecule, in order. */
22
+ positions: number[];
23
+ }
24
+ /** What a digest would give. */
25
+ export interface DigestPlan {
26
+ /** Each enzyme asked for that is a real one, and where it cuts. */
27
+ cutters: Cutter[];
28
+ /** How long each piece is, longest first. */
29
+ fragments: number[];
30
+ /** The bands the pieces would show. */
31
+ bands: Band[];
32
+ /** The bands of the ladder beside them. */
33
+ ladder: Band[];
34
+ /** The gel and the ladder it was worked out for. */
35
+ gel: string;
36
+ ladderName: string;
37
+ /** Why there is nothing to look at, said for a person, or `null` if there is. */
38
+ problem: string | null;
39
+ }
40
+ /**
41
+ * Find an enzyme whatever case its name was typed in.
42
+ *
43
+ * @param name - Something like `ecori`.
44
+ * @returns Its name as it is written, or `null` if there is no such enzyme.
45
+ */
46
+ export declare function enzymeNamed(name: string): string | null;
47
+ /**
48
+ * Where one enzyme cuts a molecule.
49
+ *
50
+ * @param part - The molecule.
51
+ * @param name - The enzyme, by its name as written.
52
+ * @returns The enzyme and its cuts, or `null` if there is no such enzyme or the molecule is not a sequence.
53
+ */
54
+ export declare function cutsOf(part: {
55
+ sequence: string;
56
+ circular: boolean;
57
+ }, name: string): Cutter | null;
58
+ /**
59
+ * The enzymes, of those usually on a shelf, that cut a molecule.
60
+ *
61
+ * @param part - The molecule.
62
+ * @param names - The enzymes to try.
63
+ * @returns Those that cut it, the ones that cut fewest times first, since one or two cuts is what a
64
+ * check digest wants.
65
+ */
66
+ export declare function cutters(part: {
67
+ sequence: string;
68
+ circular: boolean;
69
+ }, names?: readonly string[]): Cutter[];
70
+ /**
71
+ * Work out a digest and the gel it would give.
72
+ *
73
+ * @param part - The molecule.
74
+ * @param names - The enzymes, by name.
75
+ * @param options - `gel` is the agarose concentration's ID and `ladder` the ladder's, from `@biolibs/gel`.
76
+ * @returns The cuts, the pieces, the bands, and what is wrong if there is nothing to look at.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { planDigest } from "@biolibs/bionet-tools";
81
+ *
82
+ * const plan = planDigest({ sequence: "AAAAAAAAAAGAATTCAAAAAAAAAAAAAAAAAAAAGGATCCAAAAAAAAAA", circular: true }, ["EcoRI", "BamHI"]);
83
+ * plan.fragments; // [ 26, 26 ]
84
+ * plan.problem; // null
85
+ * ```
86
+ */
87
+ export declare function planDigest(part: {
88
+ sequence: string;
89
+ circular: boolean;
90
+ }, names: readonly string[], options?: {
91
+ gel?: string;
92
+ ladder?: string;
93
+ }): DigestPlan;
94
+ //# sourceMappingURL=digest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA4D,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAInG,+FAA+F;AAC/F,eAAO,MAAM,cAAc,EAAE,SAAS,MAAM,EAG3C,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,SAAS,QAAQ,CAAC;AAE/B,+DAA+D;AAC/D,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,+CAA+C;AAC/C,MAAM,WAAW,MAAM;IACrB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,gCAAgC;AAChC,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,uCAAuC;IACvC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,2CAA2C;IAC3C,MAAM,EAAE,IAAI,EAAE,CAAC;IACf,oDAAoD;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAID;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMvD;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWjG;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,KAAK,GAAE,SAAS,MAAM,EAAmB,GAAG,MAAM,EAAE,CAG1H;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EACvE,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,UAAU,CAkBtF"}
package/dist/digest.js ADDED
@@ -0,0 +1,115 @@
1
+ /**
2
+ * A restriction digest, and the gel it would give, worked out before either is run.
3
+ *
4
+ * Given a molecule and some enzymes this says where they cut, how long the pieces are, and where
5
+ * each piece would run on a gel beside a ladder. Like `pcr.ts` it knows sequences and nothing of
6
+ * the lab.
7
+ */
8
+ import { bandsOf, fragmentSizes, gelById, ladderBands, ladderById } from "@biolibs/gel";
9
+ import { enzymes } from "@biolibs/restriction";
10
+ import { Seq } from "@biolibs/seq";
11
+ /** The enzymes offered first: the ones most often on a lab's shelf. Any other may be named. */
12
+ export const COMMON_ENZYMES = [
13
+ "EcoRI", "BamHI", "HindIII", "XhoI", "NotI", "XbaI", "SpeI", "PstI", "NcoI", "NdeI", "KpnI", "SacI",
14
+ "SalI", "EcoRV", "SmaI", "BglII", "NheI", "AgeI", "ApaI", "ClaI", "MluI", "BsaI", "BsmBI", "DpnI",
15
+ ];
16
+ /** The gel a digest is run on unless somebody says otherwise: 1% agarose. */
17
+ export const USUAL_GEL = "1.0";
18
+ /** The ladder run beside it unless somebody says otherwise. */
19
+ export const USUAL_LADDER = "1kb";
20
+ const clean = (text) => text.replace(/\s+/g, "").toUpperCase();
21
+ /**
22
+ * Find an enzyme whatever case its name was typed in.
23
+ *
24
+ * @param name - Something like `ecori`.
25
+ * @returns Its name as it is written, or `null` if there is no such enzyme.
26
+ */
27
+ export function enzymeNamed(name) {
28
+ const typed = name.trim();
29
+ if (typed === "")
30
+ return null;
31
+ if (Object.hasOwn(enzymes, typed))
32
+ return typed;
33
+ const lower = typed.toLowerCase();
34
+ return Object.keys(enzymes).find((one) => one.toLowerCase() === lower) ?? null;
35
+ }
36
+ /**
37
+ * Where one enzyme cuts a molecule.
38
+ *
39
+ * @param part - The molecule.
40
+ * @param name - The enzyme, by its name as written.
41
+ * @returns The enzyme and its cuts, or `null` if there is no such enzyme or the molecule is not a sequence.
42
+ */
43
+ export function cutsOf(part, name) {
44
+ const enzyme = Object.hasOwn(enzymes, name) ? enzymes[name] : undefined;
45
+ if (enzyme === undefined)
46
+ return null;
47
+ const bases = clean(part.sequence);
48
+ try {
49
+ // The engine counts from 1 and gives the base after the cut.
50
+ const found = enzyme.search(new Seq(bases), !part.circular).map((at) => (at - 1 + bases.length) % bases.length);
51
+ return { name, site: String(enzyme.site), positions: [...new Set(found)].sort((a, b) => a - b) };
52
+ }
53
+ catch {
54
+ return null;
55
+ }
56
+ }
57
+ /**
58
+ * The enzymes, of those usually on a shelf, that cut a molecule.
59
+ *
60
+ * @param part - The molecule.
61
+ * @param names - The enzymes to try.
62
+ * @returns Those that cut it, the ones that cut fewest times first, since one or two cuts is what a
63
+ * check digest wants.
64
+ */
65
+ export function cutters(part, names = COMMON_ENZYMES) {
66
+ return names.map((name) => cutsOf(part, name)).filter((one) => one !== null && one.positions.length > 0)
67
+ .sort((a, b) => a.positions.length - b.positions.length || a.name.localeCompare(b.name));
68
+ }
69
+ /**
70
+ * Work out a digest and the gel it would give.
71
+ *
72
+ * @param part - The molecule.
73
+ * @param names - The enzymes, by name.
74
+ * @param options - `gel` is the agarose concentration's ID and `ladder` the ladder's, from `@biolibs/gel`.
75
+ * @returns The cuts, the pieces, the bands, and what is wrong if there is nothing to look at.
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * import { planDigest } from "@biolibs/bionet-tools";
80
+ *
81
+ * const plan = planDigest({ sequence: "AAAAAAAAAAGAATTCAAAAAAAAAAAAAAAAAAAAGGATCCAAAAAAAAAA", circular: true }, ["EcoRI", "BamHI"]);
82
+ * plan.fragments; // [ 26, 26 ]
83
+ * plan.problem; // null
84
+ * ```
85
+ */
86
+ export function planDigest(part, names, options = {}) {
87
+ let gel = gelById(USUAL_GEL);
88
+ let ladder = ladderById(USUAL_LADDER);
89
+ try {
90
+ gel = gelById(options.gel ?? USUAL_GEL);
91
+ }
92
+ catch { /* an unknown gel is run as the usual one */ }
93
+ try {
94
+ ladder = ladderById(options.ladder ?? USUAL_LADDER);
95
+ }
96
+ catch { /* and an unknown ladder likewise */ }
97
+ const length = clean(part.sequence).length;
98
+ const found = [...new Set(names)].map((name) => cutsOf(part, name)).filter((one) => one !== null);
99
+ const empty = { cutters: found, fragments: [], bands: [], ladder: ladderBands(ladder.sizes, gel), gel: gel.id, ladderName: ladder.name };
100
+ if (names.length === 0)
101
+ return { ...empty, problem: "Choose at least one enzyme." };
102
+ if (found.length === 0)
103
+ return { ...empty, problem: "None of those is an enzyme this knows." };
104
+ const cuts = [...new Set(found.flatMap((one) => one.positions))];
105
+ if (cuts.length === 0)
106
+ return { ...empty, problem: `${found.map((one) => one.name).join(" and ")} ${found.length === 1 ? "does" : "do"} not cut this.` };
107
+ try {
108
+ const fragments = fragmentSizes(length, part.circular ? "circular" : "linear", cuts).sort((a, b) => b - a);
109
+ return { ...empty, fragments, bands: bandsOf(fragments, gel), problem: null };
110
+ }
111
+ catch {
112
+ return { ...empty, problem: "That could not be cut into pieces." };
113
+ }
114
+ }
115
+ //# sourceMappingURL=digest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"digest.js","sourceRoot":"","sources":["../src/digest.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,E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,oCAAoC,EAAE,CAAC;IACrE,CAAC;AACH,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * `@biolibs/bionet-tools`: the tools a lab uses at the bench, tied to its freezer.
4
+ *
5
+ * A tool here works on the tubes a lab holds and records what was done with them. Running a PCR is
6
+ * choosing a template and two primers from the freezer, seeing what they would make, and recording
7
+ * the run: the template and primers drop by what was used, and the product is a new tube that knows
8
+ * which run made it.
9
+ *
10
+ * - `pcr.ts` — what a PCR would make, worked out from sequences alone
11
+ * - `digest.ts` — where enzymes cut, the pieces, and the gel they would give
12
+ * - `run.ts` — a PCR as a lab does one: which tubes, and what to record
13
+ * - `pcr-tool.tsx`, `digest-tool.tsx` — the tools
14
+ * - `tools.tsx` — getting to one: from an instrument, or from a list of them all
15
+ *
16
+ * The tools are drawn with the styles of `@biolibs/bionet-panels` and belong inside its `LabWindow`.
17
+ * Import `@biolibs/bionet-tools/tools.css` once.
18
+ */
19
+ export * from "./pcr.js";
20
+ export * from "./digest.js";
21
+ export * from "./run.js";
22
+ export * from "./pcr-tool.js";
23
+ export * from "./digest-tool.js";
24
+ export * from "./tools.js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * `@biolibs/bionet-tools`: the tools a lab uses at the bench, tied to its freezer.
4
+ *
5
+ * A tool here works on the tubes a lab holds and records what was done with them. Running a PCR is
6
+ * choosing a template and two primers from the freezer, seeing what they would make, and recording
7
+ * the run: the template and primers drop by what was used, and the product is a new tube that knows
8
+ * which run made it.
9
+ *
10
+ * - `pcr.ts` — what a PCR would make, worked out from sequences alone
11
+ * - `digest.ts` — where enzymes cut, the pieces, and the gel they would give
12
+ * - `run.ts` — a PCR as a lab does one: which tubes, and what to record
13
+ * - `pcr-tool.tsx`, `digest-tool.tsx` — the tools
14
+ * - `tools.tsx` — getting to one: from an instrument, or from a list of them all
15
+ *
16
+ * The tools are drawn with the styles of `@biolibs/bionet-panels` and belong inside its `LabWindow`.
17
+ * Import `@biolibs/bionet-tools/tools.css` once.
18
+ */
19
+ export * from "./pcr.js";
20
+ export * from "./digest.js";
21
+ export * from "./run.js";
22
+ export * from "./pcr-tool.js";
23
+ export * from "./digest-tool.js";
24
+ export * from "./tools.js";
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Run a PCR in silico from tubes the lab holds, and record it.
3
+ *
4
+ * Choose a template and two primers. If they make one product it is shown, and the run can be
5
+ * recorded: each tube drops by what was used and the product becomes a new tube. A run that gave
6
+ * nothing at the bench can be recorded too, since the tubes were used all the same.
7
+ *
8
+ * @param props - `instrument` is the thermocycler it is run on, if the lab has one; `onDone` adds a
9
+ * way to leave.
10
+ */
11
+ export declare function PcrTool({ instrument, onDone }: {
12
+ instrument?: {
13
+ id: string;
14
+ name: string;
15
+ } | null;
16
+ onDone?: () => void;
17
+ }): import("react").JSX.Element | null;
18
+ //# sourceMappingURL=pcr-tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pcr-tool.d.ts","sourceRoot":"","sources":["../src/pcr-tool.tsx"],"names":[],"mappings":"AAqCA;;;;;;;;;GASG;AACH,wBAAgB,OAAO,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,sCA+G/H"}
@@ -0,0 +1,72 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ /**
4
+ * Running a PCR from the freezer.
5
+ *
6
+ * It holds only what has been chosen. The tubes come from the lab, what the PCR would make comes
7
+ * from `planPcr`, and recording it is one thing asked of the lab. It is drawn with the panels'
8
+ * styles, so it belongs inside a `LabWindow`.
9
+ */
10
+ import { useMemo, useState } from "react";
11
+ import { useAct, useLab } from "@biolibs/bionet-react";
12
+ import { primerTm } from "./pcr.js";
13
+ import { pcrRun, pcrTubes } from "./run.js";
14
+ const whole = (text) => (text.trim() === "" ? undefined : Number(text));
15
+ function Tube({ label, name, choices, value, onChange, used, onUsed }) {
16
+ const chosen = choices.find((one) => one.item === value);
17
+ const tm = chosen !== undefined && name !== "template" ? primerTm(chosen.part.sequence) : null;
18
+ return (_jsxs("div", { className: "tube", children: [_jsxs("label", { children: [label, _jsxs("select", { value: value, onChange: (event) => onChange(event.target.value), "aria-label": label, children: [_jsx("option", { value: "", children: "Choose a tube\u2026" }), choices.map((one) => _jsx("option", { value: one.item, children: one.label }, one.item))] })] }), _jsxs("label", { className: "used", children: ["used", _jsx("input", { type: "number", min: 0, step: 1, value: used, onChange: (event) => onUsed(event.target.value), "aria-label": `${label}, amount used` })] }), chosen !== undefined && (_jsxs("p", { className: "dim small", children: [chosen.part.length, " ", chosen.part.length === 1 ? "base" : "bases", chosen.part.circular ? " · circular" : "", tm === null ? "" : ` · about ${Math.round(tm)} °C`] }))] }));
19
+ }
20
+ /**
21
+ * Run a PCR in silico from tubes the lab holds, and record it.
22
+ *
23
+ * Choose a template and two primers. If they make one product it is shown, and the run can be
24
+ * recorded: each tube drops by what was used and the product becomes a new tube. A run that gave
25
+ * nothing at the bench can be recorded too, since the tubes were used all the same.
26
+ *
27
+ * @param props - `instrument` is the thermocycler it is run on, if the lab has one; `onDone` adds a
28
+ * way to leave.
29
+ */
30
+ export function PcrTool({ instrument = null, onDone }) {
31
+ const lab = useLab()?.lab;
32
+ const act = useAct();
33
+ const [template, setTemplate] = useState("");
34
+ const [forward, setForward] = useState("");
35
+ const [reverse, setReverse] = useState("");
36
+ const [used, setUsed] = useState({ template: "1", forward: "1", reverse: "1" });
37
+ const [least, setLeast] = useState("18");
38
+ const [name, setName] = useState("");
39
+ const [amount, setAmount] = useState("50");
40
+ const [unit, setUnit] = useState("µL");
41
+ const [note, setNote] = useState("");
42
+ const [busy, setBusy] = useState(false);
43
+ const [said, setSaid] = useState(null);
44
+ const tubes = useMemo(() => (lab === null || lab === undefined ? { templates: [], primers: [] } : pcrTubes(lab)), [lab]);
45
+ const run = useMemo(() => (lab === null || lab === undefined ? null : pcrRun(lab, {
46
+ template, forward, reverse, instrument: instrument?.id ?? null, name, note,
47
+ used: { template: whole(used.template), forward: whole(used.forward), reverse: whole(used.reverse) },
48
+ annealAtLeast: whole(least), amount: whole(amount), unit: unit.trim() === "" ? null : unit.trim(),
49
+ })), [lab, template, forward, reverse, instrument, name, note, used, least, amount, unit]);
50
+ if (lab === null || lab === undefined || run === null)
51
+ return null;
52
+ const record = async (what, done) => {
53
+ if (what === null)
54
+ return;
55
+ setBusy(true);
56
+ const answer = await act("recordRun", what);
57
+ setBusy(false);
58
+ if (!answer.ok)
59
+ return;
60
+ setSaid(done);
61
+ setName("");
62
+ setNote("");
63
+ };
64
+ const product = run.plan !== null && run.plan.problem === null ? run.plan.products[0] : null;
65
+ const here = lab.runs.filter((one) => one.kind === "pcr" && (instrument === null || one.instrument === instrument.id)).slice(-5).reverse();
66
+ const partName = (checksum) => lab.parts.find((part) => part.checksum === checksum)?.name ?? "a part";
67
+ return (_jsxs("div", { className: "pcr", children: [_jsxs("section", { className: "card", children: [_jsxs("div", { className: "toolhead", children: [_jsxs("div", { children: [_jsxs("h2", { children: ["PCR", instrument === null ? "" : ` · ${instrument.name}`] }), _jsx("p", { className: "dim small", children: "Choose tubes from the freezer. The product is worked out from their sequences, and recording the run takes what was used from each." })] }), onDone !== undefined && _jsx("button", { type: "button", className: "quiet", onClick: onDone, children: "Back to the lab" })] }), tubes.templates.length === 0 ? _jsx("p", { className: "empty", children: "There are no tubes to run a PCR from. Add a part and a tube of it on the Freezer tab." }) : (_jsxs("fieldset", { disabled: busy, className: "choose", children: [_jsx(Tube, { label: "Template", name: "template", choices: tubes.templates, value: template, onChange: (item) => { setTemplate(item); setSaid(null); }, used: used.template, onUsed: (value) => setUsed({ ...used, template: value }) }), _jsx(Tube, { label: "Forward primer", name: "forward", choices: tubes.primers, value: forward, onChange: (item) => { setForward(item); setSaid(null); }, used: used.forward, onUsed: (value) => setUsed({ ...used, forward: value }) }), _jsx(Tube, { label: "Reverse primer", name: "reverse", choices: tubes.primers, value: reverse, onChange: (item) => { setReverse(item); setSaid(null); }, used: used.reverse, onUsed: (value) => setUsed({ ...used, reverse: value }) }), _jsxs("label", { className: "least", children: ["Bases at each primer's 3\u2032 end that must bind", _jsx("input", { type: "number", min: 8, max: 60, step: 1, value: least, onChange: (event) => setLeast(event.target.value) })] })] }))] }), run.plan !== null && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "What it makes" }), product === null ? _jsx("p", { className: "trouble", role: "status", children: run.plan.problem }) : (_jsxs(_Fragment, { children: [_jsxs("p", { children: [_jsxs("strong", { children: [product.length, " bp"] }), " ", _jsx("span", { className: "dim", children: "linear" })] }), _jsx("code", { className: "wrap", children: product.length <= 120 ? product.sequence : `${product.sequence.slice(0, 60)} … ${product.sequence.slice(-60)}` })] })), _jsxs("fieldset", { disabled: busy, className: "stack", children: [product !== null && (_jsxs("div", { className: "row tight", children: [_jsxs("label", { children: ["Call the product", _jsx("input", { value: name, onChange: (event) => setName(event.target.value), placeholder: run.name, maxLength: 200 })] }), _jsxs("label", { children: ["Amount", _jsx("input", { type: "number", min: 0, step: 1, value: amount, onChange: (event) => setAmount(event.target.value), className: "num" })] }), _jsxs("label", { children: ["Unit", _jsx("input", { value: unit, onChange: (event) => setUnit(event.target.value), maxLength: 20, className: "num" })] })] })), _jsxs("label", { children: ["Note", _jsx("input", { value: note, onChange: (event) => setNote(event.target.value), placeholder: "Anything worth remembering about this run", maxLength: 2000 })] }), _jsxs("div", { className: "row", children: [product !== null && _jsx("button", { type: "button", onClick: () => void record(run.worked, `Recorded. There is a new tube of ${run.name}, not yet put anywhere.`), children: "Record the run" }), _jsx("button", { type: "button", className: "quiet", onClick: () => void record(run.failed, "Recorded as a run that gave nothing. The tubes were used all the same."), children: "It was run and gave nothing" })] })] }), said !== null && _jsx("p", { className: "small", role: "status", children: said })] })), here.length > 0 && (_jsxs("section", { className: "card", children: [_jsxs("h2", { children: ["Recent runs", instrument === null ? "" : " here"] }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "Template" }), _jsx("th", { children: "Made" }), _jsx("th", { children: "Note" })] }) }), _jsx("tbody", { children: here.map((one) => {
68
+ const from = lab.items.find((item) => item.item === one.inputs.find((input) => input.role === "template")?.item);
69
+ return (_jsxs("tr", { children: [_jsx("td", { children: from === undefined ? "a tube" : partName(from.part) }), _jsx("td", { children: one.outcome === "worked" ? one.outputs.map((made) => partName(made.part)).join(", ") : _jsx("span", { className: "badge", children: "gave nothing" }) }), _jsx("td", { className: "dim", children: one.note ?? "" })] }, one.run));
70
+ }) })] })] }))] }));
71
+ }
72
+ //# sourceMappingURL=pcr-tool.js.map