@datagrok/api-samples 1.0.6 → 1.0.8

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 (152) hide show
  1. package/.eslintrc.json +47 -0
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +8 -8
  4. package/dist/package-test.js +2 -2
  5. package/files.js +39 -0
  6. package/package.json +18 -9
  7. package/scripts/dapi/groups.js +3 -0
  8. package/scripts/dapi/users.js +1 -1
  9. package/scripts/data-access/db-master-details-manual.js +3 -3
  10. package/scripts/data-access/parameterized-query.js +3 -3
  11. package/scripts/data-frame/bitset/similarity-metrics.js +3 -3
  12. package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
  13. package/scripts/data-frame/filtering/update-filter-state.js +13 -0
  14. package/scripts/data-frame/modification/remove-where.js +8 -0
  15. package/scripts/data-frame/row-matching/patterns.js +1 -3
  16. package/scripts/domains/chem/chem-benchmark.js +26 -26
  17. package/scripts/domains/chem/descriptors.js +1 -2
  18. package/scripts/domains/chem/diversity-search.js +3 -5
  19. package/scripts/domains/chem/inspect-molecule.js +1 -1
  20. package/scripts/domains/chem/mcs.js +2 -3
  21. package/scripts/domains/chem/mol-atoms-bonds.js +1 -2
  22. package/scripts/domains/chem/mol-panel.js +0 -1
  23. package/scripts/domains/chem/mol-rendering-canvas.js +4 -6
  24. package/scripts/domains/chem/mol-rendering.js +0 -1
  25. package/scripts/domains/chem/r-group.js +3 -5
  26. package/scripts/domains/chem/similarity-scoring-scores.js +0 -3
  27. package/scripts/domains/chem/similarity-scoring-sorted.js +0 -3
  28. package/scripts/domains/chem/substructure-search-benchmark.js +5 -8
  29. package/scripts/domains/chem/substructure-search-smarts-molfile-als.js +6 -9
  30. package/scripts/domains/chem/substructure-search-smarts.js +4 -7
  31. package/scripts/domains/chem/substructure-search.js +1 -4
  32. package/scripts/domains/data-science/predictive-model.js +2 -3
  33. package/scripts/functions/caching-results.js +36 -0
  34. package/scripts/functions/calling.js +2 -2
  35. package/scripts/functions/discover-functions.js +1 -1
  36. package/scripts/functions/func-call.js +18 -0
  37. package/scripts/functions/progress.js +2 -7
  38. package/scripts/grid/advanced/charts-in-cells.js +16 -14
  39. package/scripts/grid/advanced/link-click.js +19 -0
  40. package/scripts/grid/advanced/pinned-columns.js +7 -0
  41. package/scripts/grid/advanced/pinned-rows.js +8 -0
  42. package/scripts/grid/advanced/visible-cells.js +3 -4
  43. package/scripts/grid/scroll-to-pixels.js +9 -4
  44. package/scripts/misc/audit/activity-today.js +3 -3
  45. package/scripts/misc/audit/errors-summary.js +2 -4
  46. package/scripts/misc/audit/test-tracking.js +2 -4
  47. package/scripts/misc/audit/users-today.js +6 -7
  48. package/scripts/misc/package-credentials.js +2 -4
  49. package/scripts/misc/sdtm.js +8 -10
  50. package/scripts/misc/utils/hide-empty-columns.js +17 -4
  51. package/scripts/performance/all-chembl-structures.js +1 -1
  52. package/scripts/scripting/grok-scripting.js +1 -1
  53. package/scripts/scripting/scripting.js +2 -2
  54. package/scripts/shell/last-error.js +0 -4
  55. package/scripts/shell/windows/shell-windows.js +6 -0
  56. package/scripts/ui/components/balloons.js +4 -1
  57. package/scripts/ui/{elements → components}/color-palettes.js +4 -4
  58. package/scripts/ui/components/html-tables.js +27 -0
  59. package/scripts/ui/components/loading-indicators.js +4 -6
  60. package/scripts/ui/components/menu-customization.js +18 -0
  61. package/scripts/ui/components/property-grid.js +10 -10
  62. package/scripts/ui/{layouts → containers}/splitters.js +3 -3
  63. package/scripts/ui/css.js +20 -0
  64. package/scripts/ui/inputs/advanced/all-input-types.js +47 -0
  65. package/scripts/ui/inputs/{for-properties.js → advanced/for-properties.js} +17 -2
  66. package/scripts/ui/inputs/advanced/input-form.js +10 -0
  67. package/scripts/ui/inputs/forms.js +35 -0
  68. package/scripts/ui/inputs/grid-input.js +14 -0
  69. package/scripts/ui/inputs/inputs.js +24 -0
  70. package/scripts/ui/{elements/inputs → inputs}/table-input.js +1 -2
  71. package/scripts/ui/inputs/typeahead-input.js +19 -0
  72. package/scripts/ui/viewers/custom-scatterplot-rendering.js +1 -1
  73. package/scripts/ui/viewers/custom-viewer-properties.js +5 -5
  74. package/scripts/ui/viewers/js viewers/chord-viewer.js +3 -0
  75. package/scripts/ui/viewers/js viewers/globe-viewer.js +13 -0
  76. package/scripts/ui/viewers/js viewers/radar-viewer.js +9 -0
  77. package/scripts/ui/viewers/js viewers/sankey-viewer.js +4 -0
  78. package/scripts/ui/viewers/js viewers/sunburst-viewer.js +3 -0
  79. package/scripts/ui/viewers/js viewers/surface-plot.js +2 -0
  80. package/scripts/ui/viewers/js viewers/timelines-viewer.js +3 -0
  81. package/scripts/ui/viewers/js viewers/tree-viewer.js +3 -0
  82. package/scripts/ui/viewers/js viewers/word-cloud.js +5 -0
  83. package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +14 -0
  84. package/scripts/ui/views/currently-open-views.js +5 -5
  85. package/src/package-test.ts +40 -1
  86. package/scripts/dapi/files.js +0 -39
  87. package/scripts/misc/audit/errors.js +0 -4
  88. package/scripts/misc/audit/event-types-summary.js +0 -4
  89. package/scripts/misc/audit/rolling-events.js +0 -11
  90. package/scripts/ui/apps/color-checker.js +0 -328
  91. package/scripts/ui/components/panels.js +0 -19
  92. package/scripts/ui/docking/README.md +0 -16
  93. package/scripts/ui/elements/html-tables.js +0 -24
  94. package/scripts/ui/elements/inputs/inputs.js +0 -46
  95. package/scripts/ui/elements/inputs/typeahead-input.js +0 -8
  96. package/scripts/ui/layouts/templates/2 Column.js +0 -14
  97. package/scripts/ui/layouts/templates/3 Column.js +0 -15
  98. package/scripts/ui/layouts/templates/Flex box.js +0 -16
  99. package/scripts/ui/layouts/templates/Fluid layout.js +0 -19
  100. package/scripts/ui/layouts/templates/Gallery grid.js +0 -18
  101. package/scripts/ui/layouts/templates/Splitter (1 Column 2 Row).js +0 -19
  102. package/scripts/ui/layouts/templates/Splitter (2 Column).js +0 -16
  103. package/scripts/ui/layouts/templates/Splitter (2 Row).js +0 -18
  104. package/scripts/ui/layouts/templates/Splitter (2-3 Column).js +0 -23
  105. package/scripts/ui/layouts/templates/Tabs 2 column.js +0 -19
  106. package/scripts/ui/layouts/templates/Tabs navbar.js +0 -16
  107. package/scripts/ui/viewers/types/google-map.js +0 -5
  108. package/scripts/ux/Dialogs/add-new-column-dlg.js +0 -58
  109. package/scripts/ux/Dialogs/link-table-dlg.js +0 -23
  110. package/scripts/ux/Filters/data-filtering.js +0 -99
  111. package/scripts/ux/Input forms/form-types.js +0 -133
  112. package/scripts/ux/Input forms/misc.js +0 -52
  113. package/scripts/ux/Layouts/example-1.js +0 -50
  114. package/scripts/ux/Layouts/example-2.js +0 -63
  115. package/scripts/ux/Layouts/example-3.js +0 -192
  116. package/scripts/ux/Layouts/example-4.js +0 -51
  117. package/scripts/ux/Managing Collections/datasource-view.js +0 -47
  118. package/scripts/ux/Views/property-panel.js +0 -120
  119. package/scripts/ux/Views/toolbar.js +0 -131
  120. package/scripts/ux/Views/toolbox.js +0 -124
  121. /package/scripts/ui/{elements → components}/buttons.js +0 -0
  122. /package/scripts/ui/{elements → components}/icons.js +0 -0
  123. /package/scripts/ui/{elements → components}/image.js +0 -0
  124. /package/scripts/ui/{elements → components}/list.js +0 -0
  125. /package/scripts/ui/{elements → components}/range-slider.js +0 -0
  126. /package/scripts/ui/{cards → components}/summary-card.js +0 -0
  127. /package/scripts/ui/{elements → components}/typography.js +0 -0
  128. /package/scripts/ui/{layouts → containers}/blocks.js +0 -0
  129. /package/scripts/ui/{layouts → containers}/box.js +0 -0
  130. /package/scripts/ui/{layouts → containers}/containers.js +0 -0
  131. /package/scripts/ui/{layouts → containers}/flexbox.js +0 -0
  132. /package/scripts/ui/{layouts → containers}/panels.js +0 -0
  133. /package/scripts/ui/inputs/{custom-inputs.js → advanced/custom-inputs.js} +0 -0
  134. /package/scripts/ui/inputs/{for-columns.js → advanced/for-columns.js} +0 -0
  135. /package/scripts/ui/inputs/{input-events.js → advanced/input-events.js} +0 -0
  136. /package/scripts/ui/inputs/{master-details.js → advanced/master-details.js} +0 -0
  137. /package/scripts/ui/{elements/inputs → inputs}/choice-input.js +0 -0
  138. /package/scripts/ui/{elements/inputs → inputs}/column-combo-box.js +0 -0
  139. /package/scripts/ui/{elements/inputs → inputs}/column-inputs.js +0 -0
  140. /package/scripts/ui/{elements/inputs → inputs}/inputs-events.js +0 -0
  141. /package/scripts/ui/{elements/inputs → inputs}/inputs-extended.js +0 -0
  142. /package/scripts/ui/{elements/inputs → inputs}/molecule-input.js +0 -0
  143. /package/scripts/ui/{elements/inputs → inputs}/tags-input.js +0 -0
  144. /package/scripts/{ux/Interactivity → ui/interactivity}/drag-and-drop.js +0 -0
  145. /package/scripts/{ux/Interactivity → ui/interactivity}/hints.js +0 -0
  146. /package/scripts/{ux/Interactivity → ui/interactivity}/wizard-hints.js +0 -0
  147. /package/scripts/{ux/Rendering → ui/rendering}/render-items.js +0 -0
  148. /package/scripts/ui/{components/tooltips → tooltips}/row-group-tooltips.js +0 -0
  149. /package/scripts/ui/{components/tooltips → tooltips}/tooltip-events.js +0 -0
  150. /package/scripts/ui/{components/tooltips → tooltips}/tooltips.js +0 -0
  151. /package/scripts/{ux/Navigations → ui/views}/navigation.js +0 -0
  152. /package/scripts/{ux/Managing Collections → ui/views}/virtual-view.js +0 -0
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@datagrok/api-samples",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "author": {
5
- "name": "Alexander Paramonov",
6
- "email": "aparamonov@datagrok.ai"
5
+ "name": "Anna Muzychyna",
6
+ "email": "amuzychyna@datagrok.ai"
7
7
  },
