@czi-sds/data-viz 2.4.3 → 2.5.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.
@@ -1,9 +1,11 @@
1
- /// <reference types="react" />
2
1
  import { t as ColorScale } from "./colorScales.esm.js";
3
2
  import { HTMLAttributes } from "react";
3
+ import { PluginContext } from "molstar/lib/mol-plugin/context";
4
4
  import { TooltipProps } from "@czi-sds/components";
5
5
  import { PluginUISpec } from "molstar/lib/mol-plugin-ui/spec";
6
- import { CustomElementProperty } from "molstar/lib/mol-model-props/common/custom-element-property";
6
+ import { PluginStateObject } from "molstar/lib/mol-plugin-state/objects";
7
+ import { PluginUIContext } from "molstar/lib/mol-plugin-ui/context";
8
+ import { StateObjectSelector } from "molstar/lib/mol-state";
7
9
 
8
10
  //#region src/core/ProteinStructureViewer/ProteinStructureViewer.types.d.ts
9
11
  /**
@@ -101,6 +103,28 @@ interface ChainRef {
101
103
  /** Polymer residues the chain holds. */
102
104
  residueCount: number;
103
105
  }
106
+ /**
107
+ * A residue as the file names it: chain, number and insertion code, which is
108
+ * what a system that supplied the structure will recognise. `ResidueRef`
109
+ * reports the same three, so a residue the viewer reported can be handed back
110
+ * as one of these.
111
+ */
112
+ interface ResidueAddress {
113
+ /** Chain as named in the file (`auth_asym_id`). */
114
+ chainId: string;
115
+ /** Residue number as written in the file (`auth_seq_id`). */
116
+ seqId: number;
117
+ /** Insertion code, when the residue has one. */
118
+ insCode?: string;
119
+ }
120
+ /** A residue picked out in a color of its own, over whatever paints the rest. */
121
+ interface ResidueHighlight extends ResidueAddress {
122
+ /**
123
+ * As `#RRGGBB`. Highlights that name none take the next color of the
124
+ * viewer's highlight palette, in the order they are given.
125
+ */
126
+ color?: string;
127
+ }
104
128
  /**
105
129
  * What is selected, in the two ways a caller might say it. `null` selects
106
130
  * nothing.
@@ -118,6 +142,60 @@ interface StructureSelection {
118
142
  residues?: number[];
119
143
  /** Whole chains by `chainId`, each standing for every residue on it. */
120
144
  chains?: string[];
145
+ /**
146
+ * Residues by the address the file gives them, for a caller that knows a
147
+ * residue by its chain and number rather than by its position. They join
148
+ * `residues`, and an address the structure does not have selects nothing.
149
+ * The viewer reports its own selections as `residues`.
150
+ */
151
+ addresses?: ResidueAddress[];
152
+ }
153
+ /**
154
+ * How the polymer is drawn. `"surface"` is one molecular surface over the
155
+ * visible chains, so hiding a partner exposes the face it was bound to.
156
+ */
157
+ type StructureRepresentation = "cartoon" | "surface";
158
+ /** What paints the structure, when `colorBy` names it outright. */
159
+ type StructureColorBy = "chain" | "plddt" | "overlay";
160
+ type CameraProjection = "perspective" | "orthographic";
161
+ /**
162
+ * Where the camera looks from, relative to the highlighted residues: straight
163
+ * at them from outside the structure, from the far side, or from the side.
164
+ * `"overview"`, and any orientation while nothing is highlighted, looks down
165
+ * the view's default axis at the whole structure.
166
+ */
167
+ type CameraOrientation = "overview" | "facing" | "opposite" | "side";
168
+ /**
169
+ * Everything that places the camera, enough to put it back exactly where it
170
+ * was. What `onCameraChange` reports and `initialCamera` takes.
171
+ */
172
+ interface CameraState {
173
+ position: [number, number, number];
174
+ target: [number, number, number];
175
+ up: [number, number, number];
176
+ /** Field of view, in radians. */
177
+ fov: number;
178
+ /** Radius of the sphere around `target` the camera frames. */
179
+ radius: number;
180
+ /** Radius of the whole scene, which bounds how far the camera clips. */
181
+ radiusMax: number;
182
+ projection: CameraProjection;
183
+ /**
184
+ * Size of the canvas the camera framed, in pixels. Reported so an image can
185
+ * be rendered at the same aspect; ignored when the state is applied.
186
+ */
187
+ viewport?: {
188
+ width: number;
189
+ height: number;
190
+ };
191
+ }
192
+ /** What `onStructureLoad` reports for each structure loaded. */
193
+ interface StructureLoadInfo {
194
+ /** Atoms Mol* parsed. */
195
+ atomCount: number;
196
+ /** Polymer residues across every chain, as the chains count them. */
197
+ residueCount: number;
198
+ chains: ChainRef[];
121
199
  }
