@datagrok/api-samples 1.0.12 → 1.2.2

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 (138) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +2 -2
  3. package/dist/package-test.js +1848 -2
  4. package/dist/package.js +30 -2
  5. package/package.json +18 -17
  6. package/scripts/dapi/admin.js +5 -5
  7. package/scripts/dapi/applicable-layouts.js +3 -1
  8. package/scripts/dapi/fetch.js +8 -6
  9. package/scripts/dapi/files.js +7 -2
  10. package/scripts/dapi/projects-list.js +3 -3
  11. package/scripts/dapi/projects-open.js +4 -4
  12. package/scripts/dapi/who-am-i.js +10 -10
  13. package/scripts/data-access/db/ad-hoc-query.js +16 -0
  14. package/scripts/data-access/db/db-edit.js +6 -9
  15. package/scripts/data-access/{parameterized-query.js → db/parameterized-query.js} +3 -2
  16. package/scripts/data-access/db/query_builder_join.js +15 -0
  17. package/scripts/data-access/db/query_builder_simple.js +15 -0
  18. package/scripts/data-access/db-master-details-manual.js +9 -12
  19. package/scripts/data-access/external/stock-prices.js +2 -2
  20. package/scripts/data-access/files/file-exists.js +10 -0
  21. package/scripts/data-access/files/read-file.js +19 -0
  22. package/scripts/data-access/load-csv.js +2 -2
  23. package/scripts/data-access/save-and-load-df.js +6 -5
  24. package/scripts/data-frame/column-access.js +5 -1
  25. package/scripts/data-frame/columns-ordering.js +4 -0
  26. package/scripts/data-frame/construction/add-new-column.js +13 -0
  27. package/scripts/data-frame/construction/create-from-columns.js +4 -4
  28. package/scripts/data-frame/construction/date-time.js +24 -0
  29. package/scripts/data-frame/join-link/link-tables-dynamic.js +10 -9
  30. package/scripts/data-frame/join-link/link-tables.js +12 -8
  31. package/scripts/demo/med-chem.js +103 -0
  32. package/scripts/demo/stock-broker.js +1 -1
  33. package/scripts/domains/chem/chem-benchmark.js +0 -5
  34. package/scripts/domains/chem/descriptors.js +2 -4
  35. package/scripts/domains/chem/diversity-search.js +2 -4
  36. package/scripts/domains/chem/mcs.js +3 -3
  37. package/scripts/domains/chem/r-group.js +3 -3
  38. package/scripts/domains/chem/similarity-scoring-scores.js +3 -5
  39. package/scripts/domains/chem/similarity-scoring-sorted.js +3 -5
  40. package/scripts/domains/chem/substructure-search-smarts-molfile-als.js +11 -12
  41. package/scripts/domains/chem/substructure-search-smarts.js +4 -7
  42. package/scripts/domains/chem/substructure-search.js +5 -6
  43. package/scripts/domains/data-science/cluster.js +8 -10
  44. package/scripts/domains/data-science/missing-values-imputation.js +3 -3
  45. package/scripts/domains/data-science/pca.js +3 -3
  46. package/scripts/domains/data-science/predictive-model.js +4 -4
  47. package/scripts/domains/data-science/random-data.js +5 -6
  48. package/scripts/events/function-events.js +1 -1
  49. package/scripts/functions/caching-results.js +8 -9
  50. package/scripts/functions/calling.js +7 -10
  51. package/scripts/functions/func-call.js +4 -2
  52. package/scripts/functions/param-editor.js +1 -1
  53. package/scripts/functions/progress.js +2 -5
  54. package/scripts/functions/register-function.js +1 -1
  55. package/scripts/grid/advanced/column-groups.js +8 -0
  56. package/scripts/grid/advanced/dynamic-value-retrieval.js +12 -0
  57. package/scripts/grid/cell-types/tags-multi-cell.js +18 -0
  58. package/scripts/grid/color-coding/color-coding-conditional.js +1 -1
  59. package/scripts/grid/color-coding/color-coding.js +7 -4
  60. package/scripts/misc/audit/errors-summary.js +2 -2
  61. package/scripts/misc/audit/test-tracking.js +2 -2
  62. package/scripts/misc/audit/users-today.js +3 -5
  63. package/scripts/misc/package-credentials.js +2 -1
  64. package/scripts/performance/all-chembl-structures.js +2 -1
  65. package/scripts/scripting/grok-scripting.js +2 -3
  66. package/scripts/scripting/package-scripting.js +4 -2
  67. package/scripts/shell/windows/browse/customize-tree.js +1 -1
  68. package/scripts/statistics/pearson-correlation.js +39 -0
  69. package/scripts/ui/components/drop-down.js +9 -7
  70. package/scripts/ui/components/icons.js +7 -7
  71. package/scripts/ui/components/menu-advanced.js +85 -0
  72. package/scripts/ui/components/popup-menu.js +6 -5
  73. package/scripts/ui/components/summary-card.js +4 -3
  74. package/scripts/ui/containers/splitters.js +9 -17
  75. package/scripts/ui/handlers/markup-handlers.js +2 -3
  76. package/scripts/ui/inputs/advanced/all-input-types.js +21 -16
  77. package/scripts/ui/inputs/advanced/for-properties.js +1 -1
  78. package/scripts/ui/inputs/advanced/input-api.js +4 -5
  79. package/scripts/ui/inputs/advanced/input-form.js +5 -5
  80. package/scripts/ui/inputs/forms.js +5 -6
  81. package/scripts/ui/inputs/inputs.js +2 -2
  82. package/scripts/ui/inputs/validation/{visible-enabled.js → parameter-expressions.js} +1 -1
  83. package/scripts/ui/inputs/validation/{script-param-validation.js → parameter-validation.js} +2 -2
  84. package/scripts/ui/rendering/render-items.js +9 -9
  85. package/scripts/ui/tooltips/tooltip-events.js +2 -1
  86. package/scripts/ui/tooltips/tooltips.js +5 -0
  87. package/scripts/ui/viewers/advanced/descriptors.js +14 -0
  88. package/scripts/ui/viewers/filters/custom-filters.js +6 -5
  89. package/scripts/ui/viewers/js viewers/globe-viewer.js +7 -7
  90. package/scripts/ui/viewers/js viewers/surface-plot.js +19 -1
  91. package/scripts/ui/viewers/types/globe.js +2 -3
  92. package/scripts/ui/viewers/types/markup-advanced.js +1 -1
  93. package/scripts/ui/viewers/types/markup-eeg.js +5 -5
  94. package/scripts/ui/viewers/types/shape-map.js +4 -4
  95. package/scripts/ui/viewers/viewer-tooltips.js +1 -1
  96. package/scripts/ui/views/default-views.js +8 -7
  97. package/scripts/ui/widgets/widgets-tree.js +32 -0
  98. package/src/package-api.ts +8 -0
  99. package/src/package-test.ts +44 -31
  100. package/src/tests/owners.ts +8 -0
  101. package/test-console-output-1.log +6957 -0
  102. package/test-console-output-2.log +363 -0
  103. package/test-console-output-3.log +810 -0
  104. package/test-console-output-4.log +120 -0
  105. package/test-console-output-5.log +1069 -0
  106. package/test-console-output-6.log +972 -0
  107. package/test-console-output-7.log +7 -0
  108. package/test-record-1.mp4 +0 -0
  109. package/test-record-2.mp4 +0 -0
  110. package/test-record-3.mp4 +0 -0
  111. package/test-record-4.mp4 +0 -0
  112. package/test-record-5.mp4 +0 -0
  113. package/test-record-6.mp4 +0 -0
  114. package/test-record-7.mp4 +0 -0
  115. package/to fix/dynamic-loading.js +6 -6
  116. package/tsconfig.json +1 -1
  117. package/scripts/misc/audit/activity-today.js +0 -4
  118. package/src/global.d.ts +0 -13
  119. /package/scripts/data-access/{dynamic-query.js → db/dynamic-query.js} +0 -0
  120. /package/scripts/grid/{cell-bounds.js → advanced/cell-bounds.js} +0 -0
  121. /package/scripts/grid/{hit-test.js → advanced/hit-test.js} +0 -0
  122. /package/scripts/grid/{category-colors.js → color-coding/category-colors.js} +0 -0
  123. /package/scripts/grid/{custom-cell-prepare.js → events/custom-cell-prepare.js} +0 -0
  124. /package/scripts/grid/{custom-cell-rendering-indexes.js → events/custom-cell-rendering-indexes.js} +0 -0
  125. /package/scripts/grid/{custom-cell-rendering.js → events/custom-cell-rendering.js} +0 -0
  126. /package/scripts/grid/{custom-cell-tooltip.js → events/custom-cell-tooltip.js} +0 -0
  127. /package/scripts/grid/{scroll-bars.js → navigate/scroll-bars.js} +0 -0
  128. /package/scripts/grid/{scroll-to-cell.js → navigate/scroll-to-cell.js} +0 -0
  129. /package/scripts/grid/{scroll-to-pixels.js → navigate/scroll-to-pixels.js} +0 -0
  130. /package/scripts/grid/{order-columns.js → order/order-columns.js} +0 -0
  131. /package/scripts/grid/{order-rows-by-comparer.js → order/order-rows-by-comparer.js} +0 -0
  132. /package/scripts/grid/{order-rows.js → order/order-rows.js} +0 -0
  133. /package/scripts/grid/{hide-columns.js → resize/hide-columns.js} +0 -0
  134. /package/scripts/grid/{resize-columns.js → resize/resize-columns.js} +0 -0
  135. /package/scripts/grid/{resize-events.js → resize/resize-events.js} +0 -0
  136. /package/scripts/grid/{column-cell-styles.js → styles/column-cell-styles.js} +0 -0
  137. /package/scripts/grid/{column-controlled-values.js → styles/column-controlled-values.js} +0 -0
  138. /package/scripts/grid/{data-format.js → styles/data-format.js} +0 -0
