@datagrok/curves 1.8.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.
Files changed (54) hide show
  1. package/.eslintrc.json +39 -0
  2. package/.vscode/launch.json +10 -9
  3. package/.vscode/tasks.json +14 -0
  4. package/CHANGELOG.md +33 -0
  5. package/databases/plates/0000_init.sql +167 -0
  6. package/detectors.js +2 -2
  7. package/dist/package-test.js +15930 -1
  8. package/dist/package-test.js.map +1 -1
  9. package/dist/package.js +13750 -1
  10. package/dist/package.js.map +1 -1
  11. package/package.json +12 -8
  12. package/queries/plates-crud.sql +148 -0
  13. package/src/fit/const.ts +60 -60
  14. package/src/fit/data-to-curves.ts +220 -0
  15. package/src/fit/fit-demo.ts +6 -6
  16. package/src/fit/fit-grid-cell-handler.ts +48 -44
  17. package/src/fit/fit-renderer.ts +56 -55
  18. package/src/fit/multi-curve-viewer.ts +38 -18
  19. package/src/fit/render-utils.ts +315 -315
  20. package/src/package-api.ts +167 -0
  21. package/src/package-test.ts +1 -1
  22. package/src/package.g.ts +133 -3
  23. package/src/package.ts +198 -299
  24. package/src/plate/excel-plates.ts +1 -1
  25. package/src/plate/plate-cell-renderer.ts +20 -12
  26. package/src/plate/plate-drc-analysis.ts +262 -0
  27. package/src/plate/plate-reader.ts +5 -5
  28. package/src/plate/plate-well-validators.ts +41 -0
  29. package/src/plate/plate-widget.ts +132 -368
  30. package/src/plate/plate.ts +168 -57
  31. package/src/plate/plates-folder-preview.ts +63 -0
  32. package/src/plate/readers/bmg-pherastar-96.ts +7 -7
  33. package/src/plate/readers/delfia-envision-96-max-rlu.ts +4 -3
  34. package/src/plate/readers/delfia-envision-by-row.ts +3 -3
  35. package/src/plate/readers/spectramax.ts +7 -8
  36. package/src/plate/utils.ts +22 -10
  37. package/src/plates/numeric_matcher.ts +191 -0
  38. package/src/plates/objects/plate-template-handler.ts +48 -0
  39. package/src/plates/plates-app.ts +64 -0
  40. package/src/plates/plates-crud.ts +502 -0
  41. package/src/plates/plates-demo.ts +107 -0
  42. package/src/plates/plates.sql +169 -0
  43. package/src/plates/views/plates-create-view.ts +123 -0
  44. package/src/plates/views/plates-schema-view.ts +58 -0
  45. package/src/plates/views/plates-search-view.ts +137 -0
  46. package/src/plates/views/plates-templates-view.ts +38 -0
  47. package/src/tests/curves-cell-renderer-tests.ts +93 -92
  48. package/src/tests/detector-tests.ts +3 -2
  49. package/src/tests/fit-tests.ts +199 -198
  50. package/src/tests/plate-tests.ts +6 -7
  51. package/src/tests/transform-tests.ts +4 -4
  52. package/test-console-output-1.log +435 -0
  53. package/test-record-1.mp4 +0 -0
  54. package/tsconfig.json +1 -1
package/src/package.ts CHANGED
@@ -1,6 +1,8 @@
1
- import {_PlateGridCellRenderer} from './package.g';
2
- import {_MultiCurveViewer} from './package.g';
3
- import {_FitChartCellRenderer} from './package.g';
1
+ /* eslint-disable max-len */
2
+ //@ts-ignore
3
+ export * from './package.g';
4
+
5
+
4
6
  /* Do not change these import lines to match external modules in webpack configuration */
5
7
  import * as DG from 'datagrok-api/dg';
6
8
  import * as grok from 'datagrok-api/grok';
@@ -13,13 +15,17 @@ import {convertXMLToIFitChartData} from './fit/fit-parser';
13
15
  import {LogOptions} from '@datagrok-libraries/statistics/src/fit/fit-data';
14
16
  import {FitStatistics} from '@datagrok-libraries/statistics/src/fit/fit-curve';
15
17
  import {FitConstants} from './fit/const';
16
- import {PlateCellHandler} from "./plate/plate-cell-renderer";
17
- import {FitSeries} from '@datagrok-libraries/statistics/src/fit/new-fit-API';
18
+ import {PlateCellHandler} from './plate/plate-cell-renderer';
18
19
  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";
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';
23
29
 
24
30
  export const _package = new DG.Package();
25
31
  const SOURCE_COLUMN_TAG = '.sourceColumn';
@@ -27,319 +33,212 @@ const SERIES_NUMBER_TAG = '.seriesNumber';
27
33
  const SERIES_AGGREGATION_TAG = '.seriesAggregation';
