@datagrok/helm 2.2.1 → 2.3.1
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 +21 -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/files/tests/helm2-bracket.csv +2 -0
- package/package.json +13 -10
- package/src/cell-renderer.ts +8 -33
- package/src/helm-helper.ts +67 -17
- package/src/helm-monomer-placer.ts +7 -9
- package/src/helm-web-editor.ts +33 -3
- package/src/package-test.ts +8 -3
- package/src/package-utils.ts +69 -42
- package/src/package.ts +121 -141
- package/src/tests/findMonomers-tests.ts +2 -0
- package/src/tests/get-all-parts-tests.ts +5 -0
- package/src/tests/get-molfiles-tests.ts +3 -1
- package/src/tests/get-monomer-tests.ts +88 -19
- package/src/tests/helm-service-tests.ts +4 -0
- package/src/tests/helm-tests.ts +7 -1
- package/src/tests/helm-web-editor-tests.ts +55 -0
- package/src/tests/parse-helm-tests.ts +98 -0
- package/src/tests/properties-widget-tests.ts +33 -4
- package/src/tests/renderers-tests.ts +3 -1
- package/src/tests/utils.ts +6 -0
- package/src/types/index.ts +5 -0
- package/src/utils/get-hovered.ts +3 -4
- package/src/utils/{dummy-monomer.ts → get-monomer-dummy.ts} +10 -45
- package/src/utils/get-monomer-of-library.ts +90 -0
- package/src/utils/get-monomer.ts +23 -21
- package/src/utils/helm-grid-cell-renderer.ts +19 -3
- package/src/utils/helm-service.ts +6 -5
- package/src/utils/index.ts +11 -17
- package/src/widgets/properties-widget.ts +29 -9
- package/tsconfig.json +1 -1
- package/vendor/helm-web-editor.development.js +39640 -0
- package/vendor/helm-web-editor.production.js +2 -0
- package/vendor/helm-web-editor.production.js.map +1 -0
- package/webpack.config.js +15 -12
- package/helm/JSDraw/Pistoia.HELM.js +0 -27
- package/helm/JSDraw/Scilligence.JSDraw2.Lite.js +0 -12
- package/helm/JSDraw/Scilligence.JSDraw2.Resources.js +0 -762
- package/helm/JSDraw/dojo.js +0 -250
- package/helm/JSDraw/test.html +0 -24
package/src/utils/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import * as grok from 'datagrok-api/grok';
|
|
2
|
+
import * as ui from 'datagrok-api/ui';
|
|
1
3
|
import * as DG from 'datagrok-api/dg';
|
|
2
4
|
|
|
3
|
-
import
|
|
4
|
-
import * as org from 'org';
|
|
5
|
-
|
|
6
|
-
import {_package} from '../package';
|
|
5
|
+
import {OrgHelmModule, ScilModule} from '../types';
|
|
7
6
|
|
|
8
7
|
import {
|
|
9
8
|
RGROUP_CAP_GROUP_NAME,
|
|
@@ -16,6 +15,11 @@ import {
|
|
|
16
15
|
SDF_MONOMER_NAME
|
|
17
16
|
} from '../constants';
|
|
18
17
|
|
|
18
|
+
import {getMonomerLib} from '../package';
|
|
19
|
+
|
|
20
|
+
declare const scil: ScilModule;
|
|
21
|
+
declare const org: OrgHelmModule;
|
|
22
|
+
|
|
19
23
|
// Global flag is for replaceAll
|
|
20
24
|
const helmGapStartRe = /\{(\*\.)+/g;
|
|
21
25
|
const helmGapIntRe = /\.(\*\.)+/g;
|
|
@@ -109,19 +113,9 @@ export function parseHelm(s: string): string[] {
|
|
|
109
113
|
// }
|
|
110
114
|
|
|
111
115
|
/** Searches monomers of helmString for missed. */
|
|
112
|
-
export function findMonomers(
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
const monomerNames: any = [];
|
|
116
|
-
for (let i = 0; i < types.length; i++) {
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
// eslint-disable-next-line new-cap
|
|
119
|
-
monomers.push(new org.helm.webeditor.Monomers.getMonomerSet(types[i]));
|
|
120
|
-
Object.keys(monomers[i]).forEach((k) => {
|
|
121
|
-
monomerNames.push(monomers[i][k].id);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
return new Set(monomerSymbolList.filter((val) => !monomerNames.includes(val)));
|
|
116
|
+
export function findMonomers(seqMonomerSymbolList: string[]): Set<string> {
|
|
117
|
+
const monomerLib = getMonomerLib();
|
|
118
|
+
return new Set(seqMonomerSymbolList.filter((s) => monomerLib?.getMonomer(null, s)));
|
|
125
119
|
}
|
|
126
120
|
|
|
127
121
|
function findClosing(s: string, start: number, open: string, close: string) {
|
|
@@ -7,22 +7,34 @@ import $ from 'cash-dom';
|
|
|
7
7
|
import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
|
|
8
8
|
import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
9
9
|
|
|
10
|
+
import {JSDraw2HelmModule} from '../types';
|
|
10
11
|
import {removeGapsFromHelm} from '../utils';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
const helmString = sh.isHelm() ? seq : sh.getConverter(NOTATION.HELM)(seq);
|
|
14
|
-
// Remove gap symbols for compatibility with WebEditor
|
|
15
|
-
const helmString2 = removeGapsFromHelm(helmString);
|
|
13
|
+
declare const JSDraw2: JSDraw2HelmModule;
|
|
16
14
|
|
|
15
|
+
export class SeqPropertiesError extends Error {
|
|
16
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
17
|
+
super(message, options);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getPropertiesDict(seq: string, sh: SeqHandler): {} {
|
|
17
22
|
const host = ui.div([], {style: {width: '0', height: '0'}});
|
|
18
23
|
document.documentElement.appendChild(host);
|
|
19
24
|
try {
|
|
25
|
+
if (seq.length > 1000)
|
|
26
|
+
throw new SeqPropertiesError('Too long sequence to calculate molecular properties.');
|
|
27
|
+
|
|
28
|
+
const helmString = sh.isHelm() ? seq : sh.getConverter(NOTATION.HELM)(seq);
|
|
29
|
+
// Remove gap symbols for compatibility with WebEditor
|
|
30
|
+
const helmString2 = removeGapsFromHelm(helmString);
|
|
31
|
+
|
|
20
32
|
const editor = new JSDraw2.Editor(host, {viewonly: true});
|
|
21
33
|
editor.setHelm(helmString2);
|
|
22
34
|
|
|
23
35
|
const formula = editor.getFormula(true);
|
|
24
36
|
const molWeight = Math.round(editor.getMolWeight() * 100) / 100;
|
|
25
|
-
const coef = Math.round(editor.getExtinctionCoefficient(
|
|
37
|
+
const coef = Math.round(editor.getExtinctionCoefficient() * 100) / 100;
|
|
26
38
|
return {
|
|
27
39
|
'formula': formula.replace(/<sub>/g, '').replace(/<\/sub>/g, ''),
|
|
28
40
|
'molecular weight': molWeight,
|
|
@@ -37,8 +49,16 @@ export function getPropertiesDict(seq: string, sh: SeqHandler): {} {
|
|
|
37
49
|
|
|
38
50
|
export function getPropertiesWidget(value: DG.SemanticValue): DG.Widget {
|
|
39
51
|
const sh = SeqHandler.forColumn(value.cell.column);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
try {
|
|
53
|
+
const propDict = getPropertiesDict(value.value, sh);
|
|
54
|
+
return new DG.Widget(
|
|
55
|
+
ui.tableFromMap(propDict)
|
|
56
|
+
);
|
|
57
|
+
} catch (err: any) {
|
|
58
|
+
if (err instanceof SeqPropertiesError) {
|
|
59
|
+
// Display warning from err.message
|
|
60
|
+
return new DG.Widget(ui.divText(err.message));
|
|
61
|
+
}
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
44
64
|
}
|
package/tsconfig.json
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
66
66
|
|
|
67
67
|
/* Advanced Options */
|
|
68
|
-
"skipLibCheck":
|
|
68
|
+
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
69
69
|
"forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
|
|
70
70
|
//"jsx": "react"
|
|
71
71
|
}
|