@biolibs/bionet-tools 0.1.0 → 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 (86) hide show
  1. package/README.md +183 -5
  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-tool.d.ts.map +1 -1
  7. package/dist/digest-tool.js +2 -1
  8. package/dist/digest-tool.js.map +1 -1
  9. package/dist/digest-working.d.ts +155 -0
  10. package/dist/digest-working.d.ts.map +1 -0
  11. package/dist/digest-working.js +216 -0
  12. package/dist/digest-working.js.map +1 -0
  13. package/dist/index.d.ts +24 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +24 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/ligate-bench.d.ts +92 -0
  18. package/dist/ligate-bench.d.ts.map +1 -0
  19. package/dist/ligate-bench.js +139 -0
  20. package/dist/ligate-bench.js.map +1 -0
  21. package/dist/ligate-working.d.ts +96 -0
  22. package/dist/ligate-working.d.ts.map +1 -0
  23. package/dist/ligate-working.js +145 -0
  24. package/dist/ligate-working.js.map +1 -0
  25. package/dist/ligate.d.ts +152 -0
  26. package/dist/ligate.d.ts.map +1 -0
  27. package/dist/ligate.js +161 -0
  28. package/dist/ligate.js.map +1 -0
  29. package/dist/map.d.ts +69 -0
  30. package/dist/map.d.ts.map +1 -0
  31. package/dist/map.js +80 -0
  32. package/dist/map.js.map +1 -0
  33. package/dist/pcr-bench.d.ts +103 -0
  34. package/dist/pcr-bench.d.ts.map +1 -0
  35. package/dist/pcr-bench.js +211 -0
  36. package/dist/pcr-bench.js.map +1 -0
  37. package/dist/pcr-scene.d.ts +249 -0
  38. package/dist/pcr-scene.d.ts.map +1 -0
  39. package/dist/pcr-scene.js +287 -0
  40. package/dist/pcr-scene.js.map +1 -0
  41. package/dist/pcr-tool.d.ts.map +1 -1
  42. package/dist/pcr-tool.js +2 -1
  43. package/dist/pcr-tool.js.map +1 -1
  44. package/dist/pcr-working.d.ts +126 -0
  45. package/dist/pcr-working.d.ts.map +1 -0
  46. package/dist/pcr-working.js +175 -0
  47. package/dist/pcr-working.js.map +1 -0
  48. package/dist/run.d.ts +103 -5
  49. package/dist/run.d.ts.map +1 -1
  50. package/dist/run.js +132 -12
  51. package/dist/run.js.map +1 -1
  52. package/dist/sequence-file.d.ts +108 -0
  53. package/dist/sequence-file.d.ts.map +1 -0
  54. package/dist/sequence-file.js +145 -0
  55. package/dist/sequence-file.js.map +1 -0
  56. package/dist/sequences-tool.d.ts +13 -0
  57. package/dist/sequences-tool.d.ts.map +1 -0
  58. package/dist/sequences-tool.js +61 -0
  59. package/dist/sequences-tool.js.map +1 -0
  60. package/dist/tools.d.ts +7 -3
  61. package/dist/tools.d.ts.map +1 -1
  62. package/dist/tools.js +11 -5
  63. package/dist/tools.js.map +1 -1
  64. package/dist/working.d.ts +58 -0
  65. package/dist/working.d.ts.map +1 -0
  66. package/dist/working.js +55 -0
  67. package/dist/working.js.map +1 -0
  68. package/package.json +6 -2
  69. package/src/digest-bench.tsx +307 -0
  70. package/src/digest-tool.tsx +2 -1
  71. package/src/digest-working.ts +288 -0
  72. package/src/index.ts +24 -0
  73. package/src/ligate-bench.tsx +293 -0
  74. package/src/ligate-working.ts +182 -0
  75. package/src/ligate.ts +243 -0
  76. package/src/map.tsx +170 -0
  77. package/src/pcr-bench.tsx +403 -0
  78. package/src/pcr-scene.ts +410 -0
  79. package/src/pcr-tool.tsx +2 -1
  80. package/src/pcr-working.ts +228 -0
  81. package/src/run.ts +186 -14
  82. package/src/sequence-file.ts +172 -0
  83. package/src/sequences-tool.tsx +109 -0
  84. package/src/tools.tsx +15 -9
  85. package/src/working.tsx +96 -0
  86. package/tools.css +82 -0