28
34
  const STATISTICS_TAG = '.statistics';
29
35
 
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]);
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
105
43
  }
106
44
 
107
- //@ts-ignore
108
- window.getPlate = getPlate;
109
-
110
- // @ts-ignore
111
- window.jStat = jStat;
112
45
 
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
+ }
113
56
 
114
- }
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
+ }
115
66
 
116
- //name: Curve fitting
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
118
- //meta.demoPath: Curves | Curve Fitting
119
- //test: curveFitDemo() //wait: 2000
120
- export async function curveFitDemo(): Promise<void> {
121
- await curveDemo();
122
- }
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
+ }
123
73
 
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
- }
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
+ }
131
109
 
132
- //tags: init
133
- export function _initCurves(): void {
134
- DG.ObjectHandler.register(new FitGridCellHandler());
135
- DG.ObjectHandler.register(new PlateCellHandler());
136
- }
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
+ }
137
139
 
138
- //name: addStatisticsColumn
139
- //tags: Transform
140
- //input: dataframe df
141
- //input: string colName
142
- //input: string propName
143
- //input: string seriesName
144
- //input: int seriesNumber
145
- //input: string newColName
146
- export function addStatisticsColumn(df: DG.DataFrame, colName: string, propName: string, seriesName: string, seriesNumber: number, newColName?: string): void {
147
- const grid = DG.Viewer.grid(df);
148
- const chartColumn = grid.col(colName)!;
149
- const column = DG.Column.float(newColName ?? `${colName} ${seriesName} ${propName}`, chartColumn.column?.length);
150
- column.tags[SOURCE_COLUMN_TAG] = colName;
151
- column.tags[SERIES_NUMBER_TAG] = seriesNumber;
152
- column.tags[STATISTICS_TAG] = propName;
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
+ }
153
147
 
154
- column
155
- .init((i) => {
156
- const gridCell = DG.GridCell.fromColumnRow(grid, colName, grid.tableRowToGrid(i));
157
- if (gridCell.cell.value === '')
158
- return null;
159
- const chartData = gridCell.cell.column.getTag(FitConstants.TAG_FIT_CHART_FORMAT) === FitConstants.TAG_FIT_CHART_FORMAT_3DX ?
160
- convertXMLToIFitChartData(gridCell.cell.value) : getOrCreateParsedChartData(gridCell);
161
- if (chartData.series![seriesNumber] === undefined || chartData.series![seriesNumber].points.every((p) => p.outlier))
162
- return null;
163
- if (chartData.chartOptions?.allowXZeroes && chartData.chartOptions?.logX &&
164
- chartData.series?.some((series) => series.points.some((p) => p.x === 0)))
165
- substituteZeroes(chartData);
166
- const chartLogOptions: LogOptions = {logX: chartData.chartOptions?.logX, logY: chartData.chartOptions?.logY};
167
- const fitResult = calculateSeriesStats(chartData.series![seriesNumber], seriesNumber, chartLogOptions, gridCell);
168
- return fitResult[propName as keyof FitStatistics];
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);
169
156
  });
170
- df.columns.insert(column, chartColumn.idx);
171
- }
157
+ return view;
158
+ }
172
159
 
173
- //name: addAggrStatisticsColumn
174
- //tags: Transform
175
- //input: dataframe df
176
- //input: string colName
177
- //input: string propName
178
- //input: string aggrType
179
- export function addAggrStatisticsColumn(df: DG.DataFrame, colName: string, propName: string, aggrType: string): void {
180
- const grid = DG.Viewer.grid(df);
181
- const chartColumn = grid.col(colName)!;
182
- const column = DG.Column.float(`${colName} ${aggrType} ${propName}`, chartColumn.column?.length);
183
- column.tags[SOURCE_COLUMN_TAG] = colName;
184
- column.tags[SERIES_AGGREGATION_TAG] = aggrType;
185
- column.tags[STATISTICS_TAG] = propName;
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);
186
166
 
187
- column
188
- .init((i) => {
189
- const gridCell = DG.GridCell.fromColumnRow(grid, colName, grid.tableRowToGrid(i));
190
- if (gridCell.cell.value === '')
191
- return null;
192
- const chartData = gridCell.cell.column.getTag(FitConstants.TAG_FIT_CHART_FORMAT) === FitConstants.TAG_FIT_CHART_FORMAT_3DX ?
193
- convertXMLToIFitChartData(gridCell.cell.value) : getOrCreateParsedChartData(gridCell);
194
- if (chartData.series?.every((series) => series.points.every((p) => p.outlier)))
195
- return null;
196
- if (chartData.chartOptions?.allowXZeroes && chartData.chartOptions?.logX &&
197
- chartData.series?.some((series) => series.points.some((p) => p.x === 0)))
198
- substituteZeroes(chartData);
199
- const fitResult = getChartDataAggrStats(chartData, aggrType, gridCell);
200
- return fitResult[propName as keyof FitStatistics];
201
- });
202
- df.columns.insert(column, chartColumn.idx);
203
- }
167
+ view.name = 'Plate';
168
+ grok.shell.addView(view);
169
+ return [];
170
+ }
204
171
 
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
- }
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
+ }
216
181
 
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
- // }
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
+ }
247
190
 
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);
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;
259
200
  }
