@datagrok/bio 2.15.5 → 2.15.6

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.
@@ -44,5 +44,57 @@
44
44
  "id": 0,
45
45
  "polymerType": "PEPTIDE",
46
46
  "symbol": "COOH"
47
+ },
48
+ {
49
+ "monomerType": "Backbone",
50
+ "smiles": "[H:1]NC(C#C)C([OH:2])=O",
51
+ "name": "Acetylenil Glycine",
52
+ "author": "Datagrok",
53
+ "molfile": "\n MJ201900 \n\n 8 7 0 0 0 0 0 0 0 0999 V2000\n 3.7485 -4.0401 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n 4.4629 -4.4526 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 5.1773 -4.0401 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 5.8917 -4.4526 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n 5.1773 -3.2152 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 4.4630 -5.2776 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 3.7485 -5.6901 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 3.0340 -4.4526 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n 2 3 1 0 0 0 0\n 3 5 2 0 0 0 0\n 2 6 1 0 0 0 0\n 1 2 1 0 0 0 0\n 1 8 1 0 0 0 0\n 3 4 1 0 0 0 0\n 6 7 3 0 0 0 0\nM RGP 2 4 2 8 1\nM END",
54
+ "naturalAnalog": "G",
55
+ "rgroups": [
56
+ {
57
+ "capGroupSMILES": "[*:1][H]",
58
+ "alternateId": "R1-H",
59
+ "capGroupName": "H",
60
+ "label": "R1"
61
+ },
62
+ {
63
+ "capGroupSMILES": "O[*:2]",
64
+ "alternateId": "R2-OH",
65
+ "capGroupName": "OH",
66
+ "label": "R2"
67
+ }
68
+ ],
69
+ "createDate": null,
70
+ "id": 0,
71
+ "polymerType": "PEPTIDE",
72
+ "symbol": "aG"
73
+ },
74
+ {
75
+ "monomerType": "Backbone",
76
+ "smiles": "[H:1]NC(CN=[N+]=[N-])C([OH:2])=O",
77
+ "name": "Azido Glycine",
78
+ "author": "Datagrok",
79
+ "molfile": "\n MJ201900 \n\n 10 9 0 0 0 0 0 0 0 0999 V2000\n -0.7143 0.4125 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.7144 0.4125 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 1.4288 0.0000 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n 0.7144 1.2374 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0\n 0.0001 -0.8249 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n -1.4288 0.0000 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0\n -0.7142 -1.2375 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0\n -1.4511 -1.6510 0.0000 N 0 3 0 0 0 0 0 0 0 0 0 0\n -2.2101 -2.0717 0.0000 N 0 5 0 0 0 0 0 0 0 0 0 0\n 2 3 1 0 0 0 0\n 3 5 2 0 0 0 0\n 2 6 1 0 0 0 0\n 1 2 1 0 0 0 0\n 1 7 1 0 0 0 0\n 3 4 1 0 0 0 0\n 6 8 1 0 0 0 0\n 8 9 2 0 0 0 0\n 9 10 2 0 0 0 0\nM RGP 2 4 2 7 1\nM END",
80
+ "naturalAnalog": "G",
81
+ "rgroups": [
82
+ {
83
+ "capGroupSMILES": "[*:1][H]",
84
+ "alternateId": "R1-H",
85
+ "capGroupName": "H",
86
+ "label": "R1"
87
+ },
88
+ {
89
+ "capGroupSMILES": "O[*:2]",
90
+ "alternateId": "R2-OH",
91
+ "capGroupName": "OH",
92
+ "label": "R2"
93
+ }
94
+ ],
95
+ "createDate": null,
96
+ "id": "0",
97
+ "polymerType": "PEPTIDE",
98
+ "symbol": "azG"
47
99
  }
48
100
  ]
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "Aleksandr Tanas",
6
6
  "email": "atanas@datagrok.ai"
7
7
  },