122
200
  /**
123
201
  * How large a downloaded image is, in pixels.
@@ -162,21 +240,102 @@ interface StructureDownload {
162
240
  * Mol* derives from the loaded structure.
163
241
  */
164
242
  filename?: string;
243
+ /**
244
+ * Renders the image in place of the viewer's own capture, for a caller that
245
+ * has to bound its size, keep the viewport's aspect, or draw it some other
246
+ * way. Resolves with a PNG. `resolution`, `backgroundColor` and `showAxes`
247
+ * describe the viewer's own capture, so they are not applied to this one.
248
+ */
249
+ render?: (plugin: PluginUIContext) => Promise<Blob>;
250
+ /**
251
+ * Receives the PNG in place of a browser download, along with the name it
252
+ * would have been saved under, `.png` included. A sandboxed iframe blocks the
253
+ * download a click would otherwise start, so a bridge to its host goes here.
254
+ */
255
+ deliver?: (image: Blob, filename: string) => void | Promise<void>;
165
256
  }
257
+ /**
258
+ * What a load hands to `onReady`: the structure the viewer parsed, and what it
259
+ * found in it.
260
+ */
261
+ interface LoadedStructureInfo {
262
+ /**
263
+ * The parsed structure's cell in the plugin's state tree. Components and
264
+ * representations built on it are what a consumer drawing its own scene
265
+ * adds; they go when the next structure is loaded, along with the rest of
266
+ * the tree.
267
+ */
268
+ structure: StateObjectSelector<PluginStateObject.Molecule.Structure>;
269
+ /**
270
+ * Atoms Mol* parsed. A consumer holding a known count for the file can check
271
+ * the parse against it before trusting what is drawn.
272
+ */
273
+ atomCount: number;
274
+ /** The polymer chains found, as `onChainsChange` reports them. */
275
+ chains: ChainRef[];
276
+ }
277
+ /**
278
+ * Which part of the viewer's work an error reported to `onError` came from.
279
+ * `"representation"` is a representation that could not be drawn - a surface
280
+ * too large for its grid - which leaves the cartoon in its place.
281
+ */
282
+ type ViewerErrorPhase = "init" | "load" | "capture" | "representation";
283
+ /**
284
+ * Who draws the structure: the viewer, from its props, or a consumer building
285
+ * its own scene on the structure `onReady` hands it.
286
+ */
287
+ type SceneMode = "managed" | "external";
166
288
  /** A whole-structure statistic shown along the bottom of the viewer. */
167
289
  interface StructureStat {
168
290
  value: string;
169
291
  label: string;
170
292
  }
