@datagrok/sequence-translator 1.3.11 → 1.3.13

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.
@@ -0,0 +1,95 @@
1
+ import * as grok from 'datagrok-api/grok';
2
+ import * as ui from 'datagrok-api/ui';
3
+ import * as DG from 'datagrok-api/dg';
4
+
5
+ import {before, after, category, expect, test, expectArray} from '@datagrok-libraries/utils/src/test';
6
+ import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
7
+
8
+ import {PolyToolEnumeratorParams, PolyToolEnumeratorTypes} from '../polytool/types';
9
+ import {getPtEnumeratorHelm} from '../polytool/pt-enumeration-helm';
10
+
11
+ category('PolyTool', () => {
12
+ let helmHelper: IHelmHelper;
13
+
14
+ before(async () => {
15
+ helmHelper = await getHelmHelper(); // initialize JSDraw2 and org
16
+ });
17
+
18
+ after(async () => {
19
+
20
+ });
21
+
22
+ const tests: {
23
+ [testName: string]: { src: string, params: PolyToolEnumeratorParams, tgt: [string, string][] }
24
+ } = {
25
+ 'single1': {
26
+ src: 'PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0',
27
+ params: {
28
+ type: PolyToolEnumeratorTypes.Single,
29
+ placeholders: {
30
+ [4]: ['K', 'P', 'F4COO'],
31
+ [6]: ['Y', 'T'],
32
+ },
33
+ },
34
+ tgt: [
35
+ ['PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0', '-P5K'],
36
+ ['PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0', '-P5P'],
37
+ ['PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0', '-P5[F4COO]'],
38
+ ['PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0', '-[Tic]7Y'],
39
+ ['PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0', '-[Tic]7T'],
40
+ ]
41
+ },
42
+ 'single-with-original': {
43
+ src: 'PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0',
44
+ params: {
45
+ type: PolyToolEnumeratorTypes.Single,
46
+ placeholders: {
47
+ [4]: ['K', 'P', 'F4COO'],
48
+ [6]: ['Y', 'T'],
49
+ },
50
+ keepOriginal: true,
51
+ },
52
+ tgt: [
53
+ ['PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0', ''],
54
+ ['PEPTIDE1{[Ac(1)].F.W.G.K.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0', '-P5K'],
55
+ ['PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0', '-P5P'],
56
+ ['PEPTIDE1{[Ac(1)].F.W.G.[F4COO].L.[Tic].[C(1)].G.[NH2]}$$$$V2.0', '-P5[F4COO]'],
57
+ ['PEPTIDE1{[Ac(1)].F.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0', '-[Tic]7Y'],
58
+ ['PEPTIDE1{[Ac(1)].F.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0', '-[Tic]7T'],
59
+ ]
60
+ },
61
+ 'matrix1': {
62
+ src: 'PEPTIDE1{[Ac(1)].F.W.G.P.L.[Tic].[C(1)].G.[NH2]}$$$$V2.0',
63
+ params:
64
+ {
65
+ type: PolyToolEnumeratorTypes.Matrix,
66
+ placeholders: {
67
+ [1]: ['D', 'L'],
68
+ [4]: ['K', 'P', 'F4COO'],
69
+ [6]: ['Y', 'T'],
70
+ }
71
+ },
72
+ tgt: [
73
+ ["PEPTIDE1{[Ac(1)].D.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0", "-F2D-P5K-[Tic]7Y"],
74
+ ["PEPTIDE1{[Ac(1)].D.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0", "-F2D-P5K-[Tic]7T"],
75
+ ["PEPTIDE1{[Ac(1)].D.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0", "-F2D-P5P-[Tic]7Y"],
76
+ ["PEPTIDE1{[Ac(1)].D.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0", "-F2D-P5P-[Tic]7T"],
77
+ ["PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0", "-F2D-P5[F4COO]-[Tic]7Y"],
78
+ ["PEPTIDE1{[Ac(1)].D.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0", "-F2D-P5[F4COO]-[Tic]7T"],
79
+ ["PEPTIDE1{[Ac(1)].L.W.G.K.L.Y.[C(1)].G.[NH2]}$$$$V2.0", "-F2L-P5K-[Tic]7Y"],
80
+ ["PEPTIDE1{[Ac(1)].L.W.G.K.L.T.[C(1)].G.[NH2]}$$$$V2.0", "-F2L-P5K-[Tic]7T"],
81
+ ["PEPTIDE1{[Ac(1)].L.W.G.P.L.Y.[C(1)].G.[NH2]}$$$$V2.0", "-F2L-P5P-[Tic]7Y"],
82
+ ["PEPTIDE1{[Ac(1)].L.W.G.P.L.T.[C(1)].G.[NH2]}$$$$V2.0", "-F2L-P5P-[Tic]7T"],
83
+ ["PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.Y.[C(1)].G.[NH2]}$$$$V2.0", "-F2L-P5[F4COO]-[Tic]7Y"],
84
+ ["PEPTIDE1{[Ac(1)].L.W.G.[F4COO].L.T.[C(1)].G.[NH2]}$$$$V2.0", "-F2L-P5[F4COO]-[Tic]7T"],
85
+ ],
86
+ }
87
+ };
88
+
89
+ for (const [testName, testData] of Object.entries(tests)) {
90
+ test(`enumerator-${testName}`, async () => {
91
+ const res = getPtEnumeratorHelm(testData.src, '', testData.params);
92
+ expectArray(res, testData.tgt);
93
+ });
94
+ }
95
+ });
@@ -2,11 +2,13 @@ import * as grok from 'datagrok-api/grok';
2
2
  import * as DG from 'datagrok-api/dg';
