@biolibs/bionet-tools 0.1.6 → 0.1.9
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/dist/assembly-bench.d.ts +62 -0
- package/dist/assembly-bench.d.ts.map +1 -0
- package/dist/assembly-bench.js +114 -0
- package/dist/assembly-bench.js.map +1 -0
- package/dist/assembly-design.d.ts +119 -0
- package/dist/assembly-design.d.ts.map +1 -0
- package/dist/assembly-design.js +157 -0
- package/dist/assembly-design.js.map +1 -0
- package/dist/codon-bench.d.ts +51 -0
- package/dist/codon-bench.d.ts.map +1 -0
- package/dist/codon-bench.js +93 -0
- package/dist/codon-bench.js.map +1 -0
- package/dist/codons.d.ts +126 -0
- package/dist/codons.d.ts.map +1 -0
- package/dist/codons.js +287 -0
- package/dist/codons.js.map +1 -0
- package/dist/digest-bench.d.ts.map +1 -1
- package/dist/digest-bench.js +11 -2
- package/dist/digest-bench.js.map +1 -1
- package/dist/digest.d.ts +14 -0
- package/dist/digest.d.ts.map +1 -1
- package/dist/digest.js +18 -0
- package/dist/digest.js.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/ligate-bench.d.ts.map +1 -1
- package/dist/ligate-bench.js +10 -2
- package/dist/ligate-bench.js.map +1 -1
- package/dist/pcr-bench.d.ts.map +1 -1
- package/dist/pcr-bench.js +13 -2
- package/dist/pcr-bench.js.map +1 -1
- package/dist/pcr-tool.js +1 -1
- package/dist/pcr-tool.js.map +1 -1
- package/dist/plans.d.ts +66 -0
- package/dist/plans.d.ts.map +1 -0
- package/dist/plans.js +106 -0
- package/dist/plans.js.map +1 -0
- package/dist/primer-bench.js +1 -1
- package/dist/primer-bench.js.map +1 -1
- package/dist/protein.d.ts +106 -0
- package/dist/protein.d.ts.map +1 -0
- package/dist/protein.js +158 -0
- package/dist/protein.js.map +1 -0
- package/dist/run.d.ts +12 -0
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +19 -4
- package/dist/run.js.map +1 -1
- package/dist/sequences-tool.js +1 -1
- package/dist/sequences-tool.js.map +1 -1
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +7 -3
- package/dist/tools.js.map +1 -1
- package/dist/verify-bench.d.ts +48 -0
- package/dist/verify-bench.d.ts.map +1 -0
- package/dist/verify-bench.js +77 -0
- package/dist/verify-bench.js.map +1 -0
- package/dist/verify.d.ts +138 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +263 -0
- package/dist/verify.js.map +1 -0
- package/package.json +5 -3
- package/src/assembly-bench.tsx +232 -0
- package/src/assembly-design.ts +219 -0
- package/src/codon-bench.tsx +189 -0
- package/src/codons.ts +339 -0
- package/src/digest-bench.tsx +10 -1
- package/src/digest.ts +19 -0
- package/src/index.ts +16 -0
- package/src/ligate-bench.tsx +9 -1
- package/src/pcr-bench.tsx +11 -1
- package/src/pcr-tool.tsx +1 -1
- package/src/plans.tsx +137 -0
- package/src/primer-bench.tsx +1 -1
- package/src/protein.ts +204 -0
- package/src/run.ts +20 -4
- package/src/sequences-tool.tsx +1 -1
- package/src/tools.tsx +7 -3
- package/src/verify-bench.tsx +161 -0
- package/src/verify.ts +310 -0
- package/tools.css +18 -0
package/dist/verify.js
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checking that what came back is what was designed.
|
|
3
|
+
*
|
|
4
|
+
* Everything else in this package proposes. This is the one that confirms: a sequencing read
|
|
5
|
+
* against the construct it was supposed to be, difference by difference, with what each difference
|
|
6
|
+
* does to the protein. It is the check that stands between a plasmid map and a plasmid.
|
|
7
|
+
*
|
|
8
|
+
* Three things it does that a plain alignment does not.
|
|
9
|
+
*
|
|
10
|
+
* - **It tries both strands.** A read comes off whichever end the primer sat at, and a read that is
|
|
11
|
+
* simply the other way round is not a construct that is wrong.
|
|
12
|
+
* - **It says where on the design**, not where in the alignment, so a difference can be looked up on
|
|
13
|
+
* the map and found.
|
|
14
|
+
* - **It says what the difference costs.** A changed base that leaves the amino acid alone is a
|
|
15
|
+
* nuisance; one that makes a stop codon is a dead construct; one base missing is a frameshift and
|
|
16
|
+
* everything after it is wrong. Those are not the same finding and are not reported as if they were.
|
|
17
|
+
*
|
|
18
|
+
* One thing it cannot do, and does not pretend to: a base gained or lost inside a run of the same
|
|
19
|
+
* base has no single place it could have happened, since deleting any of them gives the same read.
|
|
20
|
+
* The earliest is reported. What was gained or lost, and what it costs, are right either way; only
|
|
21
|
+
* the position inside the run is a choice the alignment made.
|
|
22
|
+
*/
|
|
23
|
+
import { PairwiseAligner } from "@biolibs/align";
|
|
24
|
+
import { translate } from "@biolibs/seq";
|
|
25
|
+
import { CODON } from "./codons.js";
|
|
26
|
+
const clean = (bases) => bases.replace(/\s+/g, "").toUpperCase();
|
|
27
|
+
const PAIR = { A: "T", T: "A", G: "C", C: "G", N: "N" };
|
|
28
|
+
const flip = (bases) => [...bases].reverse().map((one) => PAIR[one] ?? "N").join("");
|
|
29
|
+
/** An aligner that finds where a read sits on a design, rather than forcing the two end to end. */
|
|
30
|
+
function reader() {
|
|
31
|
+
const aligner = new PairwiseAligner();
|
|
32
|
+
aligner.mode = "local";
|
|
33
|
+
aligner.match = 2;
|
|
34
|
+
aligner.mismatch = -3;
|
|
35
|
+
aligner.openGapScore = -5;
|
|
36
|
+
aligner.extendGapScore = -2;
|
|
37
|
+
return aligner;
|
|
38
|
+
}
|
|
39
|
+
/** The coding sequences a difference can be read against: one piece, so the frame is plain. */
|
|
40
|
+
const codingAt = (features, at) => features.filter((one) => /^cds$/i.test(one.type) && one.parts.some((piece) => at >= piece.start && at < piece.end));
|
|
41
|
+
/**
|
|
42
|
+
* What one changed base does to the protein of a coding sequence.
|
|
43
|
+
*
|
|
44
|
+
* @param design - The design's bases.
|
|
45
|
+
* @param cds - The coding sequence it falls in.
|
|
46
|
+
* @param at - Where the change is, counting from 0.
|
|
47
|
+
* @param now - What the read has there.
|
|
48
|
+
* @returns What it does, said as one of the kinds.
|
|
49
|
+
*/
|
|
50
|
+
function effectOf(design, cds, at, now) {
|
|
51
|
+
const piece = cds.parts[0];
|
|
52
|
+
if (cds.parts.length > 1)
|
|
53
|
+
return { kind: "not worked out", codon: 0, why: `${cds.label} is marked in ${cds.parts.length} pieces, so the reading frame across it is not worked out here` };
|
|
54
|
+
const bases = design.slice(piece.start, piece.end);
|
|
55
|
+
const forward = cds.strand !== -1;
|
|
56
|
+
// On the other strand the coding sequence runs the other way, and so do its codons.
|
|
57
|
+
const offset = forward ? at - piece.start : piece.end - 1 - at;
|
|
58
|
+
const coding = forward ? bases : flip(bases);
|
|
59
|
+
const codon = Math.floor(offset / CODON);
|
|
60
|
+
const start = codon * CODON;
|
|
61
|
+
const was = coding.slice(start, start + CODON);
|
|
62
|
+
if (was.length < CODON)
|
|
63
|
+
return { kind: "not worked out", codon: codon + 1, why: `${cds.label} does not end on a whole codon` };
|
|
64
|
+
const changed = `${was.slice(0, offset - start)}${forward ? now : (PAIR[now] ?? "N")}${was.slice(offset - start + 1)}`;
|
|
65
|
+
const before = String(translate(was));
|
|
66
|
+
const after = String(translate(changed));
|
|
67
|
+
if (before === after)
|
|
68
|
+
return { kind: "silent", codon: codon + 1, aminoAcid: before };
|
|
69
|
+
if (after === "*")
|
|
70
|
+
return { kind: "nonsense", codon: codon + 1, from: before };
|
|
71
|
+
return { kind: "missense", codon: codon + 1, from: before, to: after };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Check a sequencing read against the design it was supposed to be.
|
|
75
|
+
*
|
|
76
|
+
* @param design - The construct as designed: its bases and what is marked on it.
|
|
77
|
+
* @param read - The read, as bases. Either strand.
|
|
78
|
+
* @param options - `least` is how much of the read has to line up for the check to mean anything,
|
|
79
|
+
* as a fraction, 0.5 unless said.
|
|
80
|
+
* @returns What matched, what did not, and what each difference costs.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* import { checkRead } from "@biolibs/bionet-tools";
|
|
85
|
+
*
|
|
86
|
+
* const checked = checkRead({ sequence: designed, features }, fromTheFacility);
|
|
87
|
+
* checked.matches; // whether it is what was designed, over what the read covers
|
|
88
|
+
* checked.differences; // each one, where on the design, and what it does to the protein
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export function checkRead(design, read, options = {}) {
|
|
92
|
+
const nothing = (problem) => ({ reversed: false, covers: null, covered: 0, identity: 0, differences: [], matches: false, changesProtein: false, warnings: [], problem });
|
|
93
|
+
const bases = clean(design.sequence);
|
|
94
|
+
const given = clean(read);
|
|
95
|
+
if (bases.length === 0)
|
|
96
|
+
return nothing("There is nothing to check against.");
|
|
97
|
+
if (given.length === 0)
|
|
98
|
+
return nothing("There is no read to check.");
|
|
99
|
+
if (!/^[ACGTN]+$/.test(bases))
|
|
100
|
+
return nothing("The design has bases that are not A, C, G, T or N.");
|
|
101
|
+
if (!/^[ACGTN]+$/.test(given))
|
|
102
|
+
return nothing("The read has bases that are not A, C, G, T or N. A base call that could not be made is N.");
|
|
103
|
+
const aligner = reader();
|
|
104
|
+
// A read comes off whichever end its primer sat at, so both ways round are tried and the better kept.
|
|
105
|
+
const turned = flip(given);
|
|
106
|
+
const forward = aligner.score(bases, given);
|
|
107
|
+
const backward = aligner.score(bases, turned);
|
|
108
|
+
const reversed = backward > forward;
|
|
109
|
+
const query = reversed ? turned : given;
|
|
110
|
+
const [best] = aligner.align(bases, query);
|
|
111
|
+
if (best === undefined)
|
|
112
|
+
return nothing("The read does not line up against the design at all.");
|
|
113
|
+
const [onDesign, onRead] = best.indices;
|
|
114
|
+
const warnings = [];
|
|
115
|
+
const differences = [];
|
|
116
|
+
const features = design.features ?? [];
|
|
117
|
+
/** Gather a run of gaps into one difference rather than reporting each base of it. */
|
|
118
|
+
let run = null;
|
|
119
|
+
const settle = () => {
|
|
120
|
+
if (run === null)
|
|
121
|
+
return;
|
|
122
|
+
const at = run.at;
|
|
123
|
+
const inside = features.filter((one) => one.parts.some((piece) => at - 1 >= piece.start && at - 1 < piece.end)).map((one) => ({ label: one.label, type: one.type }));
|
|
124
|
+
const cds = codingAt(features, at - 1)[0];
|
|
125
|
+
const by = run.kind === "insertion" ? run.now.length : -run.was.length;
|
|
126
|
+
const protein = cds === undefined ? null
|
|
127
|
+
: cds.parts.length > 1 ? { kind: "not worked out", codon: 0, why: `${cds.label} is marked in ${cds.parts.length} pieces, so the reading frame across it is not worked out here` }
|
|
128
|
+
: { kind: Math.abs(by) % CODON === 0 ? "in frame" : "frameshift", codon: Math.floor((at - 1 - cds.parts[0].start) / CODON) + 1, by };
|
|
129
|
+
differences.push({ at, kind: run.kind, was: run.was, now: run.now, inside, protein });
|
|
130
|
+
run = null;
|
|
131
|
+
};
|
|
132
|
+
let matched = 0;
|
|
133
|
+
let from = Number.POSITIVE_INFINITY;
|
|
134
|
+
let to = 0;
|
|
135
|
+
for (let column = 0; column < onDesign.length; column++) {
|
|
136
|
+
const d = onDesign[column];
|
|
137
|
+
const q = onRead[column];
|
|
138
|
+
if (d >= 0) {
|
|
139
|
+
from = Math.min(from, d + 1);
|
|
140
|
+
to = Math.max(to, d + 1);
|
|
141
|
+
}
|
|
142
|
+
if (d >= 0 && q >= 0) {
|
|
143
|
+
settle();
|
|
144
|
+
if (bases[d] === query[q]) {
|
|
145
|
+
matched += 1;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const at = d + 1;
|
|
149
|
+
const inside = features.filter((one) => one.parts.some((piece) => d >= piece.start && d < piece.end)).map((one) => ({ label: one.label, type: one.type }));
|
|
150
|
+
const cds = codingAt(features, d)[0];
|
|
151
|
+
differences.push({ at, kind: "substitution", was: bases[d], now: query[q], inside, protein: cds === undefined ? null : effectOf(bases, cds, d, query[q]) });
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
// A gap on one side or the other: bases the read is missing, or bases it has over.
|
|
155
|
+
const kind = d < 0 ? "insertion" : "deletion";
|
|
156
|
+
const at = d < 0 ? Math.max(1, to) : d + 1;
|
|
157
|
+
if (run === null || run.kind !== kind) {
|
|
158
|
+
settle();
|
|
159
|
+
run = { kind, at, was: "", now: "" };
|
|
160
|
+
}
|
|
161
|
+
if (d < 0)
|
|
162
|
+
run.now += query[q];
|
|
163
|
+
else
|
|
164
|
+
run.was += bases[d];
|
|
165
|
+
}
|
|
166
|
+
settle();
|
|
167
|
+
const covers = to === 0 ? null : { from, to, bases: to - from + 1 };
|
|
168
|
+
const span = covers === null ? 0 : covers.bases;
|
|
169
|
+
const identity = span === 0 ? 0 : matched / span;
|
|
170
|
+
const least = options.least ?? 0.5;
|
|
171
|
+
if (given.length > 0 && span / given.length < least) {
|
|
172
|
+
warnings.push(`Only ${Math.round((span / given.length) * 100)}% of the read lines up against the design, so this says little. It may be a read of something else.`);
|
|
173
|
+
}
|
|
174
|
+
if (given.includes("N"))
|
|
175
|
+
warnings.push(`The read has ${[...given].filter((one) => one === "N").length} bases that could not be called, which are not counted as differences.`);
|
|
176
|
+
if (covers !== null && covers.bases < bases.length) {
|
|
177
|
+
warnings.push(`The read covers ${covers.from}–${covers.to} of ${bases.length} bases. The rest of the design is unchecked.`);
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
reversed, covers, covered: covers === null ? 0 : covers.bases / bases.length, identity,
|
|
181
|
+
differences, matches: differences.length === 0 && covers !== null,
|
|
182
|
+
changesProtein: differences.some((one) => one.protein !== null && one.protein.kind !== "silent"),
|
|
183
|
+
warnings, problem: null,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/** A difference, said in a line. */
|
|
187
|
+
export function saysDifference(one) {
|
|
188
|
+
const where = `at ${one.at.toLocaleString("en-US")}`;
|
|
189
|
+
const what = one.kind === "substitution" ? `${one.was} became ${one.now}`
|
|
190
|
+
: one.kind === "deletion" ? `${one.was.length} ${one.was.length === 1 ? "base" : "bases"} missing (${one.was})`
|
|
191
|
+
: `${one.now.length} ${one.now.length === 1 ? "base" : "bases"} over (${one.now})`;
|
|
192
|
+
const effect = one.protein === null ? ""
|
|
193
|
+
: one.protein.kind === "silent" ? `, which leaves ${one.protein.aminoAcid} at codon ${one.protein.codon} alone`
|
|
194
|
+
: one.protein.kind === "missense" ? `, which makes codon ${one.protein.codon} ${one.protein.from} into ${one.protein.to}`
|
|
195
|
+
: one.protein.kind === "nonsense" ? `, which makes codon ${one.protein.codon} a stop, so everything after it is lost`
|
|
196
|
+
: one.protein.kind === "frameshift" ? `, which shifts the frame from codon ${one.protein.codon} on, so the rest is read wrong`
|
|
197
|
+
: one.protein.kind === "in frame" ? `, which adds or removes whole codons from codon ${one.protein.codon}` : `, ${one.protein.why}`;
|
|
198
|
+
return `${where}: ${what}${effect}`;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The working behind a check: what was compared, and what was found.
|
|
202
|
+
*
|
|
203
|
+
* @param checked - What came of checking.
|
|
204
|
+
* @param design - How long the design is, for saying how much was covered.
|
|
205
|
+
* @returns One working for the comparison and one for what it costs.
|
|
206
|
+
*/
|
|
207
|
+
export function verifyWorking(checked, design) {
|
|
208
|
+
if (checked.problem !== null)
|
|
209
|
+
return [];
|
|
210
|
+
const count = (value) => value.toLocaleString("en-US");
|
|
211
|
+
const span = checked.covers;
|
|
212
|
+
return [
|
|
213
|
+
{
|
|
214
|
+
of: "the comparison",
|
|
215
|
+
comes: span === null ? "the read lines up nowhere on the design" : `${Math.round(checked.identity * 1000) / 10}% the same over ${count(span.bases)} bases`,
|
|
216
|
+
kind: "exact",
|
|
217
|
+
steps: [
|
|
218
|
+
`the design is ${count(clean(design.sequence).length)} bases`,
|
|
219
|
+
...(checked.reversed ? ["the read was turned round to line up, which is only which end its primer sat at"] : ["the read lines up as it was given"]),
|
|
220
|
+
...(span === null ? [] : [`it covers ${count(span.from)}–${count(span.to)}, which is ${Math.round(checked.covered * 100)}% of the design`]),
|
|
221
|
+
`${count(checked.differences.length)} ${checked.differences.length === 1 ? "place differs" : "places differ"}`,
|
|
222
|
+
"what is outside that stretch was not read and is not checked",
|
|
223
|
+
],
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
of: "what it costs",
|
|
227
|
+
comes: checked.matches ? "nothing: it is the design over everything the read covers"
|
|
228
|
+
: checked.changesProtein ? "a protein is changed" : "the differences leave the proteins alone",
|
|
229
|
+
kind: "exact",
|
|
230
|
+
steps: checked.differences.length === 0
|
|
231
|
+
? ["every base the read covers is the base the design has"]
|
|
232
|
+
: checked.differences.slice(0, 8).map((one) => saysDifference(one)).concat(checked.differences.length > 8 ? [`and ${count(checked.differences.length - 8)} more`] : []),
|
|
233
|
+
},
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A check as a run the lab would record.
|
|
238
|
+
*
|
|
239
|
+
* It uses up some of the tube that was sent and makes nothing. Whether it worked is whether the
|
|
240
|
+
* read is the design, which is what the check says, so the outcome is not a separate judgement.
|
|
241
|
+
*
|
|
242
|
+
* @param checked - What came of checking.
|
|
243
|
+
* @param choice - The tube that was sequenced, how much went, and what to say about it.
|
|
244
|
+
* @returns What to hand to the lab's `recordRun`, or `null` if there is nothing to record.
|
|
245
|
+
*/
|
|
246
|
+
export function verifyRun(checked, choice) {
|
|
247
|
+
if (checked.problem !== null || checked.covers === null)
|
|
248
|
+
return null;
|
|
249
|
+
return {
|
|
250
|
+
kind: "sequencing", instrument: null,
|
|
251
|
+
inputs: [{ item: choice.tube, amount: Math.max(0, Math.round(choice.used ?? 1)), role: "sequenced" }],
|
|
252
|
+
outputs: [],
|
|
253
|
+
settings: {
|
|
254
|
+
covered: `${checked.covers.from}-${checked.covers.to}`,
|
|
255
|
+
identity: Math.round(checked.identity * 1000) / 10,
|
|
256
|
+
differences: checked.differences.length,
|
|
257
|
+
...(choice.primer === undefined || choice.primer === null || choice.primer.trim() === "" ? {} : { primer: choice.primer.trim() }),
|
|
258
|
+
},
|
|
259
|
+
outcome: checked.matches ? "worked" : "failed",
|
|
260
|
+
note: choice.note ?? (checked.matches ? null : checked.differences.slice(0, 3).map(saysDifference).join("; ")),
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA0DpC,MAAM,KAAK,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACjF,MAAM,IAAI,GAAqC,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAC1F,MAAM,IAAI,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAErG,mGAAmG;AACnG,SAAS,MAAM;IACb,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;IACtC,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC;IACvB,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC;IAClB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IACtB,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;IAC1B,OAAO,CAAC,cAAc,GAAG,CAAC,CAA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"^1.0.0",
|
|
6
7
|
"@biolibs/assembly2": "^1.0.0",
|
|
7
|
-
"@biolibs/bionet": "^1.
|
|
8
|
-
"@biolibs/bionet-panels": "^0.3.
|
|
8
|
+
"@biolibs/bionet": "^1.5.0",
|
|
9
|
+
"@biolibs/bionet-panels": "^0.3.3",
|
|
9
10
|
"@biolibs/bionet-react": "^0.2.0",
|
|
11
|
+
"@biolibs/cloning": "^1.0.1",
|
|
10
12
|
"@biolibs/dseq": "^1.0.0",
|
|
11
13
|
"@biolibs/dseqrecord": "^1.1.1",
|
|
12
14
|
"@biolibs/gel": "^1.0.0",
|
|
@@ -63,5 +65,5 @@
|
|
|
63
65
|
],
|
|
64
66
|
"type": "module",
|
|
65
67
|
"types": "dist/index.d.ts",
|
|
66
|
-
"version": "0.1.
|
|
68
|
+
"version": "0.1.9"
|
|
67
69
|
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Building a construct: the pieces in the order they go round the ring, and the primers that make
|
|
5
|
+
* them fit.
|
|
6
|
+
*
|
|
7
|
+
* This is the step between having a sequence and having something that can be put into a cell. A
|
|
8
|
+
* ligation joins pieces that have already been cut and whose ends happen to match; here you say
|
|
9
|
+
* what the ring should be made of and the overlaps are designed, which is how a promoter, a coding
|
|
10
|
+
* sequence and a terminator actually get into a vector.
|
|
11
|
+
*
|
|
12
|
+
* It is a desk, not a machine: nothing here is at an instrument. What it hands a scene is the ring
|
|
13
|
+
* it would make, drawn over the tube of the first piece.
|
|
14
|
+
*/
|
|
15
|
+
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
|
16
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
17
|
+
import { Glossed } from "@biolibs/glossary-react";
|
|
18
|
+
import { assemblyParts, assemblyWorking, designAssembly, type AssemblyDesign } from "./assembly-design.js";
|
|
19
|
+
import { SequenceMap } from "./map.js";
|
|
20
|
+
import { moleculeOf, type DrawnMolecule } from "./sequence-file.js";
|
|
21
|
+
import { ShowWorking } from "./working.js";
|
|
22
|
+
|
|
23
|
+
/** The parts of the panel, in the order they are read, for a host that wants one of them in view. */
|
|
24
|
+
export type AssemblySection = "pieces" | "ring" | "junctions" | "primers" | "working";
|
|
25
|
+
|
|
26
|
+
/** What a host is handed to draw beside the panel. */
|
|
27
|
+
export interface AssemblyDesk {
|
|
28
|
+
/** The tube of the first piece, to look at, if the lab has one that has been put somewhere. */
|
|
29
|
+
focus: { place: string; item: string } | null;
|
|
30
|
+
/** The ring as a molecule, with what each piece carries marked on it. `null` until there is a design. */
|
|
31
|
+
molecule: DrawnMolecule | null;
|
|
32
|
+
/** The design as it stands, or `null`. */
|
|
33
|
+
design: AssemblyDesign | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const count = (value: number): string => value.toLocaleString("en-US");
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Designing a construct from the lab's own parts.
|
|
40
|
+
*
|
|
41
|
+
* @param options - `start` says what to open on, for a tour or a link.
|
|
42
|
+
* @returns `panel`, the tool itself, and `desk`, what a scene beside it should look at and picture.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* import { useAssemblyBench } from "@biolibs/bionet-tools";
|
|
47
|
+
*
|
|
48
|
+
* const bench = useAssemblyBench();
|
|
49
|
+
* <LabView lab={lab} wide beside={bench.panel} {...(bench.desk.focus === null ? {} : { focus: bench.desk.focus })} />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export function useAssemblyBench({ start }: {
|
|
53
|
+
/** What to show: the pieces in order, the overlap, and which part of the panel to have in view. Followed whenever it changes. */
|
|
54
|
+
start?: { pieces?: readonly string[]; overlap?: number; name?: string; section?: AssemblySection };
|
|
55
|
+
} = {}): { panel: ReactNode; desk: AssemblyDesk } {
|
|
56
|
+
const lab = useLab()?.lab;
|
|
57
|
+
const act = useAct();
|
|
58
|
+
const [chosen, setChosen] = useState<string[]>([...(start?.pieces ?? [])]);
|
|
59
|
+
const [fixed, setFixed] = useState<string[]>([]);
|
|
60
|
+
const [overlap, setOverlap] = useState(String(start?.overlap ?? 25));
|
|
61
|
+
const [name, setName] = useState(start?.name ?? "");
|
|
62
|
+
const [busy, setBusy] = useState(false);
|
|
63
|
+
const [said, setSaid] = useState<string | null>(null);
|
|
64
|
+
|
|
65
|
+
// A host driving the tool — a tour, or a link — says what to show by changing `start`.
|
|
66
|
+
const asked = JSON.stringify(start ?? null);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (start === undefined) return;
|
|
69
|
+
if (start.pieces !== undefined) setChosen([...start.pieces]);
|
|
70
|
+
if (start.overlap !== undefined) setOverlap(String(start.overlap));
|
|
71
|
+
if (start.name !== undefined) setName(start.name);
|
|
72
|
+
}, [asked]);
|
|
73
|
+
|
|
74
|
+
const whole = (text: string, fallback: number): number => (/^\d+$/.test(text.trim()) ? Number(text) : fallback);
|
|
75
|
+
const offered = useMemo(() => (lab === null || lab === undefined ? [] : assemblyParts(lab, whole(overlap, 25))), [lab?.parts, overlap]);
|
|
76
|
+
const design = useMemo(() => {
|
|
77
|
+
if (lab === null || lab === undefined || chosen.length < 2) return null;
|
|
78
|
+
return designAssembly(lab, {
|
|
79
|
+
pieces: chosen.map((one) => ({ part: one, amplify: !fixed.includes(one) })),
|
|
80
|
+
overlap: whole(overlap, 25), ...(name.trim() === "" ? {} : { name: name.trim() }),
|
|
81
|
+
});
|
|
82
|
+
}, [lab?.parts, chosen, fixed, overlap, name]);
|
|
83
|
+
const made = design !== null && design.problem === null ? design : null;
|
|
84
|
+
const working = useMemo(() => (made === null ? [] : assemblyWorking(made)), [made]);
|
|
85
|
+
|
|
86
|
+
const nameOf = (checksum: string): string => lab?.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
87
|
+
const firstTube = lab?.items.find((one) => one.part === chosen[0] && !one.retired && one.where !== null);
|
|
88
|
+
const desk: AssemblyDesk = {
|
|
89
|
+
focus: firstTube?.where == null ? null : { place: firstTube.where.place, item: firstTube.item },
|
|
90
|
+
molecule: made === null ? null : moleculeOf({ name: made.name, length: made.length, circular: true, features: made.features }),
|
|
91
|
+
design,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const move = (at: number, by: number): void => {
|
|
95
|
+
const to = at + by;
|
|
96
|
+
if (to < 0 || to >= chosen.length) return;
|
|
97
|
+
const next = [...chosen];
|
|
98
|
+
[next[at], next[to]] = [next[to]!, next[at]!];
|
|
99
|
+
setChosen(next);
|
|
100
|
+
setSaid(null);
|
|
101
|
+
};
|
|
102
|
+
/** Keep the designed primers as parts, so that they can be ordered and then used in the PCRs. */
|
|
103
|
+
const keep = async (): Promise<void> => {
|
|
104
|
+
if (made === null) return;
|
|
105
|
+
setBusy(true);
|
|
106
|
+
let added = 0;
|
|
107
|
+
for (const primer of made.primers) {
|
|
108
|
+
const answer = await act("addPart", { name: primer.name, sequence: primer.sequence });
|
|
109
|
+
if (answer.ok) added += 1;
|
|
110
|
+
}
|
|
111
|
+
setBusy(false);
|
|
112
|
+
setSaid(`${added} of ${made.primers.length} primers are in the lab as parts. There are no tubes of them until they are ordered and arrive.`);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const panel = lab === null || lab === undefined ? null : (
|
|
116
|
+
<div className="bionet assembly">
|
|
117
|
+
<section className="card">
|
|
118
|
+
<h2>Build a ring</h2>
|
|
119
|
+
<p className="small"><Glossed text="An assembly joins several pieces of DNA into one circle in a single reaction, with each piece overlapping the next." /></p>
|
|
120
|
+
<p className="dim small">Choose the pieces in the order they go round. The overlaps are designed for you: each amplified piece gets primer tails that reach into its neighbours. A piece used as it is cannot be given tails, so its neighbours carry the whole overlap.</p>
|
|
121
|
+
{offered.length < 2 ? <p className="empty">The lab has fewer than two parts long enough to be pieces. Bring sequences in on the Sequences tab.</p> : (
|
|
122
|
+
<fieldset disabled={busy} className="stack">
|
|
123
|
+
<label>Add a piece
|
|
124
|
+
<select value="" aria-label="Add a piece" onChange={(event) => { if (event.target.value !== "") { setChosen([...chosen, event.target.value]); setSaid(null); } }}>
|
|
125
|
+
<option value="">Choose a part…</option>
|
|
126
|
+
{offered.map((one) => <option key={one.checksum} value={one.checksum}>{one.name} · {count(one.length)} bp{one.circular ? " · circular" : ""}</option>)}
|
|
127
|
+
</select>
|
|
128
|
+
</label>
|
|
129
|
+
<label>Overlap at each join<input type="number" min={10} max={80} step={1} value={overlap} onChange={(event) => setOverlap(event.target.value)} aria-label="Overlap in bases" /> bases</label>
|
|
130
|
+
<label>Call the ring<input value={name} onChange={(event) => setName(event.target.value)} placeholder={made?.name ?? ""} maxLength={200} aria-label="What to call the ring" /></label>
|
|
131
|
+
</fieldset>
|
|
132
|
+
)}
|
|
133
|
+
{chosen.length > 0 && (
|
|
134
|
+
<ol className="pieces">
|
|
135
|
+
{chosen.map((one, at) => (
|
|
136
|
+
<li key={`${one} ${at}`}>
|
|
137
|
+
<span>{nameOf(one)}</span>
|
|
138
|
+
<label className="check small"><input type="checkbox" checked={!fixed.includes(one)} onChange={(event) => { setFixed(event.target.checked ? fixed.filter((each) => each !== one) : [...fixed, one]); setSaid(null); }} /> amplify</label>
|
|
139
|
+
<button type="button" className="plain" onClick={() => move(at, -1)} disabled={at === 0} aria-label={`Move ${nameOf(one)} earlier`}>↑</button>
|
|
140
|
+
<button type="button" className="plain" onClick={() => move(at, 1)} disabled={at === chosen.length - 1} aria-label={`Move ${nameOf(one)} later`}>↓</button>
|
|
141
|
+
<button type="button" className="plain" onClick={() => { setChosen(chosen.filter((_, each) => each !== at)); setSaid(null); }} aria-label={`Take ${nameOf(one)} out`}>take out</button>
|
|
142
|
+
</li>
|
|
143
|
+
))}
|
|
144
|
+
</ol>
|
|
145
|
+
)}
|
|
146
|
+
{design !== null && design.problem !== null && <p className="trouble" role="status">{design.problem}</p>}
|
|
147
|
+
</section>
|
|
148
|
+
|
|
149
|
+
{made !== null && (
|
|
150
|
+
<>
|
|
151
|
+
<section className="card">
|
|
152
|
+
<h2>The ring</h2>
|
|
153
|
+
<p className="voice">This design</p>
|
|
154
|
+
<p><strong>{count(made.length)} bp</strong> <span className="dim">circular · {made.pieces.length} pieces · {made.junctions.length} joins</span></p>
|
|
155
|
+
<SequenceMap name={made.name} length={made.length} circular features={made.features}
|
|
156
|
+
spans={made.pieces.map((one, at) => ({ start: one.start, end: one.end, label: one.part.name, strand: (at % 2 === 0 ? 1 : -1) as 1 | -1 }))} />
|
|
157
|
+
<p className="dim small">What was marked on each piece is marked on the ring, where that piece now is.</p>
|
|
158
|
+
</section>
|
|
159
|
+
|
|
160
|
+
<section className="card">
|
|
161
|
+
<h2>The joins</h2>
|
|
162
|
+
<table>
|
|
163
|
+
<thead><tr><th>Between</th><th>Overlap</th><th>Melts near</th><th>Carried by</th></tr></thead>
|
|
164
|
+
<tbody>
|
|
165
|
+
{made.junctions.map((one) => (
|
|
166
|
+
<tr key={`${one.from} ${one.to}`}>
|
|
167
|
+
<td>{one.from} → {one.to}</td>
|
|
168
|
+
<td><code>{one.length} bp</code></td>
|
|
169
|
+
<td className={one.tm < 48 ? "attention" : undefined}>{Math.round(one.tm)} °C</td>
|
|
170
|
+
<td className="dim small">{one.carried.toForward > 0 ? `${one.to}'s forward primer` : ""}{one.carried.toForward > 0 && one.carried.fromReverse > 0 ? " and " : ""}{one.carried.fromReverse > 0 ? `${one.from}'s reverse primer` : ""}</td>
|
|
171
|
+
</tr>
|
|
172
|
+
))}
|
|
173
|
+
</tbody>
|
|
174
|
+
</table>
|
|
175
|
+
</section>
|
|
176
|
+
|
|
177
|
+
<section className="card">
|
|
178
|
+
<h2>The primers to order</h2>
|
|
179
|
+
{made.primers.length === 0 ? <p className="dim small">Every piece is used as it is, so there is nothing to amplify and no primer to order.</p> : (
|
|
180
|
+
<>
|
|
181
|
+
<table>
|
|
182
|
+
<thead><tr><th>Primer</th><th>Tail</th><th>Binds</th><th>Melts near</th></tr></thead>
|
|
183
|
+
<tbody>
|
|
184
|
+
{made.primers.map((one) => (
|
|
185
|
+
<tr key={one.name}>
|
|
186
|
+
<td>{one.name}</td>
|
|
187
|
+
<td className="dim">{one.tail === "" ? "none" : `${one.tail.length} bases`}</td>
|
|
188
|
+
<td>{one.binding.length} bases</td>
|
|
189
|
+
<td>{Math.round(one.binding_report.tm)} °C</td>
|
|
190
|
+
</tr>
|
|
191
|
+
))}
|
|
192
|
+
</tbody>
|
|
193
|
+
</table>
|
|
194
|
+
{made.primers.map((one) => (
|
|
195
|
+
<p key={one.name} className="small"><strong>{one.name}</strong> <code className="wrap"><span className="dim">{one.tail}</span>{one.binding}</code></p>
|
|
196
|
+
))}
|
|
197
|
+
<p className="dim small">The tail is shown faint: it does not bind the template, it is the neighbour's end that makes the overlap. The annealing temperature comes from the binding part alone.</p>
|
|
198
|
+
<fieldset disabled={busy} className="row">
|
|
199
|
+
<button type="button" onClick={() => void keep()}>Keep the primers as parts</button>
|
|
200
|
+
<span className="dim small">No tubes: they have to be ordered.</span>
|
|
201
|
+
</fieldset>
|
|
202
|
+
{said !== null && <p className="small" role="status">{said}</p>}
|
|
203
|
+
</>
|
|
204
|
+
)}
|
|
205
|
+
</section>
|
|
206
|
+
|
|
207
|
+
{made.warnings.length > 0 && (
|
|
208
|
+
<section className="card">
|
|
209
|
+
<h2>Checks</h2>
|
|
210
|
+
<ul className="checks">{made.warnings.map((one) => <li key={one} className="look">{one}</li>)}</ul>
|
|
211
|
+
</section>
|
|
212
|
+
)}
|
|
213
|
+
|
|
214
|
+
<section className="card">
|
|
215
|
+
<h2>The working</h2>
|
|
216
|
+
{working.map((one) => <ShowWorking key={one.of} working={one} />)}
|
|
217
|
+
</section>
|
|
218
|
+
</>
|
|
219
|
+
)}
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
return { panel, desk };
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The assembly design tool on its own, for a lab that has not drawn its room.
|
|
227
|
+
*
|
|
228
|
+
* @param props - `start` says what to open on.
|
|
229
|
+
*/
|
|
230
|
+
export function AssemblyTool(props: Parameters<typeof useAssemblyBench>[0]) {
|
|
231
|
+
return <>{useAssemblyBench(props).panel}</>;
|
|
232
|
+
}
|