@datagrok/curves 1.10.12 → 1.10.13

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 (48) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/package-test.js +470 -4270
  3. package/dist/package-test.js.map +1 -1
  4. package/dist/package.js +254 -3895
  5. package/dist/package.js.map +1 -1
  6. package/package.json +4 -4
  7. package/src/fit/fit-demo.ts +1 -1
  8. package/src/fit/fit-grid-cell-handler.ts +385 -385
  9. package/src/fit/fit-inspection.ts +39 -0
  10. package/src/fit/fit-renderer.ts +1 -8
  11. package/src/fit/multi-curve-viewer.ts +1 -3
  12. package/src/fit/render-utils.ts +4 -2
  13. package/src/package-api.ts +2 -125
  14. package/src/package-test.ts +2 -3
  15. package/src/package.g.ts +0 -82
  16. package/src/package.ts +21 -128
  17. package/src/tests/curves-cell-renderer-tests.ts +15 -15
  18. package/src/tests/detector-tests.ts +1 -1
  19. package/src/tests/transform-tests.ts +1 -1
  20. package/test-console-output-1.log +22 -242
  21. package/test-record-1.mp4 +0 -0
  22. package/databases/plates/0000_init.sql +0 -167
  23. package/queries/plates-crud.sql +0 -148
  24. package/src/fit/const.ts +0 -73
  25. package/src/plate/excel-plates.ts +0 -112
  26. package/src/plate/plate-cell-renderer.ts +0 -50
  27. package/src/plate/plate-drc-analysis.ts +0 -262
  28. package/src/plate/plate-reader.ts +0 -28
  29. package/src/plate/plate-well-validators.ts +0 -41
  30. package/src/plate/plate-widget.ts +0 -242
  31. package/src/plate/plate.ts +0 -557
  32. package/src/plate/plates-folder-preview.ts +0 -63
  33. package/src/plate/readers/bmg-pherastar-96.ts +0 -42
  34. package/src/plate/readers/delfia-envision-96-max-rlu.ts +0 -16
  35. package/src/plate/readers/delfia-envision-by-row.ts +0 -18
  36. package/src/plate/readers/spectramax.ts +0 -42
  37. package/src/plate/utils.ts +0 -141
  38. package/src/plates/numeric_matcher.ts +0 -191
  39. package/src/plates/objects/plate-template-handler.ts +0 -48
  40. package/src/plates/plates-app.ts +0 -64
  41. package/src/plates/plates-crud.ts +0 -502
  42. package/src/plates/plates-demo.ts +0 -107
  43. package/src/plates/plates.sql +0 -169
  44. package/src/plates/views/plates-create-view.ts +0 -123
  45. package/src/plates/views/plates-schema-view.ts +0 -58
  46. package/src/plates/views/plates-search-view.ts +0 -137
  47. package/src/plates/views/plates-templates-view.ts +0 -37
  48. package/src/tests/plate-tests.ts +0 -153