@@ -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
+ //# sourceMappingUR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B,CAAC,EAAE,UAAU,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAC5F,MAAM,KAAK,GAA6B,CAAC,CAAC,SAAS,EAAE,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC;IACrL,OAAO,CACL,eAAK,SAAS,EAAC,KAAK,aAClB,cAAK,SAAS,EAAC,gBAAgB,EAAC,IAAI,EAAC,SAAS,gBAAa,YAAY,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,YACtF,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,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,KAAK,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAC9H,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,YAAG,IAAI,IADxC,GAAG,CAC+C,CAChE,CAAC,GACE,EACL,KAAK,CAAC,KAAK,IACR,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * A ligation's working: what each join is made of, where the product's length comes from, how much
3
+ * of each piece to put in, and what a careful person would ask before setting one up.
4
+ *
5
+ * Which ends fit is exact, and shown down to the bases. How much of each piece to use is arithmetic
6
+ * on a convention. Whether it will work at all is neither: it is what the checks are for.
7
+ */
8
+ import type { LigationPiece, LigationPlan, LigationProduct, PieceEndBases } from "./ligate.js";
9
+ import type { Working } from "./pcr-working.js";
10
+ /** Two ends written one over the other, to show that they pair. */
11
+ export interface JoinOverhangs {
12
+ /** The piece on the left of the join, and the one on the right. */
13
+ from: string;
14
+ to: string;
15
+ /** The overhang on the left-hand piece, 5′ to 3′ on the strand that carries it. */
16
+ left: string;
17
+ /** The right-hand piece's, written under it so each base sits beneath the one it pairs with. */
18
+ right: string;
19
+ /** Whether it is a 5′ overhang, a 3′ one, or two blunt ends. */
20
+ kind: "5′" | "3′" | "blunt";
21
+ }
22
+ /**
23
+ * One join, said as steps that can be checked against the bases.
24
+ *
25
+ * @param from - The piece on the left of the join, and which of its ends this is.
26
+ * @param to - The piece on the right, and which of its ends.
27
+ * @returns The working, with the two overhangs written one over the other.
28
+ */
29
+ export declare function joinWorking(from: {
30
+ name: string;
31
+ end: PieceEndBases;
32
+ }, to: {
33
+ name: string;
34
+ end: PieceEndBases;
35
+ }): Working & {
36
+ bases: JoinOverhangs;
37
+ };
38
+ /**
39
+ * Where a product's length comes from: the pieces, less the overhangs they share.
40
+ *
41
+ * @param product - The product.
42
+ * @param pieces - The pieces that went in, for their full lengths.
43
+ * @returns The working.
44
+ */
45
+ export declare function ligationLengthWorking(product: LigationProduct, pieces: readonly LigationPiece[]): Working;
46
+ /**
47
+ * How much of each piece to put in the tube.
48
+ *
49
+ * @param vector - The piece being cloned into, by name and length.
50
+ * @param insert - The piece going in.
51
+ * @param options - `ratio` is how many times more insert than vector, by molecule, and `ng` how
52
+ * much of the vector is used.
53
+ * @returns The working.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { ratioWorking } from "@biolibs/bionet-tools";
58
+ *
59
+ * ratioWorking({ name: "vector", length: 3000 }, { name: "insert", length: 600 }).comes; // "30 ng of insert"
60
+ * ```
61
+ */
62
+ export declare function ratioWorking(vector: {
63
+ name: string;
64
+ length: number;
65
+ }, insert: {
66
+ name: string;
67
+ length: number;
68
+ }, options?: {
69
+ ratio?: number;
70
+ ng?: number;
71
+ }): Working;
72
+ /** Something a careful person would ask before setting a ligation up. */
73
+ export interface LigationCheck {
74
+ /** `stop` if what is hoped for is unlikely as set up, `look` if it is only worth a second glance. */
75
+ weight: "stop" | "look";
76
+ /** What to ask, said for a person. */
77
+ says: string;
78
+ /** What raised it, so it can be checked. */
79
+ because: string;
80
+ }
81
+ /**
82
+ * What a careful person would ask of a ligation.
83
+ *
84
+ * These are the ways a ligation gives something other than what was wanted: a vector that closes on
85
+ * itself, an insert that can go in either way round, pieces that can join each other instead, a
86
+ * blunt join that will mostly not happen, and a PCR product whose ends ligase cannot seal.
87
+ *
88
+ * @param pieces - The pieces in the tube.
89
+ * @param plan - What they would make.
90
+ * @param options - `fromPcr` names pieces that came out of a PCR, which have no phosphate at their 5′ ends.
91
+ * @returns The checks that apply, the ones most likely to matter first.
92
+ */
93
+ export declare function ligationChecks(pieces: readonly LigationPiece[], plan: LigationPlan, options?: {
94
+ fromPcr?: readonly string[];
95
+ }): LigationCheck[];
96
+ //# sourceMappingURL=ligate-working.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ligate-working.d.ts","sourceRoot":"","sources":["../src/ligate-working.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAKhD,mEAAmE;AACnE,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,gGAAgG;IAChG,KAAK,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC;CAC7B;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,aAAa,CAAA;CAAE,EAAE,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,aAAa,CAAA;CAAE,GAAG,OAAO,GAAG;IAAE,KAAK,EAAE,aAAa,CAAA;CAAE,CA+BpJ;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,OAAO,CAazG;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAClF,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAanF;AAED,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,qGAAqG;IACrG,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,EAAE,IAAI,EAAE,YAAY,EACpD,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAO,GAAG,aAAa,EAAE,CAqC7F"}
@@ -0,0 +1,145 @@
1
+ import { endBases, endsFit } from "./ligate.js";
2
+ const count = (value) => value.toLocaleString("en-US");
3
+ const PAIR = { A: "T", T: "A", G: "C", C: "G", N: "N" };
4
+ /**
5
+ * One join, said as steps that can be checked against the bases.
6
+ *
7
+ * @param from - The piece on the left of the join, and which of its ends this is.
8
+ * @param to - The piece on the right, and which of its ends.
9
+ * @returns The working, with the two overhangs written one over the other.
10
+ */
11
+ export function joinWorking(from, to) {
12
+ const fit = endsFit(from.end, to.end);
13
+ const under = [...from.end.bases].map((base) => PAIR[base] ?? "N").join("");
14
+ const bases = { from: from.name, to: to.name, left: from.end.bases, right: [...to.end.bases].reverse().join(""), kind: fit?.kind ?? from.end.kind };
15
+ if (fit === null) {
16
+ return {
17
+ of: `${from.name} to ${to.name}`, comes: "they do not fit", kind: "exact", bases,
18
+ steps: [
19
+ `${from.name}'s end is ${from.end.kind === "blunt" ? "blunt" : `a ${from.end.kind} overhang, ${from.end.bases}`}.`,
20
+ `${to.name}'s is ${to.end.kind === "blunt" ? "blunt" : `a ${to.end.kind} overhang, ${to.end.bases}`}.`,
21
+ from.end.kind !== to.end.kind ? "A sticky end and a blunt one have nothing to pair, so ligase cannot join them."
22
+ : from.end.bases.length !== to.end.bases.length ? `One overhang is ${from.end.bases.length} bases and the other ${to.end.bases.length}. They have to be the same length.`
23
+ : `${from.end.bases} would have to meet ${under} to pair, and it meets ${[...to.end.bases].reverse().join("")}.`,
24
+ ],
25
+ };
26
+ }
27
+ if (fit.kind === "blunt") {
28
+ return {
29
+ of: `${from.name} to ${to.name}`, comes: "a blunt join", kind: "exact", bases,
30
+ steps: ["Both ends are blunt: every base is already paired with one opposite.",
31
+ "Ligase seals the backbone without anything having to find anything, so these two ends join, and so would any other two blunt ends in the tube."],
32
+ };
33
+ }
34
+ return {
35
+ of: `${from.name} to ${to.name}`, comes: `${fit.bases.length} bases, ${fit.bases}`, kind: "exact", bases,
36
+ steps: [
37
+ `${from.name} ends in a ${fit.kind} overhang of ${fit.bases.length} unpaired bases, ${fit.bases}.`,
38
+ `${to.name} begins with ${[...to.end.bases].reverse().join("")} read the other way, which is ${under}: each base is the partner of the one above it.`,
39
+ "So the two ends hold together while ligase seals the backbone on each strand.",
40
+ ],
41
+ };
42
+ }
43
+ /**
44
+ * Where a product's length comes from: the pieces, less the overhangs they share.
45
+ *
46
+ * @param product - The product.
47
+ * @param pieces - The pieces that went in, for their full lengths.
48
+ * @returns The working.
49
+ */
50
+ export function ligationLengthWorking(product, pieces) {
51
+ const lengthOf = (id) => pieces.find((piece) => piece.id === id)?.sequence.replace(/\s+/g, "").length ?? 0;
52
+ const total = product.pieces.reduce((sum, piece) => sum + lengthOf(piece.id), 0);
53
+ const shared = product.joins.reduce((sum, join) => sum + join.bases.length, 0);
54
+ return {
55
+ of: "the product's length", comes: `${count(product.length)} bp`, kind: "exact",
56
+ steps: [
57
+ `The pieces are ${product.pieces.map((piece) => `${piece.name} ${count(lengthOf(piece.id))}`).join(", ")}: ${count(total)} bases in all.`,
58
+ shared === 0 ? "They are joined blunt, so nothing is shared between them."
59
+ : `Each join's overhang belongs to both pieces at once, so it is counted once: ${product.joins.map((join) => String(join.bases.length)).join(" + ")} = ${shared}.`,
60
+ `${count(total)} − ${count(shared)} = ${count(product.length)}${product.circular ? ", closed into a circle." : "."}`,
61
+ ],
62
+ };
63
+ }
64
+ /**
65
+ * How much of each piece to put in the tube.
66
+ *
67
+ * @param vector - The piece being cloned into, by name and length.
68
+ * @param insert - The piece going in.
69
+ * @param options - `ratio` is how many times more insert than vector, by molecule, and `ng` how
70
+ * much of the vector is used.
71
+ * @returns The working.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * import { ratioWorking } from "@biolibs/bionet-tools";
76
+ *
77
+ * ratioWorking({ name: "vector", length: 3000 }, { name: "insert", length: 600 }).comes; // "30 ng of insert"
78
+ * ```
79
+ */
80
+ export function ratioWorking(vector, insert, options = {}) {
81
+ const ratio = options.ratio === undefined || options.ratio <= 0 ? 3 : options.ratio;
82
+ const ng = options.ng === undefined || options.ng <= 0 ? 50 : options.ng;
83
+ const wanted = ng * (insert.length / vector.length) * ratio;
84
+ const round = (value) => String(Math.round(value * 100) / 100);
85
+ return {
86
+ of: `how much ${insert.name} to put in`, comes: `${round(wanted)} ng of insert`, kind: "estimate",
87
+ steps: [
88
+ `A molecule of ${insert.name} is ${count(insert.length)} bases and one of ${vector.name} is ${count(vector.length)}, so the same weight holds ${round(vector.length / insert.length)} times as many molecules of the insert.`,
89
+ `For ${ratio} molecules of insert to each of vector: ${ng} ng × ${count(insert.length)} ÷ ${count(vector.length)} × ${ratio} = ${round(wanted)} ng.`,
90
+ ],
91
+ rests: "Three insert molecules to one of vector is the usual starting point, and the weight is worked out from length because a longer molecule weighs more. It assumes both preparations are what they say they are and that nothing has degraded, so it is where to start rather than a measurement.",
92
+ };
93
+ }
94
+ /**
95
+ * What a careful person would ask of a ligation.
96
+ *
97
+ * These are the ways a ligation gives something other than what was wanted: a vector that closes on
98
+ * itself, an insert that can go in either way round, pieces that can join each other instead, a
99
+ * blunt join that will mostly not happen, and a PCR product whose ends ligase cannot seal.
100
+ *
101
+ * @param pieces - The pieces in the tube.
102
+ * @param plan - What they would make.
103
+ * @param options - `fromPcr` names pieces that came out of a PCR, which have no phosphate at their 5′ ends.
104
+ * @returns The checks that apply, the ones most likely to matter first.
105
+ */
106
+ export function ligationChecks(pieces, plan, options = {}) {
107
+ const checks = [];
108
+ const wanted = plan.products.filter((product) => product.circular);
109
+ for (const piece of pieces) {
110
+ const ends = endBases(piece);
111
+ const fit = endsFit(ends.right, ends.left);
112
+ if (fit !== null && pieces.length > 1) {
113
+ checks.push({ weight: "stop", says: `${piece.name}'s two ends fit each other, so it can close on itself and give a colony with nothing in it. Cut with two different enzymes, or take the phosphate off its ends so only the insert can seal them.`,
114
+ because: fit.kind === "blunt" ? "both ends blunt" : `${ends.right.bases} meets ${ends.left.bases}` });
115
+ }
116
+ }
117
+ // The same pieces in the same order, differing only in which way round one went, is the thing a
118
+ // bench cannot tell apart without cutting the result.
119
+ const byShape = new Map();
120
+ for (const product of wanted) {
121
+ const shape = [...product.pieces].map((piece) => piece.id).sort().join("+");
122
+ byShape.set(shape, [...(byShape.get(shape) ?? []), product]);
123
+ }
124
+ for (const [, together] of byShape) {
125
+ if (together.length < 2)
126
+ continue;
127
+ const turned = together.flatMap((product) => product.pieces.filter((piece) => piece.flipped).map((piece) => piece.name));
128
+ checks.push({ weight: "look", says: `These pieces make ${together.length} products that hold the same things${turned.length === 0 ? "" : `, with ${[...new Set(turned)].join(" and ")} the other way round`}. Both will be in the tube, and a check digest is what tells one from the other.`,
129
+ because: `${together.length} circles of ${together[0].pieces.length} pieces` });
130
+ }
131
+ if (wanted.some((product) => product.joins.some((join) => join.kind === "blunt"))) {
132
+ checks.push({ weight: "look", says: "A blunt join has nothing holding the two ends together while ligase works, so it happens far less often than a sticky one. Allow more ligase, more DNA and longer, and expect fewer colonies.", because: "a blunt join" });
133
+ }
134
+ const pcr = (options.fromPcr ?? []).filter((id) => pieces.some((piece) => piece.id === id));
135
+ if (pcr.length > 0) {
136
+ const named = pcr.map((id) => pieces.find((piece) => piece.id === id).name);
137
+ checks.push({ weight: "stop", says: `${named.join(" and ")} came out of a PCR, and a PCR product has no phosphate at its 5′ ends. Ligase seals a backbone by joining a phosphate to a hydroxyl, so there is nothing for it to join until the ends are phosphorylated.`,
138
+ because: "made by pcr" });
139
+ }
140
+ if (wanted.length === 0 && plan.products.length > 0) {
141
+ checks.push({ weight: "stop", says: "Nothing here closes into a circle. The pieces join end to end and stop, which is not something that can be grown.", because: "no circular product" });
142
+ }
143
+ return checks.sort((a, b) => Number(b.weight === "stop") - Number(a.weight === "stop"));
144
+ }
145
+ //# sourceMappingURL=ligate-working.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ligate-working.js","sourceRoot":"","sources":["../src/ligate-working.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACvE,MAAM,IAAI,GAAqC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC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;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,mHAAmH,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC7L,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"}
@@ -0,0 +1,152 @@
1
+ /**
2
+ * A ligation: pieces that have already been cut, joined where their ends fit.
3
+ *
4
+ * This is the step after a digest. Each piece carries a few unpaired bases at each end, and ligase
5
+ * joins two ends only where those bases pair. Which pieces can go together, in what order and which
6
+ * way round, follows from the ends alone — so it is worked out here, from sequences, knowing nothing
7
+ * of the lab.
8
+ *
9
+ * The joining itself is `@biolibs/assembly2`'s. What this adds is what a bench needs to read: where
10
+ * each piece sits in the product, which way round it went, what each join is made of, and what the
11
+ * product carries from the pieces that made it.
12
+ */
13
+ import type { PartFeature } from "@biolibs/bionet";
14
+ import { Dseqrecord } from "@biolibs/dseqrecord";
15
+ /** What one end of a piece is like. */
16
+ export interface PieceEndBases {
17
+ /** `5′` or `3′` for an overhang, `blunt` for an end with no unpaired bases. */
18
+ kind: "5′" | "3′" | "blunt";
19
+ /** The unpaired bases, as the strand carrying them reads 5′ to 3′. Empty for a blunt end. */
20
+ bases: string;
21
+ }
22
+ /** A piece going into a ligation: a part the lab holds, as this needs it. */
23
+ export interface LigationPiece {
24
+ /** What tells it apart from the others here, such as an item's ID. */
25
+ id: string;
26
+ /** What it is called. */
27
+ name: string;
28
+ /** Every base either strand has, read along the top strand. */
29
+ sequence: string;
30
+ /** How many bases at each end are on one strand only: positive for a 5′ overhang, negative for a 3′ one. */
31
+ ends: {
32
+ left: number;
33
+ right: number;
34
+ };
35
+ /** What is marked on it. */
36
+ features?: readonly PartFeature[];
37
+ }
38
+ /** Where one piece sits in a product. */
39
+ export interface PlacedPiece {
40
+ /** Which piece. */
41
+ id: string;
42
+ name: string;
43
+ /** Whether it went in the other way round. */
44
+ flipped: boolean;
45
+ /** Where its first base is in the product. */
46
+ at: number;
47
+ /** How many of the product's bases are its own, not shared with the piece before it. */
48
+ length: number;
49
+ }
50
+ /** One join in a product: two ends that fitted. */
51
+ export interface LigationJoin {
52
+ /** The piece whose right-hand end this is, and the piece whose left-hand end it is. */
53
+ from: string;
54
+ to: string;
55
+ /** What kind of ends they were. */
56
+ kind: "5′" | "3′" | "blunt";
57
+ /** The bases the two ends shared. Empty for a blunt join. */
58
+ bases: string;
59
+ /** Where the join falls in the product: the number of bases before it. */
60
+ at: number;
61
+ }
62
+ /** One thing a ligation would make. */
63
+ export interface LigationProduct {
64
+ /** Its bases. */
65
+ sequence: string;
66
+ /** Whether it is a circle. */
67
+ circular: boolean;
68
+ /** How long it is. */
69
+ length: number;
70
+ /** The pieces, in the order they go round or along it. */
71
+ pieces: PlacedPiece[];
72
+ /** The joins, in the same order. A circle has one for each piece; a line has one fewer. */
73
+ joins: LigationJoin[];
74
+ /** What is marked on it: each piece's features, moved to where that piece now is. */
75
+ features: PartFeature[];
76
+ }
77
+ /** What a ligation would make. */
78
+ export interface LigationPlan {
79
+ /** What it would make, the circles first and the shortest first within that. */
80
+ products: LigationProduct[];
81
+ /** Why there is nothing to look at, said for a person, or `null` if there is something. */
82
+ problem: string | null;
83
+ }
84
+ /**
85
+ * A piece as a molecule with its ends.
86
+ *
87
+ * @param piece - The piece.
88
+ * @returns The molecule, with the unpaired bases at each end left unpaired.
89
+ * @throws If that is not a sequence, or the ends are longer than the piece.
90
+ */
91
+ export declare function pieceRecord(piece: LigationPiece): Dseqrecord;
92
+ /**
93
+ * What a piece's two ends are made of.
94
+ *
95
+ * The number on a part says how many bases at that end are on one strand only. Which strand carries
96
+ * them is what makes it a 5′ or a 3′ overhang: at the left-hand end a 5′ overhang is on the top
97
+ * strand, and at the right-hand end it is on the bottom one.
98
+ *
99
+ * @param piece - The piece.
100
+ * @returns Its left and right ends, each with the unpaired bases as the strand carrying them reads them.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * import { endBases } from "@biolibs/bionet-tools";
105
+ *
106
+ * endBases({ id: "1", name: "insert", sequence: "AATTCGGGGGGGGGGGATC", ends: { left: 4, right: 4 } });
107
+ * // { left: { kind: "5′", bases: "AATT" }, right: { kind: "5′", bases: "GATC" } }
108
+ * ```
109
+ */
110
+ export declare function endBases(piece: LigationPiece): {
111
+ left: PieceEndBases;
112
+ right: PieceEndBases;
113
+ };
114
+ /**
115
+ * Whether one piece's right-hand end joins another's left-hand end.
116
+ *
117
+ * Ligase joins two ends when the unpaired bases of one pair with those of the other, which means
118
+ * the same kind of overhang, the same length, and bases that are each other's partners. Two blunt
119
+ * ends join with nothing in common, which is why a blunt ligation needs no matching at all and is
120
+ * the harder one to get.
121
+ *
122
+ * @param from - The end on the left of the join.
123
+ * @param to - The end on the right of it.
124
+ * @returns What the two share, or `null` if they do not fit.
125
+ */
126
+ export declare function endsFit(from: PieceEndBases, to: PieceEndBases): {
127
+ kind: "5′" | "3′" | "blunt";
128
+ bases: string;
129
+ } | null;
130
+ /**
131
+ * Work out what a ligation would make.
132
+ *
133
+ * @param pieces - The pieces in the tube.
134
+ * @param options - `blunt` allows two blunt ends to be joined; `linear` keeps the products that did
135
+ * not close into a circle, which are the background a bench usually ignores.
136
+ * @returns What it would make, and what is wrong if it would make nothing.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { planLigation } from "@biolibs/bionet-tools";
141
+ *
142
+ * const plan = planLigation([vector, insert]);
143
+ * plan.products[0].circular; // true
144
+ * plan.products[0].pieces.length; // 2
145
+ * plan.products[0].joins[0].bases; // "GATC"
146
+ * ```
147
+ */
148
+ export declare function planLigation(pieces: readonly LigationPiece[], options?: {
149
+ blunt?: boolean;
150
+ linear?: boolean;
151
+ }): LigationPlan;
152
+ //# sourceMappingURL=ligate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ligate.d.ts","sourceRoot":"","sources":["../src/ligate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,+EAA+E;IAC/E,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,CAAC;IAC5B,6FAA6F;IAC7F,KAAK,EAAE,MAAM,CAAC;CACf;AAED,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,EAAE,EAAE,MAAM,CAAC;IACX,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,QAAQ,EAAE,MAAM,CAAC;IACjB,4GAA4G;IAC5G,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CACnC;AAED,yCAAyC;AACzC,MAAM,WAAW,WAAW;IAC1B,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,EAAE,EAAE,MAAM,CAAC;IACX,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAC3B,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,mCAAmC;IACnC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