8
+ "servicePackage": true,
8
9
  "dependencies": {
9
- "@datagrok-libraries/utils": "^1.15.5",
10
+ "@datagrok-libraries/utils": "^4.1.19",
10
11
  "cash-dom": "^8.1.1",
11
- "datagrok-api": "^1.12.0",
12
+ "datagrok-api": "^1.17.2",
12
13
  "dayjs": "latest",
13
14
  "rxjs": "^6.6.7",
14
15
  "wu": "latest"
@@ -17,14 +18,20 @@
17
18
  "@types/wu": "^2.1.42",
18
19
  "@typescript-eslint/eslint-plugin": "^5.26.0",
19
20
  "@typescript-eslint/parser": "^5.26.0",
20
- "datagrok-tools": "^4.7.2",
21
21
  "eslint": "^8.16.0",
22
22
  "eslint-config-google": "^0.14.0",
23
23
  "root-require": "latest",
24
24
  "ts-loader": "^9.2.6",
25
25
  "typescript": "^4.4.4",
26
26
  "webpack": "^5.59.1",
27
- "webpack-cli": "^4.9.1"
27
+ "webpack-cli": "^4.9.1",
28
+ "@datagrok/chem": "latest",
29
+ "@datagrok/clinical-case": "latest",
30
+ "@datagrok/power-grid": "latest",
31
+ "@datagrok/usage-analysis": "latest",
32
+ "@datagrok/charts": "latest",
33
+ "@datagrok/chembl": "latest",
34
+ "@datagrok/samples": "latest"
28
35
  },
