@datagrok/bio 1.11.1 → 1.11.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/dist/package-test.js +106 -59
- package/dist/package.js +39 -14
- package/package.json +3 -3
- package/src/tests/checkInputColumn-tests.ts +41 -38
- package/src/tests/convert-test.ts +6 -3
- package/src/tests/renderers-test.ts +39 -22
- package/src/tests/sequence-space-utils.ts +8 -3
- package/src/utils/convert.ts +4 -1
- package/{test-Bio-f1ac5a5eade4-e2085bf5.html → test-Bio-f1ac5a5eade4-a0f7e8c0.html} +2 -2
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "Leonid Stolbov",
|
|
6
6
|
"email": "lstolbov@datagrok.ai"
|
|
7
7
|
},
|
|
8
|
-
"version": "1.11.
|
|
8
|
+
"version": "1.11.2",
|
|
9
9
|
"description": "Bio is a [package](https://datagrok.ai/help/develop/develop#packages) for the [Datagrok](https://datagrok.ai) platform",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@biowasm/aioli": ">=2.4.0",
|
|
17
|
-
"@datagrok-libraries/bio": "^4.2.
|
|
17
|
+
"@datagrok-libraries/bio": "^4.2.1",
|
|
18
18
|
"@datagrok-libraries/chem-meta": "1.0.0",
|
|
19
19
|
"@datagrok-libraries/ml": "^6.0.0",
|
|
20
20
|
"@datagrok-libraries/utils": "^1.6.2",
|
|
21
21
|
"cash-dom": "latest",
|
|
22
|
-
"datagrok-api": "^1.6.
|
|
22
|
+
"datagrok-api": "^1.6.7",
|
|
23
23
|
"dayjs": "^1.11.4",
|
|
24
24
|
"openchemlib": "6.0.1",
|
|
25
25
|
"rxjs": "^6.5.5",
|
|
@@ -4,7 +4,7 @@ import * as grok from 'datagrok-api/grok';
|
|
|
4
4
|
import * as ui from 'datagrok-api/ui';
|
|
5
5
|
import * as DG from 'datagrok-api/dg';
|
|
6
6
|
|
|
7
|
-
import {checkInputColumn} from '../package';
|
|
7
|
+
import {checkInputColumn, multipleSequenceAlignmentAny} from '../package';
|
|
8
8
|
import {UNITS} from 'datagrok-api/dg';
|
|
9
9
|
import {ALPHABET, UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
10
10
|
|
|
@@ -17,53 +17,56 @@ seq2,
|
|
|
17
17
|
seq3,
|
|
18
18
|
seq4`;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
test('testMsaPos', async () => {
|
|
21
|
+
const func: DG.Func = DG.Func.find({package: 'Bio', name: 'multipleSequenceAlignmentAny'})[0];
|
|
22
|
+
const funcInputColumnProperty: DG.Property = func.inputs.find((i) => i.name == 'sequence')!;
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
const func: DG.Func = DG.Func.find({package: 'Bio', name: 'multipleSequenceAlignmentAny'})[0];
|
|
24
|
-
const funcInputColumnProperty: DG.Property = func.inputs.find((i) => i.name == 'sequence')!;
|
|
24
|
+
let k = 11;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
27
|
+
const col: DG.Column = df.getCol('seq');
|
|
28
|
+
col.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
29
|
+
col.setTag(DG.TAGS.UNITS, 'fasta');
|
|
30
|
+
col.setTag(UnitsHandler.TAGS.alphabet, ALPHABET.DNA);
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
col.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
31
|
-
col.setTag(DG.TAGS.UNITS, 'fasta');
|
|
32
|
-
col.setTag(UnitsHandler.TAGS.alphabet, ALPHABET.DNA);
|
|
32
|
+
const [res, msg]: [boolean, string] = checkInputColumn(
|
|
33
|
+
col, 'Test', ['fasta',], ['DNA', 'RNA', 'PT']);
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
expect(res, true);
|
|
36
|
+
});
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
test('testMsaNegHelm', async () => {
|
|
39
|
+
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
40
|
+
const col: DG.Column = df.getCol('seq');
|
|
41
|
+
col.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
42
|
+
col.setTag(DG.TAGS.UNITS, 'helm');
|
|
43
|
+
col.setTag(UnitsHandler.TAGS.alphabetSize, '11');
|
|
44
|
+
col.setTag(UnitsHandler.TAGS.alphabetIsMultichar, 'true');
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const col: DG.Column = df.getCol('seq');
|
|
43
|
-
col.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
44
|
-
col.setTag(DG.TAGS.UNITS, 'helm');
|
|
45
|
-
col.setTag(UnitsHandler.TAGS.alphabetSize, '11');
|
|
46
|
-
col.setTag(UnitsHandler.TAGS.alphabetIsMultichar, 'true');
|
|
46
|
+
const [res, msg]: [boolean, string] = checkInputColumn(
|
|
47
|
+
col, 'Test', ['fasta',], ['DNA', 'RNA', 'PT']);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
expect(res, false);
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
test('testMsaNegUN', async () => {
|
|
53
|
+
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
54
|
+
const col: DG.Column = df.getCol('seq');
|
|
55
|
+
col.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
56
|
+
col.setTag(DG.TAGS.UNITS, 'fasta');
|
|
57
|
+
col.setTag(UnitsHandler.TAGS.alphabet, 'UN');
|
|
58
|
+
col.setTag(UnitsHandler.TAGS.alphabetSize, '11');
|
|
59
|
+
col.setTag(UnitsHandler.TAGS.alphabetIsMultichar, 'true');
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const col: DG.Column = df.getCol('seq');
|
|
57
|
-
col.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
58
|
-
col.setTag(DG.TAGS.UNITS, 'fasta');
|
|
59
|
-
col.setTag(UnitsHandler.TAGS.alphabet, 'UN');
|
|
60
|
-
col.setTag(UnitsHandler.TAGS.alphabetSize, '11');
|
|
61
|
-
col.setTag(UnitsHandler.TAGS.alphabetIsMultichar, 'true');
|
|
61
|
+
const [res, msg]: [boolean, string] = checkInputColumn(
|
|
62
|
+
col, 'Test', ['fasta',], ['DNA', 'RNA', 'PT']);
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
expect(res, false);
|
|
65
|
+
});
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
});
|
|
67
|
+
test('testGetActionFunctionMeta', async () => {
|
|
68
|
+
const func: DG.Func = DG.Func.find({package: 'Bio', name: 'multipleSequenceAlignmentAny'})[0];
|
|
69
|
+
const sequenceInput: DG.Property = func.inputs.find((i) => i.name == 'sequence')!;
|
|
70
|
+
let k = 11;
|
|
68
71
|
});
|
|
69
72
|
});
|
|
@@ -5,7 +5,7 @@ import * as DG from 'datagrok-api/dg';
|
|
|
5
5
|
|
|
6
6
|
import {ConverterFunc} from './types';
|
|
7
7
|
import {NotationConverter} from '@datagrok-libraries/bio/src/utils/notation-converter';
|
|
8
|
-
import {NOTATION} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
8
|
+
import {NOTATION, UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
9
9
|
|
|
10
10
|
// import {mmSemType} from '../const';
|
|
11
11
|
// import {importFasta} from '../package';
|
|
@@ -145,14 +145,17 @@ RNA1{P.R(U)P.R(U)P.R(C)P.R(A)P.R(A)P.R(C)P.P.P}$$$
|
|
|
145
145
|
|
|
146
146
|
async function _testConvert(srcKey: string, converter: ConverterFunc, tgtKey: string) {
|
|
147
147
|
const srcDf: DG.DataFrame = await readCsv(srcKey);
|
|
148
|
-
const srcCol: DG.Column = srcDf.
|
|
148
|
+
const srcCol: DG.Column = srcDf.getCol('seq');
|
|
149
149
|
|
|
150
|
+
// conversion results
|
|
150
151
|
const resCol: DG.Column = converter(srcCol);
|
|
151
152
|
|
|
153
|
+
// The correct reference data to compare conversion results with.
|
|
152
154
|
const tgtDf: DG.DataFrame = await readCsv(tgtKey);
|
|
153
|
-
const tgtCol: DG.Column = tgtDf.
|
|
155
|
+
const tgtCol: DG.Column = tgtDf.getCol('seq');
|
|
154
156
|
|
|
155
157
|
expectArray(resCol.toList(), tgtCol.toList());
|
|
158
|
+
const uh: UnitsHandler = new UnitsHandler(resCol);
|
|
156
159
|
}
|
|
157
160
|
|
|
158
161
|
// FASTA tests
|
|
@@ -3,10 +3,9 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/
|
|
|
3
3
|
import * as grok from 'datagrok-api/grok';
|
|
4
4
|
import * as DG from 'datagrok-api/dg';
|
|
5
5
|
import {importFasta, multipleSequenceAlignmentAny} from '../package';
|
|
6
|
-
import {readDataframe} from './utils';
|
|
7
6
|
import {convertDo} from '../utils/convert';
|
|
8
7
|
import {ALPHABET, NOTATION, UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
9
|
-
import {
|
|
8
|
+
import {SEM_TYPES, TAGS} from '../utils/constants';
|
|
10
9
|
|
|
11
10
|
category('renderers', () => {
|
|
12
11
|
let tvList: DG.TableView[];
|
|
@@ -38,30 +37,38 @@ category('renderers', () => {
|
|
|
38
37
|
async function _testAfterMsa() {
|
|
39
38
|
const fastaTxt: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/sample_FASTA.fasta');
|
|
40
39
|
const df: DG.DataFrame = importFasta(fastaTxt)[0];
|
|
40
|
+
|
|
41
|
+
const srcSeqCol: DG.Column = df.getCol('sequence');
|
|
42
|
+
const semType: string = await grok.functions.call('Bio:detectMacromolecule', {col: srcSeqCol});
|
|
43
|
+
if (semType)
|
|
44
|
+
srcSeqCol.semType = semType;
|
|
45
|
+
|
|
41
46
|
const tv: DG.TableView = grok.shell.addTableView(df);
|
|
47
|
+
// call to calculate 'cell.renderer' tag
|
|
42
48
|
await grok.data.detectSemanticTypes(df);
|
|
43
|
-
console.log('Bio: tests/renderers/afterMsa, table view');
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
expect(srcSeqCol !== null, true);
|
|
50
|
+
console.log('Bio: tests/renderers/afterMsa, table view');
|
|
47
51
|
|
|
48
52
|
console.log('Bio: tests/renderers/afterMsa, src before test ' +
|
|
49
53
|
`semType="${srcSeqCol!.semType}", units="${srcSeqCol!.getTag(DG.TAGS.UNITS)}", ` +
|
|
50
54
|
`cell.renderer="${srcSeqCol!.getTag(DG.TAGS.CELL_RENDERER)}"`);
|
|
51
|
-
expect(srcSeqCol
|
|
52
|
-
expect(srcSeqCol
|
|
53
|
-
expect(srcSeqCol
|
|
54
|
-
expect(srcSeqCol
|
|
55
|
-
expect(srcSeqCol
|
|
55
|
+
expect(srcSeqCol.semType, DG.SEMTYPE.MACROMOLECULE);
|
|
56
|
+
expect(srcSeqCol.getTag(DG.TAGS.UNITS), NOTATION.FASTA);
|
|
57
|
+
expect(srcSeqCol.getTag(UnitsHandler.TAGS.aligned), 'SEQ');
|
|
58
|
+
expect(srcSeqCol.getTag(UnitsHandler.TAGS.alphabet), ALPHABET.PT);
|
|
59
|
+
expect(srcSeqCol.getTag(DG.TAGS.CELL_RENDERER), 'sequence');
|
|
56
60
|
|
|
57
|
-
const msaSeqCol: DG.Column
|
|
61
|
+
const msaSeqCol: DG.Column = (await multipleSequenceAlignmentAny(df, srcSeqCol!))!;
|
|
58
62
|
tv.grid.invalidate();
|
|
59
63
|
|
|
60
|
-
expect(msaSeqCol
|
|
61
|
-
expect(msaSeqCol
|
|
62
|
-
expect(msaSeqCol
|
|
63
|
-
expect(msaSeqCol
|
|
64
|
-
expect(msaSeqCol
|
|
64
|
+
expect(msaSeqCol.semType, DG.SEMTYPE.MACROMOLECULE);
|
|
65
|
+
expect(msaSeqCol.getTag(DG.TAGS.UNITS), NOTATION.FASTA);
|
|
66
|
+
expect(msaSeqCol.getTag(UnitsHandler.TAGS.aligned), 'SEQ.MSA');
|
|
67
|
+
expect(msaSeqCol.getTag(UnitsHandler.TAGS.alphabet), ALPHABET.PT);
|
|
68
|
+
expect(msaSeqCol.getTag(DG.TAGS.CELL_RENDERER), 'sequence');
|
|
69
|
+
|
|
70
|
+
// check newColumn with UnitsHandler constructor
|
|
71
|
+
const uh: UnitsHandler = new UnitsHandler(msaSeqCol);
|
|
65
72
|
|
|
66
73
|
dfList.push(df);
|
|
67
74
|
tvList.push(tv);
|
|
@@ -71,25 +78,35 @@ category('renderers', () => {
|
|
|
71
78
|
const csv: string = await grok.dapi.files.readAsText('System:AppData/Bio/samples/sample_FASTA_PT.csv');
|
|
72
79
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
73
80
|
const tv: DG.TableView = grok.shell.addTableView(df);
|
|
74
|
-
await grok.data.detectSemanticTypes(df);
|
|
75
81
|
|
|
76
82
|
const srcCol: DG.Column = df.col('sequence')!;
|
|
83
|
+
// await grok.data.detectSemanticTypes(df);
|
|
84
|
+
const semType: string = await grok.functions.call('Bio:detectMacromolecule', {col: srcCol});
|
|
85
|
+
if (semType)
|
|
86
|
+
srcCol.semType = semType;
|
|
87
|
+
await grok.data.detectSemanticTypes(df);
|
|
88
|
+
|
|
77
89
|
const tgtCol: DG.Column = await convertDo(srcCol, NOTATION.SEPARATOR, '/');
|
|
78
90
|
expect(tgtCol.getTag(DG.TAGS.CELL_RENDERER), 'sequence');
|
|
79
91
|
|
|
92
|
+
// check tgtCol with UnitsHandler constructor
|
|
93
|
+
const uh: UnitsHandler = new UnitsHandler(tgtCol);
|
|
94
|
+
|
|
80
95
|
tvList.push(tv);
|
|
81
96
|
dfList.push(df);
|
|
82
|
-
}
|
|
97
|
+
}
|
|
83
98
|
|
|
84
99
|
async function _setRendererManually() {
|
|
85
|
-
const df = DG.DataFrame.fromColumns([DG.Column.fromStrings(
|
|
100
|
+
const df = DG.DataFrame.fromColumns([DG.Column.fromStrings(
|
|
101
|
+
'SequencesDiff', ['meI/hHis/Aca/N/T/dK/Thr_PO3H2/Aca#D-Tyr_Et/Tyr_ab-dehydroMe/meN/E/N/dV'])]);
|
|
86
102
|
df.col('SequencesDiff')!.tags[DG.TAGS.UNITS] = 'separator';
|
|
87
103
|
df.col('SequencesDiff')!.tags[TAGS.SEPARATOR] = '/';
|
|
88
104
|
df.col('SequencesDiff')!.semType = SEM_TYPES.MACROMOLECULE_DIFFERENCE;
|
|
89
105
|
const tw = grok.shell.addTableView(df);
|
|
90
106
|
await delay(100);
|
|
91
107
|
const renderer = tw.dataFrame.col('SequencesDiff')?.getTag(DG.TAGS.CELL_RENDERER);
|
|
92
|
-
if (renderer !== 'MacromoleculeDifferenceCR')
|
|
93
|
-
throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been
|
|
94
|
-
|
|
108
|
+
if (renderer !== 'MacromoleculeDifferenceCR')
|
|
109
|
+
throw new Error(`Units 'separator', separator '/' and semType 'MacromoleculeDifference' have been ` +
|
|
110
|
+
`manually set on column but after df aws added as table view renderer has been reset to '${renderer}'`);
|
|
111
|
+
}
|
|
95
112
|
});
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import {expect} from '@datagrok-libraries/utils/src/test';
|
|
4
|
+
import {sequenceSpaceTopMenu} from '../package';
|
|
5
5
|
|
|
6
6
|
export async function _testSequenceSpaceReturnsResult(df: DG.DataFrame, algorithm: string, colName: string) {
|
|
7
|
-
await grok.data.detectSemanticTypes(df);
|
|
7
|
+
// await grok.data.detectSemanticTypes(df);
|
|
8
|
+
const col: DG.Column = df.getCol(colName);
|
|
9
|
+
const semType: string = await grok.functions.call('Bio:detectMacromolecule', {col: col});
|
|
10
|
+
if (semType)
|
|
11
|
+
col.semType = semType;
|
|
12
|
+
|
|
8
13
|
const sp = await sequenceSpaceTopMenu(df, df.col(colName)!, algorithm, 'Levenshtein', true);
|
|
9
14
|
expect(sp != null, true);
|
|
10
15
|
}
|
package/src/utils/convert.ts
CHANGED
|
@@ -5,7 +5,7 @@ import $ from 'cash-dom';
|
|
|
5
5
|
|
|
6
6
|
import {Subscription} from 'rxjs';
|
|
7
7
|
import {NotationConverter} from '@datagrok-libraries/bio/src/utils/notation-converter';
|
|
8
|
-
import {NOTATION} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
8
|
+
import {NOTATION, UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
let convertDialog: DG.Dialog | null = null;
|
|
@@ -85,6 +85,9 @@ export async function convertDo(
|
|
|
85
85
|
const converter = new NotationConverter(srcCol);
|
|
86
86
|
const newColumn = converter.convert(targetNotation, separator);
|
|
87
87
|
srcCol.dataFrame.columns.add(newColumn);
|
|
88
|
+
|
|
89
|
+
// call to calculate 'cell.renderer' tag
|
|
88
90
|
await grok.data.detectSemanticTypes(srcCol.dataFrame);
|
|
91
|
+
|
|
89
92
|
return newColumn;
|
|
90
93
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<html><head><meta charset="utf-8"/><title>Bio Test Report. Datagrok version datagrok/datagrok:latest SHA=f1ac5a5eade4. Commit
|
|
1
|
+
<html><head><meta charset="utf-8"/><title>Bio Test Report. Datagrok version datagrok/datagrok:latest SHA=f1ac5a5eade4. Commit a0f7e8c0.</title><style type="text/css">html,
|
|
2
2
|
body {
|
|
3
3
|
font-family: Arial, Helvetica, sans-serif;
|
|
4
4
|
font-size: 1rem;
|
|
@@ -229,7 +229,7 @@ header {
|
|
|
229
229
|
font-size: 1rem;
|
|
230
230
|
padding: 0 0.5rem;
|
|
231
231
|
}
|
|
232
|
-
</style></head><body><div id="jesthtml-content"><header><h1 id="title">Bio Test Report. Datagrok version datagrok/datagrok:latest SHA=f1ac5a5eade4. Commit
|
|
232
|
+
</style></head><body><div id="jesthtml-content"><header><h1 id="title">Bio Test Report. Datagrok version datagrok/datagrok:latest SHA=f1ac5a5eade4. Commit a0f7e8c0.</h1></header><div id="metadata-container"><div id="timestamp">Started: 2022-09-08 10:03:50</div><div id="summary"><div id="suite-summary"><div class="summary-total">Suites (1)</div><div class="summary-passed summary-empty">0 passed</div><div class="summary-failed">1 failed</div><div class="summary-pending summary-empty">0 pending</div></div><div id="test-summary"><div class="summary-total">Tests (1)</div><div class="summary-passed summary-empty">0 passed</div><div class="summary-failed">1 failed</div><div class="summary-pending summary-empty">0 pending</div></div></div></div><div id="suite-1" class="suite-container"><div class="suite-info"><div class="suite-path">/home/runner/work/public/public/packages/Bio/src/__jest__/remote.test.ts</div><div class="suite-time warn">10.76s</div></div><div class="suite-tests"><div class="test-result failed"><div class="test-info"><div class="test-suitename"> </div><div class="test-title">TEST</div><div class="test-status">failed</div><div class="test-duration">0s</div></div><div class="failureMessages"> <pre class="failureMsg">Error: Unknown server alias. Please add it to /home/runner/.grok/config.yaml
|
|
233
233
|
at getDevKey (/home/runner/work/public/public/packages/Bio/src/__jest__/test-node.ts:48:13)
|
|
234
234
|
at Object.<anonymous> (/home/runner/work/public/public/packages/Bio/src/__jest__/test-node.ts:57:15)
|
|
235
235
|
at Generator.next (<anonymous>)
|