8
- "version": "2.15.5",
8
+ "version": "2.15.6",
9
9
  "description": "Bioinformatics support (import/export of sequences, conversion, visualization, analysis). [See more](https://github.com/datagrok-ai/public/blob/master/packages/Bio/README.md) for details.",
10
10
  "repository": {
11
11
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@biowasm/aioli": "^3.1.0",
40
- "@datagrok-libraries/bio": "^5.44.1",
40
+ "@datagrok-libraries/bio": "^5.44.2",
41
41
  "@datagrok-libraries/chem-meta": "^1.2.7",
42
42
  "@datagrok-libraries/math": "^1.2.0",
43
43
  "@datagrok-libraries/ml": "^6.7.1",
@@ -62,7 +62,7 @@
62
62
  "@datagrok-libraries/js-draw-lite": "^0.0.8",
63
63
  "@datagrok/chem": "^1.12.1",
64
64
  "@datagrok/dendrogram": "^1.2.33",
65
- "@datagrok/helm": "^2.5.0",
65
+ "@datagrok/helm": "^2.5.2",
66
66
  "@types/node": "^17.0.24",
67
67
  "@types/wu": "latest",
68
68
  "@typescript-eslint/eslint-plugin": "latest",
@@ -2,12 +2,13 @@ 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
- import {runTests, TestContext, tests, initAutoTests as initTests } from '@datagrok-libraries/utils/src/test';
5
+ import {runTests, TestContext, tests, initAutoTests as initTests} from '@datagrok-libraries/utils/src/test';
6
6
 
7
7
  import './tests/_first-tests';
8
8
  import './tests/Palettes-test';
9
9
  import './tests/detectors-tests';
10
10
  import './tests/detectors-weak-and-likely-tests';
11
+ import './tests/detectors-custom-notation-tests';
11
12
  import './tests/detectors-benchmark-tests';
12
13
  import './tests/msa-tests';
13
14
  import './tests/splitters-test';
@@ -10,7 +10,7 @@ import {MmDistanceFunctionsNames} from '@datagrok-libraries/ml/src/macromolecule
10
10
  import {BitArrayMetricsNames} from '@datagrok-libraries/ml/src/typed-metrics';
11
11
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
12
12
  import {
13
- getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests
13
+ getUserLibSettings, setUserLibSettings
14
14
  } from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
15
15
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
16
16
  import {DimReductionMethods} from '@datagrok-libraries/ml/src/multi-column-dimensionality-reduction/types';
@@ -32,8 +32,7 @@ category('activityCliffs', async () => {
32
32
  userLibSettings = await getUserLibSettings();
33
33
 
34
34
  // Test 'helm' requires default monomer library loaded
35
- await setUserLibSettingsForTests();
36
- await monomerLibHelper.loadMonomerLib(true); // load default libraries
35
+ await monomerLibHelper.loadMonomerLibForTests();
37
36
  });
38
37
 
39
38
  after(async () => {
@@ -0,0 +1,37 @@
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 {category, test} from '@datagrok-libraries/utils/src/test';
6
+ import {ALIGNMENT, ALPHABET, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
7
+
8
+ import {_testNeg, _testPos, DetectorTestData, DfReaderFunc, PosCol} from './utils/detectors-utils';
9
+
10
+ category('detectors: custom', () => {
11
+ const tests: DetectorTestData = {
12
+ 'cyclized1': {
13
+ csv: `n,seq
14
+ 1,R-F-C(1)-T-G-H-F-Y-G-H-F-Y-G-H-F-Y-P-C(1)-meI
15
+ 2,C(1)-T-G-H-F-Y-P-C(1)-meI
16
+ 3,R-F-C(1)-T-G-H-F-Y-P-C(1)
17
+ 4,C(1)-T-G-H-F-H-P-C(1)
18
+ 5,R-F-D(2)-T-G-H-F-Y-P-NH2(2)
19
+ 6,R-F-aG(3)-T-G-H-F-Y-P-azG(3)-meI`,
20
+ pos: {'seq': new PosCol(NOTATION.CUSTOM, ALIGNMENT.SEQ, ALPHABET.UN, 13, true, '-')}
21
+ },
22
+ };
23
+
24
+ for (const [testName, testData] of Object.entries(tests)) {
25
+ test(`${testName}`, async () => {
26
+ const reader: DfReaderFunc = async (): Promise<DG.DataFrame> => {
27
+ return DG.DataFrame.fromCsv(testData.csv);
28
+ };
29
+ for (const negColName of testData.neg ?? [])
30
+ await _testNeg(reader, negColName);
31
+ for (const [posColName, posCol] of Object.entries(testData.pos ?? {})) {
32
+ await _testPos(reader, posColName, posCol.units, posCol.aligned,
33
+ posCol.alphabet, posCol.alphabetSize, posCol.alphabetIsMultichar, posCol.separator);
34
+ }
35
+ });
36
+ }
37
+ });
@@ -4,10 +4,12 @@ import * as DG from 'datagrok-api/dg';
4
4
 
5
5
  import {category, test, expect} from '@datagrok-libraries/utils/src/test';
6
6
 
7
- import {importFasta} from '../package';
8
7
  import {ALIGNMENT, ALPHABET, NOTATION, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
9
8
  import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
10
9
 
10
+ import {_testNeg, _testPos, DetectorTestData, DfReaderFunc, PosCol} from './utils/detectors-utils';
11
+ import {importFasta} from '../package';
12
+
11
13
  /*
12
14
  // snippet to list df columns of semType='Macromolecule' (false positive)
13
15
  const df = grok.shell.tableByName('SPGI');
@@ -19,20 +21,6 @@ for (let i = 0; i < df.columns.length; i++) {
19
21
  }
20
22
  */
21
23
 
22
- type DfReaderFunc = () => Promise<DG.DataFrame>;
23
-
24
-
25
- class PosCol {
26
- constructor(
27
- public readonly units: string,
28
- public readonly aligned: string | null,
29
- public readonly alphabet: string | null,
30
- public readonly alphabetSize: number,
31
- public readonly alphabetIsMultichar?: boolean,
32
- public readonly separator?: string,
33
- ) { };
34
- }
35
-
36
24
  category('detectors', () => {
37
25
  const enum csvTests {
38
26
  fastaDna1 = 'csvFastaDna1',
@@ -57,7 +45,7 @@ category('detectors', () => {
57
45
  helmSameLength = 'helmSameLength',
58
46
  }
59
47
 
60
- const csvData2: { [testName: string]: { csv: string, neg?: string[], pos?: { [colName: string]: PosCol } } } = {
48
+ const csvData2: DetectorTestData = {
61
49
  'negEmpty': {
62
50
  csv: `id,col1
63
51
  1,
@@ -166,6 +154,12 @@ PEPTIDE1{Ab(1).Y.V.K.H.P.F.W.R.W.Y.A.A.A.C(1).G.NH2}$$$$
166
154
  PEPTIDE1{Ad(1).S.W.Y.C.K.H.P.M.W.A.A.A.A.C(1)-G-NH2}$$$$`,
167
155
  pos: {'seq': new PosCol(NOTATION.HELM, null, null, 19, undefined, undefined)}
168
156
  },
157
+ 'fastaNonDigitAlphabet': {
158
+ csv: `flagC
159
+ "NMe-pyridazineH"
160
+ "Pyrrolo[2,3-c]pyridazineH"`,
161
+ neg: ['flagC']
162
+ }
169
163
  };
170
164
 
171
165
  const readCsv2: (key: keyof typeof csvData2) => DfReaderFunc = (key: keyof typeof csvData2) => {
@@ -517,20 +511,6 @@ export async function _testNegList(list: string[]): Promise<void> {
517
511
  }
518
512
  }
519
513
 
520
- export async function _testNeg(readDf: DfReaderFunc, colName: string) {
521
- const df: DG.DataFrame = await readDf();
522
- const col: DG.Column = df.getCol(colName)!;
523
- const semType: string = await grok.functions
524
- .call('Bio:detectMacromolecule', {col: col}) as unknown as string;
525
- if (semType)
526
- col.semType = semType;
527
-
528
- if (col.semType === DG.SEMTYPE.MACROMOLECULE) {
529
- const msg = `Negative test detected semType='${col.semType}', units='${col.meta.units}'.`;
530
- throw new Error(msg);
531
- }
532
- }
533
-
534
514
  export async function _testPosList(list: string[], units: NOTATION,
535
515
  aligned: ALIGNMENT, alphabet: ALPHABET, alphabetSize: number, alphabetIsMultichar: boolean,
536
516
  separator: string | null = null
@@ -556,35 +536,6 @@ export async function _testPosList(list: string[], units: NOTATION,
556
536
  }
557
537
  }
558
538
 
559
- export async function _testPos(
560
- readDf: DfReaderFunc, colName: string, units: string, aligned: string | null,
561
- alphabet: string | null, alphabetSize: number, alphabetIsMultichar?: boolean,
562
- separator: string | null = null,
563
- ) {
564
- const df: DG.DataFrame = await readDf();
565
- const col: DG.Column = df.col(colName)!;
566
- const semType: string = await grok.functions
567
- .call('Bio:detectMacromolecule', {col: col}) as unknown as string;
568
- if (semType)
569
- col.semType = semType;
570
-
571
- expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
572
- expect(col.meta.units, units);
573
- expect(col.getTag(bioTAGS.aligned), aligned);
574
- expect(col.getTag(bioTAGS.alphabet), alphabet);
575
- if (separator)
576
- expect(col.getTag(bioTAGS.separator), separator);
577
-
578
- const sh = SeqHandler.forColumn(col);
579
- expect(sh.getAlphabetSize(), alphabetSize);
580
- expect(sh.getAlphabetIsMultichar(), alphabetIsMultichar);
581
- if (!sh.isHelm()) {
582
- expect(sh.aligned, aligned);
583
- expect(sh.alphabet, alphabet);
584
- }
585
- }
586
-
587
-
588
539
  export async function _testDf(readDf: DfReaderFunc, posCols: { [colName: string]: PosCol }): Promise<void> {
589
540
  const df: DG.DataFrame = await readDf();
590
541
  const errList: string[] = [];
@@ -4,8 +4,8 @@ import * as DG from 'datagrok-api/dg';
4
4
 
5
5
  import {category, test} from '@datagrok-libraries/utils/src/test';
6
6
  import {ALIGNMENT, ALPHABET, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
7
- import {_testNeg, _testPos} from './detectors-tests';
8
- import {DfReaderFunc} from './types';
7
+
8
+ import {_testNeg, _testPos, DfReaderFunc} from './utils/detectors-utils';
9
9
 
10
10
 
11
11
  category('detectors:weak-and-likely', () => {
@@ -2,12 +2,16 @@ 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 {test, after, before, category, expect} from '@datagrok-libraries/utils/src/test';
5
+ import {test, after, before, category, expect, expectObject} from '@datagrok-libraries/utils/src/test';
6
6
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
7
7
  import {
8
- getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests
8
+ getUserLibSettings, setUserLibSettings
9
9
  } from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
10
10
  import {expectMonomerLib} from '@datagrok-libraries/bio/src/tests/monomer-lib-tests';
11
+ import {MonomerTypes, PolymerTypes} from '@datagrok-libraries/bio/src/helm/consts';
12
+ import {Monomer} from '@datagrok-libraries/bio/src/types/index';
13
+
14
+ import {monomerLibForTestsSummary} from '../utils/monomer-lib/consts';
11
15
 
12
16
 
13
17
  category('monomerLibraries', () => {
@@ -35,13 +39,12 @@ category('monomerLibraries', () => {
35
39
  });
36
40
 
37
41
  test('forTests', async () => {
38
- await setUserLibSettingsForTests();
39
- await monomerLibHelper.loadMonomerLib(true); // test defaultLib
42
+ await monomerLibHelper.loadMonomerLibForTests(); // test defaultLib
40
43
 
41
44
  // Currently default monomer lib set is of all files at LIB_PATH (at least HELMCoreLibrary.json)
42
45
  const currentMonomerLib = monomerLibHelper.getMonomerLib();
43
46
  // HELMCoreLibrary.json checks
44
- expectMonomerLib(currentMonomerLib);
47
+ expectMonomerLib(currentMonomerLib, monomerLibForTestsSummary);
45
48
  });
46
49
 
47
50
  test('empty', async () => {
@@ -62,4 +65,26 @@ category('monomerLibraries', () => {
62
65
  const polymerTypes = currentMonomerLib.getPolymerTypes();
63
66
  expect(polymerTypes.length === 0, true);
64
67
  });
68
+
69
+ test('override', async () => {
70
+ const overMon: Monomer = {
71
+ symbol: 'over1',
72
+ name: 'Test override monomer 1',
73
+ molfile: '',
74
+ author: 'Test Author',
75
+ id: 0,
76
+ rgroups: [],
77
+ smiles: '',
78
+ polymerType: PolymerTypes.PEPTIDE,
79
+ monomerType: MonomerTypes.BACKBONE,
80
+ createDate: null,
81
+ };
82
+ const monomerLib = monomerLibHelper.getMonomerLib();
83
+ const absentOverrideMonomer = monomerLib.getMonomer(overMon.polymerType, overMon.symbol);
84
+ expect(absentOverrideMonomer === null, true, `Unexpectedly found monomer '${overMon.symbol}' `);
85
+
86
+ const overriddenMonomerLib = monomerLib.override({[overMon.polymerType]: {[overMon.symbol]: overMon}});
87
+ const resOverMon = overriddenMonomerLib.getMonomer(overMon.polymerType, overMon.symbol);
88
+ expectObject(resOverMon as any, overMon);
89
+ });
65
90
  });
@@ -63,5 +63,5 @@ category('PepSeA', () => {
63
63
  logger.error(errMsg, undefined, errStack);
64
64
  }
65
65
  expect(logger.errorList[0].message, pepseaErrorError);
66
- },{skipReason: 'GROK-16699'});
66
+ });
67
67
  });
@@ -10,7 +10,7 @@ import {monomerToShort} from '@datagrok-libraries/bio/src/utils/macromolecule';
10
10
  import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
11
11
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
12
12
  import {
13
- getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests
13
+ getUserLibSettings, setUserLibSettings
14
14
  } from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
15
15
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
16
16
 
@@ -24,9 +24,7 @@ category('renderers: monomerPlacer', () => {
24
24
  libHelper = await getMonomerLibHelper();
25
25
  libSettings = await getUserLibSettings();
26
26
 
27
- await setUserLibSettingsForTests();
28
- await libHelper.awaitLoaded();
29
- await libHelper.loadMonomerLib(true);
27
+ await libHelper.loadMonomerLibForTests();
30
28
  });
31
29
 
32
30
  after(async () => {
@@ -10,7 +10,7 @@ import {IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monom
10
10
 
11
11
  import {getMonomerLibHelper, sequenceIdentityScoring, sequenceSimilarityScoring} from '../package';
12
12
  import {
13
- getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests
13
+ getUserLibSettings, setUserLibSettings
14
14
  } from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
15
15
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
16
16
 
@@ -41,8 +41,7 @@ PEPTIDE1{[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[1Nal].[
41
41
  monomerLibHelper = await getMonomerLibHelper();
42
42
  userLibSettings = await getUserLibSettings();
43
43
 
44
- await setUserLibSettingsForTests();
45
- await monomerLibHelper.loadMonomerLib(true); // load default libraries
44
+ await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
46
45
  });
47
46
 
48
47
  after(async () => {
@@ -5,9 +5,8 @@ import * as DG from 'datagrok-api/dg';
5
5
  import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test';
6
6
  import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
7
7
  import {NOTATION, TAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
8
- import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
9
8
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
10
- import {getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
9
+ import {getUserLibSettings, setUserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
11
10
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
12
11
 
13
12
  category('SeqHandler: getHelm', () => {
@@ -19,8 +18,7 @@ category('SeqHandler: getHelm', () => {
19
18
  userLibSettings = await getUserLibSettings();
20
19
 
21
20
  // Test 'helm' requires default monomer library loaded
22
- await setUserLibSettingsForTests();
23
- await monomerLibHelper.loadMonomerLib(true); // load default libraries
21
+ await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
24
22
  });
25
23
 
26
24
  after(async () => {
@@ -8,7 +8,7 @@ import wu from 'wu';
8
8
  import {after, before, category, test, expect, delay, testEvent, awaitCheck} from '@datagrok-libraries/utils/src/test';
9
9
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
10
10
  import {
11
- getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests
11
+ getUserLibSettings, setUserLibSettings
12
12
  } from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
13
13
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
14
14
  import {getHelmHelper, IHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
@@ -36,8 +36,7 @@ category('bio-substructure-filters', async () => {
36
36
  userLibSettings = await getUserLibSettings();
37
37
 
38
38
  // Test 'helm' requires default monomer library loaded
39
- await setUserLibSettingsForTests();
40
- await monomerLibHelper.loadMonomerLib(true); // load default libraries
39
+ await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
41
40
  });
42
41
 
43
42
  after(async () => {
@@ -12,7 +12,7 @@ import {IMonomerLib} from '@datagrok-libraries/bio/src/types';
12
12
  import {ALPHABET, NOTATION, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
13
13
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
14
14
  import {
15
- getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests
15
+ getUserLibSettings, setUserLibSettings
16
16
  } from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
17
17
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
18
18
  import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
@@ -68,9 +68,7 @@ category('toAtomicLevel', async () => {
68
68
  monomerLibHelper = await getMonomerLibHelper();
69
69
  userLibSettings = await getUserLibSettings();
70
70
  // Clear settings to test default
71
- await setUserLibSettingsForTests();
72
- await monomerLibHelper.awaitLoaded();
73
- await monomerLibHelper.loadMonomerLib(true);
71
+ await monomerLibHelper.loadMonomerLibForTests();
74
72
 
75
73
  monomerLib = monomerLibHelper.getMonomerLib();
76
74
 
@@ -5,7 +5,7 @@ import {after, before, category, expect, expectArray, test} from '@datagrok-libr
5
5
  import {IMonomerLib} from '@datagrok-libraries/bio/src/types';
6
6
  import {sequenceToMolfile} from '../utils/sequence-to-mol';
7
7
  import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
8
- import {getUserLibSettings, setUserLibSettings, setUserLibSettingsForTests} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
8
+ import {getUserLibSettings, setUserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
9
9
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
10
10
 
11
11
  import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
@@ -31,9 +31,7 @@ category('toAtomicLevel-ui', () => {
31
31
  userLibSettings = await getUserLibSettings();
32
32
 
33
33
  // Test 'helm' requires default monomer library loaded
34
- await setUserLibSettingsForTests();
35
- await monomerLibHelper.awaitLoaded();
36
- await monomerLibHelper.loadMonomerLib(true); // load default libraries
34
+ await monomerLibHelper.loadMonomerLibForTests(); // load default libraries
37
35
 
38
36
  monomerLib = monomerLibHelper.getMonomerLib();
39
37
  });
@@ -91,7 +89,7 @@ category('toAtomicLevel-ui', () => {
91
89
  test(`${testName}-nonlinear`, async () => {
92
90
  const seqCol = await getSeqCol(testData);
93
91
  await _testToAtomicLevelFunc(seqCol, true, testData.tgt);
94
- }, {skipReason: 'To publish HelmHelper.removeGaps dependency'});
92
+ });
95
93
  }
96
94
 
97
95
  async function _testToAtomicLevelFunc(
@@ -2,6 +2,4 @@ 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
- export type DfReaderFunc = () => Promise<DG.DataFrame>;
6
-
7
5
  export type ConverterFunc = (srcCol: DG.Column) => DG.Column;
@@ -0,0 +1,63 @@
1
+ import * as DG from 'datagrok-api/dg';
2
+ import * as grok from 'datagrok-api/grok';
3
+
4
+ import {ALIGNMENT, NOTATION, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
5
+ import {expect} from '@datagrok-libraries/utils/src/test';
6
+ import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
7
+
8
+ export type DetectorTestData = { [testName: string]: { csv: string, neg?: string[], pos?: { [colName: string]: PosCol } } };
9
+
10
+ export type DfReaderFunc = () => Promise<DG.DataFrame>;
11
+
12
+ export class PosCol {
13
+ constructor(
14
+ public readonly units: NOTATION,
15
+ public readonly aligned: ALIGNMENT | null,
16
+ public readonly alphabet: string | null,
17
+ public readonly alphabetSize: number,
18
+ public readonly alphabetIsMultichar?: boolean,
19
+ public readonly separator?: string,
20
+ ) { };
21
+ }
22
+
23
+ export async function _testNeg(readDf: DfReaderFunc, colName: string) {
24
+ const df: DG.DataFrame = await readDf();
25
+ const col: DG.Column = df.getCol(colName)!;
26
+ const semType: string = await grok.functions
27
+ .call('Bio:detectMacromolecule', {col: col}) as unknown as string;
28
+ if (semType)
29
+ col.semType = semType;
30
+
31
+ if (col.semType === DG.SEMTYPE.MACROMOLECULE) {
32
+ const msg = `Negative test detected semType='${col.semType}', units='${col.meta.units}'.`;
33
+ throw new Error(msg);
34
+ }
35
+ }
36
+
37
+ export async function _testPos(
38
+ readDf: DfReaderFunc, colName: string, units: string, aligned: string | null,
39
+ alphabet: string | null, alphabetSize: number, alphabetIsMultichar?: boolean,
40
+ separator: string | null = null,
41
+ ) {
42
+ const df: DG.DataFrame = await readDf();
43
+ const col: DG.Column = df.col(colName)!;
44
+ const semType: string = await grok.functions
45
+ .call('Bio:detectMacromolecule', {col: col}) as unknown as string;
46
+ if (semType)
47
+ col.semType = semType;
48
+
49
+ expect(col.semType, DG.SEMTYPE.MACROMOLECULE);
50
+ expect(col.meta.units, units);
51
+ expect(col.getTag(bioTAGS.aligned), aligned);
52
+ expect(col.getTag(bioTAGS.alphabet), alphabet);
53
+ if (separator)
54
+ expect(col.getTag(bioTAGS.separator), separator);
55
+
56
+ const sh = SeqHandler.forColumn(col);
57
+ expect(sh.getAlphabetSize(), alphabetSize);
58
+ expect(sh.getAlphabetIsMultichar(), alphabetIsMultichar);
59
+ if (!sh.isHelm()) {
60
+ expect(sh.aligned, aligned);
61
+ expect(sh.alphabet, alphabet);
62
+ }
63
+ }
@@ -0,0 +1,18 @@
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 {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
6
+ import {MonomerLibSummaryType} from '@datagrok-libraries/bio/src/types/index';
7
+
8
+ export const LIB_PATH = 'System:AppData/Bio/monomer-libraries/';
9
+ export const SETS_PATH: string = 'System:AppData/Bio/monomer-sets/';
10
+
11
+ export const HELM_JSON_SCHEMA_PATH = 'System:AppData/Bio/tests/libraries/HELMmonomerSchema.json';
12
+
13
+ export const LIB_SETTINGS_FOR_TESTS: UserLibSettings =
14
+ {explicit: ['HELMCoreLibrary.json', 'polytool-lib.json'], exclude: [], duplicateMonomerPreferences: {}};
15
+
16
+ /** Summary for settings {@link LIB_SETTINGS_FOR_TESTS} */
17
+ export const monomerLibForTestsSummary: MonomerLibSummaryType = {'PEPTIDE': 326, 'RNA': 383, 'CHEM': 0};
18
+
@@ -7,7 +7,7 @@ import {delay} from '@datagrok-libraries/utils/src/test';
7
7
  import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';
8
8
  import {IMonomerLib, IMonomerSet} from '@datagrok-libraries/bio/src/types';
9
9
  import {
10
- getUserLibSettings, setUserLibSettings, LIB_PATH, SETS_PATH
10
+ getUserLibSettings, setUserLibSettings,
11
11
  } from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
12
12
  import {UserLibSettings} from '@datagrok-libraries/bio/src/monomer-works/types';
13
13
  import {
@@ -18,6 +18,7 @@ import {MonomerLib} from './monomer-lib';
18
18
  import {MonomerSet} from './monomer-set';
19
19
  import {MonomerLibFileManager} from './library-file-manager/file-manager';
20
20
  import {MonomerLibFileEventManager} from './library-file-manager/event-manager';
21
+ import {LIB_PATH, LIB_SETTINGS_FOR_TESTS, SETS_PATH} from './consts';
21
22
 
22
23
  import {_package} from '../../package';
23
24
 
@@ -267,6 +268,15 @@ export class MonomerLibManager implements IMonomerLibHelper {
267
268
  return invalidNames;
268
269
  }
269
270
 
271
+ // -- Settings --
272
+
273
+ /** Changes userLibSettings set only HELMCoreLibrary.json, polytool-lib.json */
274
+ async loadMonomerLibForTests(): Promise<void> {
275
+ await setUserLibSettings(LIB_SETTINGS_FOR_TESTS);
276
+ await this.awaitLoaded();
277
+ await this.loadMonomerLib(true); // load default libraries
278
+ }
279
+
270
280
  // -- Instance singleton --
271
281
  public static async getInstance(): Promise<MonomerLibManager> {
272
282
  let res = window.$monomerLibHelperPromise;
@@ -8,7 +8,6 @@ import {JSONSchemaType} from 'ajv';
8
8
  import {MonomerType, PolymerType} from '@datagrok-libraries/bio/src/helm/types';
9
9
  import {IMonomerLib, IMonomerLinkData, IMonomerSet, Monomer} from '@datagrok-libraries/bio/src/types';
10
10
  import {ILogger} from '@datagrok-libraries/bio/src/utils/logger';
11
- import {LIB_PATH, SETS_PATH} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
12
11
  import {
13
12
  HELM_REQUIRED_FIELD as REQ,
14
13
  } from '@datagrok-libraries/bio/src/utils/const';
@@ -17,10 +16,10 @@ import {
17
16
  } from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
18
17
 
19
18
  import {MonomerLib} from '../monomer-lib';
20
- import {HELM_JSON_SCHEMA_PATH} from './consts';
21
19
  import {MonomerLibFileEventManager} from './event-manager';
22
20
  import {MonomerLibFileValidator} from './file-validator';
23
21
  import {MonomerSet, MonomerSetPlaceholder} from '../monomer-set';
22
+ import {HELM_JSON_SCHEMA_PATH, LIB_PATH, SETS_PATH} from '../consts';
24
23
 
25
24
  import {_package} from '../../../package';
26
25