171
- interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
293
+ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "onError" | "onSelect"> {
172
294
  /** Structure to render, as raw PDB or mmCIF (PDBx) text. */
173
295
  structure: string;
174
296
  /**
175
297
  * Per-residue pLDDT confidence on a 0-1 scale, ordered by residue. When
176
298
  * supplied the structure is colored by pLDDT unless `residueOverlay` takes
177
- * over.
299
+ * over. A `null` entry, and every residue past the end, reads as unscored
300
+ * and is painted neutral rather than at the bottom of the scale.
301
+ */
302
+ plddt?: (number | null)[] | null;
303
+ /**
304
+ * What paints the structure. Left undefined it follows what is supplied: a
305
+ * `residueOverlay` when there is one, then `plddt`, then the chain colors.
306
+ * Naming one makes it paint whatever else is set, which is how a toggle
307
+ * between confidence and chain coloring keeps both props in place. A theme
308
+ * with nothing to paint with leaves every residue neutral.
309
+ */
310
+ colorBy?: StructureColorBy;
311
+ /**
312
+ * How the polymer is drawn. Ligands stay ball-and-stick either way.
313
+ * Switching leaves the camera where it is.
314
+ * @default "cartoon"
315
+ */
316
+ representation?: StructureRepresentation;
317
+ /**
318
+ * Residues picked out in colors of their own, by the address the file gives
319
+ * them. They paint over whatever colors the rest - chain, pLDDT or overlay -
320
+ * and are drawn in ball-and-stick over the cartoon; on a surface, the
321
+ * surface itself carries them. Separate from `selection`: highlighting a
322
+ * residue neither selects it nor moves the camera.
323
+ */
324
+ highlights?: ResidueHighlight[];
325
+ /** The camera's projection. Left undefined, Mol*'s own default stands. */
326
+ projection?: CameraProjection;
327
+ /**
328
+ * Where the camera starts on each structure loaded, in place of fitting it
329
+ * to the structure. Applied once per load; moving the camera afterwards is
330
+ * the user's.
331
+ */
332
+ initialCamera?: CameraState | null;
333
+ /**
334
+ * Turns the camera to look at the highlighted residues from one side or
335
+ * another. Applied when a structure is loaded, unless `initialCamera` is
336
+ * set, and whenever it changes - not when the highlights do.
178
337
  */
179
- plddt?: number[] | null;
338
+ orientation?: CameraOrientation;
180
339
  /**
181
340
  * Canvas background, as `#RRGGBB`. Defaults to the SDS theme's base
182
341
  * background, so the canvas follows the surrounding page in both modes.
@@ -230,7 +389,8 @@ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement
230
389
  /**
231
390
  * Color per chain, by `chainId`, as `#RRGGBB`. Chains left out fall back to
232
391
  * the viewer's palette. Only visible while chain coloring is what is on
233
- * screen, which is when neither `plddt` nor `residueOverlay` is set.
392
+ * screen: when `colorBy` says so, or, left undefined, when neither `plddt`
393
+ * nor `residueOverlay` is set.
234
394
  */
235
395
  chainColors?: Record<string, string>;
236
396
  /**
@@ -270,6 +430,52 @@ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement
270
430
  * so the rest is deliberately not reactive.
271
431
  */
272
432
  molstarSpec?: Partial<PluginUISpec>;
433
+ /**
434
+ * Who draws the structure.
435
+ *
436
+ * `"managed"` draws each chain as a cartoon and its ligands as
437
+ * ball-and-stick, colors them from `plddt`, `residueOverlay` and
438
+ * `chainColors`, hides the chains `hiddenChains` names, and frames the camera
439
+ * on each structure it loads.
440
+ *
441
+ * `"external"` parses the structure and stops there: nothing is drawn,
442
+ * colored, hidden or framed, and a consumer draws its own scene on the
443
+ * structure `onReady` hands it. The sequence panel, selection, hover, legend
444
+ * and camera controls work as before; the legend describes the props rather
445
+ * than what the consumer drew, and its chain toggles report through
446
+ * `onChainVisibilityChange` without hiding anything. Mol* frames the camera
447
+ * on the first representation drawn into the empty scene.
448
+ *
449
+ * Read once, when the plugin is created.
450
+ * @default "managed"
451
+ */
452
+ sceneMode?: SceneMode;
453
+ /**
454
+ * Called with the Mol* plugin once a structure is loaded into it, and again
455
+ * for each structure that replaces it, which is how a consumer reaches the
456
+ * plugin to draw on it or drive it directly.
457
+ *
458
+ * Called once the viewer has drawn its own scene, and awaited before it
459
+ * starts answering clicks and hovers, so a scene built here is in place
460
+ * before a click reaches it. The viewer only ever recolors, hides or
461
+ * replaces the components it built itself, so representations added here
462
+ * are left as they were made. Not called for a structure that failed to
463
+ * load, or for a plugin the viewer disposed of first.
464
+ */
465
+ onReady?: (plugin: PluginUIContext, loaded: LoadedStructureInfo) => void | Promise<void>;
466
+ /**
467
+ * Called when creating the plugin, loading a structure, capturing an image or
468
+ * drawing a representation fails, in place of the message the viewer would
469
+ * otherwise log. A rejected `onReady` is reported as a `"load"` failure.
470
+ * Nothing is reported for a plugin the viewer has already disposed of.
471
+ */
472
+ onError?: (error: unknown, phase: ViewerErrorPhase) => void;
473
+ /**
474
+ * Called before the viewer disposes of a plugin it handed to `onReady`,
475
+ * including one whose `onReady` has not finished, so that whatever was built
476
+ * on it can be let go.
477
+ */
478
+ onDispose?: () => void;
273
479
  /**
274
480
  * Up to three whole-structure stats shown along the bottom. A null entry
275
481
  * reserves its column without rendering anything, so the columns never shift
@@ -299,6 +505,18 @@ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement
299
505
  * loaded. Fires with `[]` when the structure holds none.
300
506
  */
301
507
  onChainsChange?: (chains: ChainRef[]) => void;
508
+ /**
509
+ * Called for every structure that loads, reloads included - unlike
510
+ * `onChainsChange`, which stays quiet when the chains come back the same.
511
+ * What a consumer tracking "loading" and "ready" states listens for.
512
+ */
513
+ onStructureLoad?: (info: StructureLoadInfo) => void;
514
+ /**
515
+ * Called with the camera each time it comes to rest after moving, whether a
516
+ * drag, a zoom, a selection framing it, or a new structure fitting it. The
517
+ * state can be handed back as `initialCamera` to restore the view.
518
+ */
519
+ onCameraChange?: (camera: CameraState) => void;
302
520
  /**
303
521
  * Called with the chains now hidden when a visibility toggle is used. Fires
304
522
  * whether or not `hiddenChains` is controlled, so a consumer can follow the
@@ -306,6 +524,64 @@ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement
306
524
  */
307
525
  onChainVisibilityChange?: (hiddenChains: string[]) => void;
308
526
  }