@@ -1,41 +0,0 @@
1
- import { Plate } from "./plate";
2
-
3
- export interface IPlateWellValidator {
4
- name: string;
5
- description: string;
6
- validate(plate: Plate, row: number, col: number): string | null;
7
- }
8
-
9
- export const plateWellValidators: IPlateWellValidator[] = [
10
- {
11
- name: 'Concentration and volume go together',
12
- description: 'Concentration and volume should either be both present or both absent',
13
- validate: (plate: Plate, row: number, col: number) => {
14
- if (!plate.data.col('concentration') || !plate.data.col('volume'))
15
- return null;
16
-
17
- const concentration = plate.get('concentration', row, col);
18
- const volume = plate.get('volume', row, col);
19
-
20
- if ((concentration && !volume) || (!concentration && volume))
21
- return 'Concentration and volume should either be both present or both absent';
22
-
23
- return null;
24
- },
25
- },
26
-
27
- {
28
- name: 'Concentration is not negative',
29
- description: 'Concentration should not be negative',
30
- validate: (plate: Plate, row: number, col: number) => {
31
- if (!plate.data.col('concentration'))
32
- return null;
33
-
34
- const concentration = plate.get('concentration', row, col);
35
- if (concentration != null && concentration < 0)
36
- return 'Concentration should not be negative';
37
-
38
- return null;
39
- },
40
- },
41
- ];
@@ -1,242 +0,0 @@
1
- /* eslint-disable max-len */
2
- import * as DG from 'datagrok-api/dg';
3
- import {MARKER_TYPE, TYPE} from 'datagrok-api/dg';
4
- import * as ui from 'datagrok-api/ui';
5
- import {div} from 'datagrok-api/ui';
6
- import {mapFromRow, safeLog, toExcelPosition} from './utils';
7
- import {Plate, PLATE_OUTLIER_WELL_NAME} from './plate';
8
- //@ts-ignore
9
- import * as jStat from 'jstat';
10
- import {IPlateWellValidator, plateWellValidators} from './plate-well-validators';
11
- import {debounceTime, filter} from 'rxjs/operators';
12
-
13
-
14
- export type AnalysisOptions = {
15
- roleName: string,
16
- concentrationName: string,
17
- valueName: string
18
- controlColumns: string[],
19
- normalize: boolean,
20
- autoFilterOutliers: boolean,
21
- submitAction?: (plate: Plate, curvesDf: DG.DataFrame) => void,
22
- categorizeFormula: string,
23
- statisticsColumns: string[],
24
- plateStatistics?: {[key: string]: (plate: Plate) => string | number}
25
- }
26
-
27
-
28
- const colorScheme = [DG.Color.white, DG.Color.gray];
29
- export const dimensions = new Map([
30
- [96, {rows: 8, cols: 12}],
31
- [384, {rows: 16, cols: 24}],
32
- [1536, {rows: 32, cols: 48}],
33
- ]);
34
-
35
- /** Visualizes multiple layers of {@link Plate} in tabbed interface and lets you edit it */
36
- export class PlateWidget extends DG.Widget {
37
- _colorColumn?: DG.Column | undefined;
38
- _plate: Plate = new Plate(8, 12);
39
- grid: DG.Grid = DG.Viewer.heatMap(DG.DataFrame.create());
40
- colorColumnName: string = '';
41
- colorSelector?: DG.InputBase;
42
- detailsDiv?: HTMLElement;
43
- wellDetailsDiv?: HTMLElement;
44
- plateDetailsDiv?: HTMLElement;
45
- plateActionsDiv?: HTMLElement;
46
- tabs: DG.TabControl = DG.TabControl.create();
47
- tabsContainer: HTMLElement = ui.divH([], 'curves-plate-tabs-container');
48
- _editable: boolean = false;
49
- mapFromRowFunc: (row: DG.Row) => Record<string, any> = mapFromRow;
50
- grids: Map<string, DG.Grid> = new Map();
51
- wellValidators: IPlateWellValidator[] = plateWellValidators;
52
- wellValidationErrors: Map<string, string[]> = new Map();
53
-
54
- get editable() { return this._editable; }
55
- set editable(x: boolean) {
56
- this._editable = x;
57
- this.syncGrids();
58
- }
59
-
60
- constructor() {
61
- super(ui.div([], 'curves-plate-widget'));
62
-
63
- this.tabs.root.style.flexGrow = '1';
64
- // this.tabs.root.style.height = '100%';
65
- //this.tabs.addPane('Summary', () => this.grid.root);
66
-
67
- this.tabsContainer.appendChild(this.tabs.root);
68
- this.root.appendChild(this.tabsContainer);
69
-
70
- this.grid.props.showHeatmapScrollbars = false;
71
- this.grid.props.colHeaderHeight = 30;
72
- this.grid.onCellRender.subscribe((args) => this.renderCell(args, true));
73
- this.grid.onCellRendered.subscribe((args) => {
74
- const cell = args.cell;
75
- if (cell.gridRow >= 0 && cell.gridColumn.idx > 0) {
76
- try {
77
- const pos = toExcelPosition(cell.gridRow, cell.gridColumn.idx - 1);
78
- const errors = this.wellValidationErrors.get(pos);
79
- if (errors && errors.length > 0)
80
- DG.Paint.marker(args.g, DG.MARKER_TYPE.CROSS_BORDER, cell.bounds.midX, cell.bounds.midY, DG.Color.red, 10);
81
- } catch (e) {
82
- console.error(e);
83
- }
84
- }
85
- });
86
- }
87
-
88
- static fromPlate(plate: Plate) {
89
- return PlateWidget.detailedView(plate);
90
- }
91
-
92
- static detailedView(plate: Plate): PlateWidget {
93
- const pw = new PlateWidget();
94
- pw.grid.root.style.width = '100%';
95
- pw.plate = plate;
96
- pw.colorSelector = ui.input.column('Color by', {
97
- table: plate.data,
98
- value: pw._colorColumn,
99
- onValueChanged: (v) => { pw._colorColumn = v; pw.grid.invalidate(); }
100
- });
101
- pw.detailsDiv = ui.divV([]);
102
- pw.wellDetailsDiv = div();
103
- pw.detailsDiv.appendChild(pw.wellDetailsDiv!);
104
- pw.grid.onCurrentCellChanged.pipe(filter((gc) => gc.gridRow >= 0 && gc.gridColumn.idx > 0)).subscribe((gc) => {
105
- ui.empty(pw.wellDetailsDiv!);
106
- const map = pw.mapFromRowFunc(pw.plate.data.rows.get(plate._idx(gc.gridRow, gc.gridColumn.idx - 1)));
107
- pw.wellDetailsDiv!.appendChild(ui.tableFromMap(map));
108
- });
109
-
110
- pw.root.prepend(pw.colorSelector.root);
111
- pw.tabsContainer.appendChild(pw.detailsDiv);
112
- return pw;
113
- }
114
-
115
- initPlateGrid(grid: DG.Grid, isSummary: boolean = false) {
116
- grid.props.showHeatmapScrollbars = false;
117
- grid.props.allowColReordering = false;
118
- grid.props.allowRowReordering = false;
119
- grid.props.allowSorting = false;
120
- grid.props.allowEdit = !isSummary;
121
- grid.props.showRowGridlines = true;
122
- grid.props.showColumnGridlines = true;
123
- grid.props.heatmapColors = false;
124
- grid.props.colHeaderHeight = 25;
125
-
126
- grid.onCellRender.subscribe((args) => this.renderCell(args, isSummary));
127
- }
128
-
129
- get plate(): Plate { return this._plate; }
130
- set plate(p: Plate) {
131
- this._plate = p;
132
- this.refresh();
133
- }
134
-
135
- /** Re-renders the UI */
136
- refresh() {
137
- this.tabs.clear();
138
- this.tabs.addPane('Summary', () => this.grid.root);
139
- for (const layer of this.plate.getLayerNames()) {
140
- this.tabs.addPane(layer, () => {
141
- const df = this.plate.toGridDataFrame(layer);
142
- const grid = DG.Viewer.heatMap(df);
143
- grid.columns.add({gridColumnName: '0', cellType: 'string', index: 1}); // to show row numbers in Excel format - will be done in initPlateGrid
144
- df.onValuesChanged.pipe(debounceTime(1000)).subscribe(() => {
145
- const p = this.plate;
146
- for (let i = 0; i < df.rowCount; i++) {
147
- for (let j = 0; j < df.columns.length - 1; j++)
148
- p.data.col(layer)!.set(p._idx(i, j), df.get(`${j + 1}`, i));
149
- }
150
- this.wellValidationErrors = p.validateWells(this.wellValidators);
151
- });
152
- this.initPlateGrid(grid, false);
153
- this.grids.set(layer, grid);
154
- return grid.root;
155
- });
156
- }
157
- ui.tools.waitForElementInDom(this.tabs.root).then(() => {
158
- this.tabs.currentPane = this.tabs.getPane('Summary');
159
- });
160
-
161
- this.syncGrids();
162
-
163
- const t = this.plate.data;
164
- this._colorColumn = t.columns.firstWhere((col) => col.name == 'activity' && col.type == TYPE.FLOAT) ??
165
- t.columns.firstWhere((col) => (col.name == 'concentration' || col.name == 'concentrations') && col.type == TYPE.FLOAT) ??
166
- t.columns.firstWhere((col) => col.name != 'row' && col.name != 'col' && col.type == TYPE.FLOAT) ??
167
- t.columns.firstWhere((col) => col.type == TYPE.FLOAT) ??
168
- (t.columns.length > 0 ? t.columns.byIndex(0) : undefined);
169
-
170
- // row header + all columns
171
- this.grid.dataFrame = DG.DataFrame.create(this.plate.rows);
172
- this.grid.columns.clear();
173
- for (let i = 0; i <= this.plate.cols; i++)
174
- this.grid.columns.add({gridColumnName: i.toString(), cellType: 'string'});
175
-
176
- this.grid.invalidate();
177
- }
178
-
179
- renderCell(args:DG.GridCellRenderArgs, summary: boolean = false) {
180
- const gc = args.cell;
181
- args.g.fillStyle = 'grey'; //(args.cell.isColHeader ? 'red' : (args.cell.isRowHeader ? 'green' : 'blue'));
182
- args.g.strokeStyle = 'grey';
183
- args.g.lineWidth = 1;
184
- const g = args.g;
185
- const x = args.bounds.x; const y = args.bounds.y; const w = args.bounds.width; const h = args.bounds.height;
186
- g.textAlign = 'center';
187
- g.textBaseline = 'middle';
188
- g.font = `${Math.ceil(Math.min(...[16, w - 1, h - 1]))}px Roboto, Roboto Local`;
189
- const isColoredByConc = this._colorColumn?.name?.toLowerCase()?.includes('conc');
190
-
191
- // column header
192
- const hasRowHeader = gc.grid.columns.byIndex(0)?.cellType === 'row header';
193
- if (gc.isColHeader && gc.gridColumn.idx > (hasRowHeader ? 1 : 0)) {
194
- g.fillText('' + (gc.gridColumn.idx - (hasRowHeader ? 1 : 0)), x + w / 2, y + h / 2);
195
- args.preventDefault();
196
- } else if (gc.isColHeader) {
197
- args.preventDefault();
198
- return;
199
- } else if ((gc.gridColumn.name == '0' || gc.gridColumn.idx == 0) && gc.gridRow >= 0) {
200
- const prefix = gc.gridRow > 25 ? 'A' : '';
201
- g.fillText(prefix + String.fromCharCode(65 + gc.gridRow % 26), x + w / 2, y + h / 2);
202
- args.preventDefault();
203
- } else if (summary && h > 0 && gc.gridRow >= 0 && gc.gridColumn.idx > 0) {
204
- const dataRow = this._plate._idx(gc.gridRow, gc.gridColumn.idx - 1);
205
-
206
- g.beginPath();
207
- const r = Math.min(h / 2, w / 2) * 0.8;
208
- g.ellipse(x + w / 2, y + h / 2, r, r, 0, 0, 2 * Math.PI);
209
- if (this._colorColumn) {
210
- if (this._colorColumn.isCategorical && this._colorColumn.meta.colors.getType() !== DG.COLOR_CODING_TYPE.CATEGORICAL)
211
- this._colorColumn.meta.colors.setCategorical();
212
- const color = this._colorColumn.isNone(dataRow) ? DG.Color.white : this._colorColumn.isNumerical ?
213
- this.getColor(dataRow, isColoredByConc) :
214
- this._colorColumn.meta.colors.getColor(dataRow);
215
- g.fillStyle = DG.Color.toHtml(color);
216
- g.fill();
217
- }
218
-
219
- g.stroke();
220
- const outlierCol = this.plate.data.col(PLATE_OUTLIER_WELL_NAME);
221
- if (outlierCol?.get(dataRow))
222
- DG.Paint.marker(g, MARKER_TYPE.CROSS_X_BORDER, x + w / 2, y + h / 2, DG.Color.red, r * 2);
223
- }
224
-
225
- if (summary)
226
- args.preventDefault();
227
- }
228
-
229
- getColor(dataRow: number, isLog?: boolean) {
230
- const val = this._colorColumn!.get(dataRow)!;
231
- const reducedVal = isLog ? safeLog((val - this._colorColumn!.min) * 1e9) : val;
232
- const min = (isLog ? safeLog(Math.max(this._colorColumn!.min, 1)) : this._colorColumn!.min);
233
- const max = isLog ? safeLog((this._colorColumn!.max - this._colorColumn!.min) * 1e9) : this._colorColumn!.max;
234
- return DG.Color.scaleColor(reducedVal, min, max, undefined, colorScheme);
235
- }
236
-
237
- /** Applies plate widget options to all grids */
238
- syncGrids() {
239
- for (const grid of this.grids.values())
240
- grid.props.allowEdit = this.editable;
241
- }
242
- }