@datagrok/helm 0.0.5 → 1.0.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.
- package/.eslintignore +2 -0
- package/.eslintrc.json +51 -0
- package/package.json +58 -47
- package/src/package-test.ts +3 -3
- package/src/package.ts +127 -67
- package/src/tests/helm-tests.ts +16 -7
- package/webpack.config.js +10 -1
package/.eslintignore
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"env": {
|
|
3
|
+
"browser": true,
|
|
4
|
+
"es2021": true
|
|
5
|
+
},
|
|
6
|
+
"extends": [
|
|
7
|
+
"google"
|
|
8
|
+
],
|
|
9
|
+
"parser": "@typescript-eslint/parser",
|
|
10
|
+
"parserOptions": {
|
|
11
|
+
"ecmaVersion": 12,
|
|
12
|
+
"sourceType": "module"
|
|
13
|
+
},
|
|
14
|
+
"plugins": [
|
|
15
|
+
"@typescript-eslint"
|
|
16
|
+
],
|
|
17
|
+
"rules": {
|
|
18
|
+
"indent": [
|
|
19
|
+
"error",
|
|
20
|
+
2
|
|
21
|
+
],
|
|
22
|
+
"max-len": [
|
|
23
|
+
"error",
|
|
24
|
+
120
|
|
25
|
+
],
|
|
26
|
+
"no-unused-vars": "warn",
|
|
27
|
+
"require-jsdoc": "off",
|
|
28
|
+
"spaced-comment": "off",
|
|
29
|
+
"linebreak-style": "off",
|
|
30
|
+
"curly": [
|
|
31
|
+
"error",
|
|
32
|
+
"multi-or-nest",
|
|
33
|
+
"consistent"
|
|
34
|
+
],
|
|
35
|
+
"brace-style": [
|
|
36
|
+
"error",
|
|
37
|
+
"1tbs",
|
|
38
|
+
{
|
|
39
|
+
"allowSingleLine": true
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
"block-spacing": [2, "always"],
|
|
43
|
+
"comma-dangle": ["error", {
|
|
44
|
+
"arrays": "only-multiline",
|
|
45
|
+
"functions": "never",
|
|
46
|
+
"objects": "only-multiline",
|
|
47
|
+
"imports": "only-multiline"
|
|
48
|
+
}],
|
|
49
|
+
"guard-for-in": "off"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/package.json
CHANGED
|
@@ -1,49 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
2
|
+
"name": "@datagrok/helm",
|
|
3
|
+
"beta": false,
|
|
4
|
+
"friendlyName": "Helm",
|
|
5
|
+
"version": "1.0.2",
|
|
6
|
+
"description": "",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"datagrok-api": "^1.4.12",
|
|
9
|
+
"cash-dom": "latest",
|
|
10
|
+
"dayjs": "latest",
|
|
11
|
+
"@datagrok-libraries/utils": "latest",
|
|
12
|
+
"@datagrok-libraries/bio": "^2.8.3",
|
|
13
|
+
"ts-loader": "^9.2.5",
|
|
14
|
+
"typescript": "^4.4.2"
|
|
15
|
+
},
|
|
16
|
+
"sources": [
|
|
17
|
+
"css/helm.css",
|
|
18
|
+
"https://ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js",
|
|
19
|
+
"helm/JSDraw/Scilligence.JSDraw2.Lite.js",
|
|
20
|
+
"helm/JSDraw/Scilligence.JSDraw2.Resources.js",
|
|
21
|
+
"helm/JSDraw/Pistoia.HELM-uncompressed.js"
|
|
22
|
+
],
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "latest",
|
|
25
|
+
"@typescript-eslint/parser": "latest",
|
|
26
|
+
"eslint": "latest",
|
|
27
|
+
"eslint-config-google": "latest",
|
|
28
|
+
"ts-loader": "latest",
|
|
29
|
+
"typescript": "latest",
|
|
30
|
+
"webpack": "latest",
|
|
31
|
+
"webpack-cli": "latest"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"link-all": "npm link datagrok-api @datagrok-libraries/utils @datagrok-libraries/bio",
|
|
35
|
+
"debug-helm": "webpack && grok publish ",
|
|
36
|
+
"release-helm": "webpack && grok publish --release",
|
|
37
|
+
"build-helm": "webpack",
|
|
38
|
+
"build": "webpack",
|
|
39
|
+
"debug-local": "grok publish local",
|
|
40
|
+
"release-local": "grok publish local --release",
|
|
41
|
+
"debug-helm-dev": "grok publish dev --rebuild",
|
|
42
|
+
"release-helm-dev": "grok publish dev --rebuild --release",
|
|
43
|
+
"debug-helm-public": "grok publish public --rebuild",
|
|
44
|
+
"release-helm-public": "grok publish public --rebuild --release",
|
|
45
|
+
"lint": "eslint \"./src/**/*.ts\"",
|
|
46
|
+
"lint-fix": "eslint \"./src/**/*.ts\" --fix"
|
|
47
|
+
},
|
|
48
|
+
"canEdit": [
|
|
49
|
+
"Developers"
|
|
50
|
+
],
|
|
51
|
+
"canView": [
|
|
52
|
+
"All users"
|
|
53
|
+
],
|
|
54
|
+
"repository": {
|
|
55
|
+
"type": "git",
|
|
56
|
+
"url": "https://github.com/datagrok-ai/public.git",
|
|
57
|
+
"directory": "packages/Helm"
|
|
58
|
+
},
|
|
59
|
+
"category": "Bioinformatics"
|
|
49
60
|
}
|
package/src/package-test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as DG from
|
|
2
|
-
import * as grok from
|
|
1
|
+
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
import {runTests, tests} from '@datagrok-libraries/utils/src/test';
|
|
4
|
-
import './tests/helm-tests.ts'
|
|
4
|
+
import './tests/helm-tests.ts';
|
|
5
5
|
|
|
6
6
|
export const _package = new DG.Package();
|
|
7
7
|
export {tests};
|
package/src/package.ts
CHANGED
|
@@ -2,67 +2,80 @@
|
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
|
+
//import {lru} from '../../Bio/src/utils/cell-renderer';
|
|
6
|
+
import {NotationConverter, NOTATION} from '@datagrok-libraries/bio/src/utils/notation-converter';
|
|
7
|
+
import {WebLogo} from '@datagrok-libraries/bio/src/viewers/web-logo';
|
|
8
|
+
//import {ConverterFunc, DfReaderFunc} from '../../Bio/src/tests/types';
|
|
5
9
|
|
|
6
10
|
export const _package = new DG.Package();
|
|
7
11
|
|
|
8
|
-
const lru = new DG.LruCache<any, any>();
|
|
12
|
+
const lru = new DG.LruCache<any, any>();
|
|
13
|
+
|
|
9
14
|
|
|
10
15
|
//tags: init
|
|
11
16
|
export async function initChem(): Promise<void> {
|
|
12
17
|
// apparently HELMWebEditor requires dojo to be initialized first
|
|
13
18
|
return new Promise((resolve, reject) => {
|
|
14
19
|
// @ts-ignore
|
|
15
|
-
dojo.ready(function
|
|
20
|
+
dojo.ready(function() { resolve(null); });
|
|
16
21
|
});
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
//name: helmCellRenderer
|
|
21
|
-
//tags: cellRenderer,cellRenderer-Macromolecule
|
|
22
|
-
//meta.cellType: Macromolecule
|
|
23
|
-
//meta-cell-renderer-sem-type: Macromolecule
|
|
24
|
-
//output: grid_cell_renderer result
|
|
25
|
-
export function helmCellRenderer(): DG.GridCellRenderer {
|
|
26
|
-
return new HelmCellRenderer();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
//tags: cellEditor
|
|
30
25
|
//description: Macromolecule
|
|
31
26
|
//input: grid_cell cell
|
|
32
27
|
export function editMoleculeCell(cell: DG.GridCell): void {
|
|
33
|
-
|
|
28
|
+
const view = ui.div();
|
|
34
29
|
org.helm.webeditor.MolViewer.molscale = 0.8;
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
const app = new scil.helm.App(view, {
|
|
31
|
+
showabout: false,
|
|
32
|
+
mexfontsize: '90%',
|
|
33
|
+
mexrnapinontab: true,
|
|
34
|
+
topmargin: 20,
|
|
35
|
+
mexmonomerstab: true,
|
|
36
|
+
sequenceviewonly: false,
|
|
37
|
+
mexfavoritefirst: true,
|
|
38
|
+
mexfilter: true
|
|
39
|
+
});
|
|
40
|
+
const sizes = app.calculateSizes();
|
|
37
41
|
app.canvas.resize(sizes.rightwidth, sizes.topheight - 210);
|
|
38
|
-
|
|
42
|
+
let s = {width: sizes.rightwidth + 'px', height: sizes.bottomheight + 'px'};
|
|
39
43
|
//@ts-ignore
|
|
40
44
|
scil.apply(app.sequence.style, s);
|
|
41
45
|
//@ts-ignore
|
|
42
46
|
scil.apply(app.notation.style, s);
|
|
43
|
-
s = {
|
|
47
|
+
s = {width: sizes.rightwidth + 'px', height: (sizes.bottomheight + app.toolbarheight) + 'px'};
|
|
44
48
|
//@ts-ignore
|
|
45
49
|
scil.apply(app.properties.parent.style, s);
|
|
46
50
|
app.structureview.resize(sizes.rightwidth, sizes.bottomheight + app.toolbarheight);
|
|
47
51
|
app.mex.resize(sizes.topheight - 80);
|
|
52
|
+
|
|
53
|
+
let dialogValue: string;
|
|
54
|
+
if (cell.gridColumn.column.tags[DG.TAGS.UNITS] === 'HELM') {
|
|
55
|
+
dialogValue = cell.cell.value;
|
|
56
|
+
} else {
|
|
57
|
+
const converter: NotationConverter = new NotationConverter(cell.cell.column);
|
|
58
|
+
dialogValue = converter.convertStringToHelm(cell.cell.value);
|
|
59
|
+
}
|
|
60
|
+
|
|
48
61
|
setTimeout(function() {
|
|
49
|
-
app.canvas.helm.setSequence(
|
|
62
|
+
app.canvas.helm.setSequence(dialogValue, 'HELM');
|
|
50
63
|
}, 200);
|
|
51
64
|
//@ts-ignore
|
|
52
|
-
ui.dialog({
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
ui.dialog({showHeader: false, showFooter: true})
|
|
66
|
+
.add(view)
|
|
67
|
+
.onOK(() => {
|
|
68
|
+
cell.cell.value;
|
|
69
|
+
}).show({modal: true, fullScreen: true});
|
|
57
70
|
}
|
|
58
71
|
|
|
59
72
|
//name: Details
|
|
60
73
|
//tags: panel, widgets
|
|
61
74
|
//input: string helmString {semType: Macromolecule}
|
|
62
75
|
//output: widget result
|
|
63
|
-
export function detailsPanel(helmString: string){
|
|
76
|
+
export function detailsPanel(helmString: string) {
|
|
64
77
|
//return new DG.Widget(ui.divText(lru.get(helmString)));
|
|
65
|
-
|
|
78
|
+
const result = lru.get(helmString).split(',');
|
|
66
79
|
return new DG.Widget(
|
|
67
80
|
ui.tableFromMap({
|
|
68
81
|
'formula': result[0].replace(/<sub>/g, '').replace(/<\/sub>/g, ''),
|
|
@@ -72,14 +85,42 @@ export function detailsPanel(helmString: string){
|
|
|
72
85
|
'fasta': ui.wait(async () => ui.divText(await helmToFasta(helmString))),
|
|
73
86
|
'rna analogue sequence': ui.wait(async () => ui.divText(await helmToRNA(helmString))),
|
|
74
87
|
'smiles': ui.wait(async () => ui.divText(await helmToSmiles(helmString))),
|
|
75
|
-
'peptide analogue sequence': ui.wait(async () => ui.divText(await helmToPeptide(helmString))),
|
|
88
|
+
//'peptide analogue sequence': ui.wait(async () => ui.divText(await helmToPeptide(helmString))),
|
|
76
89
|
})
|
|
77
|
-
)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async function loadDialog() {
|
|
95
|
+
//@ts-ignore
|
|
96
|
+
let res = await grok.dapi.files.list('System:AppData/Helm', false, '');
|
|
97
|
+
//@ts-ignore
|
|
98
|
+
res = res.map((e) => e.path);
|
|
99
|
+
//@ts-ignore
|
|
100
|
+
const FilesList = await ui.choiceInput('Monomer Libraries', ' ', res);
|
|
101
|
+
const grid = grok.shell.tv.grid;
|
|
102
|
+
ui.dialog('Load library from file')
|
|
103
|
+
.add(FilesList)
|
|
104
|
+
.onOK(async () => {
|
|
105
|
+
await monomerManager(FilesList.value);
|
|
106
|
+
grid.invalidate();
|
|
107
|
+
}).show();
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
//name: Library
|
|
111
|
+
//tags: panel, widgets
|
|
112
|
+
//input: string helmString {semType: Macromolecule}
|
|
113
|
+
//output: widget result
|
|
114
|
+
export function libraryPanel(helmString: string) {
|
|
115
|
+
//@ts-ignore
|
|
116
|
+
const loadButton = ui.button('Load Library');
|
|
117
|
+
loadButton.addEventListener('click', loadDialog);
|
|
118
|
+
return new DG.Widget(ui.divH([loadButton]));
|
|
78
119
|
}
|
|
79
120
|
|
|
80
121
|
async function accessServer(url: string, key: string) {
|
|
81
122
|
const params: RequestInit = {
|
|
82
|
-
method: 'GET',
|
|
123
|
+
method: 'GET',
|
|
83
124
|
headers: {
|
|
84
125
|
'Accept': 'application/json',
|
|
85
126
|
}
|
|
@@ -94,7 +135,7 @@ async function accessServer(url: string, key: string) {
|
|
|
94
135
|
//input: string helmString {semType: Macromolecule}
|
|
95
136
|
//output: string res
|
|
96
137
|
export async function helmToFasta(helmString: string) {
|
|
97
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Produce/${helmString}
|
|
138
|
+
const url = `http://localhost:8081/WebService/service/Fasta/Produce/${helmString}`;
|
|
98
139
|
return await accessServer(url, 'FastaFile');
|
|
99
140
|
}
|
|
100
141
|
|
|
@@ -103,7 +144,7 @@ export async function helmToFasta(helmString: string) {
|
|
|
103
144
|
//input: string helmString {semType: Macromolecule}
|
|
104
145
|
//output: string res
|
|
105
146
|
export async function helmToRNA(helmString: string) {
|
|
106
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Convert/RNA/${helmString}
|
|
147
|
+
const url = `http://localhost:8081/WebService/service/Fasta/Convert/RNA/${helmString}`;
|
|
107
148
|
return await accessServer(url, 'Sequence');
|
|
108
149
|
}
|
|
109
150
|
|
|
@@ -113,7 +154,7 @@ export async function helmToRNA(helmString: string) {
|
|
|
113
154
|
//input: string helmString {semType: Macromolecule}
|
|
114
155
|
//output: string res
|
|
115
156
|
export async function helmToPeptide(helmString: string) {
|
|
116
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Convert/PEPTIDE/${helmString}
|
|
157
|
+
const url = `http://localhost:8081/WebService/service/Fasta/Convert/PEPTIDE/${helmString}`;
|
|
117
158
|
return await accessServer(url, 'Sequence');
|
|
118
159
|
}
|
|
119
160
|
|
|
@@ -122,24 +163,23 @@ export async function helmToPeptide(helmString: string) {
|
|
|
122
163
|
//input: string helmString {semType: Macromolecule}
|
|
123
164
|
//output: string smiles {semType: Molecule}
|
|
124
165
|
export async function helmToSmiles(helmString: string) {
|
|
125
|
-
const url = `http://localhost:8081/WebService/service/SMILES/${helmString}
|
|
166
|
+
const url = `http://localhost:8081/WebService/service/SMILES/${helmString}`;
|
|
126
167
|
return await accessServer(url, 'SMILES');
|
|
127
168
|
}
|
|
128
169
|
|
|
129
170
|
function getRS(smiles: string) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
for (
|
|
135
|
-
if (
|
|
136
|
-
if (/\d/.test(
|
|
137
|
-
digit =
|
|
138
|
-
|
|
139
|
-
for (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
171
|
+
const newS = smiles.match(/(?<=\[)[^\][]*(?=])/gm);
|
|
172
|
+
const res = {};
|
|
173
|
+
let el = '';
|
|
174
|
+
let digit;
|
|
175
|
+
for (let i = 0; i < newS.length; i++) {
|
|
176
|
+
if (newS[i] != null) {
|
|
177
|
+
if (/\d/.test(newS[i])) {
|
|
178
|
+
digit = newS[i][newS[i].length - 1];
|
|
179
|
+
newS[i] = newS[i].replace(/[0-9]/g, '');
|
|
180
|
+
for (let j = 0; j < newS[i].length; j++) {
|
|
181
|
+
if (newS[i][j] != ':')
|
|
182
|
+
el += newS[i][j];
|
|
143
183
|
}
|
|
144
184
|
res['R' + digit] = el;
|
|
145
185
|
el = '';
|
|
@@ -149,53 +189,73 @@ function getRS(smiles: string) {
|
|
|
149
189
|
return res;
|
|
150
190
|
}
|
|
151
191
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
export async function monomerManager(helmColumn: DG.Column) {
|
|
155
|
-
const file = await _package.files.readAsText('HELMCoreLibrary.json');
|
|
192
|
+
async function monomerManager(value: string) {
|
|
193
|
+
const file = await _package.files.readAsText(value.split('/')[1]);
|
|
156
194
|
const df = DG.DataFrame.fromJson(file);
|
|
157
|
-
|
|
158
|
-
for (
|
|
195
|
+
let m;
|
|
196
|
+
for (let i = 0; i < df.rowCount; i++) {
|
|
159
197
|
m = {
|
|
160
|
-
'id': df.get('symbol', i).toString(),
|
|
198
|
+
'id': df.get('symbol', i).toString(),
|
|
161
199
|
'n': df.get('name', i).toString(),
|
|
162
200
|
'na': df.get('naturalAnalog', i).toString(),
|
|
163
201
|
'type': df.get('polymerType', i).toString(),
|
|
164
|
-
'mt': df.get('monomerType', i).toString(),
|
|
165
|
-
'm': df.get('molfile', i).toString(),
|
|
166
|
-
rs: Object.keys(getRS(df.get('smiles', i).toString())).length,
|
|
167
|
-
at: getRS(df.get('smiles', i).toString()),
|
|
168
|
-
}
|
|
202
|
+
'mt': df.get('monomerType', i).toString(),
|
|
203
|
+
'm': df.get('molfile', i).toString(),
|
|
204
|
+
'rs': Object.keys(getRS(df.get('smiles', i).toString())).length,
|
|
205
|
+
'at': getRS(df.get('smiles', i).toString()),
|
|
206
|
+
};
|
|
169
207
|
org.helm.webeditor.Monomers.addOneMonomer(m);
|
|
170
208
|
}
|
|
171
209
|
}
|
|
172
210
|
|
|
173
211
|
//name: helmColumnToSmiles
|
|
174
|
-
//input: column helmColumn {semType:
|
|
212
|
+
//input: column helmColumn {semType: Macromolecule}
|
|
175
213
|
export function helmColumnToSmiles(helmColumn: DG.Column) {
|
|
176
214
|
//todo: add column with smiles to col.dataFrame.
|
|
177
215
|
}
|
|
178
216
|
|
|
217
|
+
// Synonym to overcome eslint error
|
|
218
|
+
const GetMonomerSet = scil.helm.Monomers.getMonomerSet;
|
|
179
219
|
|
|
180
|
-
|
|
220
|
+
//name: findMonomers
|
|
221
|
+
//input: string helmString { semType: Macromolecule }
|
|
222
|
+
export async function findMonomers(helmString: string) {
|
|
223
|
+
const types = Object.keys(org.helm.webeditor.monomerTypeList());
|
|
224
|
+
const monomers = [];
|
|
225
|
+
const monomerNames = [];
|
|
226
|
+
for (let i = 0; i < types.length; i++) {
|
|
227
|
+
monomers.push(new GetMonomerSet(types[i]));
|
|
228
|
+
Object.keys(monomers[i]).forEach((k) => {
|
|
229
|
+
monomerNames.push(monomers[i][k].id);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
const splitString = WebLogo.splitterAsHelm(helmString);
|
|
233
|
+
return new Set(splitString.filter((val) => !monomerNames.includes(val)));
|
|
234
|
+
}
|
|
181
235
|
|
|
236
|
+
class HelmCellRenderer extends DG.GridCellRenderer {
|
|
182
237
|
get name() { return 'macromolecule'; }
|
|
238
|
+
|
|
183
239
|
get cellType() { return 'macromolecule'; }
|
|
240
|
+
|
|
184
241
|
get defaultWidth(): number | null { return 400; }
|
|
242
|
+
|
|
185
243
|
get defaultHeight(): number | null { return 100; }
|
|
186
244
|
|
|
187
|
-
render(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number,
|
|
188
|
-
|
|
245
|
+
render(g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number,
|
|
246
|
+
gridCell: DG.GridCell, cellStyle: DG.GridCellStyle
|
|
247
|
+
) {
|
|
248
|
+
const host = ui.div([], {style: {width: `${w}px`, height: `${h}px`}});
|
|
189
249
|
host.setAttribute('dataformat', 'helm');
|
|
190
250
|
host.setAttribute('data', gridCell.cell.value);
|
|
191
251
|
|
|
192
252
|
gridCell.element = host;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
253
|
+
const canvas = new JSDraw2.Editor(host, {width: w, height: h, skin: 'w8', viewonly: true});
|
|
254
|
+
const formula = canvas.getFormula(true);
|
|
255
|
+
const molWeight = Math.round(canvas.getMolWeight() * 100) / 100;
|
|
256
|
+
const coef = Math.round(canvas.getExtinctionCoefficient(true) * 100) / 100;
|
|
257
|
+
const molfile = canvas.getMolfile();
|
|
258
|
+
const result = formula + ', ' + molWeight + ', ' + coef + ', ' + molfile;
|
|
199
259
|
lru.set(gridCell.cell.value, result);
|
|
200
260
|
}
|
|
201
261
|
}
|
package/src/tests/helm-tests.ts
CHANGED
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
import {before, category, expect, test} from '@datagrok-libraries/utils/src/test';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import {helmToFasta, helmToPeptide, helmToRNA} from '../package';
|
|
3
|
+
import {_package} from '../package-test';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
import * as grok from 'datagrok-api/grok';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
category('Helm', () => {
|
|
9
|
-
|
|
10
9
|
test('helmToFasta', async () => {
|
|
11
10
|
expect(await helmToFasta('RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$'), '>RNA1UTGCA');
|
|
12
11
|
expect(await helmToFasta('RNA1{P.R(U).P.R(T)}$$$$'), '>RNA1UT');
|
|
13
|
-
expect(await helmToFasta('PEPTIDE1{A.G}$$$$V2.0'), '>PEPTIDE1AG')
|
|
12
|
+
expect(await helmToFasta('PEPTIDE1{A.G}$$$$V2.0'), '>PEPTIDE1AG');
|
|
14
13
|
});
|
|
15
14
|
|
|
16
15
|
test('helmToRNA', async () => {
|
|
17
16
|
expect(await helmToRNA('RNA1{R(U)P.R(T)P.R(G)P.R(C)P.R(A)}$$$$'), 'UTGCA');
|
|
18
17
|
expect(await helmToRNA('RNA1{P.R(U).P.R(T)}$$$$'), 'UT');
|
|
18
|
+
// eslint-disable-next-line max-len
|
|
19
19
|
expect(await helmToRNA('RNA1{R(U)P.R(T)P}|RNA2{P.R(A)P.R(A)}$RNA1,RNA2,2:pair-6:pair|RNA1,RNA2,5:pair-3:pair$$$'), 'UT AA');
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
test('helmToPeptide', async () => {
|
|
23
23
|
expect(await helmToPeptide('PEPTIDE1{A.G}$$$$V2.0'), 'AG');
|
|
24
24
|
expect(await helmToPeptide('PEPTIDE1{L.V.A}|PEPTIDE2{L.V.A}$$$$'), 'LVA LVA');
|
|
25
|
+
// eslint-disable-next-line max-len
|
|
25
26
|
expect(await helmToPeptide('PEPTIDE1{A.R.C.A.A.K.T.C.D.A}$PEPTIDE1,PEPTIDE1,8:R3-3:R3$$$'), 'ARCAAKTCDA');
|
|
26
27
|
});
|
|
27
28
|
|
|
29
|
+
test('detectMacromolecule', async () => {
|
|
30
|
+
const file = await _package.files.readAsText('test.csv');
|
|
31
|
+
const df = DG.DataFrame.fromCsv(file);
|
|
32
|
+
const col = df.columns.byName('HELM string');
|
|
33
|
+
await grok.data.detectSemanticTypes(df);
|
|
34
|
+
expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
|
|
35
|
+
});
|
|
36
|
+
|
|
28
37
|
test('detectHelm', async () => {
|
|
29
|
-
const file = await _package.files.readAsText('test.csv')
|
|
38
|
+
const file = await _package.files.readAsText('test.csv');
|
|
30
39
|
const df = DG.DataFrame.fromCsv(file);
|
|
31
|
-
|
|
40
|
+
const col = df.columns.byName('HELM string');
|
|
32
41
|
await grok.data.detectSemanticTypes(df);
|
|
33
|
-
expect(col.
|
|
42
|
+
expect(col.tags[DG.TAGS.UNITS], 'HELM');
|
|
34
43
|
});
|
|
35
44
|
});
|
package/webpack.config.js
CHANGED
|
@@ -16,7 +16,16 @@ module.exports = {
|
|
|
16
16
|
},
|
|
17
17
|
module: {
|
|
18
18
|
rules: [
|
|
19
|
-
{
|
|
19
|
+
{
|
|
20
|
+
test: /\.ts(x?)$/,
|
|
21
|
+
use: 'ts-loader',
|
|
22
|
+
exclude: /node_modules/,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
test: /\.css$/,
|
|
26
|
+
use: ['style-loader', 'css-loader'],
|
|
27
|
+
exclude: /node_modules/,
|
|
28
|
+
},
|
|
20
29
|
],
|
|
21
30
|
},
|
|
22
31
|
devtool: 'inline-source-map',
|