@datagrok/curves 1.5.0 → 1.8.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/README.md +36 -8
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -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 +13 -11
- package/src/fit/const.ts +3 -2
- package/src/fit/fit-grid-cell-handler.ts +64 -59
- package/src/fit/fit-renderer.ts +142 -79
- package/src/fit/multi-curve-viewer.ts +32 -11
- package/src/fit/render-utils.ts +196 -138
- package/src/package-test.ts +7 -1
- package/src/package.g.ts +8 -0
- package/src/package.ts +253 -10
- package/src/plate/excel-plates.ts +112 -0
- package/src/plate/plate-cell-renderer.ts +40 -0
- package/src/plate/plate-reader.ts +28 -0
- package/src/plate/plate-widget.ts +478 -0
- package/src/plate/plate.ts +446 -0
- package/src/plate/readers/bmg-pherastar-96.ts +42 -0
- package/src/plate/readers/delfia-envision-96-max-rlu.ts +15 -0
- package/src/plate/readers/delfia-envision-by-row.ts +18 -0
- package/src/plate/readers/spectramax.ts +43 -0
- package/src/plate/utils.ts +129 -0
- package/src/tests/curves-cell-renderer-tests.ts +41 -22
- package/src/tests/fit-tests.ts +46 -11
- package/src/tests/plate-tests.ts +154 -0
- package/src/tests/transform-tests.ts +2 -2
- package/src/fit/cell-render-viewer.ts +0 -54
package/src/package.ts
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import {_PlateGridCellRenderer} from './package.g';
|
|
1
2
|
import {_MultiCurveViewer} from './package.g';
|
|
2
3
|
import {_FitChartCellRenderer} from './package.g';
|
|
3
4
|
/* Do not change these import lines to match external modules in webpack configuration */
|
|
4
5
|
import * as DG from 'datagrok-api/dg';
|
|
6
|
+
import * as grok from 'datagrok-api/grok';
|
|
7
|
+
import * as ui from 'datagrok-api/ui';
|
|
5
8
|
|
|
6
9
|
import {FitGridCellHandler, calculateSeriesStats, getChartDataAggrStats} from './fit/fit-grid-cell-handler';
|
|
7
|
-
import {
|
|
10
|
+
import {getOrCreateParsedChartData, substituteZeroes} from './fit/fit-renderer';
|
|
8
11
|
import {curveDemo} from './fit/fit-demo';
|
|
9
12
|
import {convertXMLToIFitChartData} from './fit/fit-parser';
|
|
10
13
|
import {LogOptions} from '@datagrok-libraries/statistics/src/fit/fit-data';
|
|
11
14
|
import {FitStatistics} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
12
15
|
import {FitConstants} from './fit/const';
|
|
13
|
-
|
|
16
|
+
import {PlateCellHandler} from "./plate/plate-cell-renderer";
|
|
17
|
+
import {FitSeries} from '@datagrok-libraries/statistics/src/fit/new-fit-API';
|
|
18
|
+
import {Plate} from './plate/plate';
|
|
19
|
+
import {getPlatesFolderPreview, PlateWidget} from './plate/plate-widget';
|
|
20
|
+
//@ts-ignore
|
|
21
|
+
import * as jStat from 'jstat';
|
|
22
|
+
import {PlateReader} from "./plate/plate-reader";
|
|
14
23
|
|
|
15
24
|
export const _package = new DG.Package();
|
|
16
25
|
const SOURCE_COLUMN_TAG = '.sourceColumn';
|
|
@@ -18,18 +27,112 @@ const SERIES_NUMBER_TAG = '.seriesNumber';
|
|
|
18
27
|
const SERIES_AGGREGATION_TAG = '.seriesAggregation';
|
|
19
28
|
const STATISTICS_TAG = '.statistics';
|
|
20
29
|
|
|
30
|
+
//tags: autostart
|
|
31
|
+
export function autostart() {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
window.PlateWidget = PlateWidget;
|
|
34
|
+
//@ts-ignore
|
|
35
|
+
window.Plate = Plate;
|
|
36
|
+
const concentrationCsv = `col 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
|
|
37
|
+
A,,,,,,,,,,,,,,,,,,,,,,,,
|
|
38
|
+
B,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
39
|
+
C,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,
|
|
40
|
+
D,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
41
|
+
E,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,
|
|
42
|
+
F,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
43
|
+
G,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
44
|
+
H,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,
|
|
45
|
+
I,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
46
|
+
J,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,
|
|
47
|
+
K,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
48
|
+
L,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,
|
|
49
|
+
M,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
50
|
+
N,,0.00001,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,
|
|
51
|
+
O,,0.00000,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00001,0.00000403,0.00000163,0.000000656,0.000000265,0.000000107,0.0000000431,0.0000000174,0.00000000701,0.00000000183,0.00000,
|
|
52
|
+
P,,,,,,,,,,,,,,,,,,,,,,,,`;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const layoutCsv = `col 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
|
|
56
|
+
A,,,,,,,,,,,,,,,,,,,,,,,,
|
|
57
|
+
B,,Low Control,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,High Control,
|
|
58
|
+
C,,High Control,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 1,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Compound 41,Low Control,
|
|
59
|
+
D,,Low Control,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,High Control,
|
|
60
|
+
E,,High Control,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 42,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Compound 43,Low Control,
|
|
61
|
+
F,,Low Control,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,High Control,
|
|
62
|
+
G,,High Control,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 44,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Compound 45,Low Control,
|
|
63
|
+
H,,Low Control,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,High Control,
|
|
64
|
+
I,,High Control,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 46,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Compound 47,Low Control,
|
|
65
|
+
J,,Low Control,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,High Control,
|
|
66
|
+
K,,High Control,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 48,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Compound 49,Low Control,
|
|
67
|
+
L,,Low Control,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,High Control,
|
|
68
|
+
M,,High Control,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 50,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Compound 51,Low Control,
|
|
69
|
+
N,,Low Control,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,High Control,
|
|
70
|
+
O,,High Control,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 52,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Compound 53,Low Control,
|
|
71
|
+
P,,,,,,,,,,,,,,,,,,,,,,,,`;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
const readoutCsv = `col 1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24
|
|
75
|
+
A,,,,,,,,,,,,,,,,,,,,,,,,
|
|
76
|
+
B,,0.07219099668,0.06947737465,0.07019976172,0.07263956168,0.07334269904,0.07654089128,0.07628940202,0.08834969214,0.13557287840,0.1486864679,0.1503697113,0.15200083420,0.15061775480,0.15309907440,0.15286653780,0.15379914010,0.15155727890,0.15232794460,0.15298766400,0.1538730651,0.1542393465,0.15071555580,
|
|
77
|
+
C,,0.14996855360,0.07212290660,0.06957076093,0.07069321642,0.07227733865,0.07664359412,0.07918610560,0.07808503586,0.12496495030,0.1378908893,0.1465698921,0.15578283900,0.15186884230,0.15151635070,0.15141401530,0.15052587190,0.15486747600,0.15294037650,0.15241116130,0.1546532344,0.1537365814,0.07231605295,
|
|
78
|
+
D,,0.07023863668,0.07030474895,0.07086594623,0.07378772619,0.07813099195,0.08443275691,0.10024937710,0.11821695280,0.14031173800,0.1505845411,0.1505987702,0.07099481653,0.07322787956,0.07588648236,0.08377558210,0.09888790085,0.11395358370,0.12947949180,0.14055841590,0.1493699333,0.1540055735,0.15226875140,
|
|
79
|
+
E,,0.14929130930,0.06932695867,0.07157716491,0.07214187679,0.07721194315,0.08504549754,0.10174360480,0.11748417490,0.13321393730,0.1456650512,0.1483001297,0.07167267085,0.07383087952,0.07670410142,0.08204578635,0.09386326869,0.11296832520,0.30900000000,0.13807843210,0.1487301787,0.1519785410,0.07219836243,
|
|
80
|
+
F,,0.07063914398,0.07039007372,0.07078597316,0.07132027961,0.07222210814,0.07442561862,0.08135627908,0.09196745273,0.11146019360,0.1364485205,0.1450632971,0.08126099235,0.09318398047,0.10961914380,0.12860206080,0.14110717340,0.14655533300,0.15212245890,0.15233422070,0.1521740437,0.1539843278,0.15514745160,
|
|
81
|
+
G,,0.15147635060,0.07238581078,0.06968522213,0.07128524617,0.07252406181,0.07567350355,0.07943235275,0.09117074615,0.10537654310,0.1344820888,0.1400224330,0.08242500433,0.09563371204,0.10936069820,0.12848949680,0.14108995770,0.14405660970,0.15031406210,0.15131600980,0.1522018720,0.1534152011,0.07219962790,
|
|
82
|
+
H,,0.07201551934,0.14139074650,0.10970399700,0.14927003800,0.15153471030,0.15239784500,0.15275285200,0.15300022370,0.15204696770,0.1499048651,0.1522479639,0.08013306126,0.08511773454,0.09873312909,0.11965236570,0.13423325770,0.14790643020,0.14787378410,0.15121033310,0.1516832849,0.1546688514,0.15391338010,
|
|
83
|
+
I,,0.15106747120,0.14298828240,0.14478508750,0.14400005770,0.12812788070,0.15020659840,0.15070640480,0.14981230230,0.15107167610,0.1525554191,0.1492535524,0.08018720930,0.08601155699,0.09880353225,0.11672648890,0.13325225690,0.14354164670,0.14463708830,0.15318329890,0.1521327032,0.1512182552,0.07244861048,
|
|
84
|
+
J,,0.07134151692,0.07106139536,0.07290563639,0.07320964199,0.07531163459,0.08077714646,0.08726929940,0.10068593880,0.11914215450,0.1418191958,0.1443463920,0.07247201272,0.06999750950,0.07076991276,0.07228675508,0.07237591892,0.07201251723,0.07741640477,0.08773368972,0.1219768071,0.1387552698,0.15192226570,
|
|
85
|
+
K,,0.15000436380,0.07156625599,0.07087075250,0.07123659002,0.07345421874,0.07832545577,0.08734304748,0.09985159477,0.11591447310,0.1397237122,0.1459823861,0.07214517236,0.07005683091,0.07016838344,0.07131776580,0.07200174821,0.07350492337,0.07785311421,0.08866229169,0.1234911377,0.1371697196,0.07064796366,
|
|
86
|
+
L,,0.07054096934,0.07004726921,0.07201825002,0.07179815990,0.07268889103,0.07379454514,0.07427085340,0.07982570255,0.08854676858,0.1198873673,0.1322562498,0.07034679393,0.07523627163,0.07582258339,0.08392782907,0.09669262374,0.11261560310,0.12874291890,0.14171585180,0.1491004443,0.1502214336,0.15198125010,
|
|
87
|
+
M,,0.15232172270,0.07166689716,0.07099964730,0.07172948942,0.07140356089,0.07359647053,0.07391627346,0.07872536050,0.08793247921,0.1177668597,0.1316288144,0.06733039177,0.07260462946,0.07516068933,0.08359475310,0.09611904399,0.11364151330,0.12772328380,0.14070692820,0.1486696188,0.1541842928,0.07174453270,
|
|
88
|
+
N,,0.07126884935,0.07332587669,0.07786873273,0.08482253378,0.10140499840,0.11854947500,0.13401382360,0.14613488070,0.15066237370,0.1545757395,0.1510962397,0.07286614211,0.07215169457,0.07227939024,0.07337505876,0.07530546981,0.08265249465,0.09167518260,0.11122719660,0.1391977320,0.1459690588,0.15291802550,
|
|
89
|
+
O,,0.15243482930,0.07280165939,0.07688708790,0.31500000000,0.09886803400,0.11454911710,0.12960429510,0.14047477320,0.14718270040,0.1509524590,0.1501338551,0.07212897291,0.07072700474,0.07059273173,0.07088234657,0.07421414395,0.08105493058,0.09094554089,0.10660934950,0.1358113503,0.1432621746,0.07009305748,
|
|
90
|
+
P,,,,,,,,,,,,,,,,,,,,,,,,`;
|
|
91
|
+
|
|
92
|
+
//@ts-ignore
|
|
93
|
+
window.readoutCsv = readoutCsv;
|
|
94
|
+
//@ts-ignore
|
|
95
|
+
window.concentrationCsv = concentrationCsv;
|
|
96
|
+
//@ts-ignore
|
|
97
|
+
window.layoutCsv = layoutCsv;
|
|
98
|
+
|
|
99
|
+
function getPlate(): Plate {
|
|
100
|
+
const concentration = Plate.fromCsvTable(concentrationCsv, 'concentration');
|
|
101
|
+
const layout = Plate.fromCsvTable(layoutCsv, 'role');
|
|
102
|
+
const readout = Plate.fromCsvTable(readoutCsv, 'readout');
|
|
103
|
+
|
|
104
|
+
return Plate.fromPlates([concentration, layout, readout]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//@ts-ignore
|
|
108
|
+
window.getPlate = getPlate;
|
|
109
|
+
|
|
110
|
+
// @ts-ignore
|
|
111
|
+
window.jStat = jStat;
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
}
|
|
21
115
|
|
|
22
116
|
//name: Curve fitting
|
|
23
117
|
//description: Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of data points
|
|
24
|
-
//meta.demoPath: Curves | Curve
|
|
118
|
+
//meta.demoPath: Curves | Curve Fitting
|
|
25
119
|
//test: curveFitDemo() //wait: 2000
|
|
26
120
|
export async function curveFitDemo(): Promise<void> {
|
|
27
121
|
await curveDemo();
|
|
28
122
|
}
|
|
29
123
|
|
|
124
|
+
//name: Assay Plates
|
|
125
|
+
//description: Assasy plates with concentration, layout and readout data
|
|
126
|
+
//meta.demoPath: Curves | Assay Plates
|
|
127
|
+
export async function assayPlatesDemo(): Promise<void> {
|
|
128
|
+
const plateFile = (await grok.dapi.files.list('System:DemoFiles/hts/xlsx_plates'))[0];
|
|
129
|
+
grok.shell.addView(await previewPlateXlsx(plateFile) as DG.ViewBase);
|
|
130
|
+
}
|
|
131
|
+
|
|
30
132
|
//tags: init
|
|
31
133
|
export function _initCurves(): void {
|
|
32
134
|
DG.ObjectHandler.register(new FitGridCellHandler());
|
|
135
|
+
DG.ObjectHandler.register(new PlateCellHandler());
|
|
33
136
|
}
|
|
34
137
|
|
|
35
138
|
//name: addStatisticsColumn
|
|
@@ -39,10 +142,11 @@ export function _initCurves(): void {
|
|
|
39
142
|
//input: string propName
|
|
40
143
|
//input: string seriesName
|
|
41
144
|
//input: int seriesNumber
|
|
42
|
-
|
|
145
|
+
//input: string newColName
|
|
146
|
+
export function addStatisticsColumn(df: DG.DataFrame, colName: string, propName: string, seriesName: string, seriesNumber: number, newColName?: string): void {
|
|
43
147
|
const grid = DG.Viewer.grid(df);
|
|
44
148
|
const chartColumn = grid.col(colName)!;
|
|
45
|
-
const column = DG.Column.float(`${colName}
|
|
149
|
+
const column = DG.Column.float(newColName ?? `${colName} ${seriesName} ${propName}`, chartColumn.column?.length);
|
|
46
150
|
column.tags[SOURCE_COLUMN_TAG] = colName;
|
|
47
151
|
column.tags[SERIES_NUMBER_TAG] = seriesNumber;
|
|
48
152
|
column.tags[STATISTICS_TAG] = propName;
|
|
@@ -53,14 +157,14 @@ export function addStatisticsColumn(df: DG.DataFrame, colName: string, propName:
|
|
|
53
157
|
if (gridCell.cell.value === '')
|
|
54
158
|
return null;
|
|
55
159
|
const chartData = gridCell.cell.column.getTag(FitConstants.TAG_FIT_CHART_FORMAT) === FitConstants.TAG_FIT_CHART_FORMAT_3DX ?
|
|
56
|
-
convertXMLToIFitChartData(gridCell.cell.value) :
|
|
160
|
+
convertXMLToIFitChartData(gridCell.cell.value) : getOrCreateParsedChartData(gridCell);
|
|
57
161
|
if (chartData.series![seriesNumber] === undefined || chartData.series![seriesNumber].points.every((p) => p.outlier))
|
|
58
162
|
return null;
|
|
59
163
|
if (chartData.chartOptions?.allowXZeroes && chartData.chartOptions?.logX &&
|
|
60
164
|
chartData.series?.some((series) => series.points.some((p) => p.x === 0)))
|
|
61
165
|
substituteZeroes(chartData);
|
|
62
166
|
const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
|
|
63
|
-
const fitResult = calculateSeriesStats(chartData.series![seriesNumber], chartLogOptions);
|
|
167
|
+
const fitResult = calculateSeriesStats(chartData.series![seriesNumber], seriesNumber, chartLogOptions, gridCell);
|
|
64
168
|
return fitResult[propName as keyof FitStatistics];
|
|
65
169
|
});
|
|
66
170
|
df.columns.insert(column, chartColumn.idx);
|
|
@@ -75,7 +179,7 @@ export function addStatisticsColumn(df: DG.DataFrame, colName: string, propName:
|
|
|
75
179
|
export function addAggrStatisticsColumn(df: DG.DataFrame, colName: string, propName: string, aggrType: string): void {
|
|
76
180
|
const grid = DG.Viewer.grid(df);
|
|
77
181
|
const chartColumn = grid.col(colName)!;
|
|
78
|
-
const column = DG.Column.float(`${colName}
|
|
182
|
+
const column = DG.Column.float(`${colName} ${aggrType} ${propName}`, chartColumn.column?.length);
|
|
79
183
|
column.tags[SOURCE_COLUMN_TAG] = colName;
|
|
80
184
|
column.tags[SERIES_AGGREGATION_TAG] = aggrType;
|
|
81
185
|
column.tags[STATISTICS_TAG] = propName;
|
|
@@ -86,17 +190,156 @@ export function addAggrStatisticsColumn(df: DG.DataFrame, colName: string, propN
|
|
|
86
190
|
if (gridCell.cell.value === '')
|
|
87
191
|
return null;
|
|
88
192
|
const chartData = gridCell.cell.column.getTag(FitConstants.TAG_FIT_CHART_FORMAT) === FitConstants.TAG_FIT_CHART_FORMAT_3DX ?
|
|
89
|
-
convertXMLToIFitChartData(gridCell.cell.value) :
|
|
193
|
+
convertXMLToIFitChartData(gridCell.cell.value) : getOrCreateParsedChartData(gridCell);
|
|
90
194
|
if (chartData.series?.every((series) => series.points.every((p) => p.outlier)))
|
|
91
195
|
return null;
|
|
92
196
|
if (chartData.chartOptions?.allowXZeroes && chartData.chartOptions?.logX &&
|
|
93
197
|
chartData.series?.some((series) => series.points.some((p) => p.x === 0)))
|
|
94
198
|
substituteZeroes(chartData);
|
|
95
|
-
const fitResult = getChartDataAggrStats(chartData, aggrType);
|
|
199
|
+
const fitResult = getChartDataAggrStats(chartData, aggrType, gridCell);
|
|
96
200
|
return fitResult[propName as keyof FitStatistics];
|
|
97
201
|
});
|
|
98
202
|
df.columns.insert(column, chartColumn.idx);
|
|
99
203
|
}
|
|
100
204
|
|
|
205
|
+
//name: platesFolderPreview
|
|
206
|
+
//tags: folderViewer
|
|
207
|
+
//input: file folder
|
|
208
|
+
//input: list<file> files
|
|
209
|
+
//output: widget res
|
|
210
|
+
export async function platesFolderPreview(folder: DG.FileInfo, files: DG.FileInfo[]): Promise<DG.Widget | DG.ViewBase | undefined> {
|
|
211
|
+
const nameLowerCase = folder.name?.toLowerCase();
|
|
212
|
+
if (!nameLowerCase?.includes('plate'))
|
|
213
|
+
return undefined;
|
|
214
|
+
return getPlatesFolderPreview(files);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// //name: Plates
|
|
218
|
+
// //tags: app
|
|
219
|
+
// //meta.browsePath: Chem
|
|
220
|
+
// export function plateApp() {
|
|
221
|
+
// const plateFileInput = ui.input.file('Plate file', {nullable: false});
|
|
222
|
+
// ui.dialog('Select Plate File').add(plateFileInput).onOK(async () => {
|
|
223
|
+
// const file = plateFileInput.value;
|
|
224
|
+
// if (!file || file.extension !== 'xlsx') {
|
|
225
|
+
// grok.shell.warning('Please, select an Excel file with plates');
|
|
226
|
+
// return;
|
|
227
|
+
// }
|
|
228
|
+
//
|
|
229
|
+
// try {
|
|
230
|
+
// const plate = await Plate.fromExcelFileInfo(file);
|
|
231
|
+
// const pw = PlateWidget.analysisView(plate);
|
|
232
|
+
// const view = DG.View.fromRoot(pw.root);
|
|
233
|
+
// view.name = file.name;
|
|
234
|
+
// grok.shell.addView(view);
|
|
235
|
+
// } catch (e) {
|
|
236
|
+
// grok.shell.error('Error parsing plate file');
|
|
237
|
+
// _package.logger.error(e);
|
|
238
|
+
// }
|
|
239
|
+
// }).show();
|
|
240
|
+
// // if (file.extension !== 'xlsx') {
|
|
241
|
+
// // grok.shell.warning('Please, select an Excel file with plates');
|
|
242
|
+
// // return;
|
|
243
|
+
// // }
|
|
244
|
+
// // console.log(file);
|
|
245
|
+
// // const plate = Plate.fromExcel(file.fullPath);
|
|
246
|
+
// }
|
|
247
|
+
|
|
248
|
+
//meta.fileViewer: txt
|
|
249
|
+
//meta.fileViewerCheck: Curves:checkFileIsPlate
|
|
250
|
+
//input: file file
|
|
251
|
+
//output: view result
|
|
252
|
+
export function previewPlate(file: DG.FileInfo): DG.View {
|
|
253
|
+
const view = DG.View.create();
|
|
254
|
+
view.name = file.name;
|
|
255
|
+
file.readAsString().then((content) => {
|
|
256
|
+
const plate = PlateReader.read(content);
|
|
257
|
+
if (plate !== null) {
|
|
258
|
+
view.root.appendChild(PlateWidget.fromPlate(plate).root);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return view;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
//name: importPlate
|
|
265
|
+
//tags: file-handler
|
|
266
|
+
//meta.ext: txt
|
|
267
|
+
//meta.fileViewerCheck: Curves:checkFileIsPlate
|
|
268
|
+
//input: string fileContent
|
|
269
|
+
//output: list tables
|
|
270
|
+
export async function importPlate(fileContent: string): Promise<DG.DataFrame[]> {
|
|
271
|
+
const plate = PlateReader.read(fileContent);
|
|
272
|
+
const view = DG.View.create();
|
|
273
|
+
if (plate !== null) {
|
|
274
|
+
view.root.appendChild(PlateWidget.fromPlate(plate).root);
|
|
275
|
+
}
|
|
276
|
+
view.name = 'Plate';
|
|
277
|
+
grok.shell.addView(view);
|
|
278
|
+
return [];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
//name: importPlateXlsx
|
|
282
|
+
//tags: file-handler
|
|
283
|
+
//meta.ext: xlsx
|
|
284
|
+
//meta.fileViewerCheck: Curves:checkExcelIsPlate
|
|
285
|
+
//input: blob fileContent
|
|
286
|
+
//output: list tables
|
|
287
|
+
export async function importPlateXlsx(fileContent: Uint8Array) {
|
|
288
|
+
const view = DG.View.create();
|
|
289
|
+
const plate = await parseExcelPlate(fileContent);
|
|
290
|
+
view.root.appendChild(PlateWidget.analysisView(plate).root);
|
|
291
|
+
view.name = 'Plate';
|
|
292
|
+
grok.shell.addView(view);
|
|
293
|
+
return [];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
//name: viewPlateXlsx
|
|
297
|
+
//meta.fileViewer: xlsx
|
|
298
|
+
//meta.fileViewerCheck: Curves:checkExcelIsPlate
|
|
299
|
+
//input: file file
|
|
300
|
+
//output: view result
|
|
301
|
+
export async function previewPlateXlsx(file: DG.FileInfo): Promise<DG.View> {
|
|
302
|
+
const view = DG.View.create();
|
|
303
|
+
view.name = file.friendlyName;
|
|
304
|
+
const plate = await parseExcelPlate(await file.readAsBytes());
|
|
305
|
+
view.root.appendChild(PlateWidget.analysisView(plate).root);
|
|
306
|
+
return view;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
//name checkExcelIsPlate
|
|
310
|
+
//input: blob content
|
|
311
|
+
//output: bool isPlate
|
|
312
|
+
export async function checkExcelIsPlate(content: Uint8Array): Promise<boolean> {
|
|
313
|
+
try {
|
|
314
|
+
if (content.length > 1_000_000) // haven't really seen a plate file larger than 1MB
|
|
315
|
+
return false;
|
|
316
|
+
const plate = await parseExcelPlate(content);
|
|
317
|
+
return plate !== null;
|
|
318
|
+
} catch (e) {
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async function parseExcelPlate(content: string | Uint8Array, name?: string) {
|
|
324
|
+
if (typeof content === 'string') {
|
|
325
|
+
const blob = new Blob([content], {type: 'application/octet-binary'});
|
|
326
|
+
const buf = await blob.arrayBuffer();
|
|
327
|
+
const plate = await Plate.fromExcel(new Uint8Array(buf), name);
|
|
328
|
+
return plate;
|
|
329
|
+
} else
|
|
330
|
+
return await Plate.fromExcel(content, name);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
//name: checkFileIsPlate
|
|
334
|
+
//input: string content
|
|
335
|
+
//output: bool isPlate
|
|
336
|
+
export function checkFileIsPlate(content: string): boolean {
|
|
337
|
+
if (content.length > 1_000_000)
|
|
338
|
+
return false;
|
|
339
|
+
return PlateReader.getReader(content) != null;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
101
343
|
export {_FitChartCellRenderer};
|
|
102
344
|
export {_MultiCurveViewer};
|
|
345
|
+
export {_PlateGridCellRenderer};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
import * as ExcelJS from 'exceljs';
|
|
3
|
+
import wu from 'wu';
|
|
4
|
+
import {Plate} from "./plate";
|
|
5
|
+
import {DataFrame} from "datagrok-api/dg";
|
|
6
|
+
|
|
7
|
+
interface ExcelPlatePosition {
|
|
8
|
+
sheet: ExcelJS.Worksheet;
|
|
9
|
+
startRow: number;
|
|
10
|
+
startCol: number;
|
|
11
|
+
rows: number;
|
|
12
|
+
cols: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/** Finds plate positions in the Excel workbook by iterating over sheets
|
|
17
|
+
* and finding row/column label patterns such as (1-24, A-P). */
|
|
18
|
+
export function findPlatePositions(workbook: ExcelJS.Workbook): ExcelPlatePosition[] {
|
|
19
|
+
const results: ExcelPlatePosition[] = [];
|
|
20
|
+
const ACharCode = 'A'.charCodeAt(0);
|
|
21
|
+
workbook.eachSheet((worksheet) => {
|
|
22
|
+
// TODO: Hack for current things, remove later
|
|
23
|
+
if (worksheet.name?.toLowerCase() === 'desired outputs')
|
|
24
|
+
return;
|
|
25
|
+
// Create a grid representation of the worksheet
|
|
26
|
+
const grid: any[][] = [];
|
|
27
|
+
worksheet.eachRow((row, rowIndex) => {
|
|
28
|
+
grid[rowIndex] = [];
|
|
29
|
+
row.eachCell((cell, colIndex) => {
|
|
30
|
+
grid[rowIndex][colIndex] = cell.value;
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Find numeric column headers (1, 2, 3, ...)
|
|
35
|
+
let headerRow = -1, startCol = -1, numColumns = 0;
|
|
36
|
+
for (let i = 1; i < grid.length; i++) {
|
|
37
|
+
const row = grid[i] || [];
|
|
38
|
+
let numSequence = 0, seqStart = -1;
|
|
39
|
+
|
|
40
|
+
for (let j = 1; j < row.length; j++) {
|
|
41
|
+
if (typeof row[j] === 'number' && Number.isInteger(row[j]) && row[j] === numSequence + 1) {
|
|
42
|
+
if (numSequence === 0) seqStart = j;
|
|
43
|
+
numSequence++;
|
|
44
|
+
}
|
|
45
|
+
else if (numSequence > 0)
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (numSequence >= 12) { // Minimum 12 columns
|
|
50
|
+
headerRow = i;
|
|
51
|
+
startCol = seqStart;
|
|
52
|
+
numColumns = numSequence;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Find alphabetic row headers (A, B, C, ...)
|
|
58
|
+
let headerCol = -1, startRow = -1, numRows = 0;
|
|
59
|
+
if (headerRow !== -1) {
|
|
60
|
+
for (let j = 1; j < startCol; j++) {
|
|
61
|
+
let letterSequence = 0, seqStart = -1;
|
|
62
|
+
|
|
63
|
+
for (let i = headerRow + 1; i < grid.length; i++) {
|
|
64
|
+
if (!grid[i]) continue;
|
|
65
|
+
const val = grid[i][j];
|
|
66
|
+
|
|
67
|
+
if (typeof val === 'string' && /^[A-Za-z]{1,2}$/.test(val)) {
|
|
68
|
+
const prefix = letterSequence > 25 ? 'A' : '';
|
|
69
|
+
const expected = prefix + String.fromCharCode(ACharCode + letterSequence % 26);
|
|
70
|
+
if (val?.toLowerCase() === expected?.toLowerCase()) {
|
|
71
|
+
if (letterSequence === 0) seqStart = i;
|
|
72
|
+
letterSequence++;
|
|
73
|
+
}
|
|
74
|
+
else break;
|
|
75
|
+
}
|
|
76
|
+
else if (letterSequence > 0)
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (letterSequence >= 8) { // Minimum 8 rows
|
|
81
|
+
headerCol = j;
|
|
82
|
+
startRow = seqStart;
|
|
83
|
+
numRows = letterSequence;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (headerRow !== -1 && headerCol !== -1) {
|
|
90
|
+
results.push({
|
|
91
|
+
sheet: worksheet,
|
|
92
|
+
startRow: headerRow,
|
|
93
|
+
startCol: headerCol,
|
|
94
|
+
rows: numRows,
|
|
95
|
+
cols: numColumns
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return results;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
/** Constructs a plate from the specified position in the Excel sheet. */
|
|
105
|
+
export function getPlateFromSheet(p: ExcelPlatePosition): Plate {
|
|
106
|
+
const df = DataFrame.create(p.rows);
|
|
107
|
+
for (let col = p.startCol + 1; col <= p.startCol + p.cols; col++) {
|
|
108
|
+
const strings = DG.range(p.rows).map(i => p.sheet.getCell(p.startRow + i + 1, col).toString()).toArray();
|
|
109
|
+
df.columns.add(DG.Column.fromStrings(`${col - p.startCol + 1}`, strings));
|
|
110
|
+
}
|
|
111
|
+
return Plate.fromTable(df, p.sheet.name);
|
|
112
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
import * as ui from 'datagrok-api/ui';
|
|
3
|
+
import * as grok from 'datagrok-api/grok';
|
|
4
|
+
import {PlateWidget} from "./plate-widget";
|
|
5
|
+
import {GridColumn, x} from "datagrok-api/dg";
|
|
6
|
+
|
|
7
|
+
export class PlateCellHandler extends DG.ObjectHandler {
|
|
8
|
+
get type(): string { return 'Plate'; }
|
|
9
|
+
|
|
10
|
+
isApplicable(x: any): boolean {
|
|
11
|
+
return x instanceof DG.GridCell && x.cellType === 'Plate';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
getGridCellRenderer(): DG.GridCellRenderer | null {
|
|
15
|
+
return new PlateGridCellRenderer();
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@grok.decorators.cellRenderer({cellType: 'Plate'})
|
|
21
|
+
export class PlateGridCellRenderer extends DG.GridCellRenderer {
|
|
22
|
+
plate = new PlateWidget();
|
|
23
|
+
|
|
24
|
+
get name(): string { return 'Plate'; }
|
|
25
|
+
get cellType(): string { return 'Plate'; }
|
|
26
|
+
|
|
27
|
+
getDefaultSize(gridColumn: GridColumn) { return { width: 120, height: 80 } }
|
|
28
|
+
|
|
29
|
+
render(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, gridCell: DG.GridCell, cellStyle: DG.GridCellStyle) {
|
|
30
|
+
this.plate.plateData = gridCell.value;
|
|
31
|
+
this.plate.grid.props.colHeaderHeight = h > 120 ? 16 : 0;
|
|
32
|
+
this.plate.grid.props.showRowHeader = w > 100;
|
|
33
|
+
|
|
34
|
+
this.plate.grid.render(g, new DG.Rect(x, y, w, h).cutTop(Math.min(h / 20, 5)).cutRight(Math.min(w / 20, 5)));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onClick(gridCell: DG.GridCell, e: MouseEvent) {
|
|
38
|
+
grok.shell.o = PlateWidget.detailedView(gridCell.value).root;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {Plate} from "./plate";
|
|
2
|
+
import {BmgPherastar96PlateReader} from "./readers/bmg-pherastar-96";
|
|
3
|
+
import {DelfiaEnvision96MaxRluPlateReader} from "./readers/delfia-envision-96-max-rlu";
|
|
4
|
+
import {SpectramaxPlateReader} from "./readers/spectramax";
|
|
5
|
+
import {DelfiaEnvisionByRowPlateReader} from "./readers/delfia-envision-by-row";
|
|
6
|
+
|
|
7
|
+
export interface IPlateReader {
|
|
8
|
+
isApplicable(s: string): boolean;
|
|
9
|
+
read(s: string): Plate;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export abstract class PlateReader {
|
|
14
|
+
static readers: IPlateReader[] = [
|
|
15
|
+
new DelfiaEnvision96MaxRluPlateReader(),
|
|
16
|
+
new DelfiaEnvisionByRowPlateReader(),
|
|
17
|
+
new BmgPherastar96PlateReader(),
|
|
18
|
+
new SpectramaxPlateReader(),
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
static getReader(s: string): IPlateReader | null {
|
|
22
|
+
return this.readers.find((r) => r.isApplicable(s)) ?? null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static read(s: string): Plate | null {
|
|
26
|
+
return this.getReader(s)?.read(s) ?? null;
|
|
27
|
+
}
|
|
28
|
+
}
|