260
- });
261
- return view;
262
- }
201
+ }
263
202
 
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);
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
+ }
275
212
  }
276
- view.name = 'Plate';
277
- grok.shell.addView(view);
278
- return [];
279
- }
280
213
 
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
- }
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
+ }
295
220
 
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
- }
221
+ @grok.decorators.app({name: 'Browse', browsePath: 'Plates'})
222
+ static platesApp(): DG.View {
223
+ return platesAppView();
224
+ }
308
225
 
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;
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);
320
231
  }
321
- }
322
232
 
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);
233
+ @grok.decorators.func({})
234
+ static async createDummyPlateData(): Promise<void> {
235
+ await __createDummyPlateData();
236
+ }
331
237
  }
332
238
 
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;
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);
340
244
  }
341
-
342
-
343
- export {_FitChartCellRenderer};
344
- export {_MultiCurveViewer};
345
- export {_PlateGridCellRenderer};
@@ -108,5 +108,5 @@ export function getPlateFromSheet(p: ExcelPlatePosition): Plate {
108
108
  const strings = DG.range(p.rows).map(i => p.sheet.getCell(p.startRow + i + 1, col).toString()).toArray();
109
109
  df.columns.add(DG.Column.fromStrings(`${col - p.startCol + 1}`, strings));
110
110
  }
111
- return Plate.fromTable(df, p.sheet.name);
111
+ return Plate.fromGridDataFrame(df, p.sheet.name);
112
112
  }
@@ -1,8 +1,9 @@
1
1
  import * as DG from 'datagrok-api/dg';
2
2
  import * as ui from 'datagrok-api/ui';
3
3
  import * as grok from 'datagrok-api/grok';
4
- import {PlateWidget} from "./plate-widget";
5
- import {GridColumn, x} from "datagrok-api/dg";
4
+ import {PlateWidget} from './plate-widget';
5
+ import {GridColumn, x} from 'datagrok-api/dg';
6
+ import {Plate} from "./plate";
6
7
 
7
8
  export class PlateCellHandler extends DG.ObjectHandler {
8
9
  get type(): string { return 'Plate'; }
@@ -17,24 +18,31 @@ export class PlateCellHandler extends DG.ObjectHandler {
17
18
  }
18
19
 
19
20
 
20
- @grok.decorators.cellRenderer({cellType: 'Plate'})
21
+ @grok.decorators.cellRenderer({cellType: 'Plate', name: 'PlateGridCellRenderer'})
21
22
  export class PlateGridCellRenderer extends DG.GridCellRenderer {
22
- plate = new PlateWidget();
23
+ plateWidget = new PlateWidget();
23
24
 
24
25
  get name(): string { return 'Plate'; }
25
26
  get cellType(): string { return 'Plate'; }
26
27
 
27
- getDefaultSize(gridColumn: GridColumn) { return { width: 120, height: 80 } }
28
+ getDefaultSize(_gridColumn: GridColumn) { return {width: 240, height: 160}; }
28
29
 
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;
30
+ // eslint-disable-next-line max-len
31
+ render(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, gridCell: DG.GridCell<DG.DataFrame | null>, _cellStyle: DG.GridCellStyle) {
32
+ if (gridCell.value == null) {
33
+ g.fillStyle = 'white';
34
+ g.fillRect(x, y, w, h);
35
+ return;
36
+ }
33
37
 
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)));
38
+ this.plateWidget.plate = Plate.fromTableByRow(gridCell.value!);
39
+ this.plateWidget.grid.props.colHeaderHeight = h > 120 ? 16 : 0;
40
+ this.plateWidget.grid.props.showRowHeader = w > 100;
41
+
42
+ this.plateWidget.grid.render(g, new DG.Rect(x, y, w, h).cutTop(Math.min(h / 20, 5)).cutRight(Math.min(w / 20, 5)));
35
43
  }
36
44
 
37
- onClick(gridCell: DG.GridCell, e: MouseEvent) {
38
- grok.shell.o = PlateWidget.detailedView(gridCell.value).root;
45
+ onClick(gridCell: DG.GridCell, _e: MouseEvent) {
46
+ grok.shell.o = PlateWidget.detailedView(Plate.fromTableByRow(gridCell.value!)).root;
39
47
  }
40
48
  }