@czi-sds/data-viz 2.0.0 → 2.1.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.
@@ -1,8 +1,53 @@
1
1
  /// <reference types="react" />
2
2
  import { DatasetComponentOption, ECharts, EChartsOption, ScatterSeriesOption } from "echarts";
3
3
  import { HTMLAttributes } from "react";
4
- import { DiscreteColorGeneratorOptions, TooltipTableContentProps } from "@czi-sds/components";
4
+ import { DiscreteColorGeneratorOptions, TooltipProps, 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,177 @@ 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
+ /**
255
+ * Title of the help tooltip on the legend caption. The common case: a
256
+ * string is enough. Use `tooltipProps` when the tooltip needs a subtitle, a
257
+ * custom body, or any other SDS Tooltip prop. Overrides
258
+ * `tooltipProps.title` when both are set.
259
+ */
260
+ tooltip?: string;
261
+ /**
262
+ * Props forwarded to the SDS Tooltip on the legend caption. The trigger is
263
+ * the caption's help icon, so `children` is omitted.
264
+ */
265
+ tooltipProps?: Partial<Omit<TooltipProps, "children">>;
266
+ /**
267
+ * Label for the per-residue readout that replaces a stat slot on hover.
268
+ * @default "Value"
269
+ */
270
+ readoutLabel?: string;
271
+ }
272
+ /**
273
+ * A residue the user pointed at, in each of the ways a caller might need to
274
+ * address it.
275
+ *
276
+ * `index` is the viewer's own key: the position in `plddt` and in
277
+ * `residueOverlay`'s map, and what `selectedResidue` takes. `chainId`, `seqId`
278
+ * and `insCode` are what the file says, which is what the sequence panel shows
279
+ * and what a system that supplied the structure will recognise. They differ
280
+ * from `index` whenever the file does not number a single chain from 1 -- a
281
+ * crop, or a complex -- so address a residue outside the viewer with those
282
+ * three, not with `index`.
283
+ *
284
+ * `insCode` is rarely set but is part of the address when it is: `10` and `10A`
285
+ * are different residues on the same chain, so chain and number alone do not
286
+ * name one.
287
+ */
288
+ interface ResidueRef {
289
+ /** 0-based position in the structure, counting residues in file order. */
290
+ index: number;
291
+ /** Three-letter residue code, e.g. `"LYS"`. */
292
+ compId: string;
293
+ /** Chain the residue sits on, as named in the file. */
294
+ chainId: string;
295
+ /** Residue number as written in the file. */
296
+ seqId: number;
297
+ /** Insertion code, or `""` when the residue has none. */
298
+ insCode: string;
299
+ }
300
+ /** A whole-structure statistic shown along the bottom of the viewer. */
301
+ interface StructureStat {
302
+ value: string;
303
+ label: string;
304
+ }
305
+ interface ProteinStructureViewerProps extends Omit<HTMLAttributes<HTMLDivElement>, "onSelect"> {
306
+ /** Structure to render, as raw PDB text. */
307
+ pdb: string;
308
+ /**
309
+ * Per-residue pLDDT confidence on a 0-1 scale, ordered by residue. When
310
+ * supplied the structure is colored by pLDDT unless `residueOverlay` takes
311
+ * over.
312
+ */
313
+ plddt?: number[] | null;
314
+ /**
315
+ * Canvas background, as `#RRGGBB`. Defaults to the SDS theme's base
316
+ * background, so the canvas follows the surrounding page in both modes.
317
+ */
318
+ backgroundColor?: string;
319
+ /**
320
+ * Sequence panel background, as any CSS color. Defaults to the SDS theme's
321
+ * primary surface, so the panel follows the surrounding page in both modes.
322
+ */
323
+ sequenceViewerBackgroundColor?: string;
324
+ /**
325
+ * Show the orientation axes widget and the reset-camera button.
326
+ * @default true
327
+ */
328
+ showAxes?: boolean;
329
+ /**
330
+ * Show the sequence panel pinned along the bottom of the viewer.
331
+ * @default true
332
+ */
333
+ showSequenceViewer?: boolean;
334
+ /**
335
+ * Show the stats and color scale legend overlaid on the viewer.
336
+ * @default true
337
+ */
338
+ showLegend?: boolean;
339
+ /** Per-residue values that override pLDDT coloring while set. */
340
+ residueOverlay?: ResidueValueOverlay | null;
341
+ /**
342
+ * 0-based index of the selected residue, or null when none is selected.
343
+ * Controlled: selecting a residue zooms the camera in on it, and clearing the
344
+ * selection zooms back out to the default view.
345
+ */
346
+ selectedResidue?: number | null;
347
+ /**
348
+ * Up to three whole-structure stats shown along the bottom. A null entry
349
+ * reserves its column without rendering anything, so the columns never shift
350
+ * as values come and go.
351
+ */
352
+ stats?: (StructureStat | null)[];
353
+ /** Called with the clicked residue. */
354
+ onResidueClick?: (residue: ResidueRef) => void;
355
+ /**
356
+ * Called as the pointer moves over residues, and with `null` when it leaves
357
+ * the structure.
358
+ */
359
+ onResidueHover?: (residue: ResidueRef | null) => void;
360
+ /** Called when the user clicks empty space, clearing the selection. */
361
+ onSelectionClear?: () => void;
362
+ }
363
+ /**
364
+ * Per-residue readout that replaces the whole-structure stats while a residue
365
+ * is hovered or selected.
366
+ */
367
+ interface ResidueReadout {
368
+ /** e.g. "PHE 17" */
369
+ label: string;
370
+ /** Residue pLDDT on a 0-1 scale, or null when unavailable. */
371
+ plddt: number | null;
372
+ /**
373
+ * Residue overlay value, or null when the overlay holds none for it - which
374
+ * is also what a structure paints neutral - or when no overlay is set.
375
+ */
376
+ value: number | null;
377
+ }
378
+ //#endregion
379
+ //#region src/core/ProteinStructureViewer/utils/plddt.d.ts
380
+ /**
381
+ * AlphaFold's pLDDT confidence bands. Thresholds are on the 0-1 scale that
382
+ * `plddt` values use, ascending from lowest to highest confidence.
383
+ */
384
+ declare const PLDDT_COLOR_SCALE: ColorScale;
385
+ /**
386
+ * Rewrites a PDB file's B-factor column with pLDDT scores so Mol* can read them
387
+ * off the parsed model. B-factors occupy columns 60-66 of ATOM/HETATM lines;
388
+ * scores arrive on a 0-1 scale and are stored on the conventional 0-100 one.
389
+ * Residues past the end of `plddtValues` fall back to a mid-confidence 50.
390
+ *
391
+ * A residue is identified by chain, sequence number and insertion code. The
392
+ * code has to be part of that: `10` and `10A` are two residues, Mol* counts
393
+ * them as two, and treating them as one here would hand every residue after
394
+ * them its neighbour's score.
395
+ */
396
+ declare function injectPlddtIntoPdb(pdbData: string, plddtValues: number[]): string;
397
+ //#endregion
398
+ //#region src/core/ProteinStructureViewer/index.d.ts
399
+ declare const _default$1: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<ProteinStructureViewerProps & import("react").RefAttributes<HTMLDivElement>>>;
400
+ //#endregion
185
401
  //#region src/core/StackedBarChart/StackedBarChart.types.d.ts
186
402
  interface StackedBarChartDataItem {
187
403
  /**
@@ -343,4 +559,4 @@ interface StackedBarChartProps extends HTMLAttributes<HTMLDivElement> {
343
559
  //#region src/core/StackedBarChart/index.d.ts
344
560
  declare const StackedBarChart: (props: StackedBarChartProps) => JSX.Element;
345
561
  //#endregion
346
- export { _default as HeatmapChart, HeatmapChartProps, StackedBarChart, type StackedBarChartDataItem, type StackedBarChartProps };
562
+ 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 };