@biolibs/bionet-tools 0.1.11 → 0.1.13
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 +151 -0
- package/dist/codons.d.ts +58 -0
- package/dist/codons.d.ts.map +1 -1
- package/dist/codons.js +156 -0
- package/dist/codons.js.map +1 -1
- package/dist/fusion-bench.d.ts +62 -0
- package/dist/fusion-bench.d.ts.map +1 -0
- package/dist/fusion-bench.js +114 -0
- package/dist/fusion-bench.js.map +1 -0
- package/dist/fusion.d.ts +120 -0
- package/dist/fusion.d.ts.map +1 -0
- package/dist/fusion.js +176 -0
- package/dist/fusion.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/modify.js +4 -4
- package/dist/modify.js.map +1 -1
- package/dist/protocol.d.ts +91 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +278 -0
- package/dist/protocol.js.map +1 -0
- package/dist/remedy.d.ts +137 -0
- package/dist/remedy.d.ts.map +1 -0
- package/dist/remedy.js +234 -0
- package/dist/remedy.js.map +1 -0
- package/dist/tools.d.ts +1 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +3 -2
- package/dist/tools.js.map +1 -1
- package/dist/work.d.ts.map +1 -1
- package/dist/work.js +13 -3
- package/dist/work.js.map +1 -1
- package/package.json +2 -2
- package/src/codons.ts +142 -1
- package/src/fusion-bench.tsx +209 -0
- package/src/fusion.ts +270 -0
- package/src/index.ts +8 -0
- package/src/modify.ts +4 -4
- package/src/protocol.ts +332 -0
- package/src/remedy.ts +277 -0
- package/src/tools.tsx +4 -3
- package/src/work.tsx +44 -2
- package/tools.css +7 -0
package/src/index.ts
CHANGED
|
@@ -18,12 +18,15 @@
|
|
|
18
18
|
* - `protein.ts` — the protein a gene codes for, and what its sequence says about it
|
|
19
19
|
* - `induce.ts` — growing a strain to express what was put into it, and the mass its band should run at
|
|
20
20
|
* - `modify.ts` — which residues would be phosphorylated, and whether the host has the enzyme to do it
|
|
21
|
+
* - `remedy.ts` — the ways round a host that will not, and the one of them that can be computed
|
|
21
22
|
* - `induce-bench.tsx` — an induction at the shaking incubator, with the protein gel that answers it
|
|
22
23
|
* - `verify-bench.tsx` — checking a construct against the design at a desk, saying what was not covered
|
|
23
24
|
* - `verify.ts` — a sequencing read against the design it was meant to be, and what each difference costs
|
|
24
25
|
* - `codons.ts` — a gene rewritten in a host's codons, from usage counted over that host's own genes
|
|
25
26
|
* - `codon-bench.tsx` — writing a gene in a host's codons at a desk, with the counting on the screen
|
|
26
27
|
* - `assembly-design.ts` — a ring designed from a lab's own parts: the pieces in order, and the primers that make them fit
|
|
28
|
+
* - `fusion.ts` — a promoter, a signal, a gene and a tag put together, with the frame checked at every junction
|
|
29
|
+
* - `fusion-bench.tsx` — that at a desk: the pieces in order, and the frame watched as they are laid out
|
|
27
30
|
* - `assembly-bench.tsx` — building a ring at a desk: the pieces in order, and the primers that make them fit
|
|
28
31
|
* - `ligate.ts` — pieces that have already been cut, joined where their ends fit
|
|
29
32
|
* - `ligate-working.ts` — a ligation's working: each join in its bases, the length, how much to put in
|
|
@@ -40,6 +43,7 @@
|
|
|
40
43
|
* - `plans.tsx` — runs that have been proposed, at the tool that would carry them out
|
|
41
44
|
* - `ordering.ts` — those proposals read as one piece of work: what order, what can start, what is waiting
|
|
42
45
|
* - `work.tsx` — that work drawn: the chains, in order, with what has to be got first
|
|
46
|
+
* - `protocol.ts` — the work as a sheet to carry to a bench, with what the plan does not say named
|
|
43
47
|
* - `tools.tsx` — getting to one: from an instrument, or from a list of them all
|
|
44
48
|
*
|
|
45
49
|
* The tools are drawn with the styles of `@biolibs/bionet-panels` and belong inside its `LabWindow`.
|
|
@@ -57,12 +61,15 @@ export * from "./digest-working.js";
|
|
|
57
61
|
export * from "./protein.js";
|
|
58
62
|
export * from "./induce.js";
|
|
59
63
|
export * from "./modify.js";
|
|
64
|
+
export * from "./remedy.js";
|
|
60
65
|
export * from "./induce-bench.js";
|
|
61
66
|
export * from "./verify.js";
|
|
62
67
|
export * from "./verify-bench.js";
|
|
63
68
|
export * from "./codons.js";
|
|
64
69
|
export * from "./codon-bench.js";
|
|
65
70
|
export * from "./assembly-design.js";
|
|
71
|
+
export * from "./fusion.js";
|
|
72
|
+
export * from "./fusion-bench.js";
|
|
66
73
|
export * from "./assembly-bench.js";
|
|
67
74
|
export * from "./ligate.js";
|
|
68
75
|
export * from "./ligate-working.js";
|
|
@@ -75,6 +82,7 @@ export * from "./sequences-tool.js";
|
|
|
75
82
|
export * from "./plans.js";
|
|
76
83
|
export * from "./ordering.js";
|
|
77
84
|
export * from "./work.js";
|
|
85
|
+
export * from "./protocol.js";
|
|
78
86
|
export * from "./tools.js";
|
|
79
87
|
export * from "./pcr-bench.js";
|
|
80
88
|
export * from "./primer-design.js";
|
package/src/modify.ts
CHANGED
|
@@ -248,7 +248,7 @@ export interface HostKinases {
|
|
|
248
248
|
export const HOST_KINASES: readonly HostKinases[] = [
|
|
249
249
|
{
|
|
250
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
|
|
251
|
+
says: "A bacterium has no secretory pathway of this kind and no kinase in it, so casein made in plain E. coli is unphosphorylated. That is not the end of it: co-expressing a kinase on the same plasmid has worked, and worked well — Thurmond and colleagues got every phosphorylated form of human beta-casein that the native protein has, in E. coli, with human CK2 beside it. The same trick does much less for bovine beta-casein, because CK2 reads only some of its sites. E. coli also gives the highest yields of any host tried: up to 1.45 g/L.",
|
|
252
252
|
},
|
|
253
253
|
{
|
|
254
254
|
host: "Bacillus subtilis", secretoryKinase: "no", casein2: false, standing: "well established",
|
|
@@ -256,15 +256,15 @@ export const HOST_KINASES: readonly HostKinases[] = [
|
|
|
256
256
|
},
|
|
257
257
|
{
|
|
258
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.
|
|
259
|
+
says: "Budding yeast has casein kinase I and II homologues, but no homologue of the secretory-pathway kinase has been identified. Yeast does appear to phosphorylate casein in vivo; how completely, and at which sites, is underexplored rather than measured — most studies went after secretion and yield instead. Some strains also put O-linked sugars on it, which native casein does not have.",
|
|
260
260
|
},
|
|
261
261
|
{
|
|
262
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
|
|
263
|
+
says: "The yeast formerly called Pichia pastoris, and the usual choice for a secreted protein because it secretes a great deal of it: 1 g/L of bovine beta-casein has been reported, the best of any yeast. The kinase of the secretory pathway has not been identified in it, as in budding yeast, and one report of a bovine beta-casein mutant made here found it both phosphorylated and glycosylated. How completely it phosphorylates, and where, nobody has measured.",
|
|
264
264
|
},
|
|
265
265
|
{
|
|
266
266
|
host: "Nicotiana benthamiana", secretoryKinase: "not known", casein2: true, standing: "reported",
|
|
267
|
-
says: "Plants have CK2 and a secretory pathway
|
|
267
|
+
says: "Plants have CK2 and a secretory pathway. What has actually been reported for casein in plants is poor: yields of a tenth of a per cent of total protein or less, and casein found unphosphorylated where anybody looked.",
|
|
268
268
|
},
|
|
269
269
|
{
|
|
270
270
|
host: "Cricetulus griseus", secretoryKinase: "yes", casein2: true, standing: "well established",
|
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The work written out as something a person can carry to a bench.
|
|
3
|
+
*
|
|
4
|
+
* Everything else here is for a screen: a panel that knows the lab, with the tubes in dropdowns and
|
|
5
|
+
* the working folded away. None of it is any use at a bench with gloves on, and a plan nobody can
|
|
6
|
+
* follow standing up is not finished.
|
|
7
|
+
*
|
|
8
|
+
* The whole difficulty is honesty. A plan records what the operator set — the cycling programme, the
|
|
9
|
+
* enzymes, the inducer and how long for — and a protocol wants rather more than that: a polymerase,
|
|
10
|
+
* a buffer, a final volume, a way of making cells competent. Those are not in the plan, and a tool
|
|
11
|
+
* that wrote in plausible ones would be making things up on a page somebody carries to a bench and
|
|
12
|
+
* trusts. So each step carries two lists and they are kept apart: what the plan says to do, which is
|
|
13
|
+
* exact, and what the plan does not say, which is named so the lab fills it in with its own usual
|
|
14
|
+
* way rather than discovering the hole halfway through.
|
|
15
|
+
*
|
|
16
|
+
* Nothing here invents a number. If a volume is in it, somebody set that volume.
|
|
17
|
+
*/
|
|
18
|
+
import type { PlanState } from "@biolibs/bionet";
|
|
19
|
+
import { planOfWork, type OrderingLab, type Step } from "./ordering.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* As much of a lab as a protocol reads: the work, plus the names of things, since a sheet carried to
|
|
23
|
+
* a bench says "1 µL of pGene, in Box 1" and not a checksum.
|
|
24
|
+
*/
|
|
25
|
+
export interface ProtocolLab extends OrderingLab {
|
|
26
|
+
parts: readonly { checksum: string; name: string; length: number; circular: boolean }[];
|
|
27
|
+
strains?: readonly { strain: string; name: string; host: string }[];
|
|
28
|
+
places?: readonly { place: string; name: string }[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** One step, as somebody at a bench reads it. */
|
|
32
|
+
export interface ProtocolStep {
|
|
33
|
+
/** Its number within its piece of work. */
|
|
34
|
+
number: number;
|
|
35
|
+
/** What the step is, in a line. */
|
|
36
|
+
title: string;
|
|
37
|
+
/** What to get out before starting, with how much of each and where it is. */
|
|
38
|
+
takeOut: string[];
|
|
39
|
+
/** What to set a machine to, from what the plan recorded. */
|
|
40
|
+
set: { what: string; to: string }[];
|
|
41
|
+
/** What to do, in order. */
|
|
42
|
+
doThis: string[];
|
|
43
|
+
/** What to record afterwards, which is what keeps the lab's history true. */
|
|
44
|
+
thenRecord: string;
|
|
45
|
+
/**
|
|
46
|
+
* What this plan does not say, and the lab has to supply.
|
|
47
|
+
*
|
|
48
|
+
* The most important list on the page. A protocol that quietly left these out would read as
|
|
49
|
+
* complete and send somebody to the bench without a polymerase.
|
|
50
|
+
*/
|
|
51
|
+
notSaid: string[];
|
|
52
|
+
/** Whatever the person who proposed it wanted to say. */
|
|
53
|
+
note: string | null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One piece of work, written out. */
|
|
57
|
+
export interface Protocol {
|
|
58
|
+
/** What it is called. */
|
|
59
|
+
title: string;
|
|
60
|
+
/** A line or two about what it is and what it leaves you with. */
|
|
61
|
+
about: string[];
|
|
62
|
+
/** What the lab has to have before the first step. */
|
|
63
|
+
haveReady: string[];
|
|
64
|
+
/** The steps, in the order to carry them out. */
|
|
65
|
+
steps: ProtocolStep[];
|
|
66
|
+
/** What you have at the end of it. */
|
|
67
|
+
atTheEnd: string[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** What a kind of run is called on the page, and what a plan of that kind never says. */
|
|
71
|
+
const KINDS: Readonly<Record<string, { title: string; records: string; notSaid: readonly string[] }>> = {
|
|
72
|
+
pcr: {
|
|
73
|
+
title: "Copy it by PCR",
|
|
74
|
+
records: "at the PCR tool, which takes what it used from each tube and puts the product in the freezer.",
|
|
75
|
+
notSaid: ["which polymerase and which buffer", "the final volume of the reaction, and how much water",
|
|
76
|
+
"how much of each primer, by concentration", "the first denaturation and the last extension"],
|
|
77
|
+
},
|
|
78
|
+
digest: {
|
|
79
|
+
records: "at the digest and gel tool, which takes what it used and notes whether the gel showed what was expected.", title: "Cut it, and run a gel",
|
|
80
|
+
notSaid: ["which buffer, and how much enzyme", "what temperature to cut at and for how long",
|
|
81
|
+
"how the gel is stained and how it is looked at"],
|
|
82
|
+
},
|
|
83
|
+
ligation: {
|
|
84
|
+
records: "at the ligation tool, which takes what it used and puts what came out in the freezer.", title: "Join the pieces",
|
|
85
|
+
notSaid: ["which ligase and which buffer", "the ratio of insert to vector", "what temperature to leave it at, and for how long"],
|
|
86
|
+
},
|
|
87
|
+
assembly: {
|
|
88
|
+
records: "at the assembly tool, which takes what it used and puts the ring in the freezer.", title: "Build the ring",
|
|
89
|
+
notSaid: ["which assembly mix", "what temperature to hold it at, and for how long", "how much of each piece, by concentration"],
|
|
90
|
+
},
|
|
91
|
+
transformation: {
|
|
92
|
+
records: "on the Strains page. Whether it worked is whether colonies grew, which only you can say, and either way it used what it used.", title: "Put it into a host",
|
|
93
|
+
notSaid: ["how the cells are made competent", "heat shock or electroporation, and the settings for it",
|
|
94
|
+
"how long to let them recover, and in what", "what to select on"],
|
|
95
|
+
},
|
|
96
|
+
induction: {
|
|
97
|
+
records: "at the induction tool, which takes what it used and, if the band is there, puts the protein in the freezer.", title: "Grow it and look for the protein",
|
|
98
|
+
notSaid: ["which medium, and what volume", "what density to induce at", "how the cells are broken open, if they are",
|
|
99
|
+
"how the gel is stained"],
|
|
100
|
+
},
|
|
101
|
+
sequencing: { records: "at the checking tool, which compares the read against the design and records what it found.", title: "Have it sequenced", notSaid: ["which facility, and how they want it sent", "how much to send, and at what concentration"] },
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const count = (value: number): string => value.toLocaleString("en-US");
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The work of one piece, written out as a protocol.
|
|
108
|
+
*
|
|
109
|
+
* @param lab - The lab, for the names of what its tubes hold and where they are.
|
|
110
|
+
* @param options - `project` picks one project's work; `title` names the sheet.
|
|
111
|
+
* @returns One protocol for each piece of work, in the order the pieces come.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* import { protocolsFor, protocolText } from "@biolibs/bionet-tools";
|
|
116
|
+
*
|
|
117
|
+
* for (const sheet of protocolsFor(lab, { project: "Real Vegan Cheese" })) console.log(protocolText(sheet));
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export function protocolsFor(lab: ProtocolLab, options: { project?: string; title?: string } = {}): Protocol[] {
|
|
121
|
+
const work = planOfWork(lab);
|
|
122
|
+
const threads = options.project === undefined ? work.threads
|
|
123
|
+
: work.projects.find((one) => one.name === options.project)?.threads ?? [];
|
|
124
|
+
|
|
125
|
+
const partName = (checksum: string | null | undefined): string =>
|
|
126
|
+
lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
127
|
+
const placeName = (place: string | null | undefined): string | null =>
|
|
128
|
+
(lab.places ?? []).find((one) => one.place === place)?.name ?? null;
|
|
129
|
+
/** What is in a tube, by the lab's name for it. */
|
|
130
|
+
const whatIsIn = (item: string): string => {
|
|
131
|
+
const held = lab.items.find((one) => one.item === item);
|
|
132
|
+
if (held === undefined) return "something the lab no longer has";
|
|
133
|
+
return held.part === null
|
|
134
|
+
? (lab.strains ?? []).find((one) => one.strain === held.strain)?.name ?? "a culture"
|
|
135
|
+
: partName(held.part);
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* How much of what, for an instruction: short, because the instruction is read while doing it.
|
|
139
|
+
*/
|
|
140
|
+
const tubeWords = (item: string, amount: number): string => {
|
|
141
|
+
const held = lab.items.find((one) => one.item === item);
|
|
142
|
+
const unit = held?.unit ?? "";
|
|
143
|
+
return `${count(amount)}${unit === "" ? "" : ` ${unit}`} of ${whatIsIn(item)}`;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* The same, with where it is and how much the tube holds: for the list of what to fetch before
|
|
147
|
+
* starting, which is read standing in front of a freezer and wants rather more.
|
|
148
|
+
*/
|
|
149
|
+
const fetchWords = (item: string, amount: number): string => {
|
|
150
|
+
const held = lab.items.find((one) => one.item === item);
|
|
151
|
+
if (held === undefined) return "a tube the lab no longer has";
|
|
152
|
+
const unit = held.unit ?? "";
|
|
153
|
+
const where = placeName(held.where?.place);
|
|
154
|
+
return `${tubeWords(item, amount)}${where === null ? "" : ` — in ${where}`}`
|
|
155
|
+
+ ` (the tube holds ${count(held.amount)}${unit === "" ? "" : ` ${unit}`})`;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const says = (plan: PlanState, key: string): string | null => {
|
|
159
|
+
const value = plan.settings[key];
|
|
160
|
+
return value === undefined ? null : String(value);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/** What to do, for a kind of run, from what the plan actually recorded. */
|
|
164
|
+
const doingOf = (step: Step): { doThis: string[]; set: { what: string; to: string }[] } => {
|
|
165
|
+
const plan = step.plan;
|
|
166
|
+
const used = plan.inputs.map((one) => ({
|
|
167
|
+
// A part the lab has no tube of has an amount but no unit, since the unit belongs to the tube.
|
|
168
|
+
// A bare "1 of the insert" reads as a mistake, so it is simply named.
|
|
169
|
+
...one, words: one.item === undefined ? partName(one.part) : tubeWords(one.item, one.amount),
|
|
170
|
+
}));
|
|
171
|
+
const byRole = (role: string) => used.filter((one) => one.role === role);
|
|
172
|
+
const makes = plan.expects.map((one) => `${one.name} (${count(one.length)} bp${one.circular ? ", a circle" : ""})`);
|
|
173
|
+
const set: { what: string; to: string }[] = [];
|
|
174
|
+
const doThis: string[] = [];
|
|
175
|
+
|
|
176
|
+
if (plan.kind === "pcr") {
|
|
177
|
+
const template = byRole("template")[0] ?? used[0];
|
|
178
|
+
const primers = used.filter((one) => /primer/.test(one.role));
|
|
179
|
+
doThis.push(`Set up the reaction with ${template?.words ?? "the template"} as the template`
|
|
180
|
+
+ (primers.length === 0 ? "." : `, and ${primers.map((one) => one.words).join(" and ")}.`));
|
|
181
|
+
const programme = ["denature_c", "anneal_c", "anneal_s", "extend_c", "extend_s", "cycles"].map((key) => says(plan, key));
|
|
182
|
+
if (programme.every((one) => one !== null)) {
|
|
183
|
+
set.push({ what: "Denature", to: `${programme[0]} °C` });
|
|
184
|
+
set.push({ what: "Anneal", to: `${programme[1]} °C for ${programme[2]} s` });
|
|
185
|
+
set.push({ what: "Extend", to: `${programme[3]} °C for ${programme[4]} s` });
|
|
186
|
+
set.push({ what: "Cycles", to: String(programme[5]) });
|
|
187
|
+
doThis.push("Run the programme above.");
|
|
188
|
+
} else {
|
|
189
|
+
doThis.push("Run it on the thermocycler. This plan does not record the programme, so set it as the lab usually does for these primers.");
|
|
190
|
+
}
|
|
191
|
+
doThis.push(`Expect ${makes.join(" and ") || "one product"}.`);
|
|
192
|
+
} else if (plan.kind === "digest") {
|
|
193
|
+
const enzymes = (says(plan, "enzymes") ?? "").split("+").filter((one) => one !== "");
|
|
194
|
+
doThis.push(`Cut ${used.map((one) => one.words).join(" and ")}`
|
|
195
|
+
+ (enzymes.length === 0 ? "." : ` with ${enzymes.join(" and ")}.`));
|
|
196
|
+
const gel = says(plan, "gel");
|
|
197
|
+
if (gel !== null) set.push({ what: "Gel", to: `${gel}% agarose` });
|
|
198
|
+
for (const [key, what] of [["volts", "Run at"], ["minutes", "For"]] as const) {
|
|
199
|
+
const value = says(plan, key);
|
|
200
|
+
if (value !== null) set.push({ what, to: key === "volts" ? `${value} V` : `${value} min` });
|
|
201
|
+
}
|
|
202
|
+
const expected = says(plan, "expected");
|
|
203
|
+
doThis.push("Run it on the gel beside a ladder.");
|
|
204
|
+
if (expected !== null) doThis.push(`Expect bands at ${expected.split(",").map((one) => `${count(Number(one))} bp`).join(", ")}.`);
|
|
205
|
+
} else if (plan.kind === "ligation" || plan.kind === "assembly") {
|
|
206
|
+
doThis.push(`Put ${used.map((one) => one.words).join(" and ")} together.`);
|
|
207
|
+
const overlap = says(plan, "overlap");
|
|
208
|
+
if (overlap !== null) set.push({ what: "Overlap at each join", to: `${overlap} bp` });
|
|
209
|
+
const joins = says(plan, "joins");
|
|
210
|
+
if (joins !== null) set.push({ what: "Joins", to: String(joins) });
|
|
211
|
+
doThis.push(`Expect ${makes.join(" and ") || "one product"}.`);
|
|
212
|
+
} else if (plan.kind === "transformation") {
|
|
213
|
+
const construct = byRole("construct")[0];
|
|
214
|
+
const host = byRole("host")[0];
|
|
215
|
+
doThis.push(`Put ${construct?.words ?? "the construct"} into ${host?.words ?? "the host"}.`);
|
|
216
|
+
doThis.push("Plate them out and leave them to grow.");
|
|
217
|
+
doThis.push("Whether it worked is whether colonies grew, which only you can say. Either way it used what it used.");
|
|
218
|
+
} else if (plan.kind === "induction") {
|
|
219
|
+
const culture = used[0];
|
|
220
|
+
doThis.push(`Grow ${culture?.words ?? "the culture"}.`);
|
|
221
|
+
const inducer = says(plan, "inducer");
|
|
222
|
+
const at = says(plan, "at");
|
|
223
|
+
if (inducer !== null) doThis.push(`Add ${inducer}${at === null ? "" : ` to ${at}`}.`);
|
|
224
|
+
for (const [key, what, unit] of [["celsius", "Grow at", "°C"], ["rpm", "Shaking at", "rpm"], ["hours", "For", "h"]] as const) {
|
|
225
|
+
const value = says(plan, key);
|
|
226
|
+
if (value !== null) set.push({ what, to: `${value} ${unit}` });
|
|
227
|
+
}
|
|
228
|
+
const kda = says(plan, "expected_kda");
|
|
229
|
+
doThis.push("Run a sample on a protein gel, beside a lane of the same culture before it was induced.");
|
|
230
|
+
if (kda !== null) doThis.push(`Look for a band at ${kda} kDa that is in the induced lane and not the other.`);
|
|
231
|
+
} else {
|
|
232
|
+
doThis.push(`Carry out the ${plan.kind} with ${used.map((one) => one.words).join(" and ") || "what it names"}.`);
|
|
233
|
+
if (makes.length > 0) doThis.push(`Expect ${makes.join(" and ")}.`);
|
|
234
|
+
}
|
|
235
|
+
return { doThis, set };
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
return threads.map((thread) => {
|
|
239
|
+
const steps: ProtocolStep[] = thread.steps.map((step, at) => {
|
|
240
|
+
const known = KINDS[step.plan.kind];
|
|
241
|
+
const number = at + 1;
|
|
242
|
+
const { doThis, set } = doingOf(step);
|
|
243
|
+
// Something with no tube may be made by a step before this one, which the chain already
|
|
244
|
+
// knows. Saying "order it" when step 1 makes it would send somebody shopping for nothing.
|
|
245
|
+
const madeAt = (checksum: string | undefined): number | null => {
|
|
246
|
+
const at = thread.steps.findIndex((each) => each.makes.includes(checksum ?? ""));
|
|
247
|
+
return at < 0 || at >= number ? null : at + 1;
|
|
248
|
+
};
|
|
249
|
+
const takeOut = step.plan.inputs.map((one) => {
|
|
250
|
+
if (one.item !== undefined) return fetchWords(one.item, one.amount);
|
|
251
|
+
const from = madeAt(one.part);
|
|
252
|
+
return from === null
|
|
253
|
+
? `${partName(one.part)} — the lab has no tube of it, and nothing here makes it: order or make it first`
|
|
254
|
+
: `${partName(one.part)} — what step ${from} makes`;
|
|
255
|
+
});
|
|
256
|
+
return {
|
|
257
|
+
number,
|
|
258
|
+
title: known?.title ?? `Carry out the ${step.plan.kind}`,
|
|
259
|
+
takeOut, set, doThis,
|
|
260
|
+
// Recording is what keeps the lab's history true, and where it is done differs by kind:
|
|
261
|
+
// a transformation is not run at a machine and is said on the Strains page.
|
|
262
|
+
thenRecord: `Record it ${known?.records ?? `at the ${step.plan.kind} tool.`}`,
|
|
263
|
+
notSaid: [...(known?.notSaid ?? ["what this plan does not record, the lab supplies as usual"])],
|
|
264
|
+
note: step.plan.note,
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
const needed = work.toGet.filter((one) => one.forSteps.some((each) => thread.steps.some((step) => step.plan.plan === each)));
|
|
268
|
+
// A chain that makes nothing — a digest, a check — has no product to be named by, so it is
|
|
269
|
+
// named by what it is done to, which is what somebody looking for the sheet would call it.
|
|
270
|
+
const actsOn = thread.steps[0]?.plan.inputs.flatMap((one) => (one.item === undefined ? [partName(one.part)] : [whatIsIn(one.item)])) ?? [];
|
|
271
|
+
return {
|
|
272
|
+
title: options.title ?? (thread.ends.length > 0 ? thread.name
|
|
273
|
+
: actsOn.length > 0 ? `${KINDS[thread.steps[0]!.plan.kind]?.title ?? thread.steps[0]!.plan.kind}: ${actsOn[0]}` : thread.name),
|
|
274
|
+
about: [
|
|
275
|
+
`${steps.length} ${steps.length === 1 ? "step" : "steps"}.`,
|
|
276
|
+
...(thread.ends.length === 0 ? [] : [`It ends with ${thread.ends.map((one) => partName(one.checksum) === "a part" ? one.name : partName(one.checksum)).join(" and ")}.`]),
|
|
277
|
+
"Every step is proposed, not done: nothing is used and nothing is recorded until somebody carries it out and says so.",
|
|
278
|
+
],
|
|
279
|
+
haveReady: [
|
|
280
|
+
...needed.map((one) => `${partName(one.checksum) === "a part" ? one.name : partName(one.checksum)} — nothing here makes it and the lab has no tube: order or make it first.`),
|
|
281
|
+
...[...new Set(thread.steps.flatMap((step) => step.plan.inputs.flatMap((one) => (one.item === undefined ? [] : [fetchWords(one.item, one.amount)]))))],
|
|
282
|
+
],
|
|
283
|
+
steps,
|
|
284
|
+
atTheEnd: thread.ends.map((one) => partName(one.checksum) === "a part" ? one.name : partName(one.checksum)),
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* A protocol as text, to print or to paste.
|
|
291
|
+
*
|
|
292
|
+
* Markdown, because it reads as well unrendered as rendered, and somebody at a bench is as likely to
|
|
293
|
+
* have it in a terminal or a text file as on a page.
|
|
294
|
+
*
|
|
295
|
+
* @param protocol - What `protocolsFor` gave.
|
|
296
|
+
* @returns The sheet.
|
|
297
|
+
*/
|
|
298
|
+
export function protocolText(protocol: Protocol): string {
|
|
299
|
+
const out: string[] = [`# ${protocol.title}`, ""];
|
|
300
|
+
for (const line of protocol.about) out.push(line, "");
|
|
301
|
+
if (protocol.haveReady.length > 0) {
|
|
302
|
+
out.push("## Have ready", "");
|
|
303
|
+
for (const one of protocol.haveReady) out.push(`- ${one}`);
|
|
304
|
+
out.push("");
|
|
305
|
+
}
|
|
306
|
+
for (const step of protocol.steps) {
|
|
307
|
+
out.push(`## ${step.number}. ${step.title}`, "");
|
|
308
|
+
if (step.note !== null) out.push(`*${step.note}*`, "");
|
|
309
|
+
if (step.takeOut.length > 0) {
|
|
310
|
+
out.push("**Take out**", "");
|
|
311
|
+
for (const one of step.takeOut) out.push(`- ${one}`);
|
|
312
|
+
out.push("");
|
|
313
|
+
}
|
|
314
|
+
if (step.set.length > 0) {
|
|
315
|
+
out.push("**Set**", "");
|
|
316
|
+
for (const one of step.set) out.push(`- ${one.what}: ${one.to}`);
|
|
317
|
+
out.push("");
|
|
318
|
+
}
|
|
319
|
+
out.push("**Do**", "");
|
|
320
|
+
for (const [at, one] of step.doThis.entries()) out.push(`${at + 1}. ${one}`);
|
|
321
|
+
out.push("", `**Then** ${step.thenRecord}`, "");
|
|
322
|
+
out.push("**This plan does not say**", "");
|
|
323
|
+
for (const one of step.notSaid) out.push(`- ${one}`);
|
|
324
|
+
out.push("");
|
|
325
|
+
}
|
|
326
|
+
if (protocol.atTheEnd.length > 0) out.push(`At the end you have ${protocol.atTheEnd.join(" and ")}.`, "");
|
|
327
|
+
out.push("---", "",
|
|
328
|
+
"Everything above that is a number — a volume, a temperature, a time, a length — is what somebody",
|
|
329
|
+
"set or what the lab's own tools worked out. Nothing here was filled in to make the page look finished:",
|
|
330
|
+
"what the plan does not say is listed under each step instead.");
|
|
331
|
+
return out.join("\n");
|
|
332
|
+
}
|