@datagrok/api-samples 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +47 -0
- package/CHANGELOG.md +9 -0
- package/README.md +8 -8
- package/dist/package-test.js +2 -2
- package/package.json +16 -9
- package/scripts/dapi/files.js +12 -12
- package/scripts/dapi/groups.js +3 -0
- package/scripts/dapi/users.js +1 -1
- package/scripts/data-access/db-master-details-manual.js +3 -3
- package/scripts/data-access/parameterized-query.js +3 -3
- package/scripts/data-frame/bitset/similarity-metrics.js +3 -3
- package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
- package/scripts/data-frame/modification/remove-where.js +8 -0
- package/scripts/data-frame/row-matching/patterns.js +1 -3
- package/scripts/domains/chem/chem-benchmark.js +26 -26
- package/scripts/domains/chem/descriptors.js +1 -2
- package/scripts/domains/chem/diversity-search.js +3 -5
- package/scripts/domains/chem/inspect-molecule.js +1 -1
- package/scripts/domains/chem/mcs.js +2 -3
- package/scripts/domains/chem/mol-atoms-bonds.js +1 -2
- package/scripts/domains/chem/mol-panel.js +0 -1
- package/scripts/domains/chem/mol-rendering-canvas.js +4 -6
- package/scripts/domains/chem/mol-rendering.js +0 -1
- package/scripts/domains/chem/r-group.js +3 -5
- package/scripts/domains/chem/similarity-scoring-scores.js +0 -3
- package/scripts/domains/chem/similarity-scoring-sorted.js +0 -3
- package/scripts/domains/chem/substructure-search-benchmark.js +5 -8
- package/scripts/domains/chem/substructure-search-smarts-molfile-als.js +6 -9
- package/scripts/domains/chem/substructure-search-smarts.js +4 -7
- package/scripts/domains/chem/substructure-search.js +1 -4
- package/scripts/domains/data-science/predictive-model.js +2 -3
- package/scripts/functions/caching-results.js +36 -0
- package/scripts/functions/calling.js +2 -2
- package/scripts/functions/discover-functions.js +1 -1
- package/scripts/functions/func-call.js +18 -0
- package/scripts/functions/progress.js +2 -7
- package/scripts/grid/advanced/charts-in-cells.js +16 -14
- package/scripts/grid/advanced/link-click.js +19 -0
- package/scripts/grid/advanced/pinned-columns.js +7 -0
- package/scripts/grid/advanced/pinned-rows.js +8 -0
- package/scripts/grid/advanced/visible-cells.js +3 -4
- package/scripts/grid/scroll-to-pixels.js +9 -4
- package/scripts/misc/audit/activity-today.js +3 -3
- package/scripts/misc/audit/errors-summary.js +2 -4
- package/scripts/misc/audit/test-tracking.js +2 -4
- package/scripts/misc/audit/users-today.js +6 -7
- package/scripts/misc/package-credentials.js +2 -4
- package/scripts/misc/sdtm.js +8 -10
- package/scripts/misc/utils/hide-empty-columns.js +17 -4
- package/scripts/scripting/grok-scripting.js +1 -1
- package/scripts/scripting/scripting.js +2 -2
- package/scripts/shell/last-error.js +0 -4
- package/scripts/shell/windows/shell-windows.js +6 -0
- package/scripts/ui/components/balloons.js +4 -1
- package/scripts/ui/{elements → components}/color-palettes.js +4 -4
- package/scripts/ui/components/html-tables.js +27 -0
- package/scripts/ui/components/loading-indicators.js +4 -6
- package/scripts/ui/components/menu-customization.js +18 -0
- package/scripts/ui/components/property-grid.js +10 -10
- package/scripts/ui/{layouts → containers}/splitters.js +3 -3
- package/scripts/ui/css.js +20 -0
- package/scripts/ui/inputs/advanced/all-input-types.js +47 -0
- package/scripts/ui/inputs/{for-properties.js → advanced/for-properties.js} +17 -2
- package/scripts/ui/inputs/advanced/input-form.js +10 -0
- package/scripts/ui/inputs/forms.js +35 -0
- package/scripts/ui/inputs/grid-input.js +14 -0
- package/scripts/ui/inputs/inputs.js +24 -0
- package/scripts/ui/{elements/inputs → inputs}/table-input.js +1 -2
- package/scripts/ui/inputs/typeahead-input.js +19 -0
- package/scripts/ui/viewers/custom-scatterplot-rendering.js +1 -1
- package/scripts/ui/viewers/custom-viewer-properties.js +5 -5
- package/scripts/ui/viewers/js viewers/chord-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/globe-viewer.js +13 -0
- package/scripts/ui/viewers/js viewers/radar-viewer.js +9 -0
- package/scripts/ui/viewers/js viewers/sankey-viewer.js +4 -0
- package/scripts/ui/viewers/js viewers/sunburst-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/surface-plot.js +2 -0
- package/scripts/ui/viewers/js viewers/timelines-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/tree-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/word-cloud.js +5 -0
- package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +14 -0
- package/scripts/ui/views/currently-open-views.js +5 -5
- package/src/package-test.ts +31 -1
- package/scripts/misc/audit/errors.js +0 -4
- package/scripts/misc/audit/event-types-summary.js +0 -4
- package/scripts/misc/audit/rolling-events.js +0 -11
- package/scripts/ui/apps/color-checker.js +0 -328
- package/scripts/ui/components/panels.js +0 -19
- package/scripts/ui/elements/html-tables.js +0 -24
- package/scripts/ui/elements/inputs/inputs.js +0 -46
- package/scripts/ui/elements/inputs/typeahead-input.js +0 -8
- package/scripts/ui/layouts/templates/2 Column.js +0 -14
- package/scripts/ui/layouts/templates/3 Column.js +0 -15
- package/scripts/ui/layouts/templates/Flex box.js +0 -16
- package/scripts/ui/layouts/templates/Fluid layout.js +0 -19
- package/scripts/ui/layouts/templates/Gallery grid.js +0 -18
- package/scripts/ui/layouts/templates/Splitter (1 Column 2 Row).js +0 -19
- package/scripts/ui/layouts/templates/Splitter (2 Column).js +0 -16
- package/scripts/ui/layouts/templates/Splitter (2 Row).js +0 -18
- package/scripts/ui/layouts/templates/Splitter (2-3 Column).js +0 -23
- package/scripts/ui/layouts/templates/Tabs 2 column.js +0 -19
- package/scripts/ui/layouts/templates/Tabs navbar.js +0 -16
- package/scripts/ui/viewers/types/google-map.js +0 -5
- package/scripts/ux/Dialogs/add-new-column-dlg.js +0 -58
- package/scripts/ux/Dialogs/link-table-dlg.js +0 -23
- package/scripts/ux/Filters/data-filtering.js +0 -99
- package/scripts/ux/Input forms/form-types.js +0 -133
- package/scripts/ux/Input forms/misc.js +0 -52
- package/scripts/ux/Layouts/example-1.js +0 -50
- package/scripts/ux/Layouts/example-2.js +0 -63
- package/scripts/ux/Layouts/example-3.js +0 -192
- package/scripts/ux/Layouts/example-4.js +0 -51
- package/scripts/ux/Managing Collections/datasource-view.js +0 -47
- package/scripts/ux/Views/property-panel.js +0 -120
- package/scripts/ux/Views/toolbar.js +0 -131
- package/scripts/ux/Views/toolbox.js +0 -124
- /package/scripts/ui/{elements → components}/buttons.js +0 -0
- /package/scripts/ui/{elements → components}/icons.js +0 -0
- /package/scripts/ui/{elements → components}/image.js +0 -0
- /package/scripts/ui/{elements → components}/list.js +0 -0
- /package/scripts/ui/{elements → components}/range-slider.js +0 -0
- /package/scripts/ui/{cards → components}/summary-card.js +0 -0
- /package/scripts/ui/{elements → components}/typography.js +0 -0
- /package/scripts/ui/{layouts → containers}/blocks.js +0 -0
- /package/scripts/ui/{layouts → containers}/box.js +0 -0
- /package/scripts/ui/{layouts → containers}/containers.js +0 -0
- /package/scripts/ui/{layouts → containers}/flexbox.js +0 -0
- /package/scripts/ui/{layouts → containers}/panels.js +0 -0
- /package/scripts/ui/inputs/{custom-inputs.js → advanced/custom-inputs.js} +0 -0
- /package/scripts/ui/inputs/{for-columns.js → advanced/for-columns.js} +0 -0
- /package/scripts/ui/inputs/{input-events.js → advanced/input-events.js} +0 -0
- /package/scripts/ui/inputs/{master-details.js → advanced/master-details.js} +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/choice-input.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/column-combo-box.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/column-inputs.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/inputs-events.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/inputs-extended.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/molecule-input.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/tags-input.js +0 -0
- /package/scripts/{ux/Interactivity → ui/interactivity}/drag-and-drop.js +0 -0
- /package/scripts/{ux/Interactivity → ui/interactivity}/hints.js +0 -0
- /package/scripts/{ux/Interactivity → ui/interactivity}/wizard-hints.js +0 -0
- /package/scripts/{ux/Rendering → ui/rendering}/render-items.js +0 -0
- /package/scripts/ui/{components/tooltips → tooltips}/row-group-tooltips.js +0 -0
- /package/scripts/ui/{components/tooltips → tooltips}/tooltip-events.js +0 -0
- /package/scripts/ui/{components/tooltips → tooltips}/tooltips.js +0 -0
- /package/scripts/{ux/Navigations → ui/views}/navigation.js +0 -0
- /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.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"author": {
|
|
5
|
-
"name": "
|
|
6
|
-
"email": "
|
|
5
|
+
"name": "Anna Muzychyna",
|
|
6
|
+
"email": "amuzychyna@datagrok.ai"
|
|
7
7
|
},
|
|
8
|
+
"servicePackage": true,
|
|
8
9
|
"dependencies": {
|
|
9
|
-
"@datagrok-libraries/utils": "^1.
|
|
10
|
+
"@datagrok-libraries/utils": "^4.1.19",
|
|
10
11
|
"cash-dom": "^8.1.1",
|
|
11
|
-
"datagrok-api": "^1.
|
|
12
|
+
"datagrok-api": "^1.17.0",
|
|
12
13
|
"dayjs": "latest",
|
|
13
14
|
"rxjs": "^6.6.7",
|
|
14
15
|
"wu": "latest"
|
|
@@ -17,14 +18,18 @@
|
|
|
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": "^1.8.3",
|
|
29
|
+
"@datagrok/clinical-case": "^1.0.2",
|
|
30
|
+
"@datagrok/power-grid": "^1.2.0",
|
|
31
|
+
"@datagrok/usage-analysis": "^1.0.2",
|
|
32
|
+
"@datagrok/charts": "^1.2.2"
|
|
28
33
|
},
|
|
29
34
|
"friendlyName": "API Samples",
|
|
30
35
|
"description": "API Samples",
|
|
@@ -40,7 +45,9 @@
|
|
|
40
45
|
"build": "webpack",
|
|
41
46
|
"test": "grok test",
|
|
42
47
|
"test-dev": "grok test --host dev",
|
|
43
|
-
"test-local": "grok test --host localhost"
|
|
48
|
+
"test-local": "grok test --host localhost",
|
|
49
|
+
"link-all": "npm link datagrok-api @datagrok-libraries/utils",
|
|
50
|
+
"build-all": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm run build"
|
|
44
51
|
},
|
|
45
52
|
"canEdit": [
|
|
46
53
|
"Developers"
|
|
@@ -49,4 +56,4 @@
|
|
|
49
56
|
"All users"
|
|
50
57
|
],
|
|
51
58
|
"category": "Development"
|
|
52
|
-
}
|
|
59
|
+
}
|
package/scripts/dapi/files.js
CHANGED
|
@@ -7,33 +7,33 @@
|
|
|
7
7
|
let res = null;
|
|
8
8
|
|
|
9
9
|
// Write files
|
|
10
|
-
await grok.dapi.files.write('Demo:
|
|
11
|
-
await grok.dapi.files.writeAsText('Demo:
|
|
10
|
+
await grok.dapi.files.write('Demo:Files/testFile.dat', [0, 1, 2]);
|
|
11
|
+
await grok.dapi.files.writeAsText('Demo:Files/testFile.txt', 'testString');
|
|
12
12
|
|
|
13
13
|
// Rename
|
|
14
|
-
await grok.dapi.files.writeAsText('Demo:
|
|
15
|
-
await grok.dapi.files.rename('Demo:
|
|
14
|
+
await grok.dapi.files.writeAsText('Demo:Files/forRename.txt', 'testString');
|
|
15
|
+
await grok.dapi.files.rename('Demo:Files/forRename.txt', 'renamed.txt');
|
|
16
16
|
|
|
17
17
|
// Read files
|
|
18
|
-
res = await grok.dapi.files.readAsBytes('Demo:
|
|
18
|
+
res = await grok.dapi.files.readAsBytes('Demo:Files/testFile.dat');
|
|
19
19
|
console.log(`readAsBytes: ${res}`);
|
|
20
|
-
res = await grok.dapi.files.readAsText('Demo:
|
|
20
|
+
res = await grok.dapi.files.readAsText('Demo:Files/testFile.txt');
|
|
21
21
|
console.log(`readAsText: ${res}`);
|
|
22
|
-
res = await grok.dapi.files.exists('Demo:
|
|
22
|
+
res = await grok.dapi.files.exists('Demo:Files/testFile.dat');
|
|
23
23
|
console.log(`testFile.dat exists: ${res}`);
|
|
24
24
|
|
|
25
25
|
// Search files
|
|
26
26
|
let recursive = true;
|
|
27
27
|
let searchPattern = 'world';
|
|
28
|
-
res = await grok.dapi.files.list('Demo:
|
|
28
|
+
res = await grok.dapi.files.list('Demo:Files/geo', recursive, searchPattern);
|
|
29
29
|
console.log(`list: ${res}`);
|
|
30
30
|
|
|
31
31
|
// Move files
|
|
32
|
-
await grok.dapi.files.move(['Demo:
|
|
33
|
-
res = await grok.dapi.files.exists('Demo:
|
|
32
|
+
await grok.dapi.files.move(['Demo:Files/testFile.txt'], 'geo');
|
|
33
|
+
res = await grok.dapi.files.exists('Demo:Files/geo/testFile.txt');
|
|
34
34
|
console.log(`testFile.txt was moved to geo: ${res}`);
|
|
35
35
|
|
|
36
36
|
// Delete files
|
|
37
|
-
await grok.dapi.files.delete('Demo:
|
|
38
|
-
await grok.dapi.files.delete('Demo:
|
|
37
|
+
await grok.dapi.files.delete('Demo:Files/geo/testFile.txt');
|
|
38
|
+
await grok.dapi.files.delete('Demo:Files/testFile.dat');
|
|
39
39
|
})();
|
package/scripts/dapi/groups.js
CHANGED
package/scripts/dapi/users.js
CHANGED
|
@@ -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('
|
|
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('
|
|
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('
|
|
6
|
-
.then(t => grok.shell.info('
|
|
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
|
-
|
|
8
|
-
|
|
7
|
+
grok.shell.info(bs1.similarityTo(bs1, 'tanimoto'));
|
|
8
|
+
grok.shell.info(bs1.similarityTo(bs1));
|
|
9
9
|
|
|
10
10
|
// should be 0:
|
|
11
|
-
|
|
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.
|
|
17
|
-
grok.shell.info(`Format detected on 'lifeExp': ${table.
|
|
18
|
-
grok.shell.info(`Max significant digits detected for 'lifeExp': ${table.
|
|
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,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(
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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]);
|
|
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 ${
|
|
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
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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
|
-
//
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
.dialog({title: 'Test molecule'})
|
|
24
|
+
.add(root)
|
|
25
|
+
.show();
|
|
28
26
|
})();
|
|
@@ -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=
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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('
|
|
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/
|
|
7
|
+
// https://github.com/datagrok-ai/public/blob/master/packages/Demo/scripts/r/r_dup.R
|
|
8
8
|
grok.functions
|
|
9
|
-
.call("
|
|
9
|
+
.call("Samples:RDup", {s: "Foo"})
|
|
10
10
|
.then((res) => {
|
|
11
11
|
grok.shell.info(res);
|
|
12
12
|
});
|
|
@@ -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
|
-
|
|
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
|
});
|