527
+ /**
528
+ * A structure and how to draw it, as the viewer's props describe it - for a
529
+ * scene drawn on a plugin of the caller's, or rendered straight to an image,
530
+ * with no viewer involved. Each field means what the prop of the same name
531
+ * means.
532
+ */
533
+ interface StructureSceneOptions {
534
+ /** Structure to draw, as raw PDB or mmCIF (PDBx) text. */
535
+ structure: string;
536
+ plddt?: (number | null)[] | null;
537
+ residueOverlay?: ResidueValueOverlay | null;
538
+ colorBy?: StructureColorBy;
539
+ chainColors?: Record<string, string>;
540
+ representation?: StructureRepresentation;
541
+ highlights?: ResidueHighlight[];
542
+ hiddenChains?: string[];
543
+ initialCamera?: CameraState | null;
544
+ orientation?: CameraOrientation;
545
+ projection?: CameraProjection;
546
+ /**
547
+ * Which of the light or dark neutral grays a residue without a value is
548
+ * painted in.
549
+ * @default "light"
550
+ */
551
+ mode?: "light" | "dark";
552
+ /**
553
+ * Told when a representation cannot be drawn - a surface too large for its
554
+ * grid, which leaves the cartoon in its place. A structure that fails to
555
+ * load rejects instead.
556
+ */
557
+ onError?: (error: unknown, phase: ViewerErrorPhase) => void;
558
+ }
559
+ /** A scene drawn on a plugin by `applyStructureScene`. */
560
+ interface StructureSceneHandle {
561
+ /** What the structure last loaded holds. */
562
+ readonly info: StructureLoadInfo;
563
+ /**
564
+ * Applies new options in place, leaving the camera where it is. A new
565
+ * `structure` is loaded, and the camera placed on it, as the first was.
566
+ */
567
+ update: (options: Partial<StructureSceneOptions>) => Promise<void>;
568
+ /** Where the camera is now, in the form `initialCamera` takes. */
569
+ getCamera: () => CameraState | undefined;
570
+ /**
571
+ * Stops the scene touching the plugin. The plugin, and what was drawn on
572
+ * it, stay the caller's.
573
+ */
574
+ dispose: () => void;
575
+ }
576
+ /** What `renderStructureImage` draws, and the image it draws it into. */
577
+ interface RenderStructureImageOptions extends StructureSceneOptions {
578
+ /** Width of the image, in pixels. */
579
+ width: number;
580
+ /** Height of the image, in pixels. */
581
+ height: number;
582
+ /** Background behind the structure, as `#RRGGBB`. Omit for transparent. */
583
+ backgroundColor?: string;
584
+ }
309
585
  /**
310
586
  * Readout that replaces the whole-structure stats while something is hovered
311
587
  * or selected. Covers one residue or many: a drag across the sequence and a
@@ -335,61 +611,35 @@ interface ResidueReadout {
335
611
  residueCount: number;
336
612
  }
337
613
  //#endregion
338
- //#region src/core/ProteinStructureViewer/utils/structureFormat.d.ts
339
- /**
340
- * Structure text formats Mol* can parse from the viewer's `structure` prop.
341
- *
342
- * `"mmcif"` covers both mmCIF and PDBx; they are the same text format, and
343
- * that is the name Mol*'s trajectory parser uses. Binary CIF (`.bcif`) is not
344
- * accepted: the prop is a string.
345
- */
346
- type StructureFormat = "pdb" | "mmcif";
614
+ //#region src/core/ProteinStructureViewer/scene/applyStructureScene.d.ts
347
615
  /**
348
- * Infers whether `text` is PDB or mmCIF (PDBx).
616
+ * Draws a structure on a Mol* plugin of your own, the way the viewer draws it:
617
+ * the same representations, coloring, highlights and camera, from the same
618
+ * options its props take. Works on any plugin - one rendering offscreen, one
619
+ * inside a viewer of your own - and resolves once the structure is drawn and
620
+ * the camera placed on it.
349
621
  *
350
- * mmCIF documents start with a `data_` block and name their coordinates
351
- * `_atom_site.`. PDB never does either, so either marker is enough. A leading
352
- * comment (`# ...`) before `data_` is still mmCIF.
622
+ * The scene clears the plugin's state to load the structure, and keeps what it
623
+ * draws in line with `update` from then on. It adds nothing to the plugin
624
+ * beyond the structure and its representations, and three color themes
625
+ * registered once per plugin.
353
626
  */