@@ -0,0 +1,103 @@
1
+ let t = grok.shell.table('Med Chem') ?? grok.data.demo.molecules();
2
+ let rnd = (n) => Math.floor(n * Math.random());
3
+ let rnd1 = (n) => Math.ceil(n * Math.random());
4
+ let rndCat = (categories) => categories[rnd(categories.length)];
5
+ const addCatColumn = (columnName, categories, tags) => {
6
+ let c = t.col(columnName) ?? t.columns.addNewString(columnName).init((i) => rndCat(categories));
7
+ if (tags != null) {
8
+ for (let key of Object.getOwnPropertyNames(tags))
9
+ c.tags[key] = tags[key];
10
+ }
11
+ return c;
12
+ };
13
+
14
+ // HTS image
15
+ addCatColumn('HTS', ['https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Housebeemouth100x.jpg/120px-Housebeemouth100x.jpg', 'https://en.wikipedia.org/wiki/File:RiceStemcs400x1.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Rabbitttestis100x2.jpg/120px-Rabbitttestis100x2.jpg', 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/FernProthallium400x.jpg/120px-FernProthallium400x.jpg']);
16
+
17
+ // HTS data
18
+ t.columns.addNew('HTS data', DG.TYPE.DATA_FRAME).init((i) => grok.data.demo.doseResponse(96));
19
+
20
+ let stages = t.columns.addNewString('Stage').init((i) => 'Stage ' + rnd1(4));
21
+ let species = addCatColumn('Species', ['Mouse', 'Rat']);
22
+ let strains = {
23
+ 'Mouse': ['C57BL/6', 'BALB/c', 'Swiss Webster', 'DBA/2'],
24
+ 'Rat': ['Sprague Dawley', 'Wistar', 'Long-Evans', 'Fisher 344', 'Lewis'],
25
+ };
26
+ t.columns.addNewString('Strain').init((i) => rndCat(strains[species.get(i)]));
27
+
28
+ // Chemistry
29
+ const chemTags = {quality: 'Molecule', 'cell.renderer': 'Molecule'};
30
+ addCatColumn('Core', ['n1nc([*:3])n([*:2])c1[*:1]', 'C1C2CN([*:2])CC2CN1[*:1]', 'CC1(N[*:1])CCN([*:2])C1'], chemTags);
31
+ addCatColumn('R1', ['N#Cc1cccc(C[*:1])c1', 'COCC(=O)[*:1]', 'CC(C)N1CCC(N2CCN([*:1])CC2)CC1', 'O=C(C1CC1)[*:1]', 'C#CCN1CCN([*:1])CC1', 'COCCOC(C)[*:1]', 'CCNC(=O)CN1CCN([*:1])CC1', 'COCCOC1CCN([*:1])C1', 'Cc1cnc(C(=O)[*:1])cn1', 'CC(=O)[*:1]'], chemTags);
32
+ addCatColumn('R2', ['N#CC[*:2]', 'O=C(c1ccon1)[*:2]', 'Cn1nnnc1C[*:2]', 'O=C(C[*:2])NCC(F)(F)F', 'CS(=O)(=O)CC(=O)[*:2]', 'O=C(C[*:2])NCC(F)(F)F', 'O=C(C[*:2])NCC(F)(F)F', 'c1csc(C[*:2])n1', 'c1csc(C[*:2])n1', 'c1nonc1C[*:2]', 'O=C(CCOCC(F)(F)F)[*:2]'], chemTags);
33
+ addCatColumn('R3', ['C1CCC([*:3])OC1', 'Brc1ccc([*:3])s1', 'O=C(Nc1ccccn1)[*:3]', 'c1ccc(C[*:3])nc1', 'c1ccc(-n2cc([*:3])cn2)cc1', 'c1ccc([*:3])cc1', 'CN(Cc1ccc(S(C)(=O)=O)cc1)[*:3]', 'c1cncc([*:3])c1', 'CON(C)[*:3]', 'Cc1ccc(SC[*:3])cc1', 'Brc1ccc([*:3])s1', 'Cc1cccc([*:3])n1', 'C1CC1C[*:3]', 'C1CC([*:3])C1', 'CC1(C)CCN([*:3])CC1', 'CN(Cc1nc2ccccc2s1)[*:3]', 'CC(O)(C1CCN([*:3])CC1)C(F)(F)F'], chemTags);
34
+
35
+ // Classifications
36
+ addCatColumn('BSEP classification', ['>= 60 uM', '<= 30 uM', 'Inconclusive']);
37
+ addCatColumn('HLM CLint classification', ['<=25 uL/min/mg', '>100 uL/min/mg', 'Inconclusive']);
38
+ addCatColumn('RLM CLint classification', ['<=30 uL/min/mg', '>120 uL/min/mg', 'Inconclusive']);
39
+ addCatColumn('LE-MDCK Classification', ['<=5 cm-6/s', '>=5 cm-6/s', 'Inconclusive']);
40
+ addCatColumn('PAMPA Classification', ['<=-5.3 cm/s', '>= -4.5 cm/s', 'Inconclusive']);
41
+ addCatColumn('pH6.8 HT Solubility Classification', ['<10 uM', '>100 uM', 'Inconclusive']);
42
+
43
+
44
+ // Random boolean columns
45
+ const boolNames = ['hERG alert', 'Patent pending', 'Completed'];
46
+ for (let name of boolNames)
47
+ t.columns.addNewBool(name).init((i) => rnd(3) === 1);
48
+
49
+
50
+ const toxicityRisks = ['Mutagenicity', 'Tumorigenicity', 'Irritative effects', 'Reproductive effects'];
51
+ for (const risk of toxicityRisks)
52
+ t.columns.addNewBool(risk).init((i) => rnd(3) === 1);
53
+
54
+ // const warnings = ['Mutagenicity', 'Tumorigenicity', 'Irritative effects', 'Reproductive effects'];
55
+ // const warningsCol = t.columns.getOrCreate('Toxicity', 'string').init((i) => warnings.filter((i, j) => rnd(3) === 1).join(','));
56
+ // warningsCol.setTag(DG.TAGS.CELL_RENDERER, 'Tags');
57
+
58
+ t.columns.addNewString('Idea name').init((i) => 'GRK-' + rnd(10000));
59
+ addCatColumn('Idea status', ['Created', 'Approved', 'Synthesized']);
60
+ addCatColumn('Idea author', ['Jack Hammer', 'Paul Smith', 'Maria DePiotra', 'Marlon Voicek']);
61
+ let ideaCreated = t.columns.addNewDateTime('Idea created').init((_) => dayjs().year(1990 + rnd(30)).month(rnd1(12)).day(rnd1(28)).startOf('day'));
62
+ let ideaApproved = t.columns.addNewDateTime('Idea approved').init((i) => ideaCreated.get(i).add(rnd(100), 'day'));
63
+ let ideaSynthesized = t.columns.addNewDateTime('Idea synthesized').init((i) => ideaApproved.get(i).add(rnd(100), 'day'));
64
+ ideaCreated.tags.format = 'yyyy/MM/dd';
65
+ ideaApproved.tags.format = 'yyyy/MM/dd';
66
+ ideaSynthesized.tags.format = 'yyyy/MM/dd';
67
+
68
+
69
+ addCatColumn('PDB_ID', ['2PRO', '3PIS', '1OVO', '4PRO', '3PRO', '1N6E', '3B4R', '7CR9', '1BOQ', '6IHG', '7YUT', '4NJV', '1GBA', '7FIZ']);
70
+ if (!t.col('Affinity'))
71
+ t.columns.addNewFloat('Affinity').init((i) => Math.random() * -11.67 - 4.38);
72
+
73
+ if (!t.col('JIRA'))
74
+ t.columns.addNewString('JIRA').init((i) => Math.random() > 0.3 ? '' : 'GROK-' + rnd1(15000));
75
+
76
+ const plateFiles = ['file://System:DemoFiles/hts/plate-96-1.csv', 'file://System:DemoFiles/hts/plate-96-2.csv', 'file://System:DemoFiles/hts/plate-96-3.csv'];
77
+ addCatColumn('Plate file', plateFiles).tags['cell.renderer'] = 'File';
78
+ addCatColumn('Plate folder', ['file://System:DemoFiles/hts/']).tags['cell.renderer'] = 'File';
79
+
80
+ const groups = {
81
+ 'Docking': { columns: ['PDB_ID', 'Pose', 'Affinity'] },
82
+ 'Absorption': { color: '#0b74e1', columns: ['Caco2', 'Lipophilicity', 'Solubility'] },
83
+ 'Distribution': { color: '#9d05c5', columns: ['PPBR', 'VDss']},
84
+ 'Metabolism': { color: '#03a14f', columns: ['CYP1A2-Inhibitor', 'CYP2C19-Inhibitor', 'CYP2C9-Inhibitor', 'CYP2C9-Substrate', 'CYP2D6-Inhibitor', 'CYP2D6-Substrate']},
85
+ 'Excretion': { color: '#b47b4a', columns: ['CL-Hepa', 'CL-Micro', 'Half-Life']},
86
+ 'Toxicity': { color: '#ba0f0f', columns: ['hERG', 'LD50', 'Toxicity']},
87
+ 'Chemspace': { columns: ['Chemspace id', 'Vendor', 'Pack, mg', 'Price, USD', 'Lead time, days']},
88
+ 'DRC': { columns: ['DRC', 'DRC R2', 'DRC AUC', 'Plate', 'Plate file', 'Plate folder'] },
89
+ 'R-Groups': { columns: ['Core', 'R1', 'R2', 'R3'] },
90
+ 'Classifications': {columns: ['BSEP classification', 'HLM CLint classification', 'RLM CLint classification', 'LE-MDCK Classification', 'PAMPA Classification', 'pH6.8 HT Solubility Classification'] },
91
+ 'Ideation': { columns: ['Idea status', 'Idea author', 'Idea created', 'Idea approved', 'Idea synthesized']},
92
+ }
93
+
94
+ // settings virtual columns
95
+ const tv = grok.shell.getTableView('Med Chem');
96
+ if (tv) {
97
+ tv.grid.columns.add({gridColumnName: 'Toxicity risks', cellType: 'Tags'}).settings = { columns: toxicityRisks };
98
+ tv.grid.columns.add({gridColumnName: 'plate', cellType: 'Plate'})
99
+ .onPrepareValueScript = 'return grok.data.demo.wells(96); ';
100
+ }
101
+
102
+ t.meta.detectSemanticTypes();
103
+ t.meta.setGroups(groups);
@@ -42,7 +42,7 @@ function runStockBroker() {
42
42
  let view = grok.shell.addTableView(df);
43
43
 
44
44
  view.boxPlot({
45
- categoryColumnName: 'symbol',
45
+ categoryColumnNames: ['symbol'],
46
46
  valueColumnName: 'price'
47
47
  });
48
48
 
@@ -123,11 +123,6 @@ async function testCase(title, f) {
123
123
 
124
124
  });
125
125
 
126
- await testCase(`Substructure search (server), searching benzene in ${nSearch} molecules`, async () =>
127
- await grok.chem.searchSubstructureServer(col, searchFor[0]), false);
128
- await testCase(`Substructure search (server), searching aspirin in ${nSearch} molecules`, async () =>
129
- await grok.chem.searchSubstructureServer(col, searchFor[1]), false);
130
-
131
126
  /*
132
127
  await testCase(`Similarity scoring (server), search for ${
133
128
  queryIdx.length} samples in ${nSearch} molecules`, async () => {
@@ -1,10 +1,8 @@
1
1
  // An example of using diversity search.
2
2
  // https://datagrok.ai/help/domains/chem/descriptors
3
3
 
4
- grok.chem.descriptors(grok.data.testData('molecules', 100), 'smiles', ['MolWt', 'Lipinski'])
5
- .then(function(table) {
6
- grok.shell.addTableView(table);
7
- });
4
+ let table = await grok.chem.descriptors(grok.data.testData('molecules', 100), 'smiles', ['MolWt', 'Lipinski']);
5
+ grok.shell.addTableView(table);
8
6
 
9
7
  // In 'descriptors' parameter groups or descriptors can be specified.
10
8
  //
@@ -1,7 +1,5 @@
1
1
  // An example of using diversity search.
2
2
  // https://datagrok.ai/help/domains/chem/diversity-search
3
3
 
4
- grok.chem.diversitySearch(grok.data.testData('molecules', 100).col('smiles'))
5
- .then(function(mols) {
6
- grok.shell.addTableView(mols);
7
- });
4
+ let mols = await grok.chem.diversitySearch(grok.data.testData('molecules', 100).col('smiles'));
5
+ grok.shell.addTableView(mols);
@@ -1,5 +1,5 @@
1
1
  // An example of getting Maximum Common Substructure (MCS).
2
2
 
3
- grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
4
- .then(t => grok.chem.mcs(t, 'smiles')
5
- .then(mcs => grok.shell.info(mcs)));
3
+ let t = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
4
+ let mcs = await grok.chem.mcs(t, 'smiles');
5
+ grok.shell.info(mcs)
@@ -1,6 +1,6 @@
1
1
  // An example of getting R-Groups
2
2
  // https://datagrok.ai/help/domains/chem/r-group-analysis
3
3
 
4
- grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
5
- .then(t => grok.chem.rGroup(t, 'smiles', 'O=C1Nc2ccccc2C(C2CCCCC2)=NC1')
6
- .then(t => grok.shell.addTableView(t)));
4
+ let table = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
5
+ let groupedTable = await grok.chem.rGroup(table, 'smiles', 'O=C1Nc2ccccc2C(C2CCCCC2)=NC1');
6
+ grok.shell.addTableView(groupedTable);
@@ -1,5 +1,3 @@
1
- grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv').then(molecules =>
2
- grok.chem.getSimilarities(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1').then(similar =>
3
- grok.shell.addTableView(DG.DataFrame.fromColumns([similar]))
4
- )
5
- );
1
+ let molecules =await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
2
+ let similar = await grok.chem.getSimilarities(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
3
+ grok.shell.addTableView(DG.DataFrame.fromColumns([similar]));
@@ -1,5 +1,3 @@
1
- grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv').then(molecules =>
2
- grok.chem.findSimilar(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1').then(similar =>
3
- grok.shell.addTableView(similar)
4
- )
5
- );
1
+ let molecules = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
2
+ let similar = await grok.chem.findSimilar(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
3
+ grok.shell.addTableView(similar);
@@ -1,11 +1,11 @@
1
1
  // An example of using substructure search with SMARTS pattern,
2
2
  // encoded through an ALS parameter block of a MolFile
3
3
 
4
- grok.data.getDemoTable('chem/smiles.csv')
5
- .then(t => grok.chem.searchSubstructure(
6
- t.col('canonical_smiles'), `
7
- MJ201900
8
-
4
+ let t = await grok.data.getDemoTable("chem/smiles.csv");
5
+ let bs = await grok.chem.searchSubstructure(
6
+ t.col("canonical_smiles"),
7
+ `
8
+ MJ201900\n
9
9
  6 6 1 0 0 0 0 0 0 0999 V2000
10
10
  -1.9420 0.9589 0.0000 L 0 0 0 0 0 0 0 0 0 0 0 0
11
11
  -2.6564 0.5464 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
@@ -20,11 +20,10 @@ grok.data.getDemoTable('chem/smiles.csv')
20
20
  1 2 2 0 0 0 0
21
21
  6 1 1 0 0 0 0
22
22
  1 T 2 6 7
23
- M ALS 1 2 T C N
23
+ M ALS 1 2 T C N \n
24
24
  M END
25
- `,
26
- )
27
- .then(function(bs) {
28
- t.filter.copyFrom(bs);
29
- grok.shell.addTableView(t);
30
- }));
25
+ `
26
+ );
27
+
28
+ t.filter.copyFrom(bs);
29
+ grok.shell.addTableView(t);
@@ -1,9 +1,6 @@
1
1
  // An example of using substructure search with SMARTS pattern
2
2
 
3
- grok.data.getDemoTable('chem/smiles.csv')
4
- .then(t => grok.chem.searchSubstructure(
5
- t.col('canonical_smiles'), '[!#6&!#7]1:[#6]:[#6]:[#6]:[#6]:[#6]:1')
6
- .then(function(bs) {
7
- t.filter.copyFrom(bs);
8
- grok.shell.addTableView(t);
9
- }));
3
+ let t = await grok.data.getDemoTable('chem/smiles.csv');
4
+ let bs = await grok.chem.searchSubstructure(t.col('canonical_smiles'), '[!#6&!#7]1:[#6]:[#6]:[#6]:[#6]:[#6]:1')
5
+ t.filter.copyFrom(bs);
6
+ grok.shell.addTableView(t);
@@ -1,8 +1,7 @@
1
1
  // An example of using substructure search
2
2
 
3
- grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
4
- .then(t => grok.chem.searchSubstructure(t.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
5
- .then(function(bs) {
6
- t.filter.copyFrom(bs);
7
- grok.shell.addTableView(t);
8
- }));
3
+ let t = await grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv');
4
+ let bs = await grok.chem.searchSubstructure(t.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1');
5
+
6
+ t.filter.copyFrom(bs);
7
+ grok.shell.addTableView(t);
@@ -2,13 +2,11 @@
2
2
  //
3
3
  // https://datagrok.ai/help/explore/cluster-data
4
4
 
5
- grok.data.loadTable('https://public.datagrok.ai/demo/xclara.csv')
6
- .then(t => grok.ml.cluster(t, ["V1", "V2"], 3)
7
- .then((t) => {
8
- let view = grok.shell.addTableView(t);
9
- view.scatterPlot({
10
- x: 'V1',
11
- y: 'V2',
12
- color: 'clusters',
13
- });
14
- }));
5
+ let table = await grok.data.loadTable('https://public.datagrok.ai/demo/xclara.csv');
6
+ let clusteredTable = await grok.ml.cluster(table, ["V1", "V2"], 3)
7
+ let view = grok.shell.addTableView(clusteredTable);
8
+ view.scatterPlot({
9
+ x: 'V1',
10
+ y: 'V2',
11
+ color: 'clusters',
12
+ });
@@ -2,6 +2,6 @@
2
2
  //
3
3
  // https://datagrok.ai/help/transform/missing-values-imputation
4
4
 
5
- grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv')
6
- .then(t => grok.ml.missingValuesImputation(t, ['age', 'height', 'weight'], ['age', 'height', 'weight'], 5)
7
- .then(t => grok.shell.addTableView(t)));
5
+ let t1 = await grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv');
6
+ let t2 = await grok.ml.missingValuesImputation(t1, ['age', 'height', 'weight'], ['age', 'height', 'weight'], 5);
7
+ grok.shell.addTableView(t2);
@@ -2,6 +2,6 @@
2
2
  //
3
3
  // https://datagrok.ai/help/explore/pca
4
4
 
5
- grok.data.loadTable('https://public.datagrok.ai/demo/cars.csv')
6
- .then(t => grok.ml.pca(t, ["wheel.base", "length", "width", "height", "city.mpg", "price"], 2, true, true)
7
- .then(t => grok.shell.addTableView(t)));
5
+ let t1 = await grok.data.loadTable('https://public.datagrok.ai/demo/cars.csv');
6
+ let t2 = await grok.ml.pca(t1, ["wheel.base", "length", "width", "height", "city.mpg", "price"], 2, true, true);
7
+ grok.shell.addTableView(t2);
@@ -1,6 +1,6 @@
1
1
  // An example of using predictive models.
2
- // https://datagrok.ai/help/learn/predictive-modeling
2
+ // https://datagrok.ai/help/learn/
3
3
 
4
- grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv')
5
- .then(t => grok.ml.applyModel('Samples:Models:PredictSexByBasicDemographics', t)
6
- .then(t => grok.shell.addTableView(t)));
4
+ let t1 = await grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv');
5
+ let t2 = await grok.ml.applyModel('Samples:Models:PredictSexByBasicDemographics', t1);
6
+ grok.shell.addTableView(t2);
@@ -10,9 +10,8 @@ async function generate() {
10
10
  await grok.ml.randomData(t, 'binomial', {size: 100, prob: 0.7}, 77);
11
11
  }
12
12
 
13
- generate().then(function () {
14
- let view = grok.shell.addTableView(t);
15
- view.histogram({value: 'normal'});
16
- view.histogram({value: 'uniform'});
17
- view.histogram({value: 'binomial'});
18
- });
13
+ await generate();
14
+ let view = grok.shell.addTableView(t);
15
+ view.histogram({value: 'normal'});
16
+ view.histogram({value: 'uniform'});
17
+ view.histogram({value: 'binomial'});
@@ -6,7 +6,7 @@ grok.functions.onAfterRunAction.subscribe((_) => grok.shell.info('Runs after a c
6
6
  // Filtering events to specific function calls
7
7
  grok.functions
8
8
  .onAfterRunAction
9
- .pipe(rxjs.operators.filter((call) => call.func.name == 'Max'))
9
+ .pipe(rxjs.operators.filter((call) => call.func.name === 'Max'))
10
10
  .subscribe((call) => grok.shell.info(`Max of ${Array.from(call.inputs.values())}: ${call.getOutputParamValue()}`));
11
11
 
12
12
  let x = await DG.Func.byName('Abs').apply({ x: -5 });
@@ -23,14 +23,13 @@ grok.functions.register({
23
23
  });
24
24
 
25
25
  // results are cached
26
- grok.functions.call('bar', {x: 7}).then((result) => grok.shell.info(result));
27
- grok.functions.call('bar', {x: 7}).then((result) => grok.shell.info(result));
28
- grok.functions.call('bar', {x: 7}).then((result) => grok.shell.info(result));
29
-
30
- grok.functions.call('bar', {x: 8}).then((result) => grok.shell.info(result));
31
- grok.functions.call('bar', {x: 8}).then((result) => grok.shell.info(result));
32
-
33
- grok.functions.call('foo', {x: 12}).then((result) => grok.shell.info(result));
34
- grok.functions.call('foo', {x: 12}).then((result) => grok.shell.info(result));
26
+ grok.shell.info(await grok.functions.call('bar', {x: 7}));
27
+ grok.shell.info(await grok.functions.call('bar', {x: 7}));
28
+ grok.shell.info(await grok.functions.call('bar', {x: 8}));
29
+ grok.shell.info(await grok.functions.call('bar', {x: 8}));
30
+ grok.shell.info(await grok.functions.call('bar', {x: 12}));
31
+ grok.shell.info(await grok.functions.call('bar', {x: 12}));
32
+ grok.shell.info(await grok.functions.call('bar', {x: 12}));
35
33
 
34
+ grok.shell.info(result);
36
35
  grok.shell.info(counts);
@@ -5,15 +5,12 @@
5
5
  // Calling "RDup" function that belongs to the "RSrcipts" package
6
6
  // It is implemented in R and returns a duplicated string
7
7
  // https://github.com/datagrok-ai/public/blob/master/packages/Samples/scripts/r/r_dup.R
8
- grok.functions
9
- .call("Samples:RDup", {s: "Foo"})
10
- .then((res) => {
11
- grok.shell.info(res);
12
- });
8
+ let res1 = await grok.functions
9
+ .call("Samples:RDup", {s: "Foo"});
10
+ grok.shell.info(res1);
11
+
13
12
 
14
13
  // This is a core function, package name could be omitted
15
- grok.functions
16
- .call("Sin", {x: 1.5})
17
- .then((res) => {
18
- grok.shell.info(res);
19
- });
14
+ let res2 = await grok.functions
15
+ .call("Sin", {x: 1.5});
16
+ grok.shell.info(res2);
@@ -7,7 +7,8 @@ grok.shell.info(f.name + '(' + inputs + ')' + ': ' + outputs);
7
7
 
8
8
  // simple way: f.apply
9
9
  // Any function can be called asynchronously
10
- f.apply({x: 0.5}).then((result) => grok.shell.info(result));
10
+ let result = await f.apply({x: 0.5});
11
+ grok.shell.info(result);
11
12
 
12
13
  // If we know that this is sync function, AND it's either a core function or a plugin is loaded already,
13
14
  // then we can call it synchronously using applySync:
@@ -20,4 +21,5 @@ grok.shell.info('Input name and type: ' + fc.inputParams['x'].name + ' ' + fc.in
20
21
  grok.shell.info('Input value:' + fc.inputs['x']);
21
22
 
22
23
  grok.shell.info(fc.inputs['x']);
23
- fc.call().then((call) => grok.shell.info(call.outputs['result']));
24
+ let call = await fc.call();
25
+ grok.shell.info(call.outputs['result'])
@@ -1,2 +1,2 @@
1
1
  let f = DG.Func.find({name: 'Sin'})[0];
2
- f.prepare().getEditor().then((editor) => grok.shell.o = editor);
2
+ grok.shell.o = await f.prepare().getEditor();
@@ -3,8 +3,5 @@ p.onProgressUpdated.subscribe((p) => grok.shell.info(p.percent));
3
3
  p.onLogUpdated.subscribe((line) => console.log(line));
4
4
  p.update(50, "Loading foo.csv");
5
5
 
6
- grok.functions.call("Samples:RDup",
7
- {s: "hi"}, true, p)
8
- .then((res) => {
9
- grok.shell.info(res);
10
- });
6
+ let res = await grok.functions.call("Samples:RDup", {s: "hi"}, true, p);
7
+ grok.shell.info(res);
@@ -7,7 +7,7 @@
7
7
  // To test jsWidget, create a new Dashboard, and click on "Widget" under "Widgets".
8
8
  //
9
9
  // See also https://datagrok.ai/help/datagrok/functions/function,
10
- // https://datagrok.ai/help/develop/js-api#registering-functions
10
+ // https://datagrok.ai/js-api#registering-functions
11
11
 
12
12
  grok.functions.register({
13
13
  signature: 'String jsConcat(int foo, int bar)',
@@ -0,0 +1,8 @@
1
+ let table = grok.data.demo.demog();
2
+ table.meta.setGroups(
3
+ {
4
+ 'Demographics' : { color: '#861616', columns: ['sex', 'race', 'age'] },
5
+ 'Biometrics': { color: '#1544A9FF', columns: ['height', 'weight'] }
6
+ })
7
+
8
+ let view = grok.shell.addTableView(table);
@@ -0,0 +1,12 @@
1
+ // Adds a virtual column with the renderer defined in the PowerGrid package (make sure the package is installed).
2
+
3
+ const grid = grok.shell.addTableView(grok.data.demo.demog()).grid;
4
+ //grid.columns.byName('age').onPrepareValueScript = 'return 42;';
5
+ //grid.columns.byName('sex').onPrepareValueScript = 'return "42";';
6
+
7
+ //grid.columns.add({gridColumnName: 'table', cellType: 'dataframe'})
8
+ // .onPrepareValueScript = 'return await grok.dapi.files.readCsv("System:DemoFiles/demog.csv")';
9
+
10
+ grid.columns.add({gridColumnName: 'plate', cellType: 'Plate'})
11
+ .onPrepareValueScript = 'return await grok.dapi.files.readCsv("System:DemoFiles/hts/plate-96-1.csv")';
12
+ //.onPrepareValueScript = 'return grok.data.demo.wells(96); ';
@@ -0,0 +1,18 @@
1
+ // Additional cell types supported in the PowerPack package
2
+
3
+ const t = DG.DataFrame.create(2);
4
+
5
+ // MultiChoice: each cell becomes a list of checkboxes
6
+ const dis = t.columns.addNewString('disease');
7
+ dis.set(0, 'Anxiety, Glaucoma');
8
+ dis.set(1, 'Hepatitis A, Glaucoma');
9
+ dis.meta.choices = ['Anxiety', 'Hepatitis A', 'Glaucoma'];
10
+ dis.setTag(DG.TAGS.CELL_RENDERER, 'MultiChoice');
11
+
12
+ // Tags: renders each value as a colored tag
13
+ const site = t.columns.addNewString('site');
14
+ site.set(0, 'Buffalo, Orlando');
15
+ site.set(1, 'Buffalo, Los Angeles');
16
+ site.setTag(DG.TAGS.CELL_RENDERER, 'Tags');
17
+
18
+ grok.shell.addTableView(t);
@@ -4,8 +4,8 @@ let t = grok.data.demo.demog();
4
4
 
5
5
  // Linear or conditional color coding for numerical or datetime columns
6
6
  t.col('height').meta.colors.setConditional({"20-170": "#00FF00", "170-190": "#220505"});
7
- t.col('age').meta.colors.setLinear([DG.Color.orange, DG.Color.green]);
8
7
  t.col('started').meta.colors.setLinear([DG.Color.white, DG.Color.red]);
8
+ t.col('age').meta.colors.setLinearAbsolute({19: '#bcbd22', 31.75: '#17becf', 44.50: '#ff9896', 70: '#c5b0d5'});
9
9
  t.col('weight').meta.colors.setConditional({'<100': DG.Color.green, '100-200': '#ff0000'});
10
10
 
11
11
  // Categorical for string columns
@@ -1,15 +1,18 @@
1
1
  const t = grok.data.demo.demog();
2
2
 
3
3
  // Conditional color-coding for numerical columns
4
- t.col('height').meta.colors.setConditional({"20-170": "#00FF00", "170-190": "#220505"});
4
+ t.col('height').meta.colors.setConditional({'20-170': '#00FF00', '170-190': "#220505"});
5
5
 
6
6
  // Linear color-coding for numerical columns
7
- t.col('age').meta.colors.setLinear(["#ff0000", "#ffff00", "#00ff00"]);
7
+ t.col('age').meta.colors.setLinear(['#ff0000', '#ffff00', '#00ff00'], {min: 19, belowMinColor: '#ac3400', max: 70});
8
+
9
+ // Linear color-coding with absolute values for numerical columns
10
+ t.col('weight').meta.colors.setLinearAbsolute({58.31: '#73aff5', 137.65: '#ffa500', 177.32: '#50af28', 217: '#9467bd'}, {aboveMaxColor: '#ff0000'});
8
11
 
9
12
  // Categorical color-coding for string columns
10
- t.col('race').meta.colors.setCategorical({"Asian": 4278190335, "Black": 4286578816});
13
+ t.col('race').meta.colors.setCategorical({'Asian': 4278190335, 'Black': 4286578816});
11
14
 
12
15
  grok.shell.addTableView(t);
13
16
 
14
17
  // To turn the color-coding off, use either approach:
15
- // t.col('height').meta.colors.setDisabled();
18
+ // t.col('height').meta.colors.setDisabled();
@@ -1,2 +1,2 @@
1
- grok.data.query('UsageAnalysis:TopPackageErrors', {date: 'this week', users: ['all']})
2
- .then((t) => grok.shell.addTableView(t));
1
+ let errors = await grok.data.query('UsageAnalysis:TopErrors', {date: 'this week'})
2
+ grok.shell.addTableView(errors)
@@ -1,2 +1,2 @@
1
- const df = await grok.data.query('UsageAnalysis:Tests');
2
- grok.shell.addTableView(df);
1
+ const df = await grok.data.query('UsageAnalysis:TestsDashboard', {instanceFilter: 'dev', lastBuildsNum: 5, packageFilter: null, showNotRun: false, showBenchmarks: false, showNotCiCd: false,versionFilter: null});
2
+ grok.shell.addTableView(df)
@@ -1,8 +1,6 @@
1
1
  //help-url: https://datagrok.ai/help/govern/user
2
2
  const view = grok.shell.newView('Usage');
3
3
 
4
- grok.data.query('UsageAnalysis:Usage', {date: 'today', users: ['all']})
5
- .then((t) => {
6
- const ids = new Set(t.getCol('user_id').toList());
7
- grok.dapi.getEntities([...ids]).then((users) => view.append(ui.list(users)));
8
- });
4
+ let t = await grok.data.query('UsageAnalysis:UniqueUsersList', {date: 'yesterday'});
5
+ const ids = new Set(t.getCol('id').toList());
6
+ grok.dapi.getEntities([...ids]).then((users) => view.append(ui.list(users)));
@@ -3,4 +3,5 @@
3
3
  // Read more about package credentials: https://datagrok.ai/help/develop/how-to/manage-credentials
4
4
 
5
5
  let p = await grok.dapi.packages.filter('Api Samples').first();
6
- p.getCredentials().then((c) => grok.shell.info(c ? c : 'Credentials are not set.'));
6
+ let c = await p.getCredentials();
7
+ grok.shell.info(c ? c.openParameters : 'Credentials are not set.');
@@ -1,3 +1,4 @@
1
1
  // Retrieve all molecules from chembl (~2 millions), and visualize in the grid
2
2
 
3
- grok.data.query('Chembl:CbAllChemblStructures', {}).then(t => grok.shell.addTableView(t));
3
+ let t = await grok.data.query('Chembl:CbAllChemblStructures', {});
4
+ grok.shell.addTableView(t);
@@ -1,3 +1,2 @@
1
- grok.functions
2
- .eval('OpenServerFile("System:DemoFiles/beer.csv")')
3
- .then((t) => grok.shell.addTableView(t[0]));
1
+ let t = await grok.functions.eval('OpenServerFile("System:DemoFiles/beer.csv")');
2
+ grok.shell.addTableView(t[0]);
@@ -2,5 +2,7 @@
2
2
  //help-url: https://datagrok.ai/help/compute/scripting
3
3
  // An example of using scripting (R, Python etc.)
4
4
 
5
- grok.functions.call('Samples:PythonDup', {'s': '1010'}).then(result => grok.shell.info(result));
6
- grok.functions.call('Samples:RDup', {'s': '0101'}).then(result => grok.shell.info(result));
5
+ let result1 = await grok.functions.call('Samples:PythonDup', {'s': '1010'});
6
+ let result2 = await grok.functions.call('Samples:RDup', {'s': '0101'});
7
+ grok.shell.info(result1);
8
+ grok.shell.info(result2)
@@ -1,3 +1,3 @@
1
1
  grok.events.onBrowseNodeCreated
2
- .pipe(rxjs.operators.filter(node => node.text === 'Namespaces'))
2
+ .pipe(rxjs.operators.filter(node => node.text === 'Spaces'))
3
3
  .subscribe(node => node.item('Custom node'));