@biolibs/bionet-tools 0.1.7 → 0.1.10
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 +79 -2
- 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-tool.d.ts +12 -3
- package/dist/digest-tool.d.ts.map +1 -1
- package/dist/digest-tool.js +10 -4
- package/dist/digest-tool.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 +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/induce-bench.d.ts +91 -0
- package/dist/induce-bench.d.ts.map +1 -0
- package/dist/induce-bench.js +201 -0
- package/dist/induce-bench.js.map +1 -0
- package/dist/induce.d.ts +280 -0
- package/dist/induce.d.ts.map +1 -0
- package/dist/induce.js +353 -0
- package/dist/induce.js.map +1 -0
- package/dist/modify.d.ts +197 -0
- package/dist/modify.d.ts.map +1 -0
- package/dist/modify.js +253 -0
- package/dist/modify.js.map +1 -0
- package/dist/pcr-tool.js +1 -1
- package/dist/pcr-tool.js.map +1 -1
- package/dist/plans.d.ts.map +1 -1
- package/dist/plans.js +4 -1
- package/dist/plans.js.map +1 -1
- 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 +160 -0
- package/dist/protein.js.map +1 -0
- package/dist/run.d.ts +13 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +20 -5
- 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 +12 -6
- 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 +6 -4
- 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-tool.tsx +14 -5
- package/src/digest.ts +19 -0
- package/src/index.ts +20 -0
- package/src/induce-bench.tsx +406 -0
- package/src/induce.ts +448 -0
- package/src/modify.ts +350 -0
- package/src/pcr-tool.tsx +1 -1
- package/src/plans.tsx +4 -1
- package/src/primer-bench.tsx +1 -1
- package/src/protein.ts +206 -0
- package/src/run.ts +22 -6
- package/src/sequences-tool.tsx +1 -1
- package/src/tools.tsx +11 -5
- package/src/verify-bench.tsx +161 -0
- package/src/verify.ts +310 -0
- package/tools.css +13 -0
package/src/modify.ts
ADDED
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which residues of a protein would be phosphorylated, and whether the host would do it.
|
|
3
|
+
*
|
|
4
|
+
* This exists because of the gap between a band and a protein. The induction tool can tell a lab it
|
|
5
|
+
* will get a 24 kDa band; it cannot tell the lab that the band will be the right mass and the wrong
|
|
6
|
+
* thing. For casein that is the whole question. Casein builds a micelle — which is what makes it
|
|
7
|
+
* behave like cheese rather than like dissolved protein — by binding calcium through clusters of
|
|
8
|
+
* phosphorylated serines. A casein that was made but not phosphorylated weighs almost the same,
|
|
9
|
+
* runs almost in the same place, and will not do the job.
|
|
10
|
+
*
|
|
11
|
+
* So two separate things are worked out here, and they are kept separate because one is arithmetic
|
|
12
|
+
* and the other is not.
|
|
13
|
+
*
|
|
14
|
+
* - **Which residues carry the motif.** This is a rule over the sequence and nothing more. The
|
|
15
|
+
* secretory-pathway kinase that phosphorylates milk proteins recognises Ser-x-Glu, and once a
|
|
16
|
+
* serine is phosphorylated it acts like a glutamate for the one two residues before it, so the
|
|
17
|
+
* sites march backwards along a cluster. That hierarchy is why casein's serines come in runs.
|
|
18
|
+
* {@link phosphoSites} applies it, says which round each site was found in, and shows the working.
|
|
19
|
+
* - **Whether the host has the enzyme.** This is not arithmetic, and nothing here pretends it is.
|
|
20
|
+
* {@link hostPhosphorylation} says what is generally held about the usual expression hosts, how
|
|
21
|
+
* firmly, and says plainly that it is a claim to check — which the lab's own literature tools can
|
|
22
|
+
* now do.
|
|
23
|
+
*
|
|
24
|
+
* A motif is a prediction. Where a curated record exists, as it does for the caseins in UniProt,
|
|
25
|
+
* {@link comparedWithKnown} says which predictions it confirms and which it does not, and that
|
|
26
|
+
* comparison is worth far more than either on its own.
|
|
27
|
+
*/
|
|
28
|
+
import type { Working } from "./pcr-working.js";
|
|
29
|
+
|
|
30
|
+
/** One rule for recognising a site. */
|
|
31
|
+
export interface PhosphoMotif {
|
|
32
|
+
/** What to call it. */
|
|
33
|
+
name: string;
|
|
34
|
+
/** The kinase family that uses it. */
|
|
35
|
+
kinase: string;
|
|
36
|
+
/** The rule, written as people write it. */
|
|
37
|
+
pattern: string;
|
|
38
|
+
/** Which residues it can act on. */
|
|
39
|
+
acts: string;
|
|
40
|
+
/** What it is for, in a sentence. */
|
|
41
|
+
about: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The rules applied, in the order they are applied.
|
|
46
|
+
*
|
|
47
|
+
* Only two, and deliberately only two. These are the acidophilic motifs — the ones that read a
|
|
48
|
+
* negative charge two or three residues along — and they are the ones that matter for a secreted
|
|
49
|
+
* milk protein. A kinase whose rule is a structure rather than a few residues cannot be found by
|
|
50
|
+
* looking at a sequence, and nothing here claims otherwise.
|
|
51
|
+
*/
|
|
52
|
+
export const PHOSPHO_MOTIFS: readonly PhosphoMotif[] = [
|
|
53
|
+
{
|
|
54
|
+
name: "S-x-E", kinase: "secretory-pathway casein kinase (FAM20C family)", pattern: "S-x-[E/D]", acts: "S",
|
|
55
|
+
about: "The kinase that phosphorylates milk and other secreted proteins, inside the Golgi, as they are on their way out. It reads a negative charge two residues along.",
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: "S/T-x-x-E", kinase: "casein kinase II (CK2)", pattern: "[S/T]-x-x-[E/D]", acts: "ST",
|
|
59
|
+
about: "A kinase found in essentially every eukaryote, in the cytoplasm and the nucleus rather than the secretory pathway. Named after casein because casein is what it was first shown to work on, not because casein is what it does in a cell.",
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
/** One residue that would be phosphorylated, and why. */
|
|
64
|
+
export interface PhosphoSite {
|
|
65
|
+
/** Where it is, counting from 1. */
|
|
66
|
+
at: number;
|
|
67
|
+
/** The residue, as a letter. */
|
|
68
|
+
residue: string;
|
|
69
|
+
/** The rule that found it, by name. */
|
|
70
|
+
by: string;
|
|
71
|
+
/** The kinase family that rule belongs to. */
|
|
72
|
+
kinase: string;
|
|
73
|
+
/** The residues either side of it, as they are written. */
|
|
74
|
+
context: string;
|
|
75
|
+
/**
|
|
76
|
+
* Which round found it. Round 1 is the motif read off the sequence as it stands. A later round is
|
|
77
|
+
* a site that only became one because a site found in the round before gave it the charge it
|
|
78
|
+
* needed — which is how a cluster of phosphoserines builds backwards along a chain.
|
|
79
|
+
*/
|
|
80
|
+
round: number;
|
|
81
|
+
/** What made it a site, said for a person. */
|
|
82
|
+
because: string;
|
|
83
|
+
/**
|
|
84
|
+
* Any other rule that also matches this residue.
|
|
85
|
+
*
|
|
86
|
+
* A serine can carry more than one motif, and which one is reported first depends only on the
|
|
87
|
+
* order the rules are tried in. Saying "this is a CK2 site" when it is equally the secretory
|
|
88
|
+
* kinase's would be an accident of that order presented as a finding, so the others are listed.
|
|
89
|
+
*/
|
|
90
|
+
alsoBy: { name: string; kinase: string; because: string }[];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** What was worked out about a protein. */
|
|
94
|
+
export interface Phosphorylation {
|
|
95
|
+
/** The sites, in order along the chain. */
|
|
96
|
+
sites: PhosphoSite[];
|
|
97
|
+
/** How many rounds found something. A further round, which found nothing, is what ended it. */
|
|
98
|
+
rounds: number;
|
|
99
|
+
/** Why there is nothing to say, or `null` if there is. */
|
|
100
|
+
problem: string | null;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const ACID = new Set(["E", "D"]);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The residues of a protein that carry a phosphorylation motif.
|
|
107
|
+
*
|
|
108
|
+
* The rules are applied in rounds. In the first, each is read off the sequence as it stands. In
|
|
109
|
+
* each round after, a serine whose +2 residue is a site found already counts too, because a
|
|
110
|
+
* phosphoserine carries the negative charge the kinase was reading for. That is repeated until a
|
|
111
|
+
* round finds nothing, which is what builds the runs of phosphoserines a casein has.
|
|
112
|
+
*
|
|
113
|
+
* @param protein - The amino acids, in one letter each.
|
|
114
|
+
* @param options - `motifs` are the rules to apply, {@link PHOSPHO_MOTIFS} if not given; `prime`
|
|
115
|
+
* turns off the later rounds, leaving only what the bare sequence says.
|
|
116
|
+
* @returns The sites, and how many rounds it took.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```ts
|
|
120
|
+
* import { phosphoSites } from "@biolibs/bionet-tools";
|
|
121
|
+
*
|
|
122
|
+
* const found = phosphoSites(casein.sequence);
|
|
123
|
+
* found.sites.filter((one) => one.round > 1); // the ones a neighbour made possible
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export function phosphoSites(protein: string, options: { motifs?: readonly PhosphoMotif[]; prime?: boolean } = {}): Phosphorylation {
|
|
127
|
+
const chain = protein.replace(/\s+/g, "").toUpperCase();
|
|
128
|
+
if (chain === "") return { sites: [], rounds: 0, problem: "There is no protein here to look at." };
|
|
129
|
+
if (!/^[ACDEFGHIKLMNPQRSTVWY]+$/.test(chain)) return { sites: [], rounds: 0, problem: "That is written in letters that are not the twenty standard amino acids." };
|
|
130
|
+
const motifs = options.motifs ?? PHOSPHO_MOTIFS;
|
|
131
|
+
const found = new Map<number, PhosphoSite>();
|
|
132
|
+
const context = (at: number): string => chain.slice(Math.max(0, at - 4), at + 3);
|
|
133
|
+
|
|
134
|
+
let round = 0;
|
|
135
|
+
for (;;) {
|
|
136
|
+
round += 1;
|
|
137
|
+
const fresh: PhosphoSite[] = [];
|
|
138
|
+
for (let at = 1; at <= chain.length; at += 1) {
|
|
139
|
+
const residue = chain[at - 1]!;
|
|
140
|
+
/** Every rule that matches this residue as things stand, in the order the rules are given. */
|
|
141
|
+
const matching: { name: string; kinase: string; because: string }[] = [];
|
|
142
|
+
for (const motif of motifs) {
|
|
143
|
+
if (!motif.acts.includes(residue)) continue;
|
|
144
|
+
const reach = motif.name === "S-x-E" ? 2 : 3;
|
|
145
|
+
const charged = chain[at - 1 + reach];
|
|
146
|
+
if (charged === undefined) continue;
|
|
147
|
+
if (ACID.has(charged)) {
|
|
148
|
+
matching.push({ name: motif.name, kinase: motif.kinase, because: `${residue}${at} with ${charged} ${reach} residues along: ${motif.pattern}` });
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
// A serine that is already a site carries the charge the kinase was reading for, so the one
|
|
152
|
+
// before it becomes a site in the next round. That is what builds a run of them backwards.
|
|
153
|
+
if (options.prime !== false && charged === "S" && found.has(at + reach)) {
|
|
154
|
+
matching.push({ name: motif.name, kinase: motif.kinase,
|
|
155
|
+
because: `${residue}${at} with the phosphoserine at ${at + reach} ${reach} residues along, which carries the negative charge a glutamate would` });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (matching.length === 0) continue;
|
|
159
|
+
const already = found.get(at);
|
|
160
|
+
if (already !== undefined) {
|
|
161
|
+
// A rule that only matched once a neighbour was found is still a rule that matches, so it
|
|
162
|
+
// joins the site it belongs to rather than being lost or restarting the round count.
|
|
163
|
+
for (const one of matching) {
|
|
164
|
+
if (one.name !== already.by && !already.alsoBy.some((other) => other.name === one.name)) already.alsoBy.push(one);
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
const [best, ...rest] = matching as [typeof matching[number], ...typeof matching];
|
|
169
|
+
fresh.push({ at, residue, by: best.name, kinase: best.kinase, context: context(at), round, because: best.because, alsoBy: rest });
|
|
170
|
+
}
|
|
171
|
+
for (const one of fresh) found.set(one.at, one);
|
|
172
|
+
// A round that adds nothing is the end, and is not counted: what is reported is how many
|
|
173
|
+
// rounds found something, which is what says how deep the hierarchy went.
|
|
174
|
+
if (fresh.length === 0) { round -= 1; break; }
|
|
175
|
+
if (options.prime === false) break;
|
|
176
|
+
if (round > chain.length) break;
|
|
177
|
+
}
|
|
178
|
+
return { sites: [...found.values()].sort((a, b) => a.at - b.at), rounds: Math.max(round, 1), problem: null };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** How a predicted set of sites stands against a curated one. */
|
|
182
|
+
export interface Compared {
|
|
183
|
+
/** Sites that were predicted and are recorded: the ones to trust. */
|
|
184
|
+
confirmed: number[];
|
|
185
|
+
/** Sites that are recorded and were not predicted: the rule missed them. */
|
|
186
|
+
missed: number[];
|
|
187
|
+
/** Sites that were predicted and are not recorded: they may be wrong, or merely unstudied. */
|
|
188
|
+
onlyPredicted: number[];
|
|
189
|
+
/** What fraction of the recorded sites the rule found. */
|
|
190
|
+
caught: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* How a prediction stands against what somebody has actually recorded.
|
|
195
|
+
*
|
|
196
|
+
* This is the honest way to use a motif. A rule over a sequence says what could be phosphorylated;
|
|
197
|
+
* a curated record says what somebody saw. Where both exist, how well they agree is the measure of
|
|
198
|
+
* whether to believe the rule anywhere else — on a variant, say, or on a gene that has been
|
|
199
|
+
* rewritten in another host's codons.
|
|
200
|
+
*
|
|
201
|
+
* @param predicted - Where the rule said, counting from 1.
|
|
202
|
+
* @param known - Where a record says, counting from 1 on the same sequence.
|
|
203
|
+
* @returns What agrees, what was missed, and what is predicted alone.
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```ts
|
|
207
|
+
* import { comparedWithKnown, phosphoSites } from "@biolibs/bionet-tools";
|
|
208
|
+
*
|
|
209
|
+
* const found = phosphoSites(casein.sequence);
|
|
210
|
+
* comparedWithKnown(found.sites.map((one) => one.at), [30, 32, 33, 34, 50]).caught; // 1
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
export function comparedWithKnown(predicted: readonly number[], known: readonly number[]): Compared {
|
|
214
|
+
const said = new Set(predicted);
|
|
215
|
+
const recorded = new Set(known);
|
|
216
|
+
const confirmed = [...recorded].filter((one) => said.has(one)).sort((a, b) => a - b);
|
|
217
|
+
return {
|
|
218
|
+
confirmed,
|
|
219
|
+
missed: [...recorded].filter((one) => !said.has(one)).sort((a, b) => a - b),
|
|
220
|
+
onlyPredicted: [...said].filter((one) => !recorded.has(one)).sort((a, b) => a - b),
|
|
221
|
+
caught: recorded.size === 0 ? 0 : confirmed.length / recorded.size,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** What is held about whether a host phosphorylates a secreted protein this way. */
|
|
226
|
+
export interface HostKinases {
|
|
227
|
+
/** The organism, as it would be written. */
|
|
228
|
+
host: string;
|
|
229
|
+
/** Whether it is held to have the secretory-pathway kinase, and whether it has CK2. */
|
|
230
|
+
secretoryKinase: "yes" | "no" | "not known";
|
|
231
|
+
casein2: boolean;
|
|
232
|
+
/** What is held, in a sentence or two. */
|
|
233
|
+
says: string;
|
|
234
|
+
/** How firmly: something long settled, something reported, or something to go and check. */
|
|
235
|
+
standing: "well established" | "reported" | "check";
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* What is generally held about the usual expression hosts.
|
|
240
|
+
*
|
|
241
|
+
* Everything here is a claim about biology and not something computed, which is why it carries a
|
|
242
|
+
* `standing` and why the answer tells a reader to check it. It rots: a homologue nobody had found
|
|
243
|
+
* when this was written may have been found since, and a host engineered to carry the kinase is now
|
|
244
|
+
* a thing people build. What it is for is to stop a lab discovering at the end of a month that the
|
|
245
|
+
* protein it made was never going to be phosphorylated — and then to point at the literature, which
|
|
246
|
+
* the lab's own tools can now read.
|
|
247
|
+
*/
|
|
248
|
+
export const HOST_KINASES: readonly HostKinases[] = [
|
|
249
|
+
{
|
|
250
|
+
host: "Escherichia coli", secretoryKinase: "no", casein2: false, standing: "well established",
|
|
251
|
+
says: "A bacterium has no secretory pathway of this kind and no kinase in it. Casein made in E. coli is reported unphosphorylated, and that is the usual reason a group that wanted micelles moved away from it.",
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
host: "Bacillus subtilis", secretoryKinase: "no", casein2: false, standing: "well established",
|
|
255
|
+
says: "As for E. coli: it secretes well, which is why people use it, but not through a compartment that phosphorylates what passes through.",
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
host: "Saccharomyces cerevisiae", secretoryKinase: "not known", casein2: true, standing: "reported",
|
|
259
|
+
says: "Budding yeast has casein kinase I and II homologues, but no homologue of the secretory-pathway kinase has been identified. Phosphorylation of casein expressed in yeast is reported, and reported as partial and uneven between sites rather than as the full pattern.",
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
host: "Komagataella phaffii", secretoryKinase: "not known", casein2: true, standing: "reported",
|
|
263
|
+
says: "The yeast formerly called Pichia pastoris, and the usual choice for a secreted protein because it secretes a great deal of it. The same holds as for budding yeast: the kinase of the secretory pathway has not been identified in it.",
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
host: "Nicotiana benthamiana", secretoryKinase: "not known", casein2: true, standing: "reported",
|
|
267
|
+
says: "Plants have CK2 and a secretory pathway, and phosphorylated casein has been reported from plant expression. How complete the pattern is varies by report.",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
host: "Cricetulus griseus", secretoryKinase: "yes", casein2: true, standing: "well established",
|
|
271
|
+
says: "CHO cells are mammalian and have the secretory-pathway kinase, so they phosphorylate a milk protein as a mammal does. They are slow and expensive, which is why nobody makes cheese protein in them.",
|
|
272
|
+
},
|
|
273
|
+
];
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* What is held about one host.
|
|
277
|
+
*
|
|
278
|
+
* @param host - What it is, as the lab writes it. Matched loosely, so `Pichia pastoris GS115` finds
|
|
279
|
+
* the entry for the species under its current name.
|
|
280
|
+
* @returns What is held, or `null` for a host nothing here knows about, which is not the same as a
|
|
281
|
+
* host that does not do it.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* import { hostPhosphorylation } from "@biolibs/bionet-tools";
|
|
286
|
+
*
|
|
287
|
+
* hostPhosphorylation("Saccharomyces cerevisiae W303")?.secretoryKinase; // "not known"
|
|
288
|
+
* ```
|
|
289
|
+
*/
|
|
290
|
+
export function hostPhosphorylation(host: string): HostKinases | null {
|
|
291
|
+
const asked = host.trim().toLowerCase();
|
|
292
|
+
if (asked === "") return null;
|
|
293
|
+
// The old names are what a lab's own records are most likely to say.
|
|
294
|
+
const also: Readonly<Record<string, string>> = {
|
|
295
|
+
"pichia pastoris": "komagataella phaffii", "pichia": "komagataella phaffii",
|
|
296
|
+
"e. coli": "escherichia coli", "b. subtilis": "bacillus subtilis",
|
|
297
|
+
"s. cerevisiae": "saccharomyces cerevisiae", "cho": "cricetulus griseus", "tobacco": "nicotiana benthamiana",
|
|
298
|
+
};
|
|
299
|
+
for (const [old, now] of Object.entries(also)) {
|
|
300
|
+
if (asked.includes(old)) return HOST_KINASES.find((one) => one.host.toLowerCase() === now) ?? null;
|
|
301
|
+
}
|
|
302
|
+
return HOST_KINASES.find((one) => asked.includes(one.host.toLowerCase())
|
|
303
|
+
|| asked.includes(one.host.split(" ")[0]!.toLowerCase())) ?? null;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* The working behind what was found: the rule, the rounds, and what it rests on.
|
|
308
|
+
*
|
|
309
|
+
* @param found - What {@link phosphoSites} gave.
|
|
310
|
+
* @param host - What is held about the host, if a host was named.
|
|
311
|
+
* @returns The workings, in the order to read them.
|
|
312
|
+
*/
|
|
313
|
+
export function phosphoWorking(found: Phosphorylation, host: HostKinases | null = null): Working[] {
|
|
314
|
+
if (found.problem !== null) return [];
|
|
315
|
+
const byRound = new Map<number, PhosphoSite[]>();
|
|
316
|
+
for (const one of found.sites) byRound.set(one.round, [...(byRound.get(one.round) ?? []), one]);
|
|
317
|
+
const out: Working[] = [{
|
|
318
|
+
of: "the sites the sequence carries",
|
|
319
|
+
comes: `${found.sites.length} ${found.sites.length === 1 ? "residue" : "residues"}`,
|
|
320
|
+
kind: "estimate",
|
|
321
|
+
steps: [
|
|
322
|
+
...PHOSPHO_MOTIFS.map((one) => `${one.name}: ${one.pattern}, which is ${one.kinase}.`),
|
|
323
|
+
...[...byRound.entries()].sort(([a], [b]) => a - b).map(([round, sites]) => {
|
|
324
|
+
const named = sites.map((one) => `${one.residue}${one.at}`).join(", ");
|
|
325
|
+
if (round === 1) return `Round 1 reads the sequence as it stands: ${named}.`;
|
|
326
|
+
return sites.length === 1
|
|
327
|
+
? `Round ${round} adds ${named}, which only became a site because the one two residues along was found in the round before.`
|
|
328
|
+
: `Round ${round} adds ${named}, each of which only became a site because the one two residues along was found in the round before.`;
|
|
329
|
+
}),
|
|
330
|
+
found.rounds === 1
|
|
331
|
+
? "One round found anything; the next found nothing more."
|
|
332
|
+
: `${found.rounds} rounds found something, and the next found nothing more, which is how far back along the chain the cluster builds.`,
|
|
333
|
+
],
|
|
334
|
+
rests: "A motif says a residue could be phosphorylated, not that it is. It is a rule over a few residues, and the kinases it stands for are not the only ones there are; a kinase that reads a shape rather than a sequence cannot be found this way at all. Where somebody has recorded the real sites, compare against those and believe the comparison rather than the rule.",
|
|
335
|
+
}];
|
|
336
|
+
if (host !== null) {
|
|
337
|
+
out.push({
|
|
338
|
+
of: `whether ${host.host} would do it`,
|
|
339
|
+
comes: host.secretoryKinase === "yes" ? "it has the kinase" : host.secretoryKinase === "no" ? "it has no such kinase" : "not known to have the kinase",
|
|
340
|
+
kind: "estimate",
|
|
341
|
+
steps: [
|
|
342
|
+
host.says,
|
|
343
|
+
host.casein2 ? "It does have CK2, so a site that is CK2's may still be phosphorylated." : "It has no CK2 either.",
|
|
344
|
+
"This is not worked out from anything. It is what is generally held, and it is what to check in the literature before spending a month on it.",
|
|
345
|
+
],
|
|
346
|
+
rests: `Held as ${host.standing}. A host engineered to carry the kinase is a thing people now build, and a homologue nobody had found when this was written may have been found since. Search the literature for this host and this protein rather than taking this for the answer.`,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return out;
|
|
350
|
+
}
|
package/src/pcr-tool.tsx
CHANGED
|
@@ -145,7 +145,7 @@ export function PcrTool({ instrument = null, onDone }: { instrument?: { id: stri
|
|
|
145
145
|
const from = lab.items.find((item) => item.item === one.inputs.find((input) => input.role === "template")?.item);
|
|
146
146
|
return (
|
|
147
147
|
<tr key={one.run}>
|
|
148
|
-
<td>{from === undefined ? "a tube" : partName(from.part)}</td>
|
|
148
|
+
<td>{from === undefined || from.part === null ? "a tube" : partName(from.part)}</td>
|
|
149
149
|
<td>{one.outcome === "worked" ? one.outputs.map((made) => partName(made.part)).join(", ") : <span className="badge">gave nothing</span>}</td>
|
|
150
150
|
<td className="dim">{one.note ?? ""}</td>
|
|
151
151
|
</tr>
|
package/src/plans.tsx
CHANGED
|
@@ -92,7 +92,10 @@ export function Proposed({ kind, now, onSetUp }: { kind: string; now: Record<str
|
|
|
92
92
|
const carried = planCarried(lab, now);
|
|
93
93
|
const person = (key: string): string => lab.roster.find((one) => one.key === key)?.person ?? "A device";
|
|
94
94
|
const partName = (checksum: string | undefined): string => lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
95
|
-
const tubeName = (item: string | undefined): string =>
|
|
95
|
+
const tubeName = (item: string | undefined): string => {
|
|
96
|
+
const held = lab.items.find((one) => one.item === item);
|
|
97
|
+
return held?.part === null ? lab.strains.find((one) => one.strain === held.strain)?.name ?? "a culture" : partName(held?.part);
|
|
98
|
+
};
|
|
96
99
|
const ask = async (action: "planRun" | "settlePlan", payload: unknown): Promise<void> => {
|
|
97
100
|
setBusy(true);
|
|
98
101
|
const answer = await act(action, payload);
|
package/src/primer-bench.tsx
CHANGED
|
@@ -229,7 +229,7 @@ export function usePrimerBench({ start, onPcr }: {
|
|
|
229
229
|
latest.current = lab;
|
|
230
230
|
|
|
231
231
|
// Templates worth designing on: anything long enough to hold a pair with something between them.
|
|
232
|
-
const parts = useMemo(() => (lab?.parts ?? []).filter((one) => one.length >= 2 * DEFAULT_DESIGN.minLength + 1), [lab?.parts]);
|
|
232
|
+
const parts = useMemo(() => (lab?.parts ?? []).filter((one) => one.kind !== "protein" && one.length >= 2 * DEFAULT_DESIGN.minLength + 1), [lab?.parts]);
|
|
233
233
|
const part = parts.find((one) => one.checksum === chosen) ?? parts.find((one) => one.features.length > 0) ?? parts[0];
|
|
234
234
|
const offered = useMemo(() => (part === undefined ? [] : featureStretches(part)), [part]);
|
|
235
235
|
const choose = (stretch: Stretch): void => { setFrom(String(stretch.start + 1)); setTo(String(stretch.end)); setLengths({}); setSaid(null); };
|
package/src/protein.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The protein a gene codes for, and what can be said about it.
|
|
3
|
+
*
|
|
4
|
+
* A lab that keeps only DNA stops one step short of what it is for. The point of putting a casein
|
|
5
|
+
* gene into yeast is the casein, and until the protein is a thing the lab holds there is nowhere
|
|
6
|
+
* to record that it came out, how much there is, or where the tube went.
|
|
7
|
+
*
|
|
8
|
+
* None of the numbers here are asserted. The molecular weight, the isoelectric point and the rest
|
|
9
|
+
* come from `ProteinAnalysis` in `@biolibs/seqtools`, which is a port of Biopython's ProtParam and
|
|
10
|
+
* is tested against it. What is here is the translating, the cutting of a signal peptide, and
|
|
11
|
+
* saying where each figure came from.
|
|
12
|
+
*/
|
|
13
|
+
import type { PartFeature, PartState } from "@biolibs/bionet";
|
|
14
|
+
import { translate } from "@biolibs/seq";
|
|
15
|
+
import { ProteinAnalysis } from "@biolibs/seqtools";
|
|
16
|
+
import { CODON } from "./codons.js";
|
|
17
|
+
import type { Working } from "./pcr-working.js";
|
|
18
|
+
|
|
19
|
+
/** What a gene was translated into. */
|
|
20
|
+
export interface Translated {
|
|
21
|
+
/** The amino acids, with no stop. */
|
|
22
|
+
protein: string;
|
|
23
|
+
/** How many amino acids. */
|
|
24
|
+
length: number;
|
|
25
|
+
/** The stretch of the gene it came from, counting from 1, and which strand. */
|
|
26
|
+
from: { start: number; end: number; strand: 1 | -1 };
|
|
27
|
+
/** The signal peptide that was cut off, if one was. */
|
|
28
|
+
signal: { peptide: string; label: string } | null;
|
|
29
|
+
/** Whether the gene ended in a stop codon, which a coding sequence should. */
|
|
30
|
+
stopped: boolean;
|
|
31
|
+
/** Anything a careful person would look at. */
|
|
32
|
+
warnings: string[];
|
|
33
|
+
/** Why it could not be translated, or `null`. */
|
|
34
|
+
problem: string | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** What is known about a protein, from its sequence alone. */
|
|
38
|
+
export interface ProteinFacts {
|
|
39
|
+
/** How many amino acids. */
|
|
40
|
+
length: number;
|
|
41
|
+
/** In daltons. */
|
|
42
|
+
weight: number;
|
|
43
|
+
/** The pH at which it carries no net charge. */
|
|
44
|
+
isoelectric: number;
|
|
45
|
+
/** How strongly it absorbs at 280 nm, with and without the cystines paired. */
|
|
46
|
+
extinction: { reduced: number; cystines: number };
|
|
47
|
+
/** Above 40 a protein is reckoned unstable in a test tube. */
|
|
48
|
+
instability: number;
|
|
49
|
+
/** How water-fearing it is on average: positive is water-fearing. */
|
|
50
|
+
gravy: number;
|
|
51
|
+
/** What fraction is each of helix, turn and sheet. */
|
|
52
|
+
structure: { helix: number; turn: number; sheet: number };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const clean = (bases: string): string => bases.replace(/\s+/g, "").toUpperCase();
|
|
56
|
+
const PAIR: Readonly<Record<string, string>> = { A: "T", T: "A", G: "C", C: "G", N: "N" };
|
|
57
|
+
const flip = (bases: string): string => [...bases].reverse().map((one) => PAIR[one] ?? "N").join("");
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Translate a gene, or the coding sequence marked on it, into the protein it makes.
|
|
61
|
+
*
|
|
62
|
+
* @param part - The gene: its bases and what is marked on it.
|
|
63
|
+
* @param options - `cds` names a coding sequence marked on the part to translate, in place of the
|
|
64
|
+
* whole of it; `cutSignal` cuts off a signal peptide marked inside that stretch, which is what
|
|
65
|
+
* the mature protein is.
|
|
66
|
+
* @returns The protein, and where it came from.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* import { translateGene } from "@biolibs/bionet-tools";
|
|
71
|
+
*
|
|
72
|
+
* const made = translateGene(gene, { cds: "casein", cutSignal: true });
|
|
73
|
+
* made.protein; // the mature protein, with the signal peptide gone
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export function translateGene(part: Pick<PartState, "sequence" | "features" | "circular">,
|
|
77
|
+
options: { cds?: string; cutSignal?: boolean } = {}): Translated {
|
|
78
|
+
const nothing = (problem: string): Translated =>
|
|
79
|
+
({ protein: "", length: 0, from: { start: 1, end: 0, strand: 1 }, signal: null, stopped: false, warnings: [], problem });
|
|
80
|
+
const bases = clean(part.sequence);
|
|
81
|
+
if (!/^[ACGT]+$/.test(bases)) return nothing("A gene to translate is written in A, C, G and T, with no uncertain bases.");
|
|
82
|
+
|
|
83
|
+
const named = options.cds === undefined ? undefined
|
|
84
|
+
: part.features.find((one) => one.label === options.cds && /^cds$/i.test(one.type))
|
|
85
|
+
?? part.features.find((one) => one.label === options.cds);
|
|
86
|
+
if (options.cds !== undefined && named === undefined) return nothing(`Nothing called ${JSON.stringify(options.cds)} is marked on this part.`);
|
|
87
|
+
if (named !== undefined && named.parts.length > 1) return nothing(`${named.label} is marked in ${named.parts.length} pieces, which this does not translate.`);
|
|
88
|
+
const piece = named?.parts[0] ?? { start: 0, end: bases.length };
|
|
89
|
+
const strand: 1 | -1 = named?.strand === -1 ? -1 : 1;
|
|
90
|
+
const stretch = bases.slice(piece.start, piece.end);
|
|
91
|
+
const coding = strand === -1 ? flip(stretch) : stretch;
|
|
92
|
+
if (coding.length < CODON) return nothing("That stretch is shorter than one codon.");
|
|
93
|
+
|
|
94
|
+
const warnings: string[] = [];
|
|
95
|
+
if (coding.length % CODON !== 0) warnings.push(`The stretch is ${coding.length} bases, which is not a whole number of codons, so the last ${coding.length % CODON} were left out.`);
|
|
96
|
+
const whole = coding.slice(0, coding.length - (coding.length % CODON));
|
|
97
|
+
const read = String(translate(whole));
|
|
98
|
+
const stopped = read.endsWith("*");
|
|
99
|
+
let protein = stopped ? read.slice(0, -1) : read;
|
|
100
|
+
if (!stopped) warnings.push("The stretch does not end in a stop codon, so it may not be the whole coding sequence.");
|
|
101
|
+
if (!protein.startsWith("M")) warnings.push("It does not begin with methionine, which a coding sequence usually does.");
|
|
102
|
+
const inside = protein.indexOf("*");
|
|
103
|
+
if (inside >= 0) {
|
|
104
|
+
warnings.push(`There is a stop at amino acid ${inside + 1}, before the end, so this reading frame is wrong or the gene is broken.`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// The signal peptide is the first stretch of a secreted protein, and is cut off on the way out:
|
|
108
|
+
// what the lab ends up with is what is left, so it is worth being able to ask for that.
|
|
109
|
+
let signal: Translated["signal"] = null;
|
|
110
|
+
if (options.cutSignal === true) {
|
|
111
|
+
const marked = part.features.find((one) => /^sig[_ ]?peptide$/i.test(one.type) && one.parts[0] !== undefined
|
|
112
|
+
&& one.parts[0].start >= piece.start && one.parts[0].end <= piece.end);
|
|
113
|
+
if (marked === undefined) warnings.push("No signal peptide is marked on this part, so nothing was cut off.");
|
|
114
|
+
else {
|
|
115
|
+
const first = marked.parts[0]!;
|
|
116
|
+
const from = strand === -1 ? Math.floor((piece.end - first.end) / CODON) : Math.floor((first.start - piece.start) / CODON);
|
|
117
|
+
const many = Math.floor((first.end - first.start) / CODON);
|
|
118
|
+
if (from !== 0) warnings.push(`${marked.label} is marked from amino acid ${from + 1}, not from the start, so it was not cut off.`);
|
|
119
|
+
else {
|
|
120
|
+
signal = { peptide: protein.slice(0, many), label: marked.label };
|
|
121
|
+
protein = protein.slice(many);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
protein, length: protein.length,
|
|
127
|
+
from: { start: piece.start + 1, end: piece.end, strand },
|
|
128
|
+
signal, stopped, warnings, problem: null,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* What can be said about a protein from its sequence.
|
|
134
|
+
*
|
|
135
|
+
* @param protein - The amino acids.
|
|
136
|
+
* @returns The figures, or `null` if that is not a protein of standard amino acids.
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* import { proteinFacts } from "@biolibs/bionet-tools";
|
|
141
|
+
*
|
|
142
|
+
* proteinFacts("MKVLILACLVALALAR")?.isoelectric; // the pH it carries no net charge at
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export function proteinFacts(protein: string): ProteinFacts | null {
|
|
146
|
+
const amino = clean(protein);
|
|
147
|
+
if (!/^[ACDEFGHIKLMNPQRSTVWY]+$/.test(amino)) return null;
|
|
148
|
+
try {
|
|
149
|
+
const analysis = new ProteinAnalysis(amino);
|
|
150
|
+
const [reduced, cystines] = analysis.molarExtinctionCoefficient();
|
|
151
|
+
const [helix, turn, sheet] = analysis.secondaryStructureFraction();
|
|
152
|
+
return {
|
|
153
|
+
length: amino.length,
|
|
154
|
+
weight: analysis.molecularWeight(),
|
|
155
|
+
isoelectric: analysis.isoelectricPoint(),
|
|
156
|
+
extinction: { reduced, cystines },
|
|
157
|
+
instability: analysis.instabilityIndex(),
|
|
158
|
+
gravy: analysis.gravy(),
|
|
159
|
+
structure: { helix, turn, sheet },
|
|
160
|
+
};
|
|
161
|
+
} catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The working behind a translation: what was read, and where each figure came from.
|
|
168
|
+
*
|
|
169
|
+
* @param made - What the gene was translated into.
|
|
170
|
+
* @param facts - What is known about the protein, if it could be worked out.
|
|
171
|
+
* @returns One working for the translation and one for the figures.
|
|
172
|
+
*/
|
|
173
|
+
export function proteinWorking(made: Translated, facts: ProteinFacts | null): Working[] {
|
|
174
|
+
if (made.problem !== null) return [];
|
|
175
|
+
const count = (value: number): string => value.toLocaleString("en-US");
|
|
176
|
+
const out: Working[] = [{
|
|
177
|
+
of: "the protein",
|
|
178
|
+
comes: `${count(made.length)} amino acids`,
|
|
179
|
+
kind: "exact",
|
|
180
|
+
steps: [
|
|
181
|
+
`read from bases ${count(made.from.start)}–${count(made.from.end)}${made.from.strand === -1 ? ", on the bottom strand" : ""}`,
|
|
182
|
+
`${count(made.from.end - made.from.start + 1)} bases is ${count(Math.floor((made.from.end - made.from.start + 1) / CODON))} codons`,
|
|
183
|
+
made.stopped ? "the last codon is a stop, which is not an amino acid" : "there is no stop codon at the end",
|
|
184
|
+
...(made.signal === null ? [] : [`${made.signal.label}, the first ${made.signal.peptide.length} amino acids, was cut off: it is gone from what the cell lets out`]),
|
|
185
|
+
`it begins ${made.protein.slice(0, 24)}${made.protein.length > 24 ? "…" : ""}`,
|
|
186
|
+
],
|
|
187
|
+
}];
|
|
188
|
+
if (facts !== null) {
|
|
189
|
+
out.push({
|
|
190
|
+
of: "what is known of it",
|
|
191
|
+
comes: `${count(Math.round(facts.weight))} Da, carrying no net charge at pH ${facts.isoelectric.toFixed(2)}`,
|
|
192
|
+
kind: "estimate",
|
|
193
|
+
steps: [
|
|
194
|
+
`the weight is the amino acids added up, less a water for each bond: ${count(Math.round(facts.weight))} Da`,
|
|
195
|
+
`the isoelectric point is where its charges cancel: pH ${facts.isoelectric.toFixed(2)}`,
|
|
196
|
+
facts.extinction.reduced > 0
|
|
197
|
+
? `it absorbs at 280 nm with ${count(facts.extinction.reduced)} M⁻¹cm⁻¹, which is how a concentration is read off`
|
|
198
|
+
: "it has no tryptophan, tyrosine or cystine, so it does not absorb at 280 nm and a concentration cannot be read there",
|
|
199
|
+
`the instability index is ${facts.instability.toFixed(1)}; over 40 is reckoned unstable in a tube`,
|
|
200
|
+
`${Math.round(facts.structure.helix * 100)}% helix, ${Math.round(facts.structure.turn * 100)}% turn, ${Math.round(facts.structure.sheet * 100)}% sheet`,
|
|
201
|
+
],
|
|
202
|
+
rests: "These come from scales measured on other proteins and applied to this sequence. They are what the sequence suggests, not what anybody has measured of this protein.",
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return out;
|
|
206
|
+
}
|
package/src/run.ts
CHANGED
|
@@ -21,6 +21,22 @@ export interface ToolLab {
|
|
|
21
21
|
places: readonly PlaceState[];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* The DNA part a tube holds, if it holds one.
|
|
26
|
+
*
|
|
27
|
+
* A lab keeps protein as well as DNA, and a tube of protein is nothing a polymerase, an enzyme or a
|
|
28
|
+
* ligase can be pointed at. Everything in this file works on DNA, so everything in it asks for a
|
|
29
|
+
* part this way and a protein is simply not offered.
|
|
30
|
+
*
|
|
31
|
+
* @param lab - The lab.
|
|
32
|
+
* @param checksum - What the tube is of, or `null` for a culture.
|
|
33
|
+
* @returns The part, or `undefined` if it is not one, or is not DNA.
|
|
34
|
+
*/
|
|
35
|
+
export function dnaOf(lab: Pick<ToolLab, "parts">, checksum: string | null): PartState | undefined {
|
|
36
|
+
const part = checksum === null ? undefined : lab.parts.find((one) => one.checksum === checksum);
|
|
37
|
+
return part === undefined || part.kind === "protein" ? undefined : part;
|
|
38
|
+
}
|
|
39
|
+
|
|
24
40
|
/** One tube that could be chosen. */
|
|
25
41
|
export interface TubeChoice {
|
|
26
42
|
/** The tube. */
|
|
@@ -44,7 +60,7 @@ export interface TubeChoice {
|
|
|
44
60
|
export function pcrTubes(lab: ToolLab): { templates: TubeChoice[]; primers: TubeChoice[] } {
|
|
45
61
|
const all: TubeChoice[] = [];
|
|
46
62
|
for (const item of lab.items) {
|
|
47
|
-
const part = lab
|
|
63
|
+
const part = dnaOf(lab, item.part);
|
|
48
64
|
if (part === undefined || item.retired || item.amount <= 0) continue;
|
|
49
65
|
all.push({ item: item.item, part, label: `${part.name} · ${amountOf(item)} · ${whereWords(item, lab.places)}` });
|
|
50
66
|
}
|
|
@@ -139,7 +155,7 @@ export function pcrFeatures(template: Pick<PartState, "sequence" | "features">,
|
|
|
139
155
|
export function pcrRun(lab: ToolLab, choice: PcrChoice): PcrRun {
|
|
140
156
|
const partOf = (id: string): PartState | undefined => {
|
|
141
157
|
const item = lab.items.find((one) => one.item === id);
|
|
142
|
-
return item === undefined ? undefined : lab
|
|
158
|
+
return item === undefined ? undefined : dnaOf(lab, item.part);
|
|
143
159
|
};
|
|
144
160
|
const [template, forward, reverse] = [partOf(choice.template), partOf(choice.forward), partOf(choice.reverse)];
|
|
145
161
|
const typed = choice.name?.trim() ?? "";
|
|
@@ -237,7 +253,7 @@ export interface DigestRun {
|
|
|
237
253
|
*/
|
|
238
254
|
export function digestRun(lab: ToolLab, choice: DigestChoice): DigestRun {
|
|
239
255
|
const item = lab.items.find((one) => one.item === choice.tube);
|
|
240
|
-
const part = item === undefined ? undefined : lab
|
|
256
|
+
const part = item === undefined ? undefined : dnaOf(lab, item.part);
|
|
241
257
|
if (part === undefined) return { plan: null, pieces: [], matched: null, differed: null };
|
|
242
258
|
const plan = planDigest(part, choice.enzymes, { ...(choice.gel === undefined ? {} : { gel: choice.gel }), ...(choice.ladder === undefined ? {} : { ladder: choice.ladder }) });
|
|
243
259
|
if (plan.problem !== null) return { plan, pieces: [], matched: null, differed: null };
|
|
@@ -333,7 +349,7 @@ export function ligationRun(lab: ToolLab, choice: LigationChoice): LigationRun {
|
|
|
333
349
|
const pieces: LigationPiece[] = [];
|
|
334
350
|
for (const item of choice.tubes) {
|
|
335
351
|
const held = lab.items.find((one) => one.item === item);
|
|
336
|
-
const part = held === undefined ? undefined : lab
|
|
352
|
+
const part = held === undefined ? undefined : dnaOf(lab, held.part);
|
|
337
353
|
if (part === undefined || part.circular) return { plan: null, pieces: [], product: null, name: "", worked: null, failed: null };
|
|
338
354
|
pieces.push({ id: item, name: part.name, sequence: part.sequence, ends: part.ends ?? { left: 0, right: 0 }, features: part.features });
|
|
339
355
|
}
|
|
@@ -370,10 +386,10 @@ export function ligationRun(lab: ToolLab, choice: LigationChoice): LigationRun {
|
|
|
370
386
|
}
|
|
371
387
|
|
|
372
388
|
/** The tools there are. */
|
|
373
|
-
export type ToolName = "pcr" | "digest" | "ligation";
|
|
389
|
+
export type ToolName = "pcr" | "digest" | "ligation" | "induction";
|
|
374
390
|
|
|
375
391
|
/** The model of instrument each tool is used at. */
|
|
376
|
-
export const TOOL_AT: Readonly<Record<ToolName, string>> = { pcr: "thermocycler", digest: "gel-station", ligation: "heat-block" };
|
|
392
|
+
export const TOOL_AT: Readonly<Record<ToolName, string>> = { pcr: "thermocycler", digest: "gel-station", ligation: "heat-block", induction: "shaking-incubator" };
|
|
377
393
|
|
|
378
394
|
/**
|
|
379
395
|
* Which tool an instrument opens.
|