354
- declare function detectStructureFormat(text: string): StructureFormat;
627
+ declare function applyStructureScene(plugin: PluginContext, options: StructureSceneOptions): Promise<StructureSceneHandle>;
355
628
  //#endregion
356
- //#region src/core/ProteinStructureViewer/utils/plddt.d.ts
357
- /**
358
- * AlphaFold's pLDDT confidence bands. Thresholds are on the 0-1 scale that
359
- * `plddt` values use, ascending from lowest to highest confidence.
360
- */
361
- declare const PLDDT_COLOR_SCALE: ColorScale;
629
+ //#region src/core/ProteinStructureViewer/scene/renderStructureImage.d.ts
362
630
  /**
363
- * Rewrites a PDB file's B-factor column with pLDDT scores so Mol* can read them
364
- * off the parsed model. B-factors occupy columns 60-66 of ATOM/HETATM lines;
365
- * scores arrive on a 0-1 scale and are stored on the conventional 0-100 one.
366
- * Residues past the end of `plddtValues` fall back to a mid-confidence 50.
631
+ * Renders a structure to a PNG without a viewer on the page, drawn exactly as
632
+ * the viewer would draw it from the same options - the image a caller can show
633
+ * beside the interactive view, or hand to someone who cannot open one.
367
634
  *
368
- * A residue is identified by chain, sequence number and insertion code. The
369
- * code has to be part of that: `10` and `10A` are two residues, Mol* counts
370
- * them as two, and treating them as one here would hand every residue after
371
- * them its neighbour's score.
372
- */
373
- declare function injectPlddtIntoPdb(pdbData: string, plddtValues: number[]): string;
374
- /**
375
- * Rewrites an mmCIF (PDBx) file's `_atom_site.B_iso_or_equiv` column with
376
- * pLDDT scores so Mol* can read them off the parsed model, the same way
377
- * `injectPlddtIntoPdb` rewrites the PDB B-factor column. Scores arrive on a
378
- * 0-1 scale and are stored on the conventional 0-100 one. Residues past the
379
- * end of `plddtValues` fall back to a mid-confidence 50.
635
+ * A plugin is created for the one image, offscreen, and disposed of once it is
636
+ * taken, whether or not taking it succeeded. The image is `width` by `height`
637
+ * exactly: rendered at that size rather than scaled, and not cropped to the
638
+ * structure.
380
639
  *
381
- * If the file has no B-factor column, one is appended to the atom-site loop
382
- * rather than leaving the scores behind.
640
+ * It needs a DOM and WebGL - a browser, or headless Chromium - and rejects
641
+ * when there is no WebGL to render with.
383
642
  */
