dsh-molbio-tools 0.27.0 → 0.28.0
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/CHANGELOG.md +212 -0
- package/README.md +39 -14
- package/benchmark/README.md +7 -7
- package/benchmark/_probe-v28.mjs +60 -0
- package/benchmark/harness.mjs +24 -5
- package/benchmark/profile.mjs +14 -5
- package/benchmark/tasks/10-v28.json +300 -0
- package/benchmark/verifications.mjs +49 -0
- package/build/browser-api.mjs +1 -1
- package/build/client-entry.mjs +153 -38
- package/build/panel-core.mjs +132 -11
- package/cordis.patch.yml +5 -3
- package/docs/capability-gap-survey.md +1 -1
- package/docs/client-panel.md +13 -13
- package/docs/history.md +48 -0
- package/docs/maintainer.md +9 -6
- package/docs/roadmap.md +27 -5
- package/docs/v28-plan.md +227 -0
- package/docs/workflow.md +6 -6
- package/index.mjs +636 -2
- package/lib/client.js +292 -52
- package/logo.mjs +5 -1
- package/package.json +7 -3
- package/preset/molbio-lab/agent.cordis.yml +13 -7
- package/preset/molbio-lab/preset.yml +1 -1
- package/protein-annotate.mjs +525 -0
- package/sequence-ops.mjs +203 -0
- package/sequencing.mjs +517 -0
- package/test/client-mount.mjs +6 -17
- package/test/client.mjs +106 -3
- package/test/contract.mjs +48 -23
- package/test/panel-render.mjs +114 -57
- package/test/smoke.mjs +191 -2
- package/test/svgpng.mjs +2 -0
package/build/client-entry.mjs
CHANGED
|
@@ -22,8 +22,11 @@
|
|
|
22
22
|
* The body receives the slot framework's `sessionId`/`actions` injection plus
|
|
23
23
|
* the `useSessions` selector hook the runtime synthesises from the root hook
|
|
24
24
|
* sources (every root hook becomes a `use<Name>` prop for session-scope slots),
|
|
25
|
-
* so the workspace root
|
|
26
|
-
*
|
|
25
|
+
* so the workspace root comes from `useSessions` through
|
|
26
|
+
* `selectSessionDirectory` (panel-core.mjs): the session's `workingDirectory`
|
|
27
|
+
* projection first, the summary's projection values next, `cwd` last — the
|
|
28
|
+
* order DSH 0.2.3's own tab bodies use. This package's own `inject` factory only
|
|
29
|
+
* has to hand over the Remote face.
|
|
27
30
|
*
|
|
28
31
|
* No JSX and no CSS files on purpose: the bundler lowers plain ESM only, and
|
|
29
32
|
* inline styles keep the artifact a single self-contained file — styles injected
|
|
@@ -56,6 +59,8 @@ import {
|
|
|
56
59
|
parseStructureFile,
|
|
57
60
|
plasmidSvg,
|
|
58
61
|
readWorkspaceText,
|
|
62
|
+
selectSessionDirectory,
|
|
63
|
+
sequenceText,
|
|
59
64
|
sortEntries,
|
|
60
65
|
structureImage,
|
|
61
66
|
DEFAULT_STRUCTURE_VIEW,
|
|
@@ -71,17 +76,19 @@ const PANEL_KIND = 'molbio-panel';
|
|
|
71
76
|
const PAPERS_ID = 'dsh-molbio-tools/papers';
|
|
72
77
|
const PAPERS_KIND = 'molbio-papers';
|
|
73
78
|
|
|
74
|
-
/**
|
|
79
|
+
/**
|
|
80
|
+
* Read one file's raw bytes through the workspace Remote.
|
|
81
|
+
*
|
|
82
|
+
* The FIRST argument is the SessionId `lookup` (`workspaceFileScopeId`), not a
|
|
83
|
+
* scope object: the host declares it with a strict string codec and resolves it
|
|
84
|
+
* to the Session's workspace root on its own — exactly how
|
|
85
|
+
* `ui-sidebar-documentpreview` calls `readBytes(file.sessionId, …)`. Passing
|
|
86
|
+
* `{ sessionId }` here (the shape this panel used until 0.27.1) is rejected by
|
|
87
|
+
* the gateway's argument codec, so EVERY listing and read failed and the panel
|
|
88
|
+
* showed an empty workspace no matter which extensions the files had.
|
|
89
|
+
*/
|
|
75
90
|
async function readBytes(remote, sessionId, path, signal) {
|
|
76
|
-
const
|
|
77
|
-
// Feature-detect the METHOD, normalise the VALUE (see decodeWorkspaceBytes).
|
|
78
|
-
// DSH 0.1.7-alpha.1 dropped `readAll` and answers `readBytes` with a
|
|
79
|
-
// Uint8Array, so this fallback is the live path on every current install —
|
|
80
|
-
// and the bug it hides (feeding the raw bytes to a base64 decoder) is exactly
|
|
81
|
-
// why test/panel-render.mjs now drives a Remote that has no `readAll` at all.
|
|
82
|
-
const result = typeof remote.workspaceFiles.readAll === 'function'
|
|
83
|
-
? await remote.workspaceFiles.readAll(scope, path, signal)
|
|
84
|
-
: await remote.workspaceFiles.readBytes(scope, path, { offset: 0, length: 8 * 1024 * 1024 }, signal);
|
|
91
|
+
const result = await remote.workspaceFiles.readBytes(sessionId, path, { offset: 0, length: 8 * 1024 * 1024 }, signal);
|
|
85
92
|
if (result === null || typeof result !== 'object' || !result.ok) {
|
|
86
93
|
const failure = result !== null && typeof result === 'object' ? result.error : undefined;
|
|
87
94
|
throw new Error(failure?.message ?? `the workspace read of ${path} failed`);
|
|
@@ -91,7 +98,7 @@ async function readBytes(remote, sessionId, path, signal) {
|
|
|
91
98
|
|
|
92
99
|
/** List one directory, newest-first ordering rules applied by the caller. */
|
|
93
100
|
async function listDirectory(remote, sessionId, path, signal) {
|
|
94
|
-
const result = await remote.workspaceFiles.list(
|
|
101
|
+
const result = await remote.workspaceFiles.list(sessionId, path, signal);
|
|
95
102
|
if (result === null || typeof result !== 'object' || !result.ok) {
|
|
96
103
|
const failure = result !== null && typeof result === 'object' ? result.error : undefined;
|
|
97
104
|
throw new Error(failure?.message ?? `the workspace listing of ${path} failed`);
|
|
@@ -140,6 +147,27 @@ const styles = {
|
|
|
140
147
|
error: { color: 'var(--dsh-danger, #c0392b)', padding: '10px 12px', whiteSpace: 'pre-wrap' },
|
|
141
148
|
muted: { opacity: 0.6, padding: '10px 12px' },
|
|
142
149
|
svg: { maxWidth: '100%', height: 'auto' },
|
|
150
|
+
svgScroll: {
|
|
151
|
+
overflow: 'auto',
|
|
152
|
+
maxHeight: '68vh',
|
|
153
|
+
padding: '8px',
|
|
154
|
+
border: '1px solid var(--dsh-border, #e3e6ea)',
|
|
155
|
+
borderRadius: '6px',
|
|
156
|
+
background: '#ffffff',
|
|
157
|
+
},
|
|
158
|
+
sequence: {
|
|
159
|
+
margin: 0,
|
|
160
|
+
padding: '10px',
|
|
161
|
+
maxHeight: '68vh',
|
|
162
|
+
overflow: 'auto',
|
|
163
|
+
fontFamily: 'ui-monospace, SFMono-Regular, Consolas, monospace',
|
|
164
|
+
fontSize: '12px',
|
|
165
|
+
lineHeight: 1.45,
|
|
166
|
+
whiteSpace: 'pre-wrap',
|
|
167
|
+
wordBreak: 'break-all',
|
|
168
|
+
background: 'var(--dsh-soft, #f6f7f9)',
|
|
169
|
+
borderRadius: '6px',
|
|
170
|
+
},
|
|
143
171
|
canvas: { maxWidth: '100%', height: 'auto', display: 'block', border: '1px solid var(--dsh-border, #e3e6ea)', borderRadius: '6px', cursor: 'grab', touchAction: 'none', background: '#f7f9fb' },
|
|
144
172
|
button: (active) => ({
|
|
145
173
|
fontSize: '11px',
|
|
@@ -161,12 +189,24 @@ const styles = {
|
|
|
161
189
|
|
|
162
190
|
/** The panel body: a file list on the left, the rendered record on the right. */
|
|
163
191
|
function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
164
|
-
const cwd = useSessions((
|
|
192
|
+
const cwd = useSessions((state) => selectSessionDirectory(state, sessionId));
|
|
193
|
+
// The listing never blocks on the store: `'.'` is the Session's workspace
|
|
194
|
+
// root as the HOST resolves it, so a session whose `cwd` is missing from the
|
|
195
|
+
// list snapshot (or arrives after first render) still lists its files. Reads
|
|
196
|
+
// use the same base as the listing so an absent `cwd` cannot mix the two.
|
|
197
|
+
const root = cwd ?? '.';
|
|
198
|
+
const base = cwd ?? '';
|
|
165
199
|
const [entries, setEntries] = useState([]);
|
|
166
200
|
const [selected, setSelected] = useState(null);
|
|
167
201
|
const [record, setRecord] = useState(null);
|
|
168
|
-
const [status, setStatus] = useState({ kind:
|
|
202
|
+
const [status, setStatus] = useState({ kind: 'loading' });
|
|
169
203
|
const [view, setView] = useState({ ...DEFAULT_STRUCTURE_VIEW });
|
|
204
|
+
// Multi-sequence alignments are drawn at their NATURAL pixel width and the
|
|
205
|
+
// pane scrolls; zoom scales that width. Fitting a 2 000-column logo into the
|
|
206
|
+
// pane is what made long alignments unreadable in the first place.
|
|
207
|
+
const [logoZoom, setLogoZoom] = useState(1);
|
|
208
|
+
const svgNode = useRef(null);
|
|
209
|
+
const svgNatural = useRef({ width: 0, height: 0 });
|
|
170
210
|
const [dragging, setDragging] = useState(false);
|
|
171
211
|
const svgHost = useRef(null);
|
|
172
212
|
const canvasHost = useRef(null);
|
|
@@ -174,10 +214,9 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
174
214
|
|
|
175
215
|
// Directory listing, re-read when the session's workspace root changes.
|
|
176
216
|
useEffect(() => {
|
|
177
|
-
if (cwd === undefined) return undefined;
|
|
178
217
|
const controller = new AbortController();
|
|
179
218
|
setStatus({ kind: 'loading' });
|
|
180
|
-
listDirectory(remote, sessionId,
|
|
219
|
+
listDirectory(remote, sessionId, root, controller.signal)
|
|
181
220
|
.then((rows) => {
|
|
182
221
|
if (controller.signal.aborted) return;
|
|
183
222
|
setEntries(rows);
|
|
@@ -187,14 +226,14 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
187
226
|
if (!controller.signal.aborted) setStatus({ kind: 'error', message: String(error?.message ?? error) });
|
|
188
227
|
});
|
|
189
228
|
return () => controller.abort();
|
|
190
|
-
}, [
|
|
229
|
+
}, [root, remote, sessionId]);
|
|
191
230
|
|
|
192
231
|
// The selected file, parsed with the plugin's own parsers.
|
|
193
232
|
useEffect(() => {
|
|
194
|
-
if (selected === null
|
|
233
|
+
if (selected === null) return undefined;
|
|
195
234
|
const controller = new AbortController();
|
|
196
235
|
setStatus({ kind: 'loading' });
|
|
197
|
-
readBytes(remote, sessionId, childPath(
|
|
236
|
+
readBytes(remote, sessionId, childPath(base, selected.name), controller.signal)
|
|
198
237
|
.then((bytes) => {
|
|
199
238
|
if (controller.signal.aborted) return;
|
|
200
239
|
const kind = classifyEntry(selected);
|
|
@@ -207,6 +246,7 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
207
246
|
// A new structure starts from the same deterministic camera; the
|
|
208
247
|
// previous file's yaw/pitch would be meaningless on a different molecule.
|
|
209
248
|
if (parsed.kind === 'structure') setView({ ...DEFAULT_STRUCTURE_VIEW });
|
|
249
|
+
if (parsed.kind === 'alignment') setLogoZoom(1);
|
|
210
250
|
setStatus({ kind: 'ready' });
|
|
211
251
|
})
|
|
212
252
|
.catch((error) => {
|
|
@@ -226,7 +266,11 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
226
266
|
const host = svgHost.current;
|
|
227
267
|
if (host === null) return;
|
|
228
268
|
host.replaceChildren();
|
|
229
|
-
|
|
269
|
+
svgNode.current = null;
|
|
270
|
+
// A single-sequence FASTA is printed as text (no logo, no SVG host), and a
|
|
271
|
+
// structure owns the canvas instead.
|
|
272
|
+
if (record === null || status.kind !== 'ready' || record.kind === 'structure'
|
|
273
|
+
|| (record.kind === 'alignment' && (record.single === true || record.protein === true))) return;
|
|
230
274
|
// The renderer refuses what it cannot draw (renderPlasmidMap caps a map at
|
|
231
275
|
// 200 features). Letting that throw out of the effect leaves the pane empty
|
|
232
276
|
// with no explanation, so it becomes the pane's error state instead.
|
|
@@ -243,10 +287,32 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
243
287
|
return;
|
|
244
288
|
}
|
|
245
289
|
const svg = parsed.documentElement;
|
|
246
|
-
|
|
290
|
+
if (record.kind === 'alignment') {
|
|
291
|
+
// Natural size + a scrolling pane: the zoom effect below scales this.
|
|
292
|
+
svgNatural.current = {
|
|
293
|
+
width: Number(svg.getAttribute('width')) || 0,
|
|
294
|
+
height: Number(svg.getAttribute('height')) || 0,
|
|
295
|
+
};
|
|
296
|
+
svg.setAttribute('style', 'display:block');
|
|
297
|
+
} else {
|
|
298
|
+
svgNatural.current = { width: 0, height: 0 };
|
|
299
|
+
svg.setAttribute('style', 'max-width:100%;height:auto');
|
|
300
|
+
}
|
|
301
|
+
svgNode.current = svg;
|
|
247
302
|
host.append(document.importNode(svg, true));
|
|
248
303
|
}, [record, status.kind]);
|
|
249
304
|
|
|
305
|
+
// Scale the appended alignment SVG in place: regenerating the markup on every
|
|
306
|
+
// zoom step would re-run the alignment's composition for no reason.
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
const svg = svgNode.current;
|
|
309
|
+
const natural = svgNatural.current;
|
|
310
|
+
if (svg === null || natural.width === 0) return;
|
|
311
|
+
if (record === null || record.kind !== 'alignment' || record.single === true) return;
|
|
312
|
+
svg.setAttribute('width', String(Math.max(1, Math.round(natural.width * logoZoom))));
|
|
313
|
+
svg.setAttribute('height', String(Math.max(1, Math.round(natural.height * logoZoom))));
|
|
314
|
+
}, [logoZoom, record, status.kind]);
|
|
315
|
+
|
|
250
316
|
// Structures are rasterized into an RGB buffer and painted into a canvas.
|
|
251
317
|
// The renderer is deterministic and shared with the Node tests; only the
|
|
252
318
|
// canvas plumbing lives here. During a drag the frame drops to 1x
|
|
@@ -324,7 +390,13 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
324
390
|
|
|
325
391
|
const openable = useMemo(() => entries.filter(isOpenable), [entries]);
|
|
326
392
|
|
|
327
|
-
|
|
393
|
+
// The header names the directory being listed. Without it a wrong/empty
|
|
394
|
+
// workspace is indistinguishable from "the panel is broken", which is how a
|
|
395
|
+
// missing `cwd` stayed invisible through a restart.
|
|
396
|
+
const head = h('div', { style: styles.listHead },
|
|
397
|
+
h('div', null, 'Sequence & structure files'),
|
|
398
|
+
h('div', { style: styles.listSub, title: root }, cwd ?? 'session workspace'),
|
|
399
|
+
h('div', { style: styles.listSub }, openable.length === 0 ? 'no openable files' : `${openable.length} file(s)`));
|
|
328
400
|
const list = h(
|
|
329
401
|
'div',
|
|
330
402
|
{ style: styles.list },
|
|
@@ -347,7 +419,6 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
347
419
|
);
|
|
348
420
|
|
|
349
421
|
const body = [];
|
|
350
|
-
if (status.kind === 'waiting') body.push(h('div', { key: 'wait', style: styles.muted }, 'Waiting for the session workspace…'));
|
|
351
422
|
if (status.kind === 'error') body.push(h('div', { key: 'err', style: styles.error }, status.message));
|
|
352
423
|
if (status.kind === 'loading') body.push(h('div', { key: 'load', style: styles.muted }, 'Reading…'));
|
|
353
424
|
if (status.kind === 'ready' && record === null) {
|
|
@@ -380,10 +451,47 @@ function MolbioPanel({ sessionId, remote, useSessions }) {
|
|
|
380
451
|
}
|
|
381
452
|
}
|
|
382
453
|
if (status.kind === 'ready' && record !== null && record.kind === 'alignment') {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
454
|
+
if (record.protein === true) {
|
|
455
|
+
// Protein FASTA: the aligner and the logo are nucleotide-only. Saying so
|
|
456
|
+
// beats the old behaviour, which aligned amino acids as if they were DNA
|
|
457
|
+
// ambiguity codes and drew a logo with most letters dropped.
|
|
458
|
+
body.push(h('div', { key: 'meta', style: styles.meta },
|
|
459
|
+
h('span', null, `${record.rows.length} sequence(s)`),
|
|
460
|
+
h('span', null, 'not nucleotide')));
|
|
461
|
+
body.push(h('div', { key: 'notice', style: styles.note },
|
|
462
|
+
'This FASTA is not a nucleotide (IUPAC DNA) file. The sequence logo aligns nucleotide sequences only, '
|
|
463
|
+
+ 'so these sequences are shown as plain text and are NOT aligned.'));
|
|
464
|
+
body.push(h('pre', { key: 'sequence', style: styles.sequence }, sequenceText(record)));
|
|
465
|
+
} else if (record.single === true) {
|
|
466
|
+
// One sequence is DATA, not an alignment: print it (wrapped) instead of
|
|
467
|
+
// drawing a one-glyph-per-column logo that shrinks to noise on a long
|
|
468
|
+
// sequence. No zoom controls are needed for text.
|
|
469
|
+
body.push(h('div', { key: 'meta', style: styles.meta },
|
|
470
|
+
h('span', null, '1 sequence'),
|
|
471
|
+
h('span', null, `${record.rows[0]?.length ?? 0} residues`)));
|
|
472
|
+
body.push(h('pre', { key: 'sequence', style: styles.sequence }, sequenceText(record)));
|
|
473
|
+
} else {
|
|
474
|
+
body.push(h('div', { key: 'meta', style: styles.meta },
|
|
475
|
+
h('span', null, `${record.rows.length} sequences`),
|
|
476
|
+
h('span', null, `${record.rows[0]?.length ?? 0} aligned columns`)));
|
|
477
|
+
body.push(h('div', { key: 'zoom', style: styles.meta },
|
|
478
|
+
h('button', {
|
|
479
|
+
key: 'out',
|
|
480
|
+
style: styles.button(false),
|
|
481
|
+
title: 'Zoom out',
|
|
482
|
+
onClick: () => setLogoZoom((value) => Math.max(0.1, value / 1.25)),
|
|
483
|
+
}, '−'),
|
|
484
|
+
h('span', { key: 'level', style: { minWidth: '48px', textAlign: 'center' } }, `${Math.round(logoZoom * 100)}%`),
|
|
485
|
+
h('button', {
|
|
486
|
+
key: 'in',
|
|
487
|
+
style: styles.button(false),
|
|
488
|
+
title: 'Zoom in',
|
|
489
|
+
onClick: () => setLogoZoom((value) => Math.min(8, value * 1.25)),
|
|
490
|
+
}, '+'),
|
|
491
|
+
h('button', { key: 'reset', style: styles.button(false), title: 'Actual size', onClick: () => setLogoZoom(1) }, 'Reset')));
|
|
492
|
+
body.push(h('div', { key: 'svg-scroll', style: styles.svgScroll },
|
|
493
|
+
h('div', { key: 'svg', ref: svgHost, style: { lineHeight: 0 } })));
|
|
494
|
+
}
|
|
387
495
|
}
|
|
388
496
|
if (status.kind === 'ready' && record !== null && record.kind === 'structure') {
|
|
389
497
|
body.push(h('div', { key: 'meta', style: styles.meta },
|
|
@@ -582,9 +690,15 @@ function MolbioFigureCard({ block, inspect }) {
|
|
|
582
690
|
* tools instead (see EMPTY_HINT).
|
|
583
691
|
*/
|
|
584
692
|
function PapersPanel({ sessionId, remote, useSessions }) {
|
|
585
|
-
|
|
693
|
+
// The library path is WORKSPACE-RELATIVE, matching how the tools resolve it
|
|
694
|
+
// (papers.mjs `workspaceFilePath` joins `workspaceRoot`, the sandbox root,
|
|
695
|
+
// not the session cwd). Building it from `cwd` read the wrong file whenever
|
|
696
|
+
// those two differ. `useSessions` stays in the signature because the slot
|
|
697
|
+
// runtime provides it (and the contract pins that); this panel needs no path
|
|
698
|
+
// from the store — a useless `cwd` is what the property is for.
|
|
699
|
+
const libraryPath = LIBRARY_FILE;
|
|
586
700
|
const [papers, setPapers] = useState([]);
|
|
587
|
-
const [status, setStatus] = useState({ kind: '
|
|
701
|
+
const [status, setStatus] = useState({ kind: 'loading' });
|
|
588
702
|
const [query, setQuery] = useState('');
|
|
589
703
|
const [tag, setTag] = useState('');
|
|
590
704
|
const [selectedId, setSelectedId] = useState(null);
|
|
@@ -592,13 +706,9 @@ function PapersPanel({ sessionId, remote, useSessions }) {
|
|
|
592
706
|
const keyView = ncbiKeyView(keyState);
|
|
593
707
|
|
|
594
708
|
useEffect(() => {
|
|
595
|
-
if (cwd === undefined) {
|
|
596
|
-
setStatus({ kind: 'waiting' });
|
|
597
|
-
return undefined;
|
|
598
|
-
}
|
|
599
709
|
const controller = new AbortController();
|
|
600
710
|
setStatus({ kind: 'loading' });
|
|
601
|
-
readWorkspaceText(remote, sessionId,
|
|
711
|
+
readWorkspaceText(remote, sessionId, libraryPath, controller.signal)
|
|
602
712
|
.then((result) => {
|
|
603
713
|
if (controller.signal.aborted) return;
|
|
604
714
|
if (result.kind === 'missing') {
|
|
@@ -621,7 +731,7 @@ function PapersPanel({ sessionId, remote, useSessions }) {
|
|
|
621
731
|
if (!controller.signal.aborted) setStatus({ kind: 'error', message: String(error?.message ?? error) });
|
|
622
732
|
});
|
|
623
733
|
return () => controller.abort();
|
|
624
|
-
}, [
|
|
734
|
+
}, [libraryPath, remote, sessionId]);
|
|
625
735
|
|
|
626
736
|
const tags = useMemo(() => libraryTags(papers), [papers]);
|
|
627
737
|
const visible = useMemo(() => filterPapers(papers, { query, tag }), [papers, query, tag]);
|
|
@@ -667,7 +777,6 @@ function PapersPanel({ sessionId, remote, useSessions }) {
|
|
|
667
777
|
h('div', { style: styles.listSub }, paperSummary(paper))))));
|
|
668
778
|
|
|
669
779
|
const detail = [];
|
|
670
|
-
if (status.kind === 'waiting') detail.push(h('div', { key: 'wait', style: styles.muted }, 'Waiting for the session workspace…'));
|
|
671
780
|
if (status.kind === 'loading') detail.push(h('div', { key: 'load', style: styles.muted }, 'Reading papers.json…'));
|
|
672
781
|
if (status.kind === 'error') detail.push(h('div', { key: 'err', style: styles.error }, status.message));
|
|
673
782
|
if (status.kind === 'empty') {
|
|
@@ -950,7 +1059,13 @@ function NcbiKeySection({ subject, remote }) {
|
|
|
950
1059
|
}
|
|
951
1060
|
|
|
952
1061
|
/** Required browser services. */
|
|
953
|
-
|
|
1062
|
+
// `remote.workspaceFiles` is a namespace sub-service, not a plain property:
|
|
1063
|
+
// every shipped consumer (ui-sidebar-files, ui-sidebar-documentpreview,
|
|
1064
|
+
// ui-reference, ui-open-in-app) injects it beside `remote`, and this package
|
|
1065
|
+
// used to declare only `remote`. Waiting for the namespace is what makes
|
|
1066
|
+
// `ctx.remote.workspaceFiles` usable the moment `apply()` runs and the panels
|
|
1067
|
+
// render; without it the lookup is a race the panel cannot report.
|
|
1068
|
+
const inject = ['slots', 'sidebarRightTabs', 'remote', 'remote.workspaceFiles'];
|
|
954
1069
|
|
|
955
1070
|
/**
|
|
956
1071
|
* Claim seats through `ctx.slots.inject`, never a bare `ctx.slots.register` —
|
package/build/panel-core.mjs
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
columnComposition,
|
|
19
19
|
renderSequenceLogo,
|
|
20
20
|
progressiveAlign,
|
|
21
|
+
normalizeAlignedRow,
|
|
22
|
+
normalizeMsaSequence,
|
|
21
23
|
parseStructureText,
|
|
22
24
|
renderStructureImage,
|
|
23
25
|
DEFAULT_STRUCTURE_VIEW,
|
|
@@ -51,6 +53,41 @@ export function extensionOf(name) {
|
|
|
51
53
|
return match === null ? '' : match[1].toLowerCase();
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
/**
|
|
57
|
+
* The session's workspace root, read the way DSH 0.2.3+ exposes it.
|
|
58
|
+
*
|
|
59
|
+
* 0.2.3 moved the directory into a Session projection: the shipped tab bodies
|
|
60
|
+
* (`dsh-client-ui-sidebar-files` and `dsh-client-ui-workspace`) now call a
|
|
61
|
+
* shared `selectSessionDirectory(state, sessionId)` that reads
|
|
62
|
+
* `projectionsBySession[sessionId].values.workingDirectory` first, then the
|
|
63
|
+
* summary's `projectionValues.workingDirectory`, and only then the summary's
|
|
64
|
+
* `cwd`. Reading `byId[sessionId].cwd` alone — this package's previous
|
|
65
|
+
* behaviour — worked only while the store happened to materialise `cwd`; a
|
|
66
|
+
* session whose directory exists only as a projection produced an empty panel.
|
|
67
|
+
*
|
|
68
|
+
* The order is mirrored exactly, because it is the host's contract, not this
|
|
69
|
+
* package's preference. Every step is optional and every value is type-checked
|
|
70
|
+
* so the same bundle still runs on the older DSH releases this package
|
|
71
|
+
* supports (where `projectionsBySession` does not exist and `cwd` is the only
|
|
72
|
+
* source). An empty string counts as "no root" because the panels key their
|
|
73
|
+
* loading state on `cwd === undefined`.
|
|
74
|
+
*
|
|
75
|
+
* @param {object} state the `useSessions` store snapshot.
|
|
76
|
+
* @param {string} sessionId the slot's session id.
|
|
77
|
+
* @returns {string|undefined} the workspace root, when the store has one.
|
|
78
|
+
*/
|
|
79
|
+
export function selectSessionDirectory(state, sessionId) {
|
|
80
|
+
const projected = (values, key) => {
|
|
81
|
+
if (values === null || typeof values !== 'object') return undefined;
|
|
82
|
+
const value = Reflect.get(values, key);
|
|
83
|
+
return typeof value === 'string' && value !== '' ? value : undefined;
|
|
84
|
+
};
|
|
85
|
+
const summary = state?.byId?.[sessionId];
|
|
86
|
+
return projected(state?.projectionsBySession?.[sessionId]?.values, 'workingDirectory')
|
|
87
|
+
?? projected(summary?.projectionValues, 'workingDirectory')
|
|
88
|
+
?? (typeof summary?.cwd === 'string' && summary.cwd !== '' ? summary.cwd : undefined);
|
|
89
|
+
}
|
|
90
|
+
|
|
54
91
|
/**
|
|
55
92
|
* How the panel should treat one workspace entry.
|
|
56
93
|
* @param {{name?: string, type?: string}} entry a `workspaceFiles.list` row.
|
|
@@ -99,10 +136,11 @@ export function childPath(parent, name) {
|
|
|
99
136
|
* gateway lifts native bytes into a base64 attachment and reassembles them
|
|
100
137
|
* client-side before the call resolves.
|
|
101
138
|
*
|
|
102
|
-
* Accepting both here is
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
139
|
+
* Accepting both here is cheap insurance at one boundary: every supported
|
|
140
|
+
* harness sends a `Uint8Array` (the panel calls `readBytes` directly), and a
|
|
141
|
+
* base64 string from an older transport still decodes instead of producing a
|
|
142
|
+
* wrong picture. A `Uint8Array` is passed through by reference (no copy), so a
|
|
143
|
+
* large plasmid costs nothing extra.
|
|
106
144
|
*
|
|
107
145
|
* @param {string|Uint8Array} data the `data` field of a successful read.
|
|
108
146
|
* @returns {Uint8Array} the file's raw bytes.
|
|
@@ -213,9 +251,16 @@ export function structureImage(record, options = {}) {
|
|
|
213
251
|
}
|
|
214
252
|
|
|
215
253
|
/**
|
|
216
|
-
* Parse
|
|
254
|
+
* Parse a FASTA file into the rows the panel draws.
|
|
255
|
+
*
|
|
256
|
+
* ONE sequence is not an alignment: aligning it would be an identity operation,
|
|
257
|
+
* and its logo draws one glyph per column — on a long sequence that shrinks to
|
|
258
|
+
* unreadable noise. Such a record returns `single: true` and the panel prints
|
|
259
|
+
* the residues instead. Two or more go through the plugin's own aligner, so the
|
|
260
|
+
* panel shows exactly what `molbio_msa_align` would produce for the same input.
|
|
261
|
+
*
|
|
217
262
|
* @param {Uint8Array} bytes raw FASTA content.
|
|
218
|
-
* @returns {{ids: string[], rows: string[]}}
|
|
263
|
+
* @returns {{ids: string[], rows: string[], single: boolean}}
|
|
219
264
|
*/
|
|
220
265
|
export function parseAlignmentFile(bytes) {
|
|
221
266
|
const text = new TextDecoder('utf-8').decode(bytes).replace(/^\uFEFF/, '');
|
|
@@ -235,11 +280,70 @@ export function parseAlignmentFile(bytes) {
|
|
|
235
280
|
current.push(line);
|
|
236
281
|
}
|
|
237
282
|
if (current !== null) rows.push(current.join(''));
|
|
238
|
-
if (rows.length
|
|
283
|
+
if (rows.length === 0) throw new MolbioInputError('the FASTA file contains no sequences');
|
|
284
|
+
// A FASTA can carry PROTEIN. The aligner and the logo are nucleotide-only
|
|
285
|
+
// (IUPAC DNA/RNA): handing protein rows over used to produce a meaningless
|
|
286
|
+
// alignment whose logo silently dropped every non-IUPAC letter and then
|
|
287
|
+
// counted those columns as gaps. Such a file is shown as plain text instead.
|
|
288
|
+
const nucleotide = rows.every(isNucleotideRow);
|
|
289
|
+
if (!nucleotide) return { ids, rows, single: rows.length === 1, protein: true };
|
|
290
|
+
// A pre-aligned FASTA (dashes in the rows) is already an alignment: normalize
|
|
291
|
+
// the gap spelling and never run the aligner on it again.
|
|
292
|
+
if (rows.some((sequence) => /[-.]/.test(sequence))) {
|
|
293
|
+
const normalized = rows.map((sequence, index) => normalizeAlignedRow(sequence, `sequence ${ids[index] ?? index + 1}`));
|
|
294
|
+
const width = normalized[0].length;
|
|
295
|
+
if (!normalized.every((sequence) => sequence.length === width)) {
|
|
296
|
+
throw new MolbioInputError('a pre-aligned FASTA needs equal-length rows');
|
|
297
|
+
}
|
|
298
|
+
return { ids, rows: normalized, single: normalized.length === 1, protein: false };
|
|
299
|
+
}
|
|
300
|
+
// Normalize (uppercase, U→T) before aligning: this module used to pass raw
|
|
301
|
+
// rows to the aligner, whose symbol table only knows uppercase IUPAC — a
|
|
302
|
+
// lowercase FASTA was silently treated like an unknown alphabet.
|
|
303
|
+
const sequences = rows.map((sequence, index) => normalizeMsaSequence(sequence, `sequence ${ids[index] ?? index + 1}`));
|
|
304
|
+
if (sequences.length === 1) return { ids, rows: sequences, single: true, protein: false };
|
|
239
305
|
// Reuse the plugin's own aligner so the panel shows exactly what
|
|
240
306
|
// molbio_msa_align would produce for the same input.
|
|
241
|
-
const aligned = progressiveAlign(
|
|
242
|
-
return { ids, rows: aligned.alignment.map((row) => row.sequence) };
|
|
307
|
+
const aligned = progressiveAlign(sequences.map((sequence, index) => ({ id: ids[index], sequence })));
|
|
308
|
+
return { ids, rows: aligned.alignment.map((row) => row.sequence), single: false, protein: false };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** The IUPAC nucleotide letters the aligner and the logo understand. */
|
|
312
|
+
const NUCLEOTIDE_LETTERS = new Set('ACGTURYSWKMBDHVN');
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Whether one FASTA row is nucleotide text (gaps allowed).
|
|
316
|
+
* @param {string} sequence one row as read from the file.
|
|
317
|
+
* @returns {boolean} false when it carries an amino-acid letter such as E/F/L/P/Q.
|
|
318
|
+
*/
|
|
319
|
+
export function isNucleotideRow(sequence) {
|
|
320
|
+
for (const char of sequence.toUpperCase()) {
|
|
321
|
+
if (char === '-' || char === '.') continue;
|
|
322
|
+
if (!NUCLEOTIDE_LETTERS.has(char)) return false;
|
|
323
|
+
}
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* One parsed record as FASTA text, wrapped for a `<pre>`.
|
|
329
|
+
*
|
|
330
|
+
* A single-sequence file is read as sequence data, and a raw line of 20 000
|
|
331
|
+
* residues is not readable either: the residues are wrapped at `width` with
|
|
332
|
+
* the header line kept so the id travels with them.
|
|
333
|
+
*
|
|
334
|
+
* @param {{ids?: string[], rows: string[]}} record the parsed record.
|
|
335
|
+
* @param {number} [width] residues per line.
|
|
336
|
+
* @returns {string} FASTA text without a trailing newline.
|
|
337
|
+
*/
|
|
338
|
+
export function sequenceText(record, width = 60) {
|
|
339
|
+
const step = Math.max(10, Math.floor(Number(width) || 60));
|
|
340
|
+
const blocks = record.rows.map((sequence, index) => {
|
|
341
|
+
const id = record.ids?.[index] ?? `seq${index + 1}`;
|
|
342
|
+
const lines = [`>${id}`];
|
|
343
|
+
for (let at = 0; at < sequence.length; at += step) lines.push(sequence.slice(at, at + step));
|
|
344
|
+
return lines.join('\n');
|
|
345
|
+
});
|
|
346
|
+
return blocks.join('\n\n');
|
|
243
347
|
}
|
|
244
348
|
|
|
245
349
|
/**
|
|
@@ -425,12 +529,29 @@ const PAPER_FIELDS = [
|
|
|
425
529
|
export async function readWorkspaceText(remote, sessionId, path, signal) {
|
|
426
530
|
let result;
|
|
427
531
|
try {
|
|
428
|
-
|
|
532
|
+
// First argument: the SessionId lookup (a string), not `{ sessionId }`.
|
|
533
|
+
// The gateway decodes it with a strict string codec before resolving the
|
|
534
|
+
// Session's workspace root, so an object fails the call outright.
|
|
535
|
+
// Third argument: the line window. It is REQUIRED to be an object — the
|
|
536
|
+
// host's `read()` destructures `range.offset`, so `undefined` threw
|
|
537
|
+
// "Cannot read properties of undefined (reading 'offset')" and the Papers
|
|
538
|
+
// tab could never load a library. `{}` takes the page defaults.
|
|
539
|
+
result = await remote.workspaceFiles.read(sessionId, path, {}, signal);
|
|
429
540
|
} catch (error) {
|
|
430
541
|
return { kind: 'error', message: String(error?.message ?? error) };
|
|
431
542
|
}
|
|
432
543
|
if (result === null || typeof result !== 'object') return { kind: 'error', message: 'the workspace read returned nothing' };
|
|
433
|
-
if (result.ok)
|
|
544
|
+
if (result.ok) {
|
|
545
|
+
// A page stops at the deployment's line cap; a truncated JSON document
|
|
546
|
+
// would otherwise surface as "not valid JSON" and hide the real cause.
|
|
547
|
+
if (result.value?.eof === false) {
|
|
548
|
+
return {
|
|
549
|
+
kind: 'error',
|
|
550
|
+
message: `${path} is longer than one preview page (${result.value?.lines ?? 0} lines); open it directly to read the whole library`,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
return { kind: 'text', text: result.value?.text ?? '' };
|
|
554
|
+
}
|
|
434
555
|
const failure = result.error;
|
|
435
556
|
// The wire carries typed codes; not-found is the one that means "empty".
|
|
436
557
|
if (failure?.code === 'workspace-file/not-found' || /not-found|does not exist/i.test(String(failure?.message ?? ''))) {
|
package/cordis.patch.yml
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
id: molbio-lab
|
|
48
48
|
order: 5
|
|
49
49
|
name: Molecular Biology Lab
|
|
50
|
-
description: "分子生物学专属模式:标准编码能力 +
|
|
50
|
+
description: "分子生物学专属模式:标准编码能力 + 72 个 molbio_* 工具(序列分析、引物设计(含跨内含子 qPCR、盐/浓度旋钮与目标位置偏好)、TaqMan 水解探针(含 MGB 与订购 CSV)与多重 PCR 互扰/退火温度/浓度建议、克隆模拟与选酶(含 Golden Gate)、酶目录查询、甲基化敏感位点与双酶切 buffer 兼容检查、多序列比对(每个输入残基都会进比对结果)、保守性分析与比对后处理(共识/缺口修剪/同一性矩阵/逐列覆盖度,含 sequence logo 图)、CRISPR gRNA 设计(SpCas9/SaCas9/Cas12a/Cas13,家族特定 PAM/PFS/种子)与脱靶搜索、SnapGene/GenBank 解析与质粒图谱、Sanger 测序验证、蛋白性质/电荷-pH 曲线/密码子优化/螺旋轮投影与疏水性图、qPCR 与绘图、虚拟凝胶、实验台分析(FASTQ 质控、密码子使用、系统发生树(长叶名自动折行)、in-silico PCR、CpG/GC 组成、序列 dotplot、载体/接头污染筛查、FASTQ 修剪/过滤、批量文件分析/CSV)、静默酶切位点突变设计、蛋白注释(PTM 基序/低复杂度/不稳定指数、von Heijne 信号肽与跨膜段、Kolaskar-Tongaonkar 抗原性)、注释格式导出(GFF3/BED/CSV)与序列编辑(rotate/insert/delete/replace/split/join)、Sanger 读段组装与编辑结果归类——生成的 SVG 图片自动用系统默认应用打开,文献/协议/实验记录)。"
|
|
51
51
|
plugins:
|
|
52
52
|
- id: persona
|
|
53
53
|
name: '@deepseek-ai/dsh-persona'
|
|
@@ -168,18 +168,20 @@
|
|
|
168
168
|
config:
|
|
169
169
|
fetch: true
|
|
170
170
|
searchTimeoutMs: 60000
|
|
171
|
+
- id: tool-cordis
|
|
172
|
+
name: '@deepseek-ai/dsh-tool-cordis'
|
|
171
173
|
- id: present
|
|
172
174
|
name: '@deepseek-ai/dsh-tool-present'
|
|
173
175
|
- id: tool-office
|
|
174
176
|
name: '@deepseek-ai/dsh-tool-office'
|
|
175
177
|
- id: tool-plugin-manager
|
|
176
178
|
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
177
|
-
disabled:
|
|
179
|
+
disabled: !!js "!ctx.get('profileContext')"
|
|
178
180
|
- id: tool-plugin-market
|
|
179
181
|
name: '@deepseek-ai/dsh-plugin-market/tools'
|
|
180
182
|
disabled: true
|
|
181
183
|
|
|
182
|
-
# dsh-molbio-tools: molecular-biology toolset (
|
|
184
|
+
# dsh-molbio-tools: molecular-biology toolset (72 tools across sequence
|
|
183
185
|
# analysis, primers (incl. TaqMan probes and multiplex compatibility),
|
|
184
186
|
# in-silico PCR, cloning (incl. Golden Gate), enzyme catalog, methylation-aware
|
|
185
187
|
# and double digests, plasmids, Sanger verification, proteins (incl. helical
|
|
@@ -6,7 +6,7 @@ mainstream bioinformatics landscape offer that this toolset does **not**, and wh
|
|
|
6
6
|
deterministic algorithms in a few hundred lines of dependency-free JS with **no external data files,
|
|
7
7
|
binaries, network, or reference databases**?
|
|
8
8
|
|
|
9
|
-
> **Status note (0.
|
|
9
|
+
> **Status note (0.28.0).** Rows 10, 13, 14, 21, 27 and 31 shipped in 0.28.0 (feature export + sequence editing, protein feature suite, antigenicity, signal peptide + TM segments, Sanger assembly, editing-outcome clustering). The note below records the 0.24.0 baseline. The baseline below is the 52-tool package this survey was written
|
|
10
10
|
> against. Since then rows 1–9, 11, 12, 23, 30, 34, 40 and the Cas-family half of row 20 have shipped
|
|
11
11
|
> (row 9, duplex thermodynamics, shipped as `molbio_duplex_thermo` in 0.27.0).
|
|
12
12
|
> (see [history.md](history.md) and the roadmap); the remaining rows are still candidates unless
|