@datagrok/curves 1.6.0 → 1.9.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.
- package/.eslintrc.json +39 -0
- package/.vscode/launch.json +10 -9
- package/.vscode/tasks.json +14 -0
- package/CHANGELOG.md +33 -0
- package/README.md +36 -8
- package/databases/plates/0000_init.sql +167 -0
- package/detectors.js +2 -2
- package/dist/package-test.js +15930 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +13750 -1
- package/dist/package.js.map +1 -1
- package/img/plate-dose-response-series.gif +0 -0
- package/img/plate-readers.gif +0 -0
- package/package.json +17 -11
- package/queries/plates-crud.sql +148 -0
- package/src/fit/const.ts +60 -59
- package/src/fit/data-to-curves.ts +220 -0
- package/src/fit/fit-demo.ts +6 -6
- package/src/fit/fit-grid-cell-handler.ts +94 -85
- package/src/fit/fit-renderer.ts +162 -98
- package/src/fit/multi-curve-viewer.ts +69 -28
- package/src/fit/render-utils.ts +346 -288
- package/src/package-api.ts +167 -0
- package/src/package-test.ts +7 -1
- package/src/package.g.ts +140 -2
- package/src/package.ts +221 -79
- package/src/plate/excel-plates.ts +112 -0
- package/src/plate/plate-cell-renderer.ts +48 -0
- package/src/plate/plate-drc-analysis.ts +262 -0
- package/src/plate/plate-reader.ts +28 -0
- package/src/plate/plate-well-validators.ts +41 -0
- package/src/plate/plate-widget.ts +242 -0
- package/src/plate/plate.ts +557 -0
- package/src/plate/plates-folder-preview.ts +63 -0
- package/src/plate/readers/bmg-pherastar-96.ts +42 -0
- package/src/plate/readers/delfia-envision-96-max-rlu.ts +16 -0
- package/src/plate/readers/delfia-envision-by-row.ts +18 -0
- package/src/plate/readers/spectramax.ts +42 -0
- package/src/plate/utils.ts +141 -0
- package/src/plates/numeric_matcher.ts +191 -0
- package/src/plates/objects/plate-template-handler.ts +48 -0
- package/src/plates/plates-app.ts +64 -0
- package/src/plates/plates-crud.ts +502 -0
- package/src/plates/plates-demo.ts +107 -0
- package/src/plates/plates.sql +169 -0
- package/src/plates/views/plates-create-view.ts +123 -0
- package/src/plates/views/plates-schema-view.ts +58 -0
- package/src/plates/views/plates-search-view.ts +137 -0
- package/src/plates/views/plates-templates-view.ts +38 -0
- package/src/tests/curves-cell-renderer-tests.ts +95 -75
- package/src/tests/detector-tests.ts +3 -2
- package/src/tests/fit-tests.ts +199 -163
- package/src/tests/plate-tests.ts +153 -0
- package/src/tests/transform-tests.ts +6 -6
- package/test-console-output-1.log +435 -0
- package/test-record-1.mp4 +0 -0
- package/tsconfig.json +1 -1
- package/src/fit/cell-render-viewer.ts +0 -54
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
This file is auto-generated by the grok api command.
|
|
3
|
+
If you notice any changes, please push them to the repository.
|
|
4
|
+
Do not edit this file manually.
|
|
5
|
+
*/
|
|
6
|
+
import * as grok from 'datagrok-api/grok';
|
|
7
|
+
import * as DG from 'datagrok-api/dg';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export namespace queries {
|
|
11
|
+
export async function getPlates(): Promise<DG.DataFrame> {
|
|
12
|
+
return await grok.data.query('Curves:GetPlates', {});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
Get all well level properties (either used in a well or specified in a template)
|
|
17
|
+
*/
|
|
18
|
+
export async function getWellLevelProperties(): Promise<DG.DataFrame> {
|
|
19
|
+
return await grok.data.query('Curves:GetWellLevelProperties', {});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
Get all plate level properties (either used in a plate or specified in a template)
|
|
24
|
+
*/
|
|
25
|
+
export async function getPlateLevelProperties(): Promise<DG.DataFrame> {
|
|
26
|
+
return await grok.data.query('Curves:GetPlateLevelProperties', {});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function getPropertyNames(): Promise<DG.DataFrame> {
|
|
30
|
+
return await grok.data.query('Curves:GetPropertyNames', {});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function getPlateTypes(): Promise<DG.DataFrame> {
|
|
34
|
+
return await grok.data.query('Curves:GetPlateTypes', {});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export async function getPlateTemplates(): Promise<DG.DataFrame> {
|
|
38
|
+
return await grok.data.query('Curves:GetPlateTemplates', {});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function getWellRoles(): Promise<DG.DataFrame> {
|
|
42
|
+
return await grok.data.query('Curves:GetWellRoles', {});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function getWellValuesByBarcode(barcode: string ): Promise<DG.DataFrame> {
|
|
46
|
+
return await grok.data.query('Curves:GetWellValuesByBarcode', { barcode });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function getWellValuesById(id: number ): Promise<DG.DataFrame> {
|
|
50
|
+
return await grok.data.query('Curves:GetWellValuesById', { id });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function getAllowedValues(propertyName: string ): Promise<DG.DataFrame> {
|
|
54
|
+
return await grok.data.query('Curves:GetAllowedValues', { propertyName });
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function getUniquePlatePropertyValues(): Promise<DG.DataFrame> {
|
|
58
|
+
return await grok.data.query('Curves:GetUniquePlatePropertyValues', {});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function getUniqueWellPropertyValues(): Promise<DG.DataFrame> {
|
|
62
|
+
return await grok.data.query('Curves:GetUniqueWellPropertyValues', {});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function createProperty(propertyName: string , valueType: string ): Promise<number> {
|
|
66
|
+
return await grok.data.query('Curves:CreateProperty', { propertyName, valueType });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function createTemplate(name: string , description: string ): Promise<number> {
|
|
70
|
+
return await grok.data.query('Curves:CreateTemplate', { name, description });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function getTemplateWellProperties(): Promise<DG.DataFrame> {
|
|
74
|
+
return await grok.data.query('Curves:GetTemplateWellProperties', {});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function getTemplatePlateProperties(): Promise<DG.DataFrame> {
|
|
78
|
+
return await grok.data.query('Curves:GetTemplatePlateProperties', {});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export namespace funcs {
|
|
83
|
+
export async function platesAppTreeBrowser(treeNode: any , browseView: DG.View ): Promise<void> {
|
|
84
|
+
return await grok.functions.call('Curves:PlatesAppTreeBrowser', { treeNode, browseView });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function fitChartCellRenderer(): Promise<any> {
|
|
88
|
+
return await grok.functions.call('Curves:FitChartCellRenderer', {});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
A viewer that superimposes multiple in-cell curves on one chart
|
|
93
|
+
*/
|
|
94
|
+
export async function multiCurveViewer(): Promise<any> {
|
|
95
|
+
return await grok.functions.call('Curves:MultiCurveViewer', {});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points
|
|
100
|
+
*/
|
|
101
|
+
export async function curveFitDemo(): Promise<void> {
|
|
102
|
+
return await grok.functions.call('Curves:CurveFitDemo', {});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
Assasy plates with concentration, layout and readout data
|
|
107
|
+
*/
|
|
108
|
+
export async function assayPlatesDemo(): Promise<void> {
|
|
109
|
+
return await grok.functions.call('Curves:AssayPlatesDemo', {});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function initCurves(): Promise<void> {
|
|
113
|
+
return await grok.functions.call('Curves:InitCurves', {});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export async function addStatisticsColumn(table: DG.DataFrame , colName: string , propName: string , seriesNumber: number ): Promise<DG.Column> {
|
|
117
|
+
return await grok.functions.call('Curves:AddStatisticsColumn', { table, colName, propName, seriesNumber });
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function addAggrStatisticsColumn(table: DG.DataFrame , colName: string , propName: string , aggrType: string ): Promise<DG.Column> {
|
|
121
|
+
return await grok.functions.call('Curves:AddAggrStatisticsColumn', { table, colName, propName, aggrType });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export async function platesFolderPreview(folder: DG.FileInfo , files: any ): Promise<any> {
|
|
125
|
+
return await grok.functions.call('Curves:PlatesFolderPreview', { folder, files });
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export async function previewPlate(file: DG.FileInfo ): Promise<DG.View> {
|
|
129
|
+
return await grok.functions.call('Curves:PreviewPlate', { file });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export async function importPlate(fileContent: string ): Promise<any> {
|
|
133
|
+
return await grok.functions.call('Curves:ImportPlate', { fileContent });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function importPlateXlsx(fileContent: any ): Promise<void> {
|
|
137
|
+
return await grok.functions.call('Curves:ImportPlateXlsx', { fileContent });
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export async function previewPlateXlsx(file: DG.FileInfo ): Promise<DG.View> {
|
|
141
|
+
return await grok.functions.call('Curves:PreviewPlateXlsx', { file });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export async function checkExcelIsPlate(content: any ): Promise<boolean> {
|
|
145
|
+
return await grok.functions.call('Curves:CheckExcelIsPlate', { content });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function checkFileIsPlate(content: string ): Promise<boolean> {
|
|
149
|
+
return await grok.functions.call('Curves:CheckFileIsPlate', { content });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export async function platesApp(): Promise<DG.View> {
|
|
153
|
+
return await grok.functions.call('Curves:PlatesApp', {});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export async function getPlateByBarcode(barcode: string ): Promise<any> {
|
|
157
|
+
return await grok.functions.call('Curves:GetPlateByBarcode', { barcode });
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export async function createDummyPlateData(): Promise<void> {
|
|
161
|
+
return await grok.functions.call('Curves:CreateDummyPlateData', {});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export async function plateGridCellRenderer(): Promise<any> {
|
|
165
|
+
return await grok.functions.call('Curves:PlateGridCellRenderer', {});
|
|
166
|
+
}
|
|
167
|
+
}
|
package/src/package-test.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as DG from "datagrok-api/dg";
|
|
2
2
|
|
|
3
|
-
import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test';
|
|
3
|
+
import {runTests, tests, TestContext, initAutoTests as initTests } from '@datagrok-libraries/utils/src/test';
|
|
4
4
|
|
|
5
5
|
import './tests/detector-tests';
|
|
6
6
|
import './tests/curves-cell-renderer-tests';
|
|
7
7
|
import './tests/transform-tests';
|
|
8
8
|
import './tests/fit-tests';
|
|
9
|
+
import './tests/plate-tests';
|
|
9
10
|
|
|
10
11
|
export const _package = new DG.Package();
|
|
11
12
|
export {tests};
|
|
@@ -19,3 +20,8 @@ export async function test(category: string, test: string, testContext: TestCont
|
|
|
19
20
|
const data = await runTests({category, test, testContext});
|
|
20
21
|
return DG.DataFrame.fromObjects(data)!;
|
|
21
22
|
}
|
|
23
|
+
|
|
24
|
+
//name: initAutoTests
|
|
25
|
+
export async function initAutoTests() {
|
|
26
|
+
//await initTests(_package, _package.getModule('package-test.js'));
|
|
27
|
+
}
|
package/src/package.g.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {PlateGridCellRenderer} from './plate/plate-cell-renderer';
|
|
2
|
+
import {PackageFunctions} from './package';
|
|
2
3
|
import {MultiCurveViewer} from './fit/multi-curve-viewer';
|
|
3
|
-
|
|
4
|
+
import {FitChartCellRenderer} from './fit/fit-renderer';
|
|
5
|
+
import * as DG from 'datagrok-api/dg';
|
|
4
6
|
//name: Fit
|
|
5
7
|
//tags: cellRenderer
|
|
6
8
|
//output: grid_cell_renderer renderer
|
|
@@ -15,7 +17,143 @@ export function _FitChartCellRenderer() {
|
|
|
15
17
|
//tags: viewer
|
|
16
18
|
//output: viewer result
|
|
17
19
|
//meta.icon: icons/multi-curve-viewer.png
|
|
20
|
+
//meta.trellisable: true
|
|
18
21
|
export function _MultiCurveViewer() {
|
|
19
22
|
return new MultiCurveViewer();
|
|
20
23
|
}
|
|
21
24
|
|
|
25
|
+
|
|
26
|
+
//name: Curve fitting
|
|
27
|
+
//description: Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points
|
|
28
|
+
//meta.demoPath: Curves | Curve Fitting
|
|
29
|
+
//test: curveFitDemo() //wait: 2000
|
|
30
|
+
export async function curveFitDemo() {
|
|
31
|
+
return PackageFunctions.curveFitDemo();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//name: Assay Plates
|
|
35
|
+
//description: Assasy plates with concentration, layout and readout data
|
|
36
|
+
//meta.demoPath: Curves | Assay Plates
|
|
37
|
+
export async function assayPlatesDemo() {
|
|
38
|
+
return PackageFunctions.assayPlatesDemo();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//name: _initCurves
|
|
42
|
+
//tags: init
|
|
43
|
+
export function _initCurves() {
|
|
44
|
+
return PackageFunctions._initCurves();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//name: addStatisticsColumn
|
|
48
|
+
//tags: Transform
|
|
49
|
+
//input: dataframe table
|
|
50
|
+
//input: string colName
|
|
51
|
+
//input: string propName
|
|
52
|
+
//input: int seriesNumber
|
|
53
|
+
//output: column result
|
|
54
|
+
//meta.vectorFunc: true
|
|
55
|
+
export function addStatisticsColumn(table: DG.DataFrame, colName: string, propName: string, seriesNumber: number) {
|
|
56
|
+
return PackageFunctions.addStatisticsColumn(table, colName, propName, seriesNumber);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//name: addAggrStatisticsColumn
|
|
60
|
+
//tags: Transform
|
|
61
|
+
//input: dataframe table
|
|
62
|
+
//input: string colName
|
|
63
|
+
//input: string propName
|
|
64
|
+
//input: string aggrType
|
|
65
|
+
//output: column result
|
|
66
|
+
//meta.vectorFunc: true
|
|
67
|
+
export function addAggrStatisticsColumn(table: DG.DataFrame, colName: string, propName: string, aggrType: string) {
|
|
68
|
+
return PackageFunctions.addAggrStatisticsColumn(table, colName, propName, aggrType);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//name: platesFolderPreview
|
|
72
|
+
//tags: folderViewer
|
|
73
|
+
//input: file folder
|
|
74
|
+
//input: list<file> files
|
|
75
|
+
//output: dynamic result
|
|
76
|
+
export async function platesFolderPreview(folder: DG.FileInfo, files: DG.FileInfo[]) {
|
|
77
|
+
return PackageFunctions.platesFolderPreview(folder, files);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
//name: previewPlate
|
|
81
|
+
//tags: fileViewer
|
|
82
|
+
//input: file file
|
|
83
|
+
//output: view result
|
|
84
|
+
//meta.fileViewer: txt
|
|
85
|
+
//meta.fileViewerCheck: Curves:checkFileIsPlate
|
|
86
|
+
export function previewPlate(file: DG.FileInfo) {
|
|
87
|
+
return PackageFunctions.previewPlate(file);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
//name: importPlate
|
|
91
|
+
//tags: file-handler
|
|
92
|
+
//input: string fileContent
|
|
93
|
+
//output: list result
|
|
94
|
+
//meta.ext: txt
|
|
95
|
+
//meta.fileViewerCheck: Curves:checkFileIsPlate
|
|
96
|
+
export async function importPlate(fileContent: string) {
|
|
97
|
+
return PackageFunctions.importPlate(fileContent);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//name: importPlateXlsx
|
|
101
|
+
//tags: file-handler
|
|
102
|
+
//input: blob fileContent
|
|
103
|
+
//meta.ext: xlsx
|
|
104
|
+
//meta.fileViewerCheck: Curves:checkExcelIsPlate
|
|
105
|
+
export async function importPlateXlsx(fileContent: Uint8Array) {
|
|
106
|
+
return PackageFunctions.importPlateXlsx(fileContent);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//name: viewPlateXlsx
|
|
110
|
+
//tags: fileViewer
|
|
111
|
+
//input: file file
|
|
112
|
+
//output: view result
|
|
113
|
+
//meta.fileViewer: xlsx
|
|
114
|
+
//meta.fileViewerCheck: Curves:checkExcelIsPlate
|
|
115
|
+
export async function previewPlateXlsx(file: DG.FileInfo) {
|
|
116
|
+
return PackageFunctions.previewPlateXlsx(file);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//name: checkExcelIsPlate
|
|
120
|
+
//input: blob content
|
|
121
|
+
//output: bool result
|
|
122
|
+
export async function checkExcelIsPlate(content: Uint8Array) {
|
|
123
|
+
return PackageFunctions.checkExcelIsPlate(content);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
//name: checkFileIsPlate
|
|
127
|
+
//input: string content
|
|
128
|
+
//output: bool result
|
|
129
|
+
export function checkFileIsPlate(content: string) {
|
|
130
|
+
return PackageFunctions.checkFileIsPlate(content);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//name: Browse
|
|
134
|
+
//tags: app
|
|
135
|
+
//output: view result
|
|
136
|
+
//meta.browsePath: Plates
|
|
137
|
+
export function platesApp() {
|
|
138
|
+
return PackageFunctions.platesApp();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
//name: getPlateByBarcode
|
|
142
|
+
//input: string barcode
|
|
143
|
+
//output: dynamic result
|
|
144
|
+
export async function getPlateByBarcode(barcode: string) {
|
|
145
|
+
return PackageFunctions.getPlateByBarcode(barcode);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
//name: createDummyPlateData
|
|
149
|
+
export async function createDummyPlateData() {
|
|
150
|
+
return PackageFunctions.createDummyPlateData();
|
|
151
|
+
}
|
|
152
|
+
//name: PlateGridCellRenderer
|
|
153
|
+
//tags: cellRenderer
|
|
154
|
+
//output: grid_cell_renderer renderer
|
|
155
|
+
//meta.cellType: Plate
|
|
156
|
+
export function _PlateGridCellRenderer() {
|
|
157
|
+
return new PlateGridCellRenderer();
|
|
158
|
+
}
|
|
159
|
+
|
package/src/package.ts
CHANGED
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
//@ts-ignore
|
|
3
|
+
export * from './package.g';
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
/* Do not change these import lines to match external modules in webpack configuration */
|
|
4
7
|
import * as DG from 'datagrok-api/dg';
|
|
8
|
+
import * as grok from 'datagrok-api/grok';
|
|
9
|
+
import * as ui from 'datagrok-api/ui';
|
|
5
10
|
|
|
6
11
|
import {FitGridCellHandler, calculateSeriesStats, getChartDataAggrStats} from './fit/fit-grid-cell-handler';
|
|
7
|
-
import {
|
|
12
|
+
import {getOrCreateParsedChartData, substituteZeroes} from './fit/fit-renderer';
|
|
8
13
|
import {curveDemo} from './fit/fit-demo';
|
|
9
14
|
import {convertXMLToIFitChartData} from './fit/fit-parser';
|
|
10
15
|
import {LogOptions} from '@datagrok-libraries/statistics/src/fit/fit-data';
|
|
11
16
|
import {FitStatistics} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
12
17
|
import {FitConstants} from './fit/const';
|
|
13
|
-
|
|
18
|
+
import {PlateCellHandler} from './plate/plate-cell-renderer';
|
|
19
|
+
import {Plate} from './plate/plate';
|
|
20
|
+
import {PlateWidget} from './plate/plate-widget';
|
|
21
|
+
import {PlateReader} from './plate/plate-reader';
|
|
22
|
+
import {initPlatesAppTree, platesAppView} from './plates/plates-app';
|
|
23
|
+
import {initPlates} from './plates/plates-crud';
|
|
24
|
+
import {__createDummyPlateData} from './plates/plates-demo';
|
|
25
|
+
import {getPlatesFolderPreview} from './plate/plates-folder-preview';
|
|
26
|
+
import {PlateDrcAnalysis} from './plate/plate-drc-analysis';
|
|
27
|
+
import {PlateTemplateHandler} from './plates/objects/plate-template-handler';
|
|
28
|
+
import * as api from './package-api';
|
|
14
29
|
|
|
15
30
|
export const _package = new DG.Package();
|
|
16
31
|
const SOURCE_COLUMN_TAG = '.sourceColumn';
|
|
@@ -18,85 +33,212 @@ const SERIES_NUMBER_TAG = '.seriesNumber';
|
|
|
18
33
|
const SERIES_AGGREGATION_TAG = '.seriesAggregation';
|
|
19
34
|
const STATISTICS_TAG = '.statistics';
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
36
|
+
export class Sync {
|
|
37
|
+
private static _currentPromise: Promise<any> = Promise.resolve();
|
|
38
|
+
public static async runWhenDone<T>(func: () => Promise<T>): Promise<T> {
|
|
39
|
+
Sync._currentPromise = Sync._currentPromise.then(async () => { try { return await func(); } catch (e) { _package.logger.error(e); } });
|
|
40
|
+
return Sync._currentPromise;
|
|
41
|
+
}
|
|
42
|
+
// the number at the end is the column version
|
|
28
43
|
}
|
|
29
44
|
|
|
30
|
-
//tags: init
|
|
31
|
-
export function _initCurves(): void {
|
|
32
|
-
DG.ObjectHandler.register(new FitGridCellHandler());
|
|
33
|
-
}
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
46
|
+
export class PackageFunctions {
|
|
47
|
+
@grok.decorators.demo({
|
|
48
|
+
name: 'Curve fitting',
|
|
49
|
+
description: 'Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points',
|
|
50
|
+
meta: {demoPath: 'Curves | Curve Fitting'},
|
|
51
|
+
test: {test: 'curveFitDemo()', wait: '2000'}
|
|
52
|
+
})
|
|
53
|
+
static async curveFitDemo(): Promise<void> {
|
|
54
|
+
await curveDemo();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@grok.decorators.func({
|
|
58
|
+
name: 'Assay Plates',
|
|
59
|
+
description: 'Assasy plates with concentration, layout and readout data',
|
|
60
|
+
meta: {demoPath: 'Curves | Assay Plates'},
|
|
61
|
+
})
|
|
62
|
+
static async assayPlatesDemo(): Promise<void> {
|
|
63
|
+
const plateFile = (await grok.dapi.files.list('System:DemoFiles/hts/xlsx_plates'))[0];
|
|
64
|
+
grok.shell.addView(await PackageFunctions.previewPlateXlsx(plateFile) as DG.ViewBase);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@grok.decorators.init({})
|
|
68
|
+
static _initCurves(): void {
|
|
69
|
+
DG.ObjectHandler.register(new FitGridCellHandler());
|
|
70
|
+
DG.ObjectHandler.register(new PlateCellHandler());
|
|
71
|
+
DG.ObjectHandler.register(new PlateTemplateHandler());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@grok.decorators.func({meta: {vectorFunc: 'true'}, tags: ['Transform']})
|
|
75
|
+
static addStatisticsColumn(table: DG.DataFrame, colName: string, propName: string, @grok.decorators.param({type: 'int'}) seriesNumber: number): DG.Column {
|
|
76
|
+
const df = table;
|
|
77
|
+
const col = df.col(colName)!;
|
|
78
|
+
const sourceColName = col.name;
|
|
79
|
+
const initialName = df.columns.getUnusedName(`${colName} ${seriesNumber + 1} ${propName}`);
|
|
80
|
+
|
|
81
|
+
//const grid = DG.Viewer.grid(df);
|
|
82
|
+
const column = DG.Column.float(initialName, col.length);
|
|
83
|
+
|
|
84
|
+
column.tags[SOURCE_COLUMN_TAG] = col.name;
|
|
85
|
+
column.tags[SERIES_NUMBER_TAG] = seriesNumber?.toString();
|
|
86
|
+
column.tags[STATISTICS_TAG] = propName;
|
|
87
|
+
|
|
88
|
+
column
|
|
89
|
+
.init((i) => {
|
|
90
|
+
//const gridCell = DG.GridCell.fromColumnRow(grid, colName, grid.tableRowToGrid(i));
|
|
91
|
+
const cell = df.cell(i, sourceColName);
|
|
92
|
+
if (!cell || !cell.value)
|
|
93
|
+
return null;
|
|
94
|
+
const chartData = cell.column.getTag(FitConstants.TAG_FIT_CHART_FORMAT) === FitConstants.TAG_FIT_CHART_FORMAT_3DX ?
|
|
95
|
+
convertXMLToIFitChartData(cell.value) : getOrCreateParsedChartData(cell, true); // false because there is no dataframe
|
|
96
|
+
if (chartData.series![seriesNumber] === undefined || chartData.series![seriesNumber].points.every((p) => p.outlier))
|
|
97
|
+
return null;
|
|
98
|
+
if (chartData.chartOptions?.allowXZeroes && chartData.chartOptions?.logX &&
|
|
99
|
+
chartData.series?.some((series) => series.points.some((p) => p.x === 0)))
|
|
100
|
+
substituteZeroes(chartData);
|
|
101
|
+
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
102
|
+
const fitResult = calculateSeriesStats(chartData.series![seriesNumber], seriesNumber, chartLogOptions, cell, true);
|
|
103
|
+
return fitResult[propName as keyof FitStatistics];
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
df.columns.insert(column, df.columns.names().indexOf(colName) + 1);
|
|
107
|
+
return column;
|
|
108
|
+
}
|
|
68
109
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
110
|
+
@grok.decorators.func({meta: {vectorFunc: 'true'}, tags: ['Transform']})
|
|
111
|
+
static addAggrStatisticsColumn(table: DG.DataFrame, colName: string, propName: string, aggrType: string): DG.Column {
|
|
112
|
+
const df = table;
|
|
113
|
+
const col = df.col(colName)!;
|
|
114
|
+
const nName = `${colName} ${aggrType} ${propName}`;
|
|
115
|
+
const column = DG.Column.float(df.columns.getUnusedName(nName), col?.length);
|
|
116
|
+
|
|
117
|
+
column.tags[SOURCE_COLUMN_TAG] = colName;
|
|
118
|
+
column.tags[SERIES_AGGREGATION_TAG] = aggrType;
|
|
119
|
+
column.tags[STATISTICS_TAG] = propName;
|
|
120
|
+
column
|
|
121
|
+
.init((i) => {
|
|
122
|
+
const cell = df.cell(i, colName);
|
|
123
|
+
if (!cell || !cell.value)
|
|
124
|
+
return null;
|
|
125
|
+
const chartData =
|
|
126
|
+
cell.column.getTag(FitConstants.TAG_FIT_CHART_FORMAT) === FitConstants.TAG_FIT_CHART_FORMAT_3DX ?
|
|
127
|
+
convertXMLToIFitChartData(cell.value) : getOrCreateParsedChartData(cell);
|
|
128
|
+
if (chartData.series?.every((series) => series.points.every((p) => p.outlier)))
|
|
129
|
+
return null;
|
|
130
|
+
if (chartData.chartOptions?.allowXZeroes && chartData.chartOptions?.logX &&
|
|
131
|
+
chartData.series?.some((series) => series.points.some((p) => p.x === 0)))
|
|
132
|
+
substituteZeroes(chartData);
|
|
133
|
+
const fitResult = getChartDataAggrStats(chartData, aggrType, cell);
|
|
134
|
+
return fitResult[propName as keyof FitStatistics];
|
|
135
|
+
});
|
|
136
|
+
df.columns.insert(column, df.columns.names().indexOf(colName) + 1);
|
|
137
|
+
return column;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@grok.decorators.folderViewer({})
|
|
141
|
+
static async platesFolderPreview(folder: DG.FileInfo, files: DG.FileInfo[]): Promise<DG.Widget | DG.ViewBase | undefined> {
|
|
142
|
+
const nameLowerCase = folder.name?.toLowerCase();
|
|
143
|
+
if (!nameLowerCase?.includes('plate'))
|
|
144
|
+
return undefined;
|
|
145
|
+
return getPlatesFolderPreview(files);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
@grok.decorators.fileViewer({fileViewer: 'txt', fileViewerCheck: 'Curves:checkFileIsPlate'})
|
|
149
|
+
static previewPlate(file: DG.FileInfo): DG.View {
|
|
150
|
+
const view = DG.View.create();
|
|
151
|
+
view.name = file.name;
|
|
152
|
+
file.readAsString().then((content) => {
|
|
153
|
+
const plate = PlateReader.read(content);
|
|
154
|
+
if (plate !== null)
|
|
155
|
+
view.root.appendChild(PlateWidget.fromPlate(plate).root);
|
|
97
156
|
});
|
|
98
|
-
|
|
157
|
+
return view;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
@grok.decorators.fileHandler({ext: 'txt', fileViewerCheck: 'Curves:checkFileIsPlate'})
|
|
161
|
+
static async importPlate(fileContent: string): Promise<DG.DataFrame[]> {
|
|
162
|
+
const plate = PlateReader.read(fileContent);
|
|
163
|
+
const view = DG.View.create();
|
|
164
|
+
if (plate !== null)
|
|
165
|
+
view.root.appendChild(PlateWidget.fromPlate(plate).root);
|
|
166
|
+
|
|
167
|
+
view.name = 'Plate';
|
|
168
|
+
grok.shell.addView(view);
|
|
169
|
+
return [];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@grok.decorators.fileHandler({outputs: [], ext: 'xlsx', fileViewerCheck: 'Curves:checkExcelIsPlate'})
|
|
173
|
+
static async importPlateXlsx(fileContent: Uint8Array): Promise<any[]> {
|
|
174
|
+
const view = DG.View.create();
|
|
175
|
+
const plate = await PackageFunctions.parseExcelPlate(fileContent);
|
|
176
|
+
view.root.appendChild(PlateDrcAnalysis.analysisView(plate).root);
|
|
177
|
+
view.name = 'Plate';
|
|
178
|
+
grok.shell.addView(view);
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@grok.decorators.fileViewer({name: 'viewPlateXlsx', fileViewer: 'xlsx', fileViewerCheck: 'Curves:checkExcelIsPlate'})
|
|
183
|
+
static async previewPlateXlsx(file: DG.FileInfo): Promise<DG.View> {
|
|
184
|
+
const view = DG.View.create();
|
|
185
|
+
view.name = file.friendlyName;
|
|
186
|
+
const plate = await PackageFunctions.parseExcelPlate(await file.readAsBytes());
|
|
187
|
+
view.root.appendChild(PlateDrcAnalysis.analysisView(plate).root);
|
|
188
|
+
return view;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
@grok.decorators.func({})
|
|
192
|
+
static async checkExcelIsPlate(content: Uint8Array): Promise<boolean> {
|
|
193
|
+
try {
|
|
194
|
+
if (content.length > 1_000_000) // haven't really seen a plate file larger than 1MB
|
|
195
|
+
return false;
|
|
196
|
+
const plate = await PackageFunctions.parseExcelPlate(content);
|
|
197
|
+
return plate !== null;
|
|
198
|
+
} catch (e) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static async parseExcelPlate(content: string | Uint8Array, name?: string) {
|
|
204
|
+
if (typeof content === 'string') {
|
|
205
|
+
const blob = new Blob([content], {type: 'application/octet-binary'});
|
|
206
|
+
const buf = await blob.arrayBuffer();
|
|
207
|
+
const plate = await Plate.fromExcel(new Uint8Array(buf), name);
|
|
208
|
+
return plate;
|
|
209
|
+
} else {
|
|
210
|
+
return await Plate.fromExcel(content, name);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@grok.decorators.func({})
|
|
215
|
+
static checkFileIsPlate(content: string): boolean {
|
|
216
|
+
if (content.length > 1_000_000)
|
|
217
|
+
return false;
|
|
218
|
+
return PlateReader.getReader(content) != null;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@grok.decorators.app({name: 'Browse', browsePath: 'Plates'})
|
|
222
|
+
static platesApp(): DG.View {
|
|
223
|
+
return platesAppView();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@grok.decorators.func({})
|
|
227
|
+
static async getPlateByBarcode(barcode: string): Promise<Plate> {
|
|
228
|
+
await initPlates();
|
|
229
|
+
const df: DG.DataFrame = await api.queries.getWellValuesByBarcode(barcode);
|
|
230
|
+
return Plate.fromDbDataFrame(df);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@grok.decorators.func({})
|
|
234
|
+
static async createDummyPlateData(): Promise<void> {
|
|
235
|
+
await __createDummyPlateData();
|
|
236
|
+
}
|
|
99
237
|
}
|
|
100
238
|
|
|
101
|
-
|
|
102
|
-
|
|
239
|
+
//name: platesAppTreeBrowser
|
|
240
|
+
//input: dynamic treeNode
|
|
241
|
+
//input: view browseView
|
|
242
|
+
export async function platesAppTreeBrowser(treeNode: DG.TreeViewGroup, browseView: DG.BrowsePanel) {
|
|
243
|
+
await initPlatesAppTree(treeNode);
|
|
244
|
+
}
|