384
- declare function injectPlddtIntoMmcif(mmcifData: string, plddtValues: number[]): string;
385
- /**
386
- * Rewrites a structure file's B-factors with pLDDT scores. Dispatches to
387
- * `injectPlddtIntoPdb` or `injectPlddtIntoMmcif` from `format`, or from
388
- * detecting the format of `data` when `format` is omitted.
389
- */
390
- declare function injectPlddt(data: string, plddtValues: number[], format?: StructureFormat): string;
391
- //#endregion
392
- //#region src/core/ProteinStructureViewer/index.d.ts
393
- declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<ProteinStructureViewerProps & import("react").RefAttributes<HTMLDivElement>>>;
643
+ declare function renderStructureImage(options: RenderStructureImageOptions): Promise<Blob>;
394
644
  //#endregion
395
- 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 };
645
+ export { StructureSceneOptions as C, ViewerErrorPhase as E, StructureSceneHandle as S, StructureStat as T, SceneMode as _, CameraState as a, StructureLoadInfo as b, DownloadResolution as c, RenderStructureImageOptions as d, ResidueAddress as f, ResidueValueOverlay as g, ResidueRef as h, CameraProjection as i, LoadedStructureInfo as l, ResidueReadout as m, applyStructureScene as n, ChainRef as o, ResidueHighlight as p, CameraOrientation as r, DOWNLOAD_RESOLUTIONS as s, renderStructureImage as t, ProteinStructureViewerProps as u, StructureColorBy as v, StructureSelection as w, StructureRepresentation as x, StructureDownload as y };
@@ -1,166 +1,69 @@
1
1
  /// <reference types="react" />