3
3
  import * as ui from 'datagrok-api/ui';
4
4
 
5
- import {defaultErrorHandler} from './err-info';
6
- import {_package, addContextMenu} from '../package';
7
5
  import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
8
6
  import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
9
- import {polyToolEnumerateHelmUI} from '../polytool/pt-dialog';
7
+
8
+ import {defaultErrorHandler} from './err-info';
9
+ import {polyToolEnumerateHelmUI} from '../polytool/pt-enumeration-helm-dialog';
10
+
11
+ import {_package} from '../package';
10
12
 
11
13
  export type SequenceTranslatorWindowType = Window & {
12
14
  $sequenceTranslator?: {
@@ -6,8 +6,9 @@ import {errInfo} from '@datagrok-libraries/bio/src/utils/err-info';
6
6
 
7
7
  import {_package} from '../package';
8
8
 
9
- export function defaultErrorHandler(err: any): void {
9
+ export function defaultErrorHandler(err: any, shell: boolean = true): [string, string | undefined] {
10
10
  const [errMsg, errStack] = errInfo(err);
11
11
  _package.logger.error(errMsg, undefined, errStack);
12
- grok.shell.error(errMsg);
12
+ if (shell) grok.shell.error(errMsg);
13
+ return [errMsg, errStack];
13
14
  }
package/webpack.config.js CHANGED
@@ -17,16 +17,9 @@ module.exports = {
17
17
  },
18
18
  module: {
19
19
  rules: [
20
- {
21
- test: /\.ts(x?)$/,
22
- use: 'ts-loader',
23
- exclude: /node_modules/,
24
- },
25
- {
26
- test: /\.css$/,
27
- use: ['style-loader', 'css-loader'],
28
- exclude: /node_modules/,
29
- },
20
+ {test: /\.js$/, enforce: 'pre', use: ['source-map-loader'], exclude: [/node_modules/]},
21
+ {test: /\.ts(x?)$/, use: 'ts-loader', exclude: [/node_modules/]},
22
+ {test: /\.css$/, use: ['style-loader', 'css-loader'], exclude: [/node_modules/]},
30
23
  ],
31
24
  },
32
25
  devtool: 'source-map',