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