2
- import { HTMLAttributes } from "react";
3
- import { DiscreteColorGeneratorOptions, TooltipTableContentProps } from "@czi-sds/components";
4
-
5
- //#region src/core/StackedBarChart/StackedBarChart.types.d.ts
6
- interface StackedBarChartDataItem {
7
- /**
8
- * The segment's label in the legend, and the key the animations track it by.
9
- * Must be unique within the chart.
10
- */
11
- name: string;
12
- /**
13
- * The quantity the segment stands for.
14
- */
15
- value: number;
16
- /**
17
- * Any CSS color. Without it the segment takes a generated palette color,
18
- * which can shift as categories come and go.
19
- */
20
- color?: string;
21
- /**
22
- * A unit for this item's counted value, for data that mixes units across
23
- * categories.
24
- */
25
- unit?: string;
26
- /**
27
- * Takes the segment and its legend item out of every interaction: no hover,
28
- * no tooltip, no selection.
29
- * @default false
30
- */
31
- disabled?: boolean;
32
- /**
33
- * Content for a TooltipTable shown above the segment on hover. Use it for the
34
- * breakdown behind the number; a segment without it has no tooltip.
35
- */
36
- tooltip?: TooltipTableContentProps;
37
- }
38
- interface StackedBarChartProps extends HTMLAttributes<HTMLDivElement> {
39
- /**
40
- * A heading above the bar. It is also what makes room for the badge; with no
41
- * title, no badge is drawn.
42
- */
43
- title?: string;
44
- /**
45
- * Overrides the badge text, which otherwise counts the data and the selection
46
- * ("7", or "3 of 7").
47
- */
48
- badge?: string;
49
- /**
50
- * Removes the badge, leaving the title on its own.
51
- * @default false
52
- */
53
- hideBadge?: boolean;
54
- /**
55
- * The segments, in the order they are drawn.
56
- */
57
- data: StackedBarChartDataItem[];
58
- /**
59
- * Any CSS width; a number is read as pixels. It sets the width of the whole
60
- * chart, legend included.
61
- * @default 100%
62
- */
63
- width?: number | string;
64
- /**
65
- * Height of the bar in pixels. Values below 1 are clamped to 1, so the bar
66
- * cannot disappear.
67
- * @default 16
68
- */
69
- barHeight?: number;
70
- /**
71
- * Draws the legend below the bar. It is the only place segment names appear,
72
- * and the only part of the chart a keyboard can reach.
73
- * @default true
74
- */
75
- showLegend?: boolean;
76
- /**
77
- * Shows each item's value beside its name in the legend.
78
- * @default true
79
- */
80
- showLegendValues?: boolean;
81
- /**
82
- * "percentage" shows the segment's share of the bar, rounded. "count" shows
83
- * the raw value followed by the item's unit, or the chart's unit if the item
84
- * has none.
85
- * @default "percentage"
86
- */
87
- legendValueFormat?: "percentage" | "count";
88
- /**
89
- * Indices into data that are currently selected. The chart is controlled: it
90
- * draws this and never changes it.
91
- */
92
- selectedIndices?: number[];
93
- /**
94
- * Called with the next selection when a segment or legend item is clicked.
95
- * Without it, clicking selects nothing.
96
- */
97
- onSelectionChange?: (selectedIndices: number[], selectedData: StackedBarChartDataItem[]) => void;
98
- /**
99
- * Called when the pointer enters a segment. The chart already syncs its own
100
- * hover highlight between bar and legend, so this is for driving something
101
- * outside it.
102
- */
103
- onSegmentMouseEnter?: (item: StackedBarChartDataItem, index: number) => void;
104
- /**
105
- * Called when the pointer leaves a segment.
106
- */
107
- onSegmentMouseLeave?: (item: StackedBarChartDataItem, index: number) => void;
108
- /**
109
- * Called when the pointer enters a legend item.
110
- */
111
- onLegendItemMouseEnter?: (item: StackedBarChartDataItem, index: number) => void;
112
- /**
113
- * Called when the pointer leaves a legend item.
114
- */
115
- onLegendItemMouseLeave?: (item: StackedBarChartDataItem, index: number) => void;
116
- /**
117
- * Fires on a segment click, alongside any selection change rather than
118
- * instead of it.
119
- */
120
- onSegmentClick?: (item: StackedBarChartDataItem, index: number) => void;
121
- /**
122
- * The same, for a click on a legend item.
123
- */
124
- onLegendItemClick?: (item: StackedBarChartDataItem, index: number) => void;
125
- /**
126
- * What a selection does to the unselected segments: fade them to 20% opacity,
127
- * or drop them from the bar and let the rest take the space.
128
- * @default "dim"
129
- */
130
- selectionBehavior?: "dim" | "hide";
131
- /**
132
- * Whether the bar shows a breakdown of the data (segments always fill it) or
133
- * progress towards maxAmount.
134
- * @default "proportional"
135
- */
136
- mode?: "proportional" | "cumulative";
137
- /**
138
- * Cumulative mode only. The value the full bar represents. Any difference
139
- * between it and the sum of the data is drawn as the Remaining segment.
140
- */
141
- maxAmount?: number;
142
- /**
143
- * Name of the grey gap segment in cumulative mode.
144
- * @default "Remaining"
145
- */
146
- remainingLabel?: string;
147
- /**
148
- * A unit for the Remaining segment's value alone.
149
- */
150
- remainingUnit?: string;
151
- /**
152
- * The unit appended to counted values, for items that do not carry one of
153
- * their own.
154
- */
155
- unit?: string;
156
- /**
157
- * Tunes the generated palette (start hue, rotations, lightness range, gamma).
158
- * Items with their own color are untouched by it.
159
- */
160
- colorGeneratorOptions?: DiscreteColorGeneratorOptions;
161
- }
2
+ import { t as ColorScale } from "./colorScales.cjs.js";
3
+ import { u as ProteinStructureViewerProps } from "./index2.cjs.js";
4
+ //#region src/core/ProteinStructureViewer/utils/structureFormat.d.ts
5
+ /**
6
+ * Structure text formats Mol* can parse from the viewer's `structure` prop.
7
+ *
8
+ * `"mmcif"` covers both mmCIF and PDBx; they are the same text format, and
9
+ * that is the name Mol*'s trajectory parser uses. Binary CIF (`.bcif`) is not
10
+ * accepted: the prop is a string.
11
+ */
12
+ type StructureFormat = "pdb" | "mmcif";
13
+ /**
14
+ * Infers whether `text` is PDB or mmCIF (PDBx).
15
+ *
16
+ * mmCIF documents start with a `data_` block and name their coordinates
17
+ * `_atom_site.`. PDB never does either, so either marker is enough. A leading
18
+ * comment (`# ...`) before `data_` is still mmCIF.
19
+ */
20
+ declare function detectStructureFormat(text: string): StructureFormat;
162
21
  //#endregion
