@czi-sds/data-viz 2.3.0 → 2.4.1

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.
Files changed (39) hide show
  1. package/dist/HeatmapChart.cjs.d.ts +2 -0
  2. package/dist/HeatmapChart.cjs.js +8 -0
  3. package/dist/HeatmapChart.esm.d.ts +2 -0
  4. package/dist/HeatmapChart.esm.js +3 -0
  5. package/dist/ProteinStructureViewer.cjs.d.ts +2 -0
  6. package/dist/ProteinStructureViewer.cjs.js +14 -0
  7. package/dist/ProteinStructureViewer.esm.d.ts +2 -0
  8. package/dist/ProteinStructureViewer.esm.js +3 -0
  9. package/dist/StackedBarChart.cjs.d.ts +2 -0
  10. package/dist/StackedBarChart.cjs.js +8 -0
  11. package/dist/StackedBarChart.esm.d.ts +2 -0
  12. package/dist/StackedBarChart.esm.js +3 -0
  13. package/dist/colorScales.cjs.d.ts +2 -0
  14. package/dist/colorScales.cjs.js +6 -0
  15. package/dist/colorScales.esm.d.ts +2 -0
  16. package/dist/colorScales.esm.js +3 -0
  17. package/dist/index.cjs.d.ts +4 -772
  18. package/dist/index.cjs.js +16 -5765
  19. package/dist/index.esm.d.ts +4 -774
  20. package/dist/index.esm.js +4 -5719
  21. package/dist/shared/HeatmapChart.cjs.js +349 -0
  22. package/dist/shared/HeatmapChart.esm.js +342 -0
  23. package/dist/shared/ProteinStructureViewer.cjs.js +4790 -0
  24. package/dist/shared/ProteinStructureViewer.esm.js +4738 -0
  25. package/dist/shared/StackedBarChart.cjs.js +489 -0
  26. package/dist/shared/StackedBarChart.esm.js +483 -0
  27. package/dist/shared/colorScales.cjs.d.ts +45 -0
  28. package/dist/shared/colorScales.cjs.js +126 -0
  29. package/dist/shared/colorScales.esm.d.ts +45 -0
  30. package/dist/shared/colorScales.esm.js +103 -0
  31. package/dist/shared/index.cjs.d.ts +183 -0
  32. package/dist/shared/index.esm.d.ts +183 -0
  33. package/dist/shared/index2.cjs.d.ts +389 -0
  34. package/dist/shared/index2.esm.d.ts +391 -0
  35. package/dist/shared/index3.cjs.d.ts +166 -0
  36. package/dist/shared/index3.esm.d.ts +166 -0
  37. package/dist/shared/objectSpread2.cjs.js +124 -0
  38. package/dist/shared/objectSpread2.esm.js +85 -0
  39. package/package.json +65 -2
