@czi-sds/data-viz 2.0.0 → 2.1.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.
@@ -2,7 +2,52 @@
2
2
  import { DatasetComponentOption, ECharts, EChartsOption, ScatterSeriesOption } from "echarts";
3
3
  import { HTMLAttributes } from "react";
4
4
  import { DiscreteColorGeneratorOptions, TooltipTableContentProps } from "@czi-sds/components";
5
+ import { CustomElementProperty } from "molstar/lib/mol-model-props/common/custom-element-property";
5
6
 
7
+ //#region src/common/colorScales.d.ts
8
+ /** RGB triplet with each channel in the range 0-255. */
9
+ type Rgb = [number, number, number];
10
+ /** A stop on a continuous color scale, positioned at `t` in the range 0-1. */
11
+ interface ContinuousColorStop {
12
+ t: number;
13
+ color: string;
14
+ }
15
+ /**
16
+ * A band on a stepped color scale. `threshold` is the upper bound of the band
17
+ * on the normalized 0-1 value range; `label` is rendered above the band in the
18
+ * legend.
19
+ */
20
+ interface SteppedColorStop {
21
+ threshold: number;
22
+ color: string;
23
+ label: string;
24
+ }
25
+ /**
26
+ * How values map to colors, both in a visualization and in its legend. A
27
+ * continuous scale interpolates between its stops and renders as a gradient
28
+ * bar; a stepped scale renders as discrete bands.
29
+ */
30
+ type ColorScale = {
31
+ kind: "continuous";
32
+ stops: ContinuousColorStop[];
33
+ } | {
34
+ kind: "stepped";
35
+ stops: SteppedColorStop[];
36
+ };
37
+ /**
38
+ * Perceptually uniform sequential scale (matplotlib's plasma), the default for
39
+ * value overlays.
40
+ */
41
+ declare const PLASMA_COLOR_SCALE: ColorScale;
42
+ /**
43
+ * Colors a raw value against a scale, normalizing it into `min`-`max` first.
44
+ * Returns null when the value sits at or below `min`, or when the range is
45
+ * degenerate, so callers can fall back to a neutral color.
46
+ */
47
+ declare function sampleColorScale(scale: ColorScale, value: number, max: number, min?: number): Rgb | null;
48
+ /** CSS `linear-gradient` spanning a continuous scale, for the legend bar. */
49
+ declare function toCssGradient(stops: ContinuousColorStop[]): string;
50
+ //#endregion
6
51
  //#region src/core/HeatmapChart/hooks/utils.d.ts
