@datagrok/helm 2.1.23 → 2.1.25
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/CHANGELOG.md +6 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +4 -4
- package/src/helm-web-editor.ts +4 -2
- package/src/utils/index.ts +47 -13
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/helm",
|
|
3
3
|
"friendlyName": "Helm",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.25",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Oleksandra Serhiienko",
|
|
7
7
|
"email": "oserhiienko@datagrok.ai"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"helm/JSDraw/Pistoia.HELM-uncompressed.js"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@datagrok-libraries/bio": "^5.39.
|
|
18
|
+
"@datagrok-libraries/bio": "^5.39.18",
|
|
19
19
|
"@datagrok-libraries/chem-meta": "^1.2.1",
|
|
20
20
|
"@datagrok-libraries/utils": "^4.0.17",
|
|
21
21
|
"cash-dom": "^8.1.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@datagrok/bio": "^2.11.8"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"link-all": "npm link datagrok-api @datagrok-libraries/utils @datagrok-libraries/bio",
|
|
42
|
+
"link-all": "npm link @datagrok-libraries/chem-meta datagrok-api @datagrok-libraries/utils @datagrok-libraries/bio",
|
|
43
43
|
"debug-helm": "webpack && grok publish",
|
|
44
44
|
"release-helm": "webpack && grok publish --release",
|
|
45
45
|
"build-helm": "webpack",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"test": "grok test",
|
|
56
56
|
"test-dev": "grok test --host dev",
|
|
57
57
|
"test-local": "grok test --host localhost",
|
|
58
|
-
"build-all": "npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm --prefix ./../../libraries/bio run build && npm run build"
|
|
58
|
+
"build-all": "npm --prefix ./../../libraries/chem-meta run build && npm --prefix ./../../js-api run build && npm --prefix ./../../libraries/utils run build && npm --prefix ./../../libraries/bio run build && npm run build"
|
|
59
59
|
},
|
|
60
60
|
"canEdit": [
|
|
61
61
|
"Developers"
|
package/src/helm-web-editor.ts
CHANGED
|
@@ -2,7 +2,9 @@ import * as grok from 'datagrok-api/grok';
|
|
|
2
2
|
import * as ui from 'datagrok-api/ui';
|
|
3
3
|
import * as DG from 'datagrok-api/dg';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import {IHelmWebEditor} from '@datagrok-libraries/bio/src/types/editor';
|
|
6
|
+
|
|
7
|
+
export class HelmWebEditor implements IHelmWebEditor {
|
|
6
8
|
host: any;
|
|
7
9
|
editor: any;
|
|
8
10
|
w = 200;
|
|
@@ -44,7 +46,7 @@ export class HelmWebEditor {
|
|
|
44
46
|
scil.apply(webEditor.properties.parent.style, s);
|
|
45
47
|
webEditor.structureview.resize(sizes.rightwidth, sizes.bottomheight + webEditor.toolbarheight);
|
|
46
48
|
webEditor.mex.resize(sizes.topheight - 80);
|
|
47
|
-
setTimeout(
|
|
49
|
+
setTimeout(() => {
|
|
48
50
|
webEditor.canvas.helm.setSequence(value, 'HELM');
|
|
49
51
|
}, 200);
|
|
50
52
|
return {editorDiv: editorView, webEditor: webEditor};
|
package/src/utils/index.ts
CHANGED
|
@@ -46,14 +46,16 @@ export function parseHelm(s: string): string[] {
|
|
|
46
46
|
for (const monomer of ss) {
|
|
47
47
|
if (!monomer || monomer === '') continue;
|
|
48
48
|
if (monomer.startsWith('[') && monomer.includes(']')) {
|
|
49
|
-
const
|
|
49
|
+
const closingIndex = findClosing(monomer, 1, '[', ']');
|
|
50
|
+
const element = monomer.substring(1, closingIndex);
|
|
50
51
|
monomers.push(element);
|
|
51
|
-
const residue = monomer.substring(
|
|
52
|
+
const residue = monomer.substring(closingIndex + 1);
|
|
52
53
|
ss.push(residue);
|
|
53
54
|
} else if (monomer.includes('[') && monomer.endsWith(']')) {
|
|
54
|
-
const
|
|
55
|
+
const openingIndex = findOpening(monomer, monomer.length - 2, '[', ']');
|
|
56
|
+
const element = monomer.substring(openingIndex + 1, monomer.length - 1);
|
|
55
57
|
monomers.push(element);
|
|
56
|
-
const residue = monomer.substring(0,
|
|
58
|
+
const residue = monomer.substring(0, openingIndex);
|
|
57
59
|
ss.push(residue);
|
|
58
60
|
} else if (monomer.includes('(') && monomer.includes(')')) {
|
|
59
61
|
// here we only want to split the string at first '(' and last ')'
|
|
@@ -64,9 +66,8 @@ export function parseHelm(s: string): string[] {
|
|
|
64
66
|
const elements = [firstPiece, secondPiece, thirdPiece];
|
|
65
67
|
for (const el of elements)
|
|
66
68
|
ss.push(el);
|
|
67
|
-
} else
|
|
69
|
+
} else
|
|
68
70
|
monomers.push(monomer);
|
|
69
|
-
}
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -111,6 +112,40 @@ export function findMonomers(monomerSymbolList: string[]): Set<string> {
|
|
|
111
112
|
return new Set(monomerSymbolList.filter((val) => !monomerNames.includes(val)));
|
|
112
113
|
}
|
|
113
114
|
|
|
115
|
+
function findClosing(s: string, start: number, open: string, close: string) {
|
|
116
|
+
let i = start;
|
|
117
|
+
let count = 0;
|
|
118
|
+
while (i < s.length) {
|
|
119
|
+
if (s[i] === open)
|
|
120
|
+
count++;
|
|
121
|
+
|
|
122
|
+
if (s[i] === close) {
|
|
123
|
+
if (count === 0)
|
|
124
|
+
return i;
|
|
125
|
+
count--;
|
|
126
|
+
}
|
|
127
|
+
i++;
|
|
128
|
+
}
|
|
129
|
+
return -1;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function findOpening(s: string, start: number, open: string, close: string) {
|
|
133
|
+
let i = start;
|
|
134
|
+
let count = 0;
|
|
135
|
+
while (i >= 0) {
|
|
136
|
+
if (s[i] === close)
|
|
137
|
+
count++;
|
|
138
|
+
|
|
139
|
+
if (s[i] === open) {
|
|
140
|
+
if (count === 0)
|
|
141
|
+
return i;
|
|
142
|
+
count--;
|
|
143
|
+
}
|
|
144
|
+
i--;
|
|
145
|
+
}
|
|
146
|
+
return -1;
|
|
147
|
+
}
|
|
148
|
+
|
|
114
149
|
function split(s: string, sep: string) {
|
|
115
150
|
const ret = [];
|
|
116
151
|
let frag = '';
|
|
@@ -136,19 +171,18 @@ function split(s: string, sep: string) {
|
|
|
136
171
|
if (c == '\"') {
|
|
137
172
|
if (!(i > 0 && s.substring(i - 1, i) == '\\'))
|
|
138
173
|
quote = quote == 0 ? 1 : 0;
|
|
139
|
-
} else if (c == '[')
|
|
174
|
+
} else if (c == '[')
|
|
140
175
|
++bracket;
|
|
141
|
-
|
|
176
|
+
else if (c == ']')
|
|
142
177
|
--bracket;
|
|
143
|
-
|
|
178
|
+
else if (c == '(')
|
|
144
179
|
++parentheses;
|
|
145
|
-
|
|
180
|
+
else if (c == ')')
|
|
146
181
|
--parentheses;
|
|
147
|
-
|
|
182
|
+
else if (c == '{')
|
|
148
183
|
++braces;
|
|
149
|
-
|
|
184
|
+
else if (c == '}')
|
|
150
185
|
--braces;
|
|
151
|
-
}
|
|
152
186
|
}
|
|
153
187
|
}
|
|
154
188
|
ret.push(frag);
|