29
36
  "friendlyName": "API Samples",
30
37
  "description": "API Samples",
@@ -40,7 +47,9 @@
40
47
  "build": "webpack",
41
48
  "test": "grok test",
42
49
  "test-dev": "grok test --host dev",
43
- "test-local": "grok test --host localhost"
50
+ "test-local": "grok test --host localhost",
51
+ "link-all": "npm link datagrok-api @datagrok-libraries/utils",
52
+ "build-all": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm run build"
44
53
  },
45
54
  "canEdit": [
46
55
  "Developers"
@@ -49,4 +58,4 @@
49
58
  "All users"
50
59
  ],
51
60
  "category": "Development"
52
- }
61
+ }
@@ -24,6 +24,9 @@ async function groupsTest() {
24
24
 
25
25
  // Delete subgroup
26
26
  await grok.dapi.groups.delete(demoSubGroup);
27
+
28
+ // Delete Demo group
29
+ await grok.dapi.groups.delete(demoGroup);
27
30
  }
28
31
 
29
32
  groupsTest();
@@ -3,4 +3,4 @@ user.login = 'newlogin';
3
3
  user.firstName = 'new';
4
4
  user.lastName = 'user';
5
5
 
6
- await grok.dapi.users.save(user);
6
+ // await grok.dapi.users.save(user);
@@ -1,11 +1,11 @@
1
1
  //tags: DataQuery
2
- //help-url: https://datagrok.ai/help/access/parameterized-queries
2
+ //help-url: https://datagrok.ai/help/access/databases#parameterized-queries
3
3
  // Manual master-details linking of tables that are dynamically retrieved from the database