163
- //#region src/core/StackedBarChart/index.d.ts
164
- declare const StackedBarChart: (props: StackedBarChartProps) => JSX.Element;
22
+ //#region src/core/ProteinStructureViewer/utils/plddt.d.ts
23
+ /**
24
+ * AlphaFold's pLDDT confidence bands. Thresholds are on the 0-1 scale that
25
+ * `plddt` values use, ascending from lowest to highest confidence.
26
+ */
27
+ declare const PLDDT_COLOR_SCALE: ColorScale;
28
+ /**
29
+ * Rewrites a PDB file's B-factor column with pLDDT scores so Mol* can read them
30
+ * off the parsed model. B-factors occupy columns 60-66 of ATOM/HETATM lines;
31
+ * scores arrive on a 0-1 scale and are stored on the conventional 0-100 one.
32
+ * Residues past the end of `plddtValues` fall back to a mid-confidence 50.
33
+ *
34
+ * A residue is identified by chain, sequence number and insertion code. The
35
+ * code has to be part of that: `10` and `10A` are two residues, Mol* counts
36
+ * them as two, and treating them as one here would hand every residue after
37
+ * them its neighbour's score.
38
+ */
39
+ declare function injectPlddtIntoPdb(pdbData: string, plddtValues: number[]): string;
40
+ /**
41
+ * Rewrites an mmCIF (PDBx) file's `_atom_site.B_iso_or_equiv` column with
42
+ * pLDDT scores so Mol* can read them off the parsed model, the same way
43
+ * `injectPlddtIntoPdb` rewrites the PDB B-factor column. Scores arrive on a
44
+ * 0-1 scale and are stored on the conventional 0-100 one. Residues past the
45
+ * end of `plddtValues` fall back to a mid-confidence 50.
46
+ *
47
+ * If the file has no B-factor column, one is appended to the atom-site loop
48
+ * rather than leaving the scores behind.
49
+ */
50
+ declare function injectPlddtIntoMmcif(mmcifData: string, plddtValues: number[]): string;
51
+ /**
52
+ * Rewrites a structure file's B-factors with pLDDT scores. Dispatches to
53
+ * `injectPlddtIntoPdb` or `injectPlddtIntoMmcif` from `format`, or from
54
+ * detecting the format of `data` when `format` is omitted.
55
+ */
56
+ declare function injectPlddt(data: string, plddtValues: number[], format?: StructureFormat): string;
165
57
  //#endregion
166
- export { StackedBarChartDataItem as n, StackedBarChartProps as r, StackedBarChart as t };
58
+ //#region src/core/ProteinStructureViewer/utils/highlights.d.ts
59
+ /**
60
+ * Colors for highlights that name none, in the order the highlights are given.
61
+ * Saturated enough to stand out over a chain, pLDDT or overlay coloring, and
62
+ * wrapping around once they run out.
63
+ */
64
+ declare const HIGHLIGHT_COLOR_PALETTE: readonly ["#E64545", "#F0C229", "#12A9A0", "#BD57D4", "#FF8A32", "#559DF3"];
65
+ //#endregion
66
+ //#region src/core/ProteinStructureViewer/index.d.ts
67
+ declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<ProteinStructureViewerProps & import("react").RefAttributes<HTMLDivElement>>>;
68
+ //#endregion
69
+ export { injectPlddtIntoMmcif as a, detectStructureFormat as c, injectPlddt as i, HIGHLIGHT_COLOR_PALETTE as n, injectPlddtIntoPdb as o, PLDDT_COLOR_SCALE as r, StructureFormat as s, _default as t };