@biolibs/bionet-tools 0.1.10 → 0.1.11
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 +60 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/ordering.d.ts +147 -0
- package/dist/ordering.d.ts.map +1 -0
- package/dist/ordering.js +203 -0
- package/dist/ordering.js.map +1 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +4 -1
- package/dist/tools.js.map +1 -1
- package/dist/work.d.ts +18 -0
- package/dist/work.d.ts.map +1 -0
- package/dist/work.js +145 -0
- package/dist/work.js.map +1 -0
- package/package.json +2 -2
- package/src/index.ts +4 -0
- package/src/ordering.ts +301 -0
- package/src/tools.tsx +4 -1
- package/src/work.tsx +277 -0
- package/tools.css +11 -0
package/dist/work.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Every open proposal, read as one piece of work rather than as a pile of cards.
|
|
5
|
+
*
|
|
6
|
+
* The tools each show the proposals for their own machine, which is right when somebody is standing
|
|
7
|
+
* at that machine. It is no use at all for seeing where a build has got to: eleven proposals spread
|
|
8
|
+
* over four tabs, in the order they happened to be made, with nothing saying which comes first or
|
|
9
|
+
* what is waiting on what. This is the other view — the whole of it, in order, in chains.
|
|
10
|
+
*
|
|
11
|
+
* It asserts nothing. Everything here comes from `planOfWork`, which works the order out from what
|
|
12
|
+
* each proposal makes and what each one needs, so what is drawn cannot drift from what is true.
|
|
13
|
+
*/
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { useAct, useLab } from "@biolibs/bionet-react";
|
|
16
|
+
import { Glossed } from "@biolibs/glossary-react";
|
|
17
|
+
import { FILED_UNDER, UNFILED, planOfWork, saysWork } from "./ordering.js";
|
|
18
|
+
/** What a step is called, by what kind of run it is. */
|
|
19
|
+
const CALLED = {
|
|
20
|
+
pcr: "Copy it", digest: "Cut it", ligation: "Join it", assembly: "Build the ring",
|
|
21
|
+
transformation: "Put it into a host", induction: "Grow it and look for the protein",
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The lab's open proposals as one piece of work: in order, in chains, with what can start now.
|
|
25
|
+
*
|
|
26
|
+
* @param props - `onOpen`, if given, offers a way to go to the tool that would carry a step out,
|
|
27
|
+
* and is handed the proposal.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { WorkToDo } from "@biolibs/bionet-tools";
|
|
32
|
+
*
|
|
33
|
+
* <WorkToDo onOpen={(plan) => goToTool(plan.kind)} />
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function WorkToDo({ onOpen } = {}) {
|
|
37
|
+
const lab = useLab()?.lab;
|
|
38
|
+
const act = useAct();
|
|
39
|
+
// Which project is being looked at, or null for all of them at once.
|
|
40
|
+
const [only, setOnly] = useState(null);
|
|
41
|
+
const [filing, setFiling] = useState(null);
|
|
42
|
+
const [into, setInto] = useState("");
|
|
43
|
+
// Writing the method out, and taking one somebody else wrote.
|
|
44
|
+
const [method, setMethod] = useState(null);
|
|
45
|
+
const [taking, setTaking] = useState("");
|
|
46
|
+
const [told, setTold] = useState(null);
|
|
47
|
+
if (lab === null || lab === undefined)
|
|
48
|
+
return null;
|
|
49
|
+
const whole = planOfWork(lab);
|
|
50
|
+
const shown = only === null ? undefined : whole.projects.find((one) => one.name === only);
|
|
51
|
+
// Looking at one project shows its chains and its steps, and nothing of anybody else's.
|
|
52
|
+
const work = shown === undefined ? whole : (() => {
|
|
53
|
+
const mine = new Set(shown.order.map((one) => one.plan.plan));
|
|
54
|
+
return {
|
|
55
|
+
...whole, threads: shown.threads, order: shown.order, ready: shown.ready,
|
|
56
|
+
held: shown.order.filter((one) => one.held !== null),
|
|
57
|
+
// What to get first is this project's, not the lab's: showing another project's missing part
|
|
58
|
+
// here would have somebody ordering something their own work does not need.
|
|
59
|
+
toGet: whole.toGet.flatMap((one) => {
|
|
60
|
+
const forSteps = one.forSteps.filter((each) => mine.has(each));
|
|
61
|
+
return forSteps.length === 0 ? [] : [{ ...one, forSteps }];
|
|
62
|
+
}),
|
|
63
|
+
tangled: whole.tangled.filter((one) => mine.has(one)),
|
|
64
|
+
};
|
|
65
|
+
})();
|
|
66
|
+
const said = saysWork(whole);
|
|
67
|
+
const projects = whole.projects;
|
|
68
|
+
const filedAs = (plan) => {
|
|
69
|
+
const says = plan.fields[FILED_UNDER];
|
|
70
|
+
return typeof says === "string" && says.trim() !== "" ? says.trim() : UNFILED;
|
|
71
|
+
};
|
|
72
|
+
const writeOut = async () => {
|
|
73
|
+
const answer = await act("publishMethod", { ...(only === null ? {} : { project: only }) });
|
|
74
|
+
setTold(answer.ok ? null : answer.error);
|
|
75
|
+
setMethod(answer.ok ? JSON.stringify(answer.result, null, 2) : null);
|
|
76
|
+
};
|
|
77
|
+
const take = async () => {
|
|
78
|
+
const answer = await act("takeMethod", { method: taking, ...(only === null || only === UNFILED ? {} : { project: only }) });
|
|
79
|
+
if (!answer.ok) {
|
|
80
|
+
setTold(answer.error);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const got = answer.result;
|
|
84
|
+
setTaking("");
|
|
85
|
+
setTold(`${got.proposed.length} ${got.proposed.length === 1 ? "step is" : "steps are"} proposed here.`
|
|
86
|
+
+ (got.missing.length === 0 ? "" : ` ${got.missing.map((one) => one.name).join(" and ")} has to be got first.`)
|
|
87
|
+
+ (got.alive.length === 0 ? "" : ` ${got.alive.map((one) => one.name).join(" and ")} is alive and cannot be sent: make your own.`));
|
|
88
|
+
};
|
|
89
|
+
const file = async (plan, name) => {
|
|
90
|
+
await act("setField", { on: "plan", id: plan, field: FILED_UNDER, value: name.trim() === "" ? null : name.trim() });
|
|
91
|
+
setFiling(null);
|
|
92
|
+
setInto("");
|
|
93
|
+
};
|
|
94
|
+
const person = (key) => lab.roster.find((one) => one.key === key)?.person ?? "a device";
|
|
95
|
+
const partName = (checksum) => lab.parts.find((one) => one.checksum === checksum)?.name ?? "a part";
|
|
96
|
+
const tubeName = (item) => {
|
|
97
|
+
const held = lab.items.find((one) => one.item === item);
|
|
98
|
+
if (held === undefined)
|
|
99
|
+
return "a tube";
|
|
100
|
+
return held.part === null ? lab.strains.find((one) => one.strain === held.strain)?.name ?? "a culture" : partName(held.part);
|
|
101
|
+
};
|
|
102
|
+
const stepName = (plan) => CALLED[plan.kind] ?? plan.kind;
|
|
103
|
+
/**
|
|
104
|
+
* Where a step sits in its own piece of work.
|
|
105
|
+
*
|
|
106
|
+
* Counted inside the chain and not across the whole lot, which is safe because a chain is every
|
|
107
|
+
* step joined to every other by what they make and need: a step can only ever wait on one in the
|
|
108
|
+
* same chain. Numbering across all of them would make the numbers in one card jump wherever
|
|
109
|
+
* another chain's steps fell between, for no gain.
|
|
110
|
+
*/
|
|
111
|
+
const at = (id) => {
|
|
112
|
+
const thread = work.threads.find((one) => one.steps.some((step) => step.plan.plan === id));
|
|
113
|
+
return (thread?.steps.findIndex((step) => step.plan.plan === id) ?? 0) + 1;
|
|
114
|
+
};
|
|
115
|
+
const why = (step) => {
|
|
116
|
+
if (step.held === null)
|
|
117
|
+
return _jsx("span", { className: "good", children: "could be done now" });
|
|
118
|
+
if (step.held.why === "a step before it") {
|
|
119
|
+
return _jsxs(_Fragment, { children: ["waiting on ", step.held.steps.map((one) => `step ${at(one)}`).join(" and ")] });
|
|
120
|
+
}
|
|
121
|
+
if (step.held.why === "something nobody is making") {
|
|
122
|
+
return _jsxs("span", { className: "attention", children: [step.held.parts.map((one) => partName(one)).join(" and "), " has to be ordered or made first"] });
|
|
123
|
+
}
|
|
124
|
+
return _jsxs("span", { className: "attention", children: [step.held.tubes.map(tubeName).join(" and "), " has been retired or run short"] });
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Giving the work to somebody else, and taking somebody's.
|
|
128
|
+
*
|
|
129
|
+
* Shown whether or not this lab has any work of its own, because a lab taking a method for the
|
|
130
|
+
* first time has none — which is exactly the lab that needs this, and the one that would have
|
|
131
|
+
* found nothing here if it were only drawn beside work that already existed.
|
|
132
|
+
*/
|
|
133
|
+
const crossing = (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Giving it to somebody else" }), _jsx("p", { className: "small", children: _jsx(Glossed, { text: "A method is this plan written so another lab can carry it out: every tube replaced by the checksum of what is in it, which is the one name two labs that have never spoken already agree on." }) }), _jsx("p", { className: "dim small", children: "Two things cannot be sent, and it says so rather than pretending. Anything alive: a strain is this lab\u2019s own, so whoever follows it makes their own. And a starting molecule\u2019s sequence, if a keeper chose not to publish it \u2014 then it says which molecules are needed and not what they are." }), work.order.length > 0 && (_jsxs("div", { className: "row tight", children: [_jsxs("button", { type: "button", onClick: () => void writeOut(), children: ["Write ", only === null ? "it all" : only, " out"] }), method !== null && _jsx("button", { type: "button", className: "quiet", onClick: () => setMethod(null), children: "Hide it" })] })), method !== null && _jsx("textarea", { className: "method", value: method, readOnly: true, rows: 12, "aria-label": "The method, to give to somebody", onFocus: (event) => event.currentTarget.select() }), _jsx("p", { className: "voice", children: "Taking one" }), _jsxs("form", { className: "stack", onSubmit: (event) => { event.preventDefault(); void take(); }, children: [_jsxs("label", { children: ["A method somebody published", _jsx("textarea", { value: taking, onChange: (event) => setTaking(event.target.value), rows: 4, spellCheck: false, placeholder: "Paste it here", "aria-label": "A method to take" })] }), _jsx("div", { className: "row", children: _jsx("button", { type: "submit", disabled: taking.trim() === "", children: "Propose its steps here" }) })] }), _jsx("p", { className: "dim small", children: "Nothing is used and nothing is recorded as done: what lands is proposals, as if somebody here had made them. A molecule it needs that this lab has never heard of is said rather than guessed at." }), told !== null && _jsx("p", { className: "small", role: "status", children: told })] }));
|
|
134
|
+
if (work.order.length === 0 && work.tangled.length === 0) {
|
|
135
|
+
return (_jsxs("div", { className: "bionet work", children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "The work" }), _jsx("p", { className: "empty", children: "Nothing is proposed here. A proposal is a run somebody could carry out, and a lab member or its adviser makes one at the tool that would do it. Several together are read as one piece of work." })] }), crossing] }));
|
|
136
|
+
}
|
|
137
|
+
return (_jsxs("div", { className: "bionet work", children: [_jsxs("section", { className: "card", children: [_jsx("h2", { children: "The work" }), _jsx("p", { className: "small", children: _jsx(Glossed, { text: "Each step is a proposed run: nothing has been used and nothing is recorded as done until somebody carries it out and says so." }) }), said.map((one) => _jsx("p", { className: "small", children: one }, one)), projects.length > 1 && (_jsxs("div", { className: "row tight pick", role: "tablist", "aria-label": "Projects", children: [_jsx("button", { type: "button", role: "tab", "aria-selected": only === null, className: only === null ? "" : "quiet", onClick: () => setOnly(null), children: "Everything" }), projects.map((one) => (_jsxs("button", { type: "button", role: "tab", "aria-selected": only === one.name, className: only === one.name ? "" : "quiet", onClick: () => setOnly(one.name), children: [one.name, one.ready.length > 0 ? ` · ${one.ready.length} ready` : ""] }, one.name)))] })), _jsx("p", { className: "dim small", children: "Nothing here was declared. A proposal says what it expects to make and what it needs, and where one expects what another needs, the first has to happen first. The chain stops at a transformation: what that makes is alive and has no checksum to point at, so what follows is proposed afresh once there is something growing." })] }), crossing, work.toGet.length > 0 && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "To get first" }), _jsxs("p", { className: "small", children: ["Nothing proposed makes ", work.toGet.length === 1 ? "this" : "these", ", and the lab has no tube of ", work.toGet.length === 1 ? "it" : "them", ". Until ", work.toGet.length === 1 ? "it arrives" : "they arrive", " the steps that need ", work.toGet.length === 1 ? "it" : "them", " cannot start."] }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "What" }), _jsx("th", { children: "For" })] }) }), _jsx("tbody", { children: work.toGet.map((one) => (_jsxs("tr", { children: [_jsxs("td", { children: [partName(one.checksum) === "a part" ? one.name : partName(one.checksum), " ", _jsx("code", { children: one.checksum.slice(0, 12) })] }), _jsx("td", { className: "dim", children: [...new Set(one.forSteps.map((each) => {
|
|
138
|
+
const thread = work.threads.find((who) => who.steps.some((step) => step.plan.plan === each));
|
|
139
|
+
return `step ${at(each)} of ${thread?.name ?? "the work"}`;
|
|
140
|
+
}))].join(", ") })] }, one.checksum))) })] })] })), work.threads.map((thread) => (_jsxs("section", { className: "card", children: [_jsxs("div", { className: "toolhead", children: [_jsx("h2", { children: thread.name }), _jsxs("span", { className: "dim small", children: [[...new Set(thread.steps.map((one) => filedAs(one.plan)))].join(", "), " \u00B7 ", thread.steps.length, " ", thread.steps.length === 1 ? "step" : "steps"] })] }), !thread.clear && _jsx("p", { className: "small attention", children: "Something in this one has to be dealt with before it can be finished." }), _jsx("ol", { className: "steps", children: thread.steps.map((step) => (_jsxs("li", { className: step.held === null ? "ready" : "held", children: [_jsxs("p", { className: "small", children: [_jsxs("strong", { children: [at(step.plan.plan), ". ", stepName(step.plan)] }), _jsxs("span", { className: "dim", children: [" \u00B7 ", step.plan.kind] }), " — ", why(step)] }), _jsxs("p", { className: "dim small", children: ["Uses ", step.plan.inputs.map((one) => `${one.item === undefined ? partName(one.part) : tubeName(one.item)} as ${one.role}`).join(", ") || "nothing the lab holds", step.plan.expects.length > 0 && _jsxs(_Fragment, { children: [", making ", step.plan.expects.map((one) => `${one.name} (${one.length.toLocaleString("en-US")} bp${one.circular ? ", circular" : ""})`).join(" and ")] }), step.plan.expects.length === 0 && _jsx(_Fragment, { children: ", making nothing the lab can name: what comes of it is alive" }), ". Proposed by ", person(step.plan.by), "."] }), step.plan.note !== null && _jsx("p", { className: "small why", children: step.plan.note }), _jsxs("div", { className: "row tight", children: [onOpen !== undefined && step.held === null && _jsx("button", { type: "button", onClick: () => onOpen(step.plan), children: "Set it up" }), _jsx("button", { type: "button", className: "quiet", onClick: () => { setFiling(filing === step.plan.plan ? null : step.plan.plan); setInto(filedAs(step.plan) === UNFILED ? "" : filedAs(step.plan)); }, children: filedAs(step.plan) === UNFILED ? "File it under…" : "Move it…" }), _jsx("button", { type: "button", className: "quiet", onClick: () => void act("settlePlan", { plan: step.plan.plan }), children: "Set it aside" })] }), filing === step.plan.plan && (_jsxs("form", { className: "row tight", onSubmit: (event) => { event.preventDefault(); void file(step.plan.plan, into); }, children: [_jsx("input", { value: into, onChange: (event) => setInto(event.target.value), maxLength: 200, list: "bionet-projects", placeholder: "Which project", "aria-label": "Which project to file it under" }), _jsx("datalist", { id: "bionet-projects", children: projects.filter((one) => one.filed).map((one) => _jsx("option", { value: one.name }, one.name)) }), _jsx("button", { type: "submit", children: into.trim() === "" ? "Take it out" : "File it" })] }))] }, step.plan.plan))) }), thread.ends.length > 0 && (_jsxs("p", { className: "dim small", children: ["It ends with ", thread.ends.map((one) => partName(one.checksum) === "a part" ? one.name : partName(one.checksum)).join(" and "), "."] }))] }, thread.name + thread.steps[0].plan.plan))), work.tangled.length > 0 && (_jsxs("section", { className: "card", children: [_jsx("h2", { children: "Cannot be ordered" }), _jsxs("p", { className: "small trouble", children: [work.tangled.length, " ", work.tangled.length === 1 ? "proposal depends" : "proposals depend", " on each other in a circle, so there is no order to carry them out in. Set one aside and propose it again."] }), _jsx("ul", { className: "checks", children: work.tangled.map((one) => {
|
|
141
|
+
const plan = lab.plans.find((each) => each.plan === one);
|
|
142
|
+
return _jsxs("li", { className: "stop", children: [stepName(plan), " \u00B7 ", plan.kind, " \u00B7 proposed by ", person(plan.by)] }, one);
|
|
143
|
+
}) })] }))] }));
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=work.js.map
|
package/dist/work.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"work.js","sourceRoot":"","sources":["../src/work.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb;;;;;;;;;;GAUG;AACH,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM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
11
11
|
"@biolibs/cloning": "^1.0.1",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
],
|
|
66
66
|
"type": "module",
|
|
67
67
|
"types": "dist/index.d.ts",
|
|
68
|
-
"version": "0.1.
|
|
68
|
+
"version": "0.1.11"
|
|
69
69
|
}
|
package/src/index.ts
CHANGED
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
* - `primer-working.ts` — the working behind a design: the melting temperature's sum, the GC count, the bases that pair
|
|
39
39
|
* - `primer-bench.tsx` — designing primers at a desk: the panel, and the template with the pair marked on it for a scene
|
|
40
40
|
* - `plans.tsx` — runs that have been proposed, at the tool that would carry them out
|
|
41
|
+
* - `ordering.ts` — those proposals read as one piece of work: what order, what can start, what is waiting
|
|
42
|
+
* - `work.tsx` — that work drawn: the chains, in order, with what has to be got first
|
|
41
43
|
* - `tools.tsx` — getting to one: from an instrument, or from a list of them all
|
|
42
44
|
*
|
|
43
45
|
* The tools are drawn with the styles of `@biolibs/bionet-panels` and belong inside its `LabWindow`.
|
|
@@ -71,6 +73,8 @@ export * from "./working.js";
|
|
|
71
73
|
export * from "./map.js";
|
|
72
74
|
export * from "./sequences-tool.js";
|
|
73
75
|
export * from "./plans.js";
|
|
76
|
+
export * from "./ordering.js";
|
|
77
|
+
export * from "./work.js";
|
|
74
78
|
export * from "./tools.js";
|
|
75
79
|
export * from "./pcr-bench.js";
|
|
76
80
|
export * from "./primer-design.js";
|
package/src/ordering.ts
ADDED
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The order a lab's open proposals have to be carried out in, worked out from what each one makes
|
|
3
|
+
* and what each one needs.
|
|
4
|
+
*
|
|
5
|
+
* A proposal is one run. Nothing in the log says that eleven of them are one piece of work, or which
|
|
6
|
+
* comes first, and until now nothing read them as anything but eleven unrelated cards. But the order
|
|
7
|
+
* is not missing from the data — it is simply never followed. A plan says what it `expects` to make,
|
|
8
|
+
* each thing with the checksum that would be its identity; another plan says what it needs, and may
|
|
9
|
+
* name a part there is no tube of yet by that same checksum. Where one plan expects what another
|
|
10
|
+
* needs, the first has to happen first. That is a fact about the molecules, not a declaration
|
|
11
|
+
* somebody made, and it is true whether or not anybody wrote it down.
|
|
12
|
+
*
|
|
13
|
+
* So this derives the order rather than adding a way to assert one. No new kind of entry, nothing an
|
|
14
|
+
* older device has to understand, and no way for the stated order and the real one to disagree.
|
|
15
|
+
*
|
|
16
|
+
* **Where the chain stops, and why.** It stops at a transformation. What a transformation makes is
|
|
17
|
+
* alive, so it has no checksum to point at: a strain is this lab's own, known by an ID, and the
|
|
18
|
+
* culture that would be an induction's input does not exist until somebody has grown it. A plan
|
|
19
|
+
* cannot name a tube that is not there. So the work up to and including putting a construct into a
|
|
20
|
+
* host can be proposed as one chain, and what follows it has to be proposed afresh once there is
|
|
21
|
+
* something growing. That is a real limit and it is said here rather than hidden: a plan that
|
|
22
|
+
* claimed to run past it would be claiming to name something nothing can name yet.
|
|
23
|
+
*/
|
|
24
|
+
import type { ItemState, PlanState } from "@biolibs/bionet";
|
|
25
|
+
|
|
26
|
+
/** As much of a lab as the ordering reads. */
|
|
27
|
+
export interface OrderingLab {
|
|
28
|
+
plans: readonly PlanState[];
|
|
29
|
+
items: readonly ItemState[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Why a step cannot be carried out yet, or `null` if it can. */
|
|
33
|
+
export type Holding =
|
|
34
|
+
| { why: "a step before it"; steps: string[] }
|
|
35
|
+
| { why: "something nobody is making"; parts: string[] }
|
|
36
|
+
| { why: "a tube that has run short"; tubes: string[] };
|
|
37
|
+
|
|
38
|
+
/** One step: a proposal, where it sits in the order, and what stands in its way. */
|
|
39
|
+
export interface Step {
|
|
40
|
+
/** The proposal itself. */
|
|
41
|
+
plan: PlanState;
|
|
42
|
+
/** The plans that have to be carried out before it, by ID. */
|
|
43
|
+
after: string[];
|
|
44
|
+
/** How deep it is: 0 for a step with nothing before it. */
|
|
45
|
+
depth: number;
|
|
46
|
+
/** What stands in its way, or `null` if it could be done now. */
|
|
47
|
+
held: Holding | null;
|
|
48
|
+
/** The checksums it would make. */
|
|
49
|
+
makes: string[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The field a plan is filed under, unless a lab uses another word for it. */
|
|
53
|
+
export const FILED_UNDER = "project";
|
|
54
|
+
|
|
55
|
+
/** What a piece of work with no project is called. */
|
|
56
|
+
export const UNFILED = "Not filed";
|
|
57
|
+
|
|
58
|
+
/** One chain of steps that leads to one thing. */
|
|
59
|
+
export interface Thread {
|
|
60
|
+
/** What to call it: what it ends by making. */
|
|
61
|
+
name: string;
|
|
62
|
+
/** Its steps, in an order that can be carried out. */
|
|
63
|
+
steps: Step[];
|
|
64
|
+
/** What it ends with: what it makes that nothing else in it consumes. */
|
|
65
|
+
ends: { checksum: string; name: string }[];
|
|
66
|
+
/** Whether every step of it could be carried out as things stand. */
|
|
67
|
+
clear: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Everything on in one project. */
|
|
71
|
+
export interface Project {
|
|
72
|
+
/** What it is called, as somebody filed it. */
|
|
73
|
+
name: string;
|
|
74
|
+
/** Whether anybody actually filed it, or it is the heap of what nobody did. */
|
|
75
|
+
filed: boolean;
|
|
76
|
+
/** Its chains. */
|
|
77
|
+
threads: Thread[];
|
|
78
|
+
/** Its steps, in one order that works. */
|
|
79
|
+
order: Step[];
|
|
80
|
+
/** The ones that could be carried out now. */
|
|
81
|
+
ready: Step[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The open proposals, read as work to be done. */
|
|
85
|
+
export interface PlanOfWork {
|
|
86
|
+
/**
|
|
87
|
+
* What is on, by project.
|
|
88
|
+
*
|
|
89
|
+
* A chain is not a project and cannot be: four caseins are four chains in one project, and two
|
|
90
|
+
* unrelated projects are also chains. Which work belongs together is a thing people decide, so it
|
|
91
|
+
* is filed rather than derived, and a plan nobody filed is in `Not filed` rather than silently
|
|
92
|
+
* lumped in with somebody else's.
|
|
93
|
+
*/
|
|
94
|
+
projects: Project[];
|
|
95
|
+
/** The chains, each leading to one thing. A lab building four proteins has four. */
|
|
96
|
+
threads: Thread[];
|
|
97
|
+
/** Every open step, in one order that works. */
|
|
98
|
+
order: Step[];
|
|
99
|
+
/** The steps that could be carried out now. */
|
|
100
|
+
ready: Step[];
|
|
101
|
+
/** The steps that could not, and what each is waiting on. */
|
|
102
|
+
held: Step[];
|
|
103
|
+
/**
|
|
104
|
+
* Plans that need something nothing makes and no tube holds: what has to be ordered or
|
|
105
|
+
* synthesised before any of this can start, by checksum.
|
|
106
|
+
*/
|
|
107
|
+
toGet: { checksum: string; name: string; forSteps: string[] }[];
|
|
108
|
+
/** Plans that somehow depend on each other in a circle, by ID. Empty, unless something is wrong. */
|
|
109
|
+
tangled: string[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Whether the lab holds a tube of a part that has anything in it. */
|
|
113
|
+
const holds = (lab: OrderingLab, checksum: string): boolean =>
|
|
114
|
+
lab.items.some((one) => one.part === checksum && !one.retired && one.amount > 0);
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The open proposals, read as work: what order they go in, what can start now, what is waiting.
|
|
118
|
+
*
|
|
119
|
+
* @param lab - The lab, with its plans and its tubes.
|
|
120
|
+
* @returns The work, in threads and in one order.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { planOfWork } from "@biolibs/bionet-tools";
|
|
125
|
+
*
|
|
126
|
+
* const work = planOfWork(lab);
|
|
127
|
+
* work.ready.map((one) => one.plan.kind); // what somebody could go and do now
|
|
128
|
+
* work.toGet; // what has to be ordered before any of it
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
export function planOfWork(lab: OrderingLab): PlanOfWork {
|
|
132
|
+
const open = lab.plans.filter((one) => one.settled === null);
|
|
133
|
+
const byId = new Map(open.map((one) => [one.plan, one]));
|
|
134
|
+
|
|
135
|
+
// What each open plan would make, and who would make each thing.
|
|
136
|
+
const makers = new Map<string, string[]>();
|
|
137
|
+
for (const plan of open) {
|
|
138
|
+
for (const expected of plan.expects) makers.set(expected.checksum, [...(makers.get(expected.checksum) ?? []), plan.plan]);
|
|
139
|
+
}
|
|
140
|
+
const nameOf = (checksum: string): string =>
|
|
141
|
+
open.flatMap((one) => one.expects).find((one) => one.checksum === checksum)?.name ?? checksum.slice(0, 12);
|
|
142
|
+
|
|
143
|
+
/** What each plan waits on, and what it needs that nothing is making. */
|
|
144
|
+
const after = new Map<string, string[]>();
|
|
145
|
+
const missing = new Map<string, string[]>();
|
|
146
|
+
for (const plan of open) {
|
|
147
|
+
const waits: string[] = [];
|
|
148
|
+
const nowhere: string[] = [];
|
|
149
|
+
for (const input of plan.inputs) {
|
|
150
|
+
if (input.part === undefined) continue;
|
|
151
|
+
// A plan names a part rather than a tube when there was no tube of it when it was proposed.
|
|
152
|
+
// There may be one now, and that is a fact about the lab, not about the plan.
|
|
153
|
+
if (holds(lab, input.part)) continue;
|
|
154
|
+
const made = (makers.get(input.part) ?? []).filter((one) => one !== plan.plan);
|
|
155
|
+
if (made.length > 0) waits.push(...made);
|
|
156
|
+
else nowhere.push(input.part);
|
|
157
|
+
}
|
|
158
|
+
after.set(plan.plan, [...new Set(waits)]);
|
|
159
|
+
missing.set(plan.plan, [...new Set(nowhere)]);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// The order: a step comes after everything it waits on. Kahn's algorithm, which also finds a
|
|
163
|
+
// circle if the proposals somehow make one.
|
|
164
|
+
const left = new Set(open.map((one) => one.plan));
|
|
165
|
+
const depth = new Map<string, number>();
|
|
166
|
+
const order: string[] = [];
|
|
167
|
+
for (let guard = 0; left.size > 0 && guard <= open.length; guard += 1) {
|
|
168
|
+
const free = [...left].filter((id) => (after.get(id) ?? []).every((before) => !left.has(before)));
|
|
169
|
+
if (free.length === 0) break;
|
|
170
|
+
// In the order they were proposed, so that two steps that could both go now keep their order.
|
|
171
|
+
free.sort((a, b) => open.findIndex((one) => one.plan === a) - open.findIndex((one) => one.plan === b));
|
|
172
|
+
for (const id of free) {
|
|
173
|
+
depth.set(id, Math.max(0, ...(after.get(id) ?? []).map((before) => (depth.get(before) ?? 0) + 1)));
|
|
174
|
+
order.push(id);
|
|
175
|
+
left.delete(id);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const tangled = [...left];
|
|
179
|
+
|
|
180
|
+
const stepOf = (id: string): Step => {
|
|
181
|
+
const plan = byId.get(id)!;
|
|
182
|
+
const waits = (after.get(id) ?? []).filter((one) => byId.has(one));
|
|
183
|
+
const nowhere = missing.get(id) ?? [];
|
|
184
|
+
const held: Holding | null =
|
|
185
|
+
waits.length > 0 ? { why: "a step before it", steps: waits }
|
|
186
|
+
: nowhere.length > 0 ? { why: "something nobody is making", parts: nowhere }
|
|
187
|
+
: plan.wanting.length > 0 ? { why: "a tube that has run short", tubes: [...plan.wanting] }
|
|
188
|
+
: null;
|
|
189
|
+
return { plan, after: waits, depth: depth.get(id) ?? 0, held, makes: plan.expects.map((one) => one.checksum) };
|
|
190
|
+
};
|
|
191
|
+
const steps = order.map(stepOf);
|
|
192
|
+
const tangledSteps = tangled.map(stepOf);
|
|
193
|
+
|
|
194
|
+
// A thread is a set of steps joined by what they make and need: a lab building four proteins has
|
|
195
|
+
// four of them, and they are four separate pieces of work however they were proposed.
|
|
196
|
+
const where = new Map<string, number>();
|
|
197
|
+
const threads: Step[][] = [];
|
|
198
|
+
const join = (id: string, into: number): void => {
|
|
199
|
+
const was = where.get(id);
|
|
200
|
+
if (was === into) return;
|
|
201
|
+
if (was === undefined) { where.set(id, into); return; }
|
|
202
|
+
// Two threads met, so they were one thread: everything in the older joins the newer.
|
|
203
|
+
for (const [each, at] of where) if (at === was) where.set(each, into);
|
|
204
|
+
};
|
|
205
|
+
for (const step of steps) {
|
|
206
|
+
const joined = [step.plan.plan, ...step.after].map((id) => where.get(id)).find((at) => at !== undefined);
|
|
207
|
+
const at = joined ?? threads.push([]) - 1;
|
|
208
|
+
join(step.plan.plan, at);
|
|
209
|
+
for (const before of step.after) join(before, at);
|
|
210
|
+
}
|
|
211
|
+
for (const step of steps) threads[where.get(step.plan.plan)!]!.push(step);
|
|
212
|
+
|
|
213
|
+
const made = new Set(steps.flatMap((one) => one.makes));
|
|
214
|
+
const woven: Thread[] = threads.filter((one) => one.length > 0).map((one) => {
|
|
215
|
+
const inside = new Set(one.flatMap((step) => step.makes));
|
|
216
|
+
const needed = new Set(one.flatMap((step) => step.plan.inputs.flatMap((input) => (input.part === undefined ? [] : [input.part]))));
|
|
217
|
+
// What it ends with is what it makes that nothing in it then uses.
|
|
218
|
+
let ends = [...inside].filter((checksum) => !needed.has(checksum)).map((checksum) => ({ checksum, name: nameOf(checksum) }));
|
|
219
|
+
// Unless there is no such thing, which happens whenever a chain finishes with a transformation:
|
|
220
|
+
// every molecule it made went into the host, and what came out is alive and has no checksum to
|
|
221
|
+
// be named by. The last thing that can be named is then what the chain is known by.
|
|
222
|
+
if (ends.length === 0) {
|
|
223
|
+
const last = [...one].reverse().find((step) => step.makes.length > 0);
|
|
224
|
+
ends = (last?.makes ?? []).map((checksum) => ({ checksum, name: nameOf(checksum) }));
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
// A chain is known by what it is for, which is the last thing it makes.
|
|
228
|
+
name: ends.map((each) => each.name).join(" and ") || `${one.length} ${one.length === 1 ? "step" : "steps"}`,
|
|
229
|
+
steps: one, ends, clear: one.every((step) => step.held === null || step.held.why === "a step before it"),
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
const toGet = new Map<string, string[]>();
|
|
234
|
+
for (const step of [...steps, ...tangledSteps]) {
|
|
235
|
+
for (const checksum of missing.get(step.plan.plan) ?? []) toGet.set(checksum, [...(toGet.get(checksum) ?? []), step.plan.plan]);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Filed, not derived: which chains belong to one project is somebody's decision.
|
|
239
|
+
const filedAs = (step: Step): string => {
|
|
240
|
+
const said = step.plan.fields[FILED_UNDER];
|
|
241
|
+
return typeof said === "string" && said.trim() !== "" ? said.trim() : UNFILED;
|
|
242
|
+
};
|
|
243
|
+
const byProject = new Map<string, Step[]>();
|
|
244
|
+
for (const step of steps) byProject.set(filedAs(step), [...(byProject.get(filedAs(step)) ?? []), step]);
|
|
245
|
+
const projects: Project[] = [...byProject].map(([name, own]) => ({
|
|
246
|
+
name, filed: name !== UNFILED,
|
|
247
|
+
// A chain belongs to a project if any of its steps was filed under it. A chain whose steps were
|
|
248
|
+
// filed differently is shown under each, since the steps really are in both and saying
|
|
249
|
+
// otherwise would hide work from one of them.
|
|
250
|
+
threads: woven.filter((thread) => thread.steps.some((step) => filedAs(step) === name)),
|
|
251
|
+
order: own, ready: own.filter((step) => step.held === null),
|
|
252
|
+
// What nobody filed goes last: it is a heap, not a project.
|
|
253
|
+
})).sort((a, b) => Number(a.name === UNFILED) - Number(b.name === UNFILED) || a.name.localeCompare(b.name));
|
|
254
|
+
|
|
255
|
+
return {
|
|
256
|
+
projects, threads: woven, order: steps,
|
|
257
|
+
ready: steps.filter((one) => one.held === null),
|
|
258
|
+
held: steps.filter((one) => one.held !== null),
|
|
259
|
+
toGet: [...toGet].map(([checksum, forSteps]) => ({ checksum, name: made.has(checksum) ? nameOf(checksum) : checksum.slice(0, 12), forSteps })),
|
|
260
|
+
tangled,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The work said in a sentence or two, for somebody who wants to know where things stand.
|
|
266
|
+
*
|
|
267
|
+
* @param work - What `planOfWork` gave.
|
|
268
|
+
* @returns A line for each thing worth saying. Empty if nothing is proposed.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```ts
|
|
272
|
+
* import { planOfWork, saysWork } from "@biolibs/bionet-tools";
|
|
273
|
+
*
|
|
274
|
+
* saysWork(planOfWork(lab));
|
|
275
|
+
* // ["Eleven steps are proposed, in four pieces of work.", "Three could be done now.", …]
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
export function saysWork(work: PlanOfWork): string[] {
|
|
279
|
+
if (work.order.length === 0 && work.tangled.length === 0) return [];
|
|
280
|
+
const count = (many: number, one: string, more: string): string => `${many} ${many === 1 ? one : more}`;
|
|
281
|
+
const filed = work.projects.filter((one) => one.filed);
|
|
282
|
+
const said: string[] = [
|
|
283
|
+
`${count(work.order.length, "step is", "steps are")} proposed, in ${count(work.threads.length, "piece", "pieces")} of work`
|
|
284
|
+
+ (filed.length === 0 ? "." : `, across ${count(filed.length, "project", "projects")}: ${filed.map((one) => one.name).join(", ")}.`),
|
|
285
|
+
];
|
|
286
|
+
const loose = work.projects.find((one) => !one.filed);
|
|
287
|
+
if (loose !== undefined && filed.length > 0) {
|
|
288
|
+
said.push(`${count(loose.order.length, "step is", "steps are")} filed under no project.`);
|
|
289
|
+
}
|
|
290
|
+
if (work.ready.length > 0) said.push(`${count(work.ready.length, "step", "steps")} could be carried out now.`);
|
|
291
|
+
else if (work.order.length > 0) said.push("Nothing can be carried out yet.");
|
|
292
|
+
const waiting = work.held.filter((one) => one.held?.why === "a step before it").length;
|
|
293
|
+
if (waiting > 0) said.push(`${count(waiting, "step is", "steps are")} waiting on a step before it.`);
|
|
294
|
+
if (work.toGet.length > 0) {
|
|
295
|
+
said.push(`${count(work.toGet.length, "part has", "parts have")} to be ordered or made first: nothing proposed makes ${work.toGet.length === 1 ? "it" : "them"}, and there is no tube.`);
|
|
296
|
+
}
|
|
297
|
+
const short = work.held.filter((one) => one.held?.why === "a tube that has run short").length;
|
|
298
|
+
if (short > 0) said.push(`${count(short, "step counts", "steps count")} on a tube that has been retired or run short.`);
|
|
299
|
+
if (work.tangled.length > 0) said.push(`${count(work.tangled.length, "step", "steps")} depend on each other in a circle and cannot be ordered.`);
|
|
300
|
+
return said;
|
|
301
|
+
}
|
package/src/tools.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
/** Getting to a tool: from the instrument it is used at, or from a list of them all. */
|
|
4
|
-
import { useState, type ReactNode } from "react";
|
|
4
|
+
import { useEffect, useState, type ReactNode } from "react";
|
|
5
5
|
import { useLab } from "@biolibs/bionet-react";
|
|
6
6
|
import { DigestTool } from "./digest-tool.js";
|
|
7
7
|
import { InductionTool } from "./induce-bench.js";
|
|
@@ -65,6 +65,9 @@ export function InstrumentTool({ place, onDone }: { place: string; onDone?: () =
|
|
|
65
65
|
export function Tools({ tool: first = "pcr", views = {} }: { tool?: ToolName | DeskTool; views?: Partial<Record<ToolName | DeskTool, ReactNode | ((go: (tool: ToolName | DeskTool) => void) => ReactNode)>> }) {
|
|
66
66
|
const lab = useLab()?.lab;
|
|
67
67
|
const [tool, setTool] = useState<ToolName | DeskTool>(first);
|
|
68
|
+
// Followed rather than read once, so that something elsewhere in the window — a list of the work
|
|
69
|
+
// to be done, say — can send somebody to the tool that would carry a step out.
|
|
70
|
+
useEffect(() => { setTool(first); }, [first]);
|
|
68
71
|
if (lab === null || lab === undefined) return null;
|
|
69
72
|
const shown = views[tool];
|
|
70
73
|
const names: [ToolName | DeskTool, string][] = [["sequences", "Sequences"], ["primers", "Primers"], ["codons", "Codons"], ["assembly", "Assembly"], ["verify", "Check"], ...(Object.keys(TOOL_NAMES) as ToolName[]).map((one): [ToolName, string] => [one, TOOL_NAMES[one]])];
|