4
- grok.data.query('Demo:Northwind:Countries', {}).then((countries) => {
4
+ grok.data.query('Samples:Countries', {}).then((countries) => {
5
5
  let customersView = null;
6
6
  grok.shell.addTableView(countries);
7
7
  countries.onCurrentRowChanged.subscribe((_) => {
8
- grok.data.query('northwind:customersByCountry', {country: countries.currentRow['country']}).then((t) => {
8
+ grok.data.query('Samples:CustomersInCountry', {country: countries.currentRow['country']}).then((t) => {
9
9
  if (customersView === null)
10
10
  customersView = grok.shell.addTableView(t);
11
11
  customersView.dataFrame = t;
@@ -1,6 +1,6 @@
1
1
  //tags: DataQuery
2
- //help-url: https://datagrok.ai/help/access/parameterized-queries
2
+ //help-url: https://datagrok.ai/help/access/databases#parameterized-queries
3
3
  // An example of using parameterized query
4
4
 
5
- grok.data.query('System:CoffeeCompany:StoresInState', {'state': 'NY'})
6
- .then(t => grok.shell.info('Stores: ' + t.rowCount));
5
+ grok.data.query('DBTests:PostgresqlByDouble', {freight: 100.1})
6
+ .then(t => grok.shell.info('Number of orders: ' + t.rowCount));
@@ -4,8 +4,8 @@ let bs1 = DG.BitSet.fromString('00000');
4
4
  let bs2 = DG.BitSet.fromString('00100');
5
5
 
6
6
  // both should be 1:
7
- console.log(bs1.similarityTo(bs1, 'tanimoto'));
8
- console.log(bs1.similarityTo(bs1));
7
+ grok.shell.info(bs1.similarityTo(bs1, 'tanimoto'));
8
+ grok.shell.info(bs1.similarityTo(bs1));
9
9
 
10
10
  // should be 0:
11
- console.log(bs1.similarityTo(bs2, 'tanimoto'))
11
+ grok.shell.info(bs1.similarityTo(bs2, 'tanimoto'))
@@ -13,6 +13,6 @@ Zambia, Africa, 1992, 46.1, 8381163, 1210.8846436
13
13
  `);
14
14
 
15
15
  let view = grok.shell.addTableView(table);
16
- grok.shell.info(`Format detected on 'gdpPercap': ${table.columns['gdpPercap'].tags[DG.TAGS.FORMAT]}`);
17
- grok.shell.info(`Format detected on 'lifeExp': ${table.columns['lifeExp'].tags[DG.TAGS.FORMAT]}`);
18
- grok.shell.info(`Max significant digits detected for 'lifeExp': ${table.columns['lifeExp'].tags[DG.TAGS.SOURCE_PRECISION]}`);
16
+ grok.shell.info(`Format detected on 'gdpPercap': ${table.getCol('gdpPercap').tags[DG.TAGS.FORMAT]}`);
17
+ grok.shell.info(`Format detected on 'lifeExp': ${table.getCol('lifeExp').tags[DG.TAGS.FORMAT]}`);
18
+ grok.shell.info(`Max significant digits detected for 'lifeExp': ${table.getCol('lifeExp').tags[DG.TAGS.SOURCE_PRECISION]}`);
@@ -0,0 +1,13 @@
1
+ //updating state of opened filter
2
+ let beer = await grok.data.getDemoTable('beer.csv');
3
+ let view = grok.shell.addTableView(beer)
4
+
5
+ setTimeout(function(){
6
+ let filters = view.filters()
7
+ filters.updateOrAdd({
8
+ type: "text",
9
+ column: "Flavor",
10
+ gridNames: ['malt'],
11
+ value: "sour"
12
+ })
13
+ }, 500)
@@ -0,0 +1,8 @@
1
+ let t = DG.DataFrame.fromCsv(
2
+ `make, model, cylinders, volume, price
3
+ Honda, Civic, 4, 1.4, 15000
4
+ Honda, Accord, 6, 1.8, 20000
5
+ Tesla, Roadster, , 1.6, 100000
6
+ Tesla, Model S, , 1.6, 120000`);
7
+ t.rows.removeWhere((row) => row.get('make') === 'Honda');
8
+ grok.shell.addTableView(t);
@@ -1,9 +1,7 @@
1
1
  // Matching rows by patterns.
2
- //
3
2
 
4
- let d = grok.data.demo.demog(20000);
3
+ let d = grok.data.demo.demog(1000);
5
4
  grok.shell.addTableView(d).scatterPlot();
6
5
 
7
- d.rows.match({ age: '>30', sex: 'M'}).filter();
8
6
  d.rows.match('age > 50').select();
9
7
  d.rows.match('race = Asian').highlight();
@@ -1,16 +1,14 @@
1
- //name: chemBenchmark
2
- //language: javascript
3
-
4
1
  // https://stackoverflow.com/a/47593316
2
+
5
3
  function mulberry32(a) {
6
- return function() {
7
- var t = a += 0x6D2B79F5;
8
- t = Math.imul(t ^ t >>> 15, t | 1);
9
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
10
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
11
- }
4
+ return function() {
5
+ let t = a += 0x6D2B79F5;
6
+ t = Math.imul(t ^ t >>> 15, t | 1);
7
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
8
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
9
+ };
12
10
  }
13
- var rand = mulberry32(42); // seed = 42
11
+ let rand = mulberry32(42); // seed = 42
14
12
 
15
13
  const randomInt = (min, max) => min + Math.floor((max - min) * rand());
16
14
  const range = (l, r) => new Array(r - l).fill().map((_, k) => k + l);
@@ -18,7 +16,7 @@ const range = (l, r) => new Array(r - l).fill().map((_, k) => k + l);
18
16
  function getIdxRandomSubset(N, n) {
19
17
  let arr = range(0, N);
20
18
  let shuffled = arr.slice(0);
21
- let i = arr.length, temp, index;
19
+ let i = arr.length; let temp; let index;
22
20
  while (i--) {
23
21
  index = randomInt(0, i + 1);
24
22
  temp = shuffled[index];
@@ -39,7 +37,7 @@ let caseCntr = 0;
39
37
  async function testCase(title, f) {
40
38
  let msg = await DG.timeAsync(++caseCntr + '. ' + title, f);
41
39
  if (typeof msg === 'string')
42
- console.log(" " + msg);
40
+ console.log(' ' + msg);
43
41
  }
44
42
 
45
43
  (async () => {
@@ -73,26 +71,26 @@ async function testCase(title, f) {
73
71
 
74
72
  rowsInd = getIdxRandomSubarray(nSearch, nRender);
75
73
  await testCase(`Rendering a ${rowsInd.length} random molecules`, () => {
76
- for (i of rowsInd) {
74
+ for (i of rowsInd)
77
75
  render(i);
78
- }
76
+
79
77
  });
80
78
 
81
79
  rowsInd = getIdxRandomSubarray(nSearch, nScroll);
82
80
  await testCase(`Horizontal scrolling (${rowsInd.length} random molecules, ${tScroll} times)`, () => {
83
81
  for (let t = 0; t < tScroll; ++t) {
84
- for (let i of rowsInd) {
82
+ for (let i of rowsInd)
85
83
  render(i);
86
- }
84
+
87
85
  }
88
86
  });
89
87
 
90
88
  rowsInd = getIdxRandomSubarray(nSearch, nScroll + tScroll);
91
89
  await testCase(`Vertical scrolling (${nScroll} random molecules, ${tScroll} times)`, () => {
92
90
  for (let t = 0; t < tScroll; ++t) {
93
- for (let i of rowsInd.slice(t, t + nScroll)) {
91
+ for (let i of rowsInd.slice(t, t + nScroll))
94
92
  render(i);
95
- }
93
+
96
94
  }
97
95
  });
98
96
 
@@ -100,7 +98,7 @@ async function testCase(title, f) {
100
98
  'c1ccccc1', // Benzene https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL277500/
101
99
  'CC(=O)Oc1ccccc1C(=O)O', // Aspirin https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL25/
102
100
  'CCCCCCCCCCCCCCCCCC(=O)O', // Stearic acid https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL46403/
103
- 'NCCCC[C@H](N)C(=O)O' // Lusine https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL8085/
101
+ 'NCCCC[C@H](N)C(=O)O', // Lusine https://www.ebi.ac.uk/chembl/compound_report_card/CHEMBL8085/
104
102
  ];
105
103
 
106
104
  const searchForNames = ['Benzene', 'Aspirin', 'Stearic acid', 'Lusine'];
@@ -109,17 +107,20 @@ async function testCase(title, f) {
109
107
  await grok.chem.searchSubstructure(col));
110
108
 
111
109
 
112
- for (let i = 0; i < searchFor.length; ++i)
110
+ for (let i = 0; i < searchFor.length; ++i) {
113
111
  await testCase(`Substructure search, searching ${searchForNames[i]} in ${nSearch} molecules`, async () => {
114
- let s = await grok.chem.searchSubstructure(col, searchFor[i]); return `Found ${s.trueCount} molecules for ${searchFor[i]}`; });
112
+ let s = await grok.chem.searchSubstructure(col, searchFor[i]);
113
+ return `Found ${s.trueCount} molecules for ${searchFor[i]}`;
114
+ });
115
+ }
115
116
 
116
117
  await testCase(`Similarity scoring, building a library of ${col.length} molecules`, async () =>
117
118
  await grok.chem.getSimilarities(col));
118
119
  const queryIdx = getIdxRandomSubset(nSearch, nSample);
119
120
  await testCase(`Similarity scoring, search for ${queryIdx.length} samples in ${nSearch} molecules`, async () => {
120
- for (let i of queryIdx) {
121
+ for (let i of queryIdx)
121
122
  await grok.chem.getSimilarities(col, col.get(i));
122
- }
123
+
123
124
  });
124
125
 
125
126
  await testCase(`Substructure search (server), searching benzene in ${nSearch} molecules`, async () =>
@@ -128,10 +129,9 @@ async function testCase(title, f) {
128
129
  await grok.chem.searchSubstructureServer(col, searchFor[1]), false);
129
130
 
130
131
  /*
131
- await testCase(`Similarity scoring (server), search for ${queryIdx.length} samples in ${nSearch} molecules`, async () => {
132
+ await testCase(`Similarity scoring (server), search for ${
133
+ queryIdx.length} samples in ${nSearch} molecules`, async () => {
132
134
  await grok.chem.findSimilarServer(col, searchFor[0]);
133
135
  });
134
136
  */
135
-
136
-
137
137
  })();
@@ -1,9 +1,8 @@
1
1
  // An example of using diversity search.
2
- //
3
2
  // https://datagrok.ai/help/domains/chem/descriptors
4
3
 
5
4
  grok.chem.descriptors(grok.data.testData('molecules', 100), 'smiles', ['MolWt', 'Lipinski'])
6
- .then(function (table) {
5
+ .then(function(table) {
7
6
  grok.shell.addTableView(table);
8
7
  });
9
8
 
@@ -1,9 +1,7 @@
1
1
  // An example of using diversity search.
2
- //
3
2
  // https://datagrok.ai/help/domains/chem/diversity-search
4
3
 
5
4
  grok.chem.diversitySearch(grok.data.testData('molecules', 100).col('smiles'))
6
- .then(function (mols) {
7
- let col = DG.Column.fromStrings('smiles', mols);
8
- grok.shell.addTableView(DG.DataFrame.fromColumns([col]));
9
- });
5
+ .then(function(mols) {
6
+ grok.shell.addTableView(mols);
7
+ });
@@ -1 +1 @@
1
- grok.shell.o = DG.SemanticValue.fromValueType('Fc1cc(Cl)ccc1Br', 'Molecule')
1
+ grok.shell.o = DG.SemanticValue.fromValueType('Fc1cc(Cl)ccc1Br', 'Molecule');
@@ -1,6 +1,5 @@
1
1
  // An example of getting Maximum Common Substructure (MCS).
2
2
 
3
3
  grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
4
- .then(t => grok.chem.mcs(t.col('smiles'))
5
- .then(mcs => grok.shell.info(mcs)));
6
-
4
+ .then(t => grok.chem.mcs(t, 'smiles')
5
+ .then(mcs => grok.shell.info(mcs)));
@@ -1,5 +1,4 @@
1
1
  // Atom manipulations
2
- //
3
2
  // Original example: http://www.cheminfo.org/Chemistry/Cheminformatics/OpenChemLib_js/index.html
4
3
  // For more details, visit https://github.com/cheminfo/openchemlib-js
5
4
 
@@ -31,7 +30,7 @@ for (let i = 0; i < m.getAllAtoms(); i++) {
31
30
  atom.queryFeatures = m.getAtomQueryFeatures(i);
32
31
  atom.radical = m.getAtomRadical(i);
33
32
  atom.x = m.getAtomX(i);
34
- atom.y = m.getAtomY(i)
33
+ atom.y = m.getAtomY(i);
35
34
  atom.z = m.getAtomZ(i);
36
35
  atom.allConnected = m.getAllConnAtoms(i);
37
36
  atom.hydrogens = m.getAllHydrogens(i);
@@ -1,7 +1,6 @@
1
1
  // Register a function that provides an information panel for a molecule.
2
2
  // It gets natively integrated with the platform's data augmentation system.
3
3
  // To see the panel in action, open a file containing molecules, and click on a molecule.
4
- //
5
4
  // See also: https://datagrok.ai/help/discover/info-panels
6
5
 
7
6
  grok.functions.register({
@@ -1,6 +1,4 @@
1
- //name: chemTestCanvasMol
2
- //description: Test rendering a single molecule to a canvas with an optional SMARTS-scaffold
3
- //language: javascript
1
+ // Test rendering a single molecule to a canvas with an optional SMARTS-scaffold
4
2
 
5
3
  (async () => {
6
4
  let root = ui.div();
@@ -22,7 +20,7 @@
22
20
  0, 0, width, height, canvas2,
23
21
  'CN1CCC(O)(CC1)c2ccccc2');
24
22
  ui
25
- .dialog({title:'Test molecule'})
26
- .add(root)
27
- .show();
23
+ .dialog({title: 'Test molecule'})
24
+ .add(root)
25
+ .show();
28
26
  })();
@@ -1,5 +1,4 @@
1
1
  // Different ways to render a molecule using the openchemlib library
2
- //
3
2
  // For more details, visit https://github.com/cheminfo/openchemlib-js
4
3
 
5
4
  grok.shell.newView('chem rendering').root.appendChild(ui.div([
@@ -1,8 +1,6 @@
1
- // An example of getting R-Groups.
2
- //
1
+ // An example of getting R-Groups
3
2
  // https://datagrok.ai/help/domains/chem/r-group-analysis
4
3
 
5
4
  grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
6
- .then(t => grok.chem.rGroup(t, 'smiles', 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
7
- .then(t => grok.shell.addTableView(t)));
8
-
5
+ .then(t => grok.chem.rGroup(t, 'smiles', 'O=C1Nc2ccccc2C(C2CCCCC2)=NC1')
6
+ .then(t => grok.shell.addTableView(t)));
@@ -1,6 +1,3 @@
1
- //name: testSimilarityScoringScores
2
- //language: javascript
3
-
4
1
  grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv').then(molecules =>
5
2
  grok.chem.getSimilarities(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1').then(similar =>
6
3
  grok.shell.addTableView(DG.DataFrame.fromColumns([similar]))
@@ -1,6 +1,3 @@
1
- //name: testSimilarityScoringSorted
2
- //language: javascript
3
-
4
1
  grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv').then(molecules =>
5
2
  grok.chem.findSimilar(molecules.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1').then(similar =>
6
3
  grok.shell.addTableView(similar)
@@ -1,12 +1,10 @@
1
- //name: testSubstructureSearch
2
- //description: Substructure search via RDKit
3
- //language: javascript
1
+ // Substructure search via RDKit
4
2
 
5
3
  async function time(name, n, f) {
6
4
  let start = new Date();
7
- for (let k = 0; k < n; ++k) {
5
+ for (let k = 0; k < n; ++k)
8
6
  await f();
9
- }
7
+
10
8
  let stop = new Date();
11
9
  console.log(`${name}: ${(stop - start) / n} ms`);
12
10
  }
@@ -26,7 +24,7 @@ async function time(name, n, f) {
26
24
 
27
25
  await time(`Graph-based search on ${df.rowCount} molecules`, n, async () => {
28
26
  for (let s of searchFor) {
29
- let result = await grok.chem.searchSubstructure(col, s, {substructLibrary: false});
27
+ await grok.chem.searchSubstructure(col, s, {substructLibrary: false});
30
28
  // console.log(s + ": " + result.toString());
31
29
  }
32
30
  });
@@ -37,9 +35,8 @@ async function time(name, n, f) {
37
35
 
38
36
  await time(`Searching the library on ${searchFor.length} molecules`, n, async () => {
39
37
  for (let s of searchFor) {
40
- let result = await grok.chem.searchSubstructure(col, s);
38
+ await grok.chem.searchSubstructure(col, s);
41
39
  // console.log(s + ": " + result.toString());
42
40
  }
43
41
  });
44
-
45
42
  })();
@@ -1,6 +1,3 @@
1
- //name: testSubstructureSearchSmarts
2
- //language: javascript
3
-
4
1
  // An example of using substructure search with SMARTS pattern,
5
2
  // encoded through an ALS parameter block of a MolFile
6
3
 
@@ -25,9 +22,9 @@ grok.data.getDemoTable('chem/smiles.csv')
25
22
  1 T 2 6 7
26
23
  M ALS 1 2 T C N
27
24
  M END
28
- `
29
- )
30
- .then(function (bs) {
31
- t.filter.copyFrom(bs);
32
- grok.shell.addTableView(t);
33
- }));
25
+ `,
26
+ )
27
+ .then(function(bs) {
28
+ t.filter.copyFrom(bs);
29
+ grok.shell.addTableView(t);
30
+ }));
@@ -1,12 +1,9 @@
1
- //name: testSubstructureSearchSmarts
2
- //language: javascript
3
-
4
1
  // An example of using substructure search with SMARTS pattern
5
2
 
6
3
  grok.data.getDemoTable('chem/smiles.csv')
7
4
  .then(t => grok.chem.searchSubstructure(
8
5
  t.col('canonical_smiles'), '[!#6&!#7]1:[#6]:[#6]:[#6]:[#6]:[#6]:1')
9
- .then(function (bs) {
10
- t.filter.copyFrom(bs);
11
- grok.shell.addTableView(t);
12
- }));
6
+ .then(function(bs) {
7
+ t.filter.copyFrom(bs);
8
+ grok.shell.addTableView(t);
9
+ }));
@@ -1,11 +1,8 @@
1
- //name: testSubstructureSearchLibrary
2
- //language: javascript
3
-
4
1
  // An example of using substructure search
5
2
 
6
3
  grok.data.loadTable('https://public.datagrok.ai/demo/sar_small.csv')
7
4
  .then(t => grok.chem.searchSubstructure(t.col('smiles'), 'O=C1CN=C(C2CCCCC2)C2:C:C:C:C:C:2N1')
8
- .then(function (bs) {
5
+ .then(function(bs) {
9
6
  t.filter.copyFrom(bs);
10
7
  grok.shell.addTableView(t);
11
8
  }));
@@ -1,7 +1,6 @@
1
1
  // An example of using predictive models.
2
- //
3
2
  // https://datagrok.ai/help/learn/predictive-modeling
4
3
 
5
4
  grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv')
6
- .then(t => grok.ml.applyModel('Demo:PredictSexByBasicDemographics', t)
7
- .then(t => grok.shell.addTableView(t)));
5
+ .then(t => grok.ml.applyModel('Samples:Models:PredictSexByBasicDemographics', t)
6
+ .then(t => grok.shell.addTableView(t)));
@@ -0,0 +1,36 @@
1
+ // Demonstrates function result caching.
2
+ // The following code uses dynamic function registration, for package functions you can do that:
3
+ // //input: int x
4
+ // //output: int bar
5
+ // //meta.cache: true
6
+
7
+ //grok.functions.clientCache.clear();
8
+ let counts = {};
9
+
10
+ grok.functions.register({
11
+ signature: 'int bar(int x)',
12
+ run: (x) => {
13
+ grok.shell.info('Evaluating bar(' + x + ')');
14
+ return x * x;
15
+ },
16
+ options: { cache: 'true', 'cache.invalidateOn': '* * * * *'} // invalidate every minute
17
+ });
18
+
19
+ grok.functions.register({
20
+ signature: 'int foo(int x)',
21
+ run: (x) => { grok.shell.info('Evaluating foo(' + x + ')'); return x; },
22
+ options: { cache: 'true'}
23
+ });
24
+
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));
35
+
36
+ grok.shell.info(counts);
@@ -4,9 +4,9 @@
4
4
 
5
5
  // Calling "RDup" function that belongs to the "RSrcipts" package
6
6
  // It is implemented in R and returns a duplicated string
7
- // https://github.com/datagrok-ai/public/blob/master/packages/DemoScripts/scripts/r/r_dup.R
7
+ // https://github.com/datagrok-ai/public/blob/master/packages/Samples/scripts/r/r_dup.R
8
8
  grok.functions
9
- .call("DemoScripts:RDup", {s: "Foo"})
9
+ .call("Samples:RDup", {s: "Foo"})
10
10
  .then((res) => {
11
11
  grok.shell.info(res);
12
12
  });
@@ -4,4 +4,4 @@ let widgetFunctions = DG.Func.find({returnType: 'widget'});
4
4
 
5
5
  let dialog = ui.dialog().show();
6
6
  for (let f of widgetFunctions)
7
- f.apply().then((w) => dialog.add(w));
7
+ dialog.add(ui.render(f));
@@ -0,0 +1,18 @@
1
+ let f = DG.Func.find({name: 'Sin'})[0];
2
+
3
+ // inspect function parameters
4
+ let inputs = f.inputs.map(input => input.propertyType + ' ' + input.name);
5
+ let outputs = f.outputs.map(output => output.propertyType + ' ' + output.name);
6
+ grok.shell.info(f.name + '(' + inputs + ')' + ': ' + outputs);
7
+
8
+ // simple way: f.apply
9
+ f.apply({x: 0.5}).then((result) => grok.shell.info(result));
10
+
11
+ // more complex: preparing a FuncCall that lets you track inputs and outputs, intercept execution, etc
12
+ let fc = f.prepare({"x": 0.5});
13
+
14
+ grok.shell.info('Input name and type: ' + fc.inputParams['x'].name + ' ' + fc.inputParams['x'].property.propertyType);
15
+ grok.shell.info('Input value:' + fc.inputs['x']);
16
+
17
+ grok.shell.info(fc.inputs['x']);
18
+ fc.call().then((call) => grok.shell.info(call.outputs['result']));
@@ -1,15 +1,10 @@
1
- //tags: Func
2
- // See Discovery:countToTen function:
3
- // https://github.com/datagrok-ai/public/blob/master/packages/Discovery/src/package.js
4
-
5
1
  let p = DG.ProgressIndicator.create();
6
2
  p.onProgressUpdated.subscribe((p) => grok.shell.info(p.percent));
7
3
  p.onLogUpdated.subscribe((line) => console.log(line));
8
4
  p.update(50, "Loading foo.csv");
9
5
 
10
-
11
- grok.functions.call("Discovery:countToTen",
12
- {s: "a"}, true, p)
6
+ grok.functions.call("Samples:RDup",
7
+ {s: "hi"}, true, p)
13
8
  .then((res) => {
14
9
  grok.shell.info(res);
15
10
  });
@@ -6,23 +6,25 @@ let tv = grok.shell.addTableView(t);
6
6
  tv.grid.columns.byName('ic50').cellType = 'html';
7
7
  tv.grid.columns.byName('hist').cellType = 'html';
8
8
  tv.grid.columns.byName('ic50').width = 300;
9
-
10
- const lineOptions = {
11
- xColumnName: 'concentration [ug/ml]',
12
- yColumnNames: ['viability [%]'],
13
- splitColumnName: 'compound',
14
- xAxisType: 'logarithmic',
15
- style: 'dashboard',
16
- showTopPanel: 'false',
17
- showSplitSelector: 'false',
18
- legendVisibility: 'Never',
19
- showXAxis: 'false',
20
- showYAxis: 'false',
21
- showLegend: 'false'
22
- };
9
+ tv.grid.columns.byName('hist').width = 300;
23
10
 
24
11
  tv.grid.setOptions({rowHeight: 200});
12
+
25
13
  tv.grid.onCellPrepare((gc) => {
14
+ const lineOptions = {
15
+ xColumnName: 'concentration [ug/ml]',
16
+ yColumnNames: ['viability [%]'],
17
+ splitColumnName: 'compound',
18
+ xAxisType: 'logarithmic',
19
+ style: 'dashboard',
20
+ showTopPanel: 'false',
21
+ showSplitSelector: 'false',
22
+ legendVisibility: 'Never',
23
+ showXAxis: 'false',
24
+ showYAxis: 'false',
25
+ showLegend: 'false'
26
+ };
27
+
26
28
  if (gc.isTableCell && gc.gridColumn.name === 'ic50' && gc.cell.value != null)
27
29
  gc.style.element = gc.cell.value.plot.line(lineOptions).root;
28
30
  if (gc.isTableCell && gc.gridColumn.name === 'hist' && gc.cell.value != null)