@@ -0,0 +1,389 @@
1
+ /// <reference types="react" />
2
+ import { t as ColorScale } from "./colorScales.cjs.js";
3
+ import { HTMLAttributes } from "react";
4
+ import { TooltipProps } from "@czi-sds/components";
5
+ import { PluginUISpec } from "molstar/lib/mol-plugin-ui/spec";
6
+ //#region src/core/ProteinStructureViewer/ProteinStructureViewer.types.d.ts
7
+ /**
8
+ * Per-residue values painted onto the structure in place of the default pLDDT
9
+ * coloring, along with the legend that describes them.
10
+ */
11
+ interface ResidueValueOverlay {
12
+ /** 0-based residue index to value. Residues absent from the map read as 0. */
13
+ values: Map<number, number>;
14
+ /** Value mapped to the top of the color scale. */
15
+ max: number;
16
+ /**
17
+ * Values at or below this render in a neutral gray rather than on the scale.
18
+ * Values above it are normalized into `min`-`max` before being sampled, so
19
+ * this is also what the legend's lower tick reports.
20
+ * @default 0
21
+ */
22
+ min?: number;
23
+ /**
24
+ * Scale used to color residues and to draw the legend.
25
+ * @default PLASMA_COLOR_SCALE
26
+ */
27
+ colorScale?: ColorScale;
28
+ /** Legend caption, e.g. "Feature activation". */
29
+ label?: string;
30
+ /**
31
+ * Title of the help tooltip on the legend caption. The common case: a
32
+ * string is enough. Use `tooltipProps` when the tooltip needs a subtitle, a
33
+ * custom body, or any other SDS Tooltip prop. Overrides
34
+ * `tooltipProps.title` when both are set.
35
+ */
36
+ tooltip?: string;
37
+ /**
38
+ * Props forwarded to the SDS Tooltip on the legend caption. The trigger is
39
+ * the caption's help icon, so `children` is omitted.
40
+ */
41
+ tooltipProps?: Partial<Omit<TooltipProps, "children">>;
42
+ /**
43
+ * Label for the per-residue readout that replaces a stat slot on hover.
44
+ * @default "Value"
45
+ */
46
+ readoutLabel?: string;
47
+ }
48
+ /**
49
+ * A residue the user pointed at, in each of the ways a caller might need to
50
+ * address it.
51
+ *
52
+ * `index` is the viewer's own key: the position in `plddt` and in
53
+ * `residueOverlay`'s map, and what `selectedResidue` takes. `chainId`, `seqId`
54
+ * and `insCode` are what the file says, which is what the sequence panel shows
55
+ * and what a system that supplied the structure will recognise. They differ
56
+ * from `index` whenever the file does not number a single chain from 1 -- a
57
+ * crop, or a complex -- so address a residue outside the viewer with those
58
+ * three, not with `index`.
59
+ *
60
+ * `insCode` is rarely set but is part of the address when it is: `10` and `10A`
61
+ * are different residues on the same chain, so chain and number alone do not
62
+ * name one.
63
+ */
64
+ interface ResidueRef {
65
+ /** 0-based position in the structure, counting residues in file order. */
66
+ index: number;
67
+ /** Three-letter residue code, e.g. `"LYS"`. */
68
+ compId: string;
69
+ /** Chain the residue sits on, as named in the file. */
70
+ chainId: string;
71
+ /** Residue number as written in the file. */
72
+ seqId: number;
73
+ /** Insertion code, or `""` when the residue has none. */
74
+ insCode: string;
75
+ }
76
+ /**
77
+ * A chain the viewer found in the structure it loaded, reported through
78
+ * `onChainsChange` so a consumer can label, color or hide chains by name
79
+ * without parsing the structure itself.
80
+ *
81
+ * `chainId` is the file's own name for the chain, the same one `ResidueRef`
82
+ * reports, and the key every chain-keyed prop takes. A chain carrying several
83
+ * symmetry operators appears once, under the first.
84
+ *
85
+ * Describes the chain's polymer. The ligands and ions sitting on it are drawn
86
+ * and are hidden and selected with it, but are not counted here or spanned by
87
+ * the range below - they are no part of the sequence. A chain holding nothing
88
+ * but heteroatoms is left out altogether, having no sequence to describe.
89
+ */
90
+ interface ChainRef {
91
+ /** Chain as named in the file (`auth_asym_id`), e.g. `"A"`. */
92
+ chainId: string;
93
+ /** Chain as the sequence panel captions it. */
94
+ label: string;
95
+ /** Lowest 0-based residue index of the chain's polymer. */
96
+ startIndex: number;
97
+ /** Highest 0-based residue index of the chain's polymer. */
98
+ endIndex: number;
99
+ /** Polymer residues the chain holds. */
100
+ residueCount: number;
101
+ }
102
+ /**
103
+ * What is selected, in the two ways a caller might say it. `null` selects
104
+ * nothing.
105
+ *
106
+ * The two combine: `{ chains: ["A"], residues: [150] }` takes all of chain A
107
+ * plus one residue elsewhere. `chains` is kept as named rather than expanded
108
+ * into indices, so a whole-chain selection survives a round trip through a
109
+ * consumer's state at its original size.
110
+ */
111
+ interface StructureSelection {
112
+ /**
113
+ * 0-based residue indices, counting residues in file order across the whole
114
+ * structure - the same index `plddt` and `residueOverlay` are keyed by.
115
+ */
116
+ residues?: number[];
117
+ /** Whole chains by `chainId`, each standing for every residue on it. */
118
+ chains?: string[];
119
+ }
120
+ /**
121
+ * How large a downloaded image is, in pixels.
122
+ *
123
+ * Named rather than given as dimensions because the aspect is Mol*'s to
124
+ * choose: each of these is one of its own presets, and a size picked here
125
+ * would have to be reconciled with the canvas the image is rendered from.
126
+ */
127
+ type DownloadResolution = "low" | "medium" | "high" | "maximum";
128
+ /** Pixel dimensions each resolution produces, for documentation and labels. */
129
+ declare const DOWNLOAD_RESOLUTIONS: Record<DownloadResolution, string>;
130
+ /**
131
+ * Turns on the capture button under the reset-camera control, and says what it
132
+ * should produce. Omit it and no button is drawn.
133
+ *
134
+ * The image is rendered fresh at the size asked for rather than scaled up from
135
+ * the canvas, so a high resolution costs time rather than sharpness - which is
136
+ * why the default sits in the middle rather than at the top.
137
+ */
138
+ interface StructureDownload {
139
+ /**
140
+ * Size of the image. See `DOWNLOAD_RESOLUTIONS` for the pixel dimensions.
141
+ * @default "medium"
142
+ */
143
+ resolution?: DownloadResolution;
144
+ /**
145
+ * Background behind the structure, as `#RRGGBB`. Omit for a transparent
146
+ * one, which is what a figure usually wants - the viewer's own canvas color
147
+ * is deliberately not inherited, since a screenshot tends to outlive the
148
+ * theme it was taken under.
149
+ */
150
+ backgroundColor?: string;
151
+ /**
152
+ * Draw the orientation axes into the image. Independent of `showAxes`, which
153
+ * is about the view rather than the capture: the widget orients a reader who
154
+ * can turn the structure, and earns its place less in a still.
155
+ * @default false
156
+ */
157
+ showAxes?: boolean;
158
+ /**
159
+ * Name for the downloaded file, without an extension. Defaults to the one
160
+ * Mol* derives from the loaded structure.
161
+ */
162
+ filename?: string;
163
+ }
164
+ /** A whole-structure statistic shown along the bottom of the viewer. */
165
+ interface StructureStat {
166
+ value: string;
167
+ label: string;
168
+ }
169
+ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
170
+ /** Structure to render, as raw PDB or mmCIF (PDBx) text. */
171
+ structure: string;
172
+ /**
173
+ * Per-residue pLDDT confidence on a 0-1 scale, ordered by residue. When
174
+ * supplied the structure is colored by pLDDT unless `residueOverlay` takes
175
+ * over.
176
+ */
177
+ plddt?: number[] | null;
178
+ /**
179
+ * Canvas background, as `#RRGGBB`. Defaults to the SDS theme's base
180
+ * background, so the canvas follows the surrounding page in both modes.
181
+ */
182
+ backgroundColor?: string;
183
+ /**
184
+ * Sequence panel background, as any CSS color. Defaults to the SDS theme's
185
+ * primary surface, so the panel follows the surrounding page in both modes.
186
+ */
187
+ sequenceViewerBackgroundColor?: string;
188
+ /**
189
+ * Show the orientation axes widget and the reset-camera button.
190
+ * @default true
191
+ */
192
+ showAxes?: boolean;
193
+ /**
194
+ * Adds a capture button beneath the reset-camera control, which downloads a
195
+ * PNG of the structure as it currently stands. Omit for no button.
196
+ */
197
+ download?: StructureDownload | null;
198
+ /**
199
+ * Show the sequence panel pinned along the bottom of the viewer.
200
+ * @default true
201
+ */
202
+ showSequenceViewer?: boolean;
203
+ /**
204
+ * Show the stats and color scale legend overlaid on the viewer.
205
+ * @default true
206
+ */
207
+ showLegend?: boolean;
208
+ /** Per-residue values that override pLDDT coloring while set. */
209
+ residueOverlay?: ResidueValueOverlay | null;
210
+ /**
211
+ * What is selected, or null when nothing is. Controlled: the camera frames
212
+ * whatever the selection covers, and clearing it zooms back out to the
213
+ * default view.
214
+ *
215
+ * Residues are drawn in ball-and-stick over the cartoon; whole chains are
216
+ * left as they are and the chains around them dim, the same as hovering a
217
+ * chain's name.
218
+ */
219
+ selection?: StructureSelection | null;
220
+ /**
221
+ * Chains hidden from the 3D view, by `chainId`. Leave undefined to let the
222
+ * viewer own visibility itself, which is what the chain legend's toggles
223
+ * drive; passing it takes that over, and the toggles then only report.
224
+ */
225
+ hiddenChains?: string[];
226
+ /**
227
+ * Color per chain, by `chainId`, as `#RRGGBB`. Chains left out fall back to
228
+ * the viewer's palette. Only visible while chain coloring is what is on
229
+ * screen, which is when neither `plddt` nor `residueOverlay` is set.
230
+ */
231
+ chainColors?: Record<string, string>;
232
+ /**
233
+ * Show the chain legend, which lists each chain with its color and a
234
+ * visibility toggle. Ignored on a single-chain structure, where there is
235
+ * nothing to tell apart or hide.
236
+ * @default true
237
+ */
238
+ showChainLegend?: boolean;
239
+ /**
240
+ * Stop other chains from dimming in the 3D view while a chain's name is
241
+ * pointed at, in the legend or above its grid in the sequence panel.
242
+ *
243
+ * The dim is on by default, since on a complex it is how a reader finds out
244
+ * which chain is which. Turn it off where the movement is more distracting
245
+ * than the answer is useful - a grid of viewers a pointer crosses on its way
246
+ * somewhere else, or a page driving its own highlighting through `selection`.
247
+ * @default false
248
+ */
249
+ disableChainHighlightOnHover?: boolean;
250
+ /**
251
+ * Mol* plugin spec laid over the viewer's own, which is how the whole of
252
+ * Mol*'s configuration is reachable without a prop here for each setting.
253
+ * Anything named here wins, so `canvas3d.postprocessing`, a `PluginConfig`
254
+ * item, or `layout.initial` can all be set to something other than the
255
+ * default the viewer picked.
256
+ *
257
+ * List-valued keys - `behaviors`, `config`, `actions`, `animations`,
258
+ * `customFormats`, `customParamEditors` - are appended to rather than
259
+ * replaced. For `config` that is what lets an entry override the viewer's,
260
+ * since Mol* reads the list in order. It also means a behavior cannot be
261
+ * taken away: the ones the viewer drops stay dropped, and the ones it keeps
262
+ * cannot be removed from here.
263
+ *
264
+ * Read once, when the plugin is created, except for `canvas3d`, which is
265
+ * re-applied whenever it changes. Creating the plugin throws away the camera,
266
+ * so the rest is deliberately not reactive.
267
+ */
268
+ molstarSpec?: Partial<PluginUISpec>;
269
+ /**
270
+ * Up to three whole-structure stats shown along the bottom. A null entry
271
+ * reserves its column without rendering anything, so the columns never shift
272
+ * as values come and go.
273
+ */
274
+ stats?: (StructureStat | null)[];
275
+ /** Called with the clicked residue. */
276
+ onResidueClick?: (residue: ResidueRef) => void;
277
+ /**
278
+ * Called as the pointer moves over residues, and with `null` when it leaves
279
+ * the structure.
280
+ */
281
+ onResidueHover?: (residue: ResidueRef | null) => void;
282
+ /**
283
+ * Called with the new selection whenever the user makes one - clicking a
284
+ * residue, dragging across the sequence, clicking a chain caption - and with
285
+ * `null` when they click empty space to clear it.
286
+ *
287
+ * A whole-chain selection arrives as `{ chains: [id] }` rather than as every
288
+ * index on it, so echoing it straight back into `selection` costs nothing.
289
+ */
290
+ onSelectionChange?: (selection: StructureSelection | null) => void;
291
+ /**
292
+ * Called with the chains found in the structure, whenever a structure is
293
+ * loaded. Fires with `[]` when the structure holds none.
294
+ */
295
+ onChainsChange?: (chains: ChainRef[]) => void;
296
+ /**
297
+ * Called with the chains now hidden when a visibility toggle is used. Fires
298
+ * whether or not `hiddenChains` is controlled, so a consumer can follow the
299
+ * viewer's own state without owning it.
300
+ */
301
+ onChainVisibilityChange?: (hiddenChains: string[]) => void;
302
+ }
303
+ /**
304
+ * Readout that replaces the whole-structure stats while something is hovered
305
+ * or selected. Covers one residue or many: a drag across the sequence and a
306
+ * whole-chain selection report through this too, as a mean over what they
307
+ * cover.
308
+ */
309
+ interface ResidueReadout {
310
+ /** e.g. "PHE 17", "Chain A", or "24 residues". */
311
+ label: string;
312
+ /**
313
+ * pLDDT on a 0-1 scale, or null when unavailable. The mean across the
314
+ * residues covered when there is more than one, ignoring those without a
315
+ * score.
316
+ */
317
+ plddt: number | null;
318
+ /**
319
+ * Overlay value, or null when the overlay holds none - which is also what a
320
+ * structure paints neutral - or when no overlay is set. The mean across the
321
+ * residues covered when there is more than one, ignoring those the overlay
322
+ * says nothing about.
323
+ */
324
+ value: number | null;
325
+ /**
326
+ * Residues the readout covers, which is what makes the numbers above means
327
+ * rather than readings. 1 for a single residue.
328
+ */
329
+ residueCount: number;
330
+ }
331
+ //#endregion
332
+ //#region src/core/ProteinStructureViewer/utils/structureFormat.d.ts
333
+ /**
334
+ * Structure text formats Mol* can parse from the viewer's `structure` prop.
335
+ *
336
+ * `"mmcif"` covers both mmCIF and PDBx; they are the same text format, and
337
+ * that is the name Mol*'s trajectory parser uses. Binary CIF (`.bcif`) is not
338
+ * accepted: the prop is a string.
339
+ */
340
+ type StructureFormat = "pdb" | "mmcif";
341
+ /**
342
+ * Infers whether `text` is PDB or mmCIF (PDBx).
343
+ *
344
+ * mmCIF documents start with a `data_` block and name their coordinates
345
+ * `_atom_site.`. PDB never does either, so either marker is enough. A leading
346
+ * comment (`# ...`) before `data_` is still mmCIF.
347
+ */
348
+ declare function detectStructureFormat(text: string): StructureFormat;
349
+ //#endregion
350
+ //#region src/core/ProteinStructureViewer/utils/plddt.d.ts
351
+ /**
352
+ * AlphaFold's pLDDT confidence bands. Thresholds are on the 0-1 scale that
353
+ * `plddt` values use, ascending from lowest to highest confidence.
354
+ */
355
+ declare const PLDDT_COLOR_SCALE: ColorScale;
356
+ /**
357
+ * Rewrites a PDB file's B-factor column with pLDDT scores so Mol* can read them
358
+ * off the parsed model. B-factors occupy columns 60-66 of ATOM/HETATM lines;
359
+ * scores arrive on a 0-1 scale and are stored on the conventional 0-100 one.
360
+ * Residues past the end of `plddtValues` fall back to a mid-confidence 50.
361
+ *
362
+ * A residue is identified by chain, sequence number and insertion code. The
363
+ * code has to be part of that: `10` and `10A` are two residues, Mol* counts
364
+ * them as two, and treating them as one here would hand every residue after
365
+ * them its neighbour's score.
366
+ */
367
+ declare function injectPlddtIntoPdb(pdbData: string, plddtValues: number[]): string;
368
+ /**
369
+ * Rewrites an mmCIF (PDBx) file's `_atom_site.B_iso_or_equiv` column with
370
+ * pLDDT scores so Mol* can read them off the parsed model, the same way
371
+ * `injectPlddtIntoPdb` rewrites the PDB B-factor column. Scores arrive on a
372
+ * 0-1 scale and are stored on the conventional 0-100 one. Residues past the
373
+ * end of `plddtValues` fall back to a mid-confidence 50.
374
+ *
375
+ * If the file has no B-factor column, one is appended to the atom-site loop
376
+ * rather than leaving the scores behind.
377
+ */
378
+ declare function injectPlddtIntoMmcif(mmcifData: string, plddtValues: number[]): string;
379
+ /**
380
+ * Rewrites a structure file's B-factors with pLDDT scores. Dispatches to
381
+ * `injectPlddtIntoPdb` or `injectPlddtIntoMmcif` from `format`, or from
382
+ * detecting the format of `data` when `format` is omitted.
383
+ */
384
+ declare function injectPlddt(data: string, plddtValues: number[], format?: StructureFormat): string;
385
+ //#endregion
386
+ //#region src/core/ProteinStructureViewer/index.d.ts
387
+ declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<ProteinStructureViewerProps & import("react").RefAttributes<HTMLDivElement>>>;
388
+ //#endregion
389
+ export { StructureStat as _, injectPlddtIntoPdb as a, ChainRef as c, ProteinStructureViewerProps as d, ResidueReadout as f, StructureSelection as g, StructureDownload as h, injectPlddtIntoMmcif as i, DOWNLOAD_RESOLUTIONS as l, ResidueValueOverlay as m, PLDDT_COLOR_SCALE as n, StructureFormat as o, ResidueRef as p, injectPlddt as r, detectStructureFormat as s, _default as t, DownloadResolution as u };