7
52
  interface CreateChartOptionsProps {
8
53
  /**
@@ -182,6 +227,167 @@ interface HeatmapChartProps extends HTMLAttributes<HTMLDivElement>, CreateChartO
182
227
  }
183
228
  declare const _default: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<HeatmapChartProps & import("react").RefAttributes<HTMLDivElement>>>;
184
229
  //#endregion
230
+ //#region src/core/ProteinStructureViewer/ProteinStructureViewer.types.d.ts
231
+ /**
232
+ * Per-residue values painted onto the structure in place of the default pLDDT
233
+ * coloring, along with the legend that describes them.
234
+ */
235
+ interface ResidueValueOverlay {
236
+ /** 0-based residue index to value. Residues absent from the map read as 0. */
237
+ values: Map<number, number>;
238
+ /** Value mapped to the top of the color scale. */
239
+ max: number;
240
+ /**
241
+ * Values at or below this render in a neutral gray rather than on the scale.
242
+ * Values above it are normalized into `min`-`max` before being sampled, so
243
+ * this is also what the legend's lower tick reports.
244
+ * @default 0
245
+ */
246
+ min?: number;
247
+ /**
248
+ * Scale used to color residues and to draw the legend.
249
+ * @default PLASMA_COLOR_SCALE
250
+ */
251
+ colorScale?: ColorScale;
252
+ /** Legend caption, e.g. "Feature activation". */
253
+ label?: string;
254
+ /** Help tooltip attached to the legend caption. */
255
+ tooltip?: string;
256
+ /**
257
+ * Label for the per-residue readout that replaces a stat slot on hover.
258
+ * @default "Value"
259
+ */
260
+ readoutLabel?: string;
261
+ }
262
+ /**
263
+ * A residue the user pointed at, in each of the ways a caller might need to
264
+ * address it.
265
+ *
266
+ * `index` is the viewer's own key: the position in `plddt` and in
267
+ * `residueOverlay`'s map, and what `selectedResidue` takes. `chainId`, `seqId`
268
+ * and `insCode` are what the file says, which is what the sequence panel shows
269
+ * and what a system that supplied the structure will recognise. They differ
270
+ * from `index` whenever the file does not number a single chain from 1 -- a
271
+ * crop, or a complex -- so address a residue outside the viewer with those
272
+ * three, not with `index`.
273
+ *
274
+ * `insCode` is rarely set but is part of the address when it is: `10` and `10A`
275
+ * are different residues on the same chain, so chain and number alone do not
276
+ * name one.
277
+ */
278
+ interface ResidueRef {
279
+ /** 0-based position in the structure, counting residues in file order. */
280
+ index: number;
281
+ /** Three-letter residue code, e.g. `"LYS"`. */
282
+ compId: string;
283
+ /** Chain the residue sits on, as named in the file. */
284
+ chainId: string;
285
+ /** Residue number as written in the file. */
286
+ seqId: number;
287
+ /** Insertion code, or `""` when the residue has none. */
288
+ insCode: string;
289
+ }
290
+ /** A whole-structure statistic shown along the bottom of the viewer. */
291
+ interface StructureStat {
292
+ value: string;
293
+ label: string;
294
+ }
295
+ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
296
+ /** Structure to render, as raw PDB text. */
297
+ pdb: string;
298
+ /**
299
+ * Per-residue pLDDT confidence on a 0-1 scale, ordered by residue. When
300
+ * supplied the structure is colored by pLDDT unless `residueOverlay` takes
301
+ * over.
302
+ */
303
+ plddt?: number[] | null;
304
+ /**
305
+ * Canvas background, as `#RRGGBB`. Defaults to the SDS theme's base
306
+ * background, so the canvas follows the surrounding page in both modes.
307
+ */
308
+ backgroundColor?: string;
309
+ /**
310
+ * Sequence panel background, as any CSS color. Defaults to the SDS theme's
311
+ * primary surface, so the panel follows the surrounding page in both modes.
312
+ */
313
+ sequenceViewerBackgroundColor?: string;
314
+ /**
315
+ * Show the orientation axes widget and the reset-camera button.
316
+ * @default true
317
+ */
318
+ showAxes?: boolean;
319
+ /**
320
+ * Show the sequence panel pinned along the bottom of the viewer.
321
+ * @default true
322
+ */
323
+ showSequenceViewer?: boolean;
324
+ /**
325
+ * Show the stats and color scale legend overlaid on the viewer.
326
+ * @default true
327
+ */
328
+ showLegend?: boolean;
329
+ /** Per-residue values that override pLDDT coloring while set. */
330
+ residueOverlay?: ResidueValueOverlay | null;
331
+ /**
332
+ * 0-based index of the selected residue, or null when none is selected.
333
+ * Controlled: selecting a residue zooms the camera in on it, and clearing the
334
+ * selection zooms back out to the default view.
335
+ */
336
+ selectedResidue?: number | null;
337
+ /**
338
+ * Up to three whole-structure stats shown along the bottom. A null entry
339
+ * reserves its column without rendering anything, so the columns never shift
340
+ * as values come and go.
341
+ */
342
+ stats?: (StructureStat | null)[];
343
+ /** Called with the clicked residue. */
344
+ onResidueClick?: (residue: ResidueRef) => void;
345
+ /**
346
+ * Called as the pointer moves over residues, and with `null` when it leaves
347
+ * the structure.
348
+ */
349
+ onResidueHover?: (residue: ResidueRef | null) => void;
350
+ /** Called when the user clicks empty space, clearing the selection. */
351
+ onSelectionClear?: () => void;
352
+ }
353
+ /**
354
+ * Per-residue readout that replaces the whole-structure stats while a residue
355
+ * is hovered or selected.
356
+ */
357
+ interface ResidueReadout {
358
+ /** e.g. "PHE 17" */
359
+ label: string;
360
+ /** Residue pLDDT on a 0-1 scale, or null when unavailable. */
361
+ plddt: number | null;
362
+ /**
363
+ * Residue overlay value, or null when the overlay holds none for it - which
364
+ * is also what a structure paints neutral - or when no overlay is set.
365
+ */
366
+ value: number | null;
367
+ }
368
+ //#endregion
369
+ //#region src/core/ProteinStructureViewer/utils/plddt.d.ts
370
+ /**
371
+ * AlphaFold's pLDDT confidence bands. Thresholds are on the 0-1 scale that
372
+ * `plddt` values use, ascending from lowest to highest confidence.
373
+ */
374
+ declare const PLDDT_COLOR_SCALE: ColorScale;
375
+ /**
376
+ * Rewrites a PDB file's B-factor column with pLDDT scores so Mol* can read them
377
+ * off the parsed model. B-factors occupy columns 60-66 of ATOM/HETATM lines;
378
+ * scores arrive on a 0-1 scale and are stored on the conventional 0-100 one.
379
+ * Residues past the end of `plddtValues` fall back to a mid-confidence 50.
380
+ *
381
+ * A residue is identified by chain, sequence number and insertion code. The
382
+ * code has to be part of that: `10` and `10A` are two residues, Mol* counts
383
+ * them as two, and treating them as one here would hand every residue after
384
+ * them its neighbour's score.
385
+ */
386
+ declare function injectPlddtIntoPdb(pdbData: string, plddtValues: number[]): string;
387
+ //#endregion
388
+ //#region src/core/ProteinStructureViewer/index.d.ts
389
+ declare const _default$1: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<ProteinStructureViewerProps & import("react").RefAttributes<HTMLDivElement>>>;
390
+ //#endregion
185
391
  //#region src/core/StackedBarChart/StackedBarChart.types.d.ts
186
392
  interface StackedBarChartDataItem {
187
393
  /**
@@ -343,4 +549,4 @@ interface StackedBarChartProps extends HTMLAttributes<HTMLDivElement> {
343
549
  //#region src/core/StackedBarChart/index.d.ts
344
550
  declare const StackedBarChart: (props: StackedBarChartProps) => JSX.Element;
345
551
  //#endregion
346
- export { _default as HeatmapChart, HeatmapChartProps, StackedBarChart, type StackedBarChartDataItem, type StackedBarChartProps };
552
+ export { type ColorScale, type ContinuousColorStop, _default as HeatmapChart, HeatmapChartProps, PLASMA_COLOR_SCALE, PLDDT_COLOR_SCALE, _default$1 as ProteinStructureViewer, ProteinStructureViewerProps, ResidueReadout, ResidueRef, ResidueValueOverlay, StackedBarChart, type StackedBarChartDataItem, type StackedBarChartProps, type SteppedColorStop, StructureStat, injectPlddtIntoPdb, sampleColorScale, toCssGradient };