@datagrok/bio 2.1.11 → 2.4.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/README.md +11 -12
- package/css/helm.css +10 -0
- package/detectors.js +83 -59
- package/dist/package-test.js +2 -68651
- package/dist/package-test.js.map +1 -0
- package/dist/package.js +2 -66040
- package/dist/package.js.map +1 -0
- package/dockerfiles/Dockerfile +86 -0
- package/files/icons/composition-analysis.svg +17 -0
- package/files/icons/sequence-diversity-viewer.svg +4 -0
- package/files/icons/sequence-similarity-viewer.svg +4 -0
- package/files/icons/vdregions-viewer.svg +22 -0
- package/files/icons/weblogo-viewer.svg +7 -0
- package/files/tests/testUrl.csv +11 -0
- package/files/tests/toAtomicLevelTest.csv +4 -0
- package/package.json +29 -32
- package/src/analysis/sequence-activity-cliffs.ts +15 -13
- package/src/analysis/sequence-diversity-viewer.ts +3 -2
- package/src/analysis/sequence-search-base-viewer.ts +4 -2
- package/src/analysis/sequence-similarity-viewer.ts +4 -4
- package/src/analysis/sequence-space.ts +2 -1
- package/src/calculations/monomerLevelMols.ts +6 -6
- package/src/package-test.ts +9 -2
- package/src/package.ts +230 -145
- package/src/substructure-search/substructure-search.ts +25 -22
- package/src/tests/Palettes-test.ts +9 -9
- package/src/tests/WebLogo-positions-test.ts +131 -68
- package/src/tests/_first-tests.ts +9 -0
- package/src/tests/activity-cliffs-tests.ts +8 -7
- package/src/tests/activity-cliffs-utils.ts +17 -9
- package/src/tests/bio-tests.ts +30 -21
- package/src/tests/checkInputColumn-tests.ts +17 -17
- package/src/tests/converters-test.ts +81 -46
- package/src/tests/detectors-benchmark-tests.ts +17 -17
- package/src/tests/detectors-tests.ts +190 -178
- package/src/tests/fasta-export-tests.ts +2 -3
- package/src/tests/monomer-libraries-tests.ts +34 -0
- package/src/tests/pepsea-tests.ts +21 -0
- package/src/tests/renderers-test.ts +33 -29
- package/src/tests/sequence-space-test.ts +6 -4
- package/src/tests/similarity-diversity-tests.ts +4 -4
- package/src/tests/splitters-test.ts +6 -7
- package/src/tests/substructure-filters-tests.ts +23 -1
- package/src/tests/utils/sequences-generators.ts +7 -7
- package/src/tests/utils.ts +2 -1
- package/src/tests/viewers.ts +16 -0
- package/src/utils/cell-renderer.ts +116 -54
- package/src/utils/constants.ts +7 -6
- package/src/utils/convert.ts +17 -11
- package/src/utils/monomer-lib.ts +174 -0
- package/src/utils/multiple-sequence-alignment.ts +49 -26
- package/src/utils/pepsea.ts +78 -0
- package/src/utils/save-as-fasta.ts +9 -8
- package/src/utils/ui-utils.ts +15 -3
- package/src/viewers/vd-regions-viewer.ts +125 -83
- package/src/viewers/web-logo-viewer.ts +1031 -0
- package/src/widgets/bio-substructure-filter.ts +38 -24
- package/tsconfig.json +71 -72
- package/webpack.config.js +4 -11
- package/dist/vendors-node_modules_datagrok-libraries_ml_src_workers_dimensionality-reducer_js.js +0 -8988
- package/jest.config.js +0 -33
- package/src/__jest__/remote.test.ts +0 -77
- package/src/__jest__/test-node.ts +0 -98
- package/test-Bio-91c83d8913ff-bb573307.html +0 -392
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
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
|
-
import * as bio from '@datagrok-libraries/bio';
|
|
5
4
|
|
|
6
|
-
import * as C from '../utils/constants';
|
|
7
5
|
import {getMonomericMols} from '../calculations/monomerLevelMols';
|
|
8
6
|
import {updateDivInnerHTML} from '../utils/ui-utils';
|
|
9
|
-
import {
|
|
7
|
+
import {delay} from '@datagrok-libraries/utils/src/test';
|
|
8
|
+
import {TAGS as bioTAGS, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
10
9
|
|
|
11
10
|
export const MONOMER_MOLS_COL = 'monomeric-mols';
|
|
12
11
|
|
|
@@ -16,14 +15,16 @@ export const enum MONOMERIC_COL_TAGS {
|
|
|
16
15
|
MONOMERS_DICT = 'monomers-dict'
|
|
17
16
|
}
|
|
18
17
|
|
|
18
|
+
const SUBSTR_HELM_COL_NAME = 'substr_helm';
|
|
19
|
+
|
|
19
20
|
/**
|
|
20
21
|
* Searches substructure in each row of Macromolecule column
|
|
21
22
|
*
|
|
22
23
|
* @param {DG.column} col Column with 'Macromolecule' semantic type
|
|
23
24
|
*/
|
|
24
|
-
export function substructureSearchDialog(col: DG.Column): void {
|
|
25
|
+
export function substructureSearchDialog(col: DG.Column<string>): void {
|
|
25
26
|
const units = col.getTag(DG.TAGS.UNITS);
|
|
26
|
-
const separator = col.getTag(
|
|
27
|
+
const separator = col.getTag(bioTAGS.separator);
|
|
27
28
|
// const notations = [NOTATION.FASTA, NOTATION.SEPARATOR, NOTATION.HELM];
|
|
28
29
|
|
|
29
30
|
const substructureInput = ui.textInput('Substructure', '');
|
|
@@ -32,40 +33,41 @@ export function substructureSearchDialog(col: DG.Column): void {
|
|
|
32
33
|
updateDivInnerHTML(inputsDiv, grid.root);
|
|
33
34
|
await ui.tools.waitForElementInDom(grid.root);
|
|
34
35
|
setTimeout(() => {
|
|
35
|
-
grid.cell(
|
|
36
|
+
grid.cell(SUBSTR_HELM_COL_NAME, 0).element.children[0].dispatchEvent(
|
|
37
|
+
new KeyboardEvent('keydown', {key: 'Enter'}));
|
|
36
38
|
}, 100);
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
const df = DG.DataFrame.create(1);
|
|
40
|
-
df.columns.addNewString(
|
|
41
|
-
df.col(
|
|
42
|
-
df.col(
|
|
42
|
+
df.columns.addNewString(SUBSTR_HELM_COL_NAME).init((i) => '');
|
|
43
|
+
df.col(SUBSTR_HELM_COL_NAME)!.semType = col.semType;
|
|
44
|
+
df.col(SUBSTR_HELM_COL_NAME)!.setTag(DG.TAGS.UNITS, NOTATION.HELM);
|
|
43
45
|
const grid = df.plot.grid();
|
|
44
46
|
const separatorInput = ui.textInput('Separator', separator);
|
|
45
47
|
|
|
46
48
|
const inputsDiv = ui.div();
|
|
47
49
|
|
|
48
|
-
const inputs = units ===
|
|
49
|
-
units ===
|
|
50
|
+
const inputs = units === NOTATION.HELM ? ui.divV([editHelmLink]) :
|
|
51
|
+
units === NOTATION.SEPARATOR ? ui.inputs([substructureInput, separatorInput]) :
|
|
50
52
|
ui.inputs([substructureInput]);
|
|
51
53
|
|
|
52
54
|
updateDivInnerHTML(inputsDiv, inputs);
|
|
53
55
|
|
|
54
|
-
ui.dialog('Substructure
|
|
56
|
+
ui.dialog('Substructure Search')
|
|
55
57
|
.add(ui.divV([
|
|
56
58
|
ui.divText(`Notation: ${units}`),
|
|
57
59
|
inputsDiv
|
|
58
60
|
]))
|
|
59
61
|
.onOK(async () => {
|
|
60
|
-
let substructure = units ===
|
|
61
|
-
if (units ===
|
|
62
|
+
let substructure = units === NOTATION.HELM ? df.get(SUBSTR_HELM_COL_NAME, 0) : substructureInput.value;
|
|
63
|
+
if (units === NOTATION.SEPARATOR && separatorInput.value !== separator && separatorInput.value !== '')
|
|
62
64
|
substructure = substructure.replaceAll(separatorInput.value, separator);
|
|
63
65
|
const matchesColName = `Matches: ${substructure}`;
|
|
64
66
|
const colExists = col.dataFrame.columns.names()
|
|
65
67
|
.filter((it) => it.toLocaleLowerCase() === matchesColName.toLocaleLowerCase()).length > 0;
|
|
66
68
|
if (!colExists) {
|
|
67
69
|
let matches: DG.BitSet;
|
|
68
|
-
if (units ===
|
|
70
|
+
if (units === NOTATION.HELM)
|
|
69
71
|
matches = await helmSubstructureSearch(substructure, col);
|
|
70
72
|
else
|
|
71
73
|
matches = linearSubstructureSearch(substructure, col);
|
|
@@ -75,11 +77,11 @@ export function substructureSearchDialog(col: DG.Column): void {
|
|
|
75
77
|
.show();
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
export function linearSubstructureSearch(substructure: string, col: DG.Column
|
|
80
|
+
export function linearSubstructureSearch(substructure: string, col: DG.Column<string>, separator?: string): DG.BitSet {
|
|
79
81
|
const re = separator ? prepareSubstructureRegex(substructure, separator) : substructure;
|
|
80
82
|
const resultArray = DG.BitSet.create(col.length);
|
|
81
83
|
for (let i = 0; i < col.length; i++) {
|
|
82
|
-
const macromolecule = col.get(i)
|
|
84
|
+
const macromolecule: string = col.get(i)!;
|
|
83
85
|
if (macromolecule.match(re) || macromolecule === substructure)
|
|
84
86
|
resultArray.set(i, true, false);
|
|
85
87
|
}
|
|
@@ -91,18 +93,19 @@ function prepareSubstructureRegex(substructure: string, separator: string) {
|
|
|
91
93
|
const startsWithSep = substructure.charAt(0) === separator;
|
|
92
94
|
const endsWithSep = substructure.charAt(substructure.length - 1) === separator;
|
|
93
95
|
const substrWithoutSep = substructure.replace(new RegExp(`^${char}|${char}$`, 'g'), '');
|
|
94
|
-
const re = startsWithSep ?
|
|
96
|
+
const re = startsWithSep ?
|
|
97
|
+
endsWithSep ? `${char}${substrWithoutSep}${char}` :
|
|
95
98
|
`${char}${substrWithoutSep}${char}|${char}${substrWithoutSep}$` :
|
|
96
99
|
endsWithSep ? `^${substrWithoutSep}${char}|${char}${substrWithoutSep}${char}` :
|
|
97
100
|
`^${substrWithoutSep}${char}|${char}${substrWithoutSep}${char}|${char}${substrWithoutSep}$`;
|
|
98
101
|
return re;
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
export async function helmSubstructureSearch(substructure: string, col: DG.Column): Promise<DG.BitSet> {
|
|
104
|
+
export async function helmSubstructureSearch(substructure: string, col: DG.Column<string>): Promise<DG.BitSet> {
|
|
102
105
|
if (col.version !== col.temp[MONOMERIC_COL_TAGS.LAST_INVALIDATED_VERSION])
|
|
103
106
|
await invalidateMols(col, true);
|
|
104
|
-
const substructureCol = DG.Column.string('helm', 1).init((i) => substructure);
|
|
105
|
-
substructureCol.setTag(DG.TAGS.UNITS,
|
|
107
|
+
const substructureCol: DG.Column<string> = DG.Column.string('helm', 1).init((i) => substructure);
|
|
108
|
+
substructureCol.setTag(DG.TAGS.UNITS, NOTATION.HELM);
|
|
106
109
|
const substructureMolsCol =
|
|
107
110
|
await getMonomericMols(substructureCol, true, col.temp[MONOMERIC_COL_TAGS.MONOMERS_DICT]);
|
|
108
111
|
const matchesCol = await grok.functions.call('Chem:searchSubstructure', {
|
|
@@ -113,7 +116,7 @@ export async function helmSubstructureSearch(substructure: string, col: DG.Colum
|
|
|
113
116
|
return matchesCol.get(0);
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
export async function invalidateMols(col: DG.Column
|
|
119
|
+
export async function invalidateMols(col: DG.Column<string>, pattern: boolean) {
|
|
117
120
|
const progressBar = DG.TaskBarProgressIndicator.create(`Invalidating molfiles for ${col.name}`);
|
|
118
121
|
await delay(10);
|
|
119
122
|
const monomersDict = new Map();
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
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
|
-
import * as bio from '@datagrok-libraries/bio';
|
|
5
4
|
|
|
6
5
|
import {after, before, category, test, expect, expectObject} from '@datagrok-libraries/utils/src/test';
|
|
7
6
|
|
|
8
7
|
import {_testPaletteN, _testPaletteAA} from '@datagrok-libraries/bio/src/tests/palettes-tests';
|
|
8
|
+
import {AminoacidsPalettes} from '@datagrok-libraries/bio/src/aminoacids';
|
|
9
9
|
|
|
10
10
|
category('Palettes', () => {
|
|
11
11
|
test('testPaletteN', async () => { await _testPaletteN(); });
|
|
12
12
|
test('testPaletteAA', async () => { await _testPaletteAA(); });
|
|
13
13
|
|
|
14
14
|
test('testPalettePtMe', async () => {
|
|
15
|
-
const colorMeNle =
|
|
16
|
-
const colorMeA =
|
|
17
|
-
const colorMeG =
|
|
18
|
-
const colorMeF =
|
|
15
|
+
const colorMeNle = AminoacidsPalettes.GrokGroups.get('MeNle');
|
|
16
|
+
const colorMeA = AminoacidsPalettes.GrokGroups.get('MeA');
|
|
17
|
+
const colorMeG = AminoacidsPalettes.GrokGroups.get('MeG');
|
|
18
|
+
const colorMeF = AminoacidsPalettes.GrokGroups.get('MeF');
|
|
19
19
|
|
|
20
|
-
const colorL =
|
|
21
|
-
const colorA =
|
|
22
|
-
const colorG =
|
|
23
|
-
const colorF =
|
|
20
|
+
const colorL = AminoacidsPalettes.GrokGroups.get('L');
|
|
21
|
+
const colorA = AminoacidsPalettes.GrokGroups.get('A');
|
|
22
|
+
const colorG = AminoacidsPalettes.GrokGroups.get('G');
|
|
23
|
+
const colorF = AminoacidsPalettes.GrokGroups.get('F');
|
|
24
24
|
|
|
25
25
|
expect(colorMeNle, colorL);
|
|
26
26
|
expect(colorMeA, colorA);
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import * as grok from 'datagrok-api/grok';
|
|
2
|
-
import * as ui from 'datagrok-api/ui';
|
|
3
2
|
import * as DG from 'datagrok-api/dg';
|
|
4
|
-
import * as bio from '@datagrok-libraries/bio';
|
|
5
3
|
|
|
6
|
-
import {after, before, category,
|
|
4
|
+
import {after, before, category, expect, expectArray, test} from '@datagrok-libraries/utils/src/test';
|
|
5
|
+
import {ALPHABET, NOTATION, SplitterFunc, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
6
|
+
import {
|
|
7
|
+
countForMonomerAtPosition,
|
|
8
|
+
FilterSources,
|
|
9
|
+
PositionInfo as PI,
|
|
10
|
+
PositionMonomerInfo as PMI,
|
|
11
|
+
WebLogoViewer
|
|
12
|
+
} from '../viewers/web-logo-viewer';
|
|
7
13
|
|
|
8
14
|
category('WebLogo-positions', () => {
|
|
9
15
|
let tvList: DG.TableView[];
|
|
@@ -21,13 +27,14 @@ ATC-G-TTGC--
|
|
|
21
27
|
before(async () => {
|
|
22
28
|
tvList = [];
|
|
23
29
|
dfList = [];
|
|
24
|
-
currentView = grok.shell.v;
|
|
30
|
+
// currentView = grok.shell.v;
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
after(async () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
// Closing opened views causes the error 'Cannot read properties of null (reading 'f')'
|
|
35
|
+
// dfList.forEach((df: DG.DataFrame) => { grok.shell.closeTable(df); });
|
|
36
|
+
// tvList.forEach((tv: DG.TableView) => tv.close());
|
|
37
|
+
// grok.shell.v = currentView;
|
|
31
38
|
});
|
|
32
39
|
|
|
33
40
|
test('allPositions', async () => {
|
|
@@ -36,31 +43,31 @@ ATC-G-TTGC--
|
|
|
36
43
|
|
|
37
44
|
const seqCol: DG.Column = df.getCol('seq');
|
|
38
45
|
seqCol.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
39
|
-
seqCol.setTag(DG.TAGS.UNITS,
|
|
40
|
-
seqCol.setTag(
|
|
41
|
-
seqCol.setTag(
|
|
46
|
+
seqCol.setTag(DG.TAGS.UNITS, NOTATION.FASTA);
|
|
47
|
+
seqCol.setTag(bioTAGS.alphabet, ALPHABET.DNA);
|
|
48
|
+
seqCol.setTag(bioTAGS.aligned, 'SEQ.MSA');
|
|
42
49
|
|
|
43
|
-
const wlViewer:
|
|
50
|
+
const wlViewer: WebLogoViewer = (await df.plot.fromType('WebLogo')) as WebLogoViewer;
|
|
44
51
|
tv.dockManager.dock(wlViewer.root, DG.DOCK_TYPE.DOWN);
|
|
45
52
|
|
|
46
53
|
tvList.push(tv);
|
|
47
54
|
dfList.push(df);
|
|
48
55
|
|
|
49
|
-
const positions:
|
|
50
|
-
|
|
51
|
-
const resAllDf1:
|
|
52
|
-
new
|
|
53
|
-
new
|
|
54
|
-
new
|
|
55
|
-
new
|
|
56
|
-
new
|
|
57
|
-
new
|
|
58
|
-
new
|
|
59
|
-
new
|
|
60
|
-
new
|
|
61
|
-
new
|
|
62
|
-
new
|
|
63
|
-
new
|
|
56
|
+
const positions: PI[] = wlViewer['positions'];
|
|
57
|
+
|
|
58
|
+
const resAllDf1: PI[] = [
|
|
59
|
+
new PI(0, '1', {'A': new PMI(2), '-': new PMI(3)}),
|
|
60
|
+
new PI(1, '2', {'T': new PMI(5)}),
|
|
61
|
+
new PI(2, '3', {'C': new PMI(5)}),
|
|
62
|
+
new PI(3, '4', {'-': new PMI(5)}),
|
|
63
|
+
new PI(4, '5', {'G': new PMI(5)}),
|
|
64
|
+
new PI(5, '6', {'-': new PMI(3), 'C': new PMI(2)}),
|
|
65
|
+
new PI(6, '7', {'T': new PMI(5)}),
|
|
66
|
+
new PI(7, '8', {'T': new PMI(5)}),
|
|
67
|
+
new PI(8, '9', {'G': new PMI(5)}),
|
|
68
|
+
new PI(9, '10', {'C': new PMI(5)}),
|
|
69
|
+
new PI(10, '11', {'-': new PMI(5)}),
|
|
70
|
+
new PI(11, '12', {'-': new PMI(5)}),
|
|
64
71
|
];
|
|
65
72
|
|
|
66
73
|
expect(positions.length, resAllDf1.length);
|
|
@@ -73,8 +80,8 @@ ATC-G-TTGC--
|
|
|
73
80
|
}
|
|
74
81
|
});
|
|
75
82
|
|
|
76
|
-
test('positions with shrinkEmptyTail option true (
|
|
77
|
-
|
|
83
|
+
test('positions with shrinkEmptyTail option true (filtered)', async () => {
|
|
84
|
+
const csvDf2 = `seq
|
|
78
85
|
-TC-G-TTGC--
|
|
79
86
|
-TC-GCTTGC--
|
|
80
87
|
-T--C-GT-
|
|
@@ -86,33 +93,33 @@ ATC-G-TTGC--
|
|
|
86
93
|
|
|
87
94
|
const seqCol: DG.Column = df.getCol('seq');
|
|
88
95
|
seqCol.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
89
|
-
seqCol.setTag(DG.TAGS.UNITS,
|
|
90
|
-
seqCol.setTag(
|
|
91
|
-
seqCol.setTag(
|
|
96
|
+
seqCol.setTag(DG.TAGS.UNITS, NOTATION.FASTA);
|
|
97
|
+
seqCol.setTag(bioTAGS.alphabet, ALPHABET.DNA);
|
|
98
|
+
seqCol.setTag(bioTAGS.aligned, 'SEQ');
|
|
92
99
|
|
|
93
100
|
df.filter.init((i) => {
|
|
94
101
|
return i > 2;
|
|
95
102
|
});
|
|
96
103
|
df.filter.fireChanged();
|
|
97
|
-
const wlViewer:
|
|
98
|
-
{'shrinkEmptyTail': true})) as
|
|
104
|
+
const wlViewer: WebLogoViewer = (await df.plot.fromType('WebLogo',
|
|
105
|
+
{'shrinkEmptyTail': true})) as WebLogoViewer;
|
|
99
106
|
tv.dockManager.dock(wlViewer.root, DG.DOCK_TYPE.DOWN);
|
|
100
107
|
|
|
101
108
|
tvList.push(tv);
|
|
102
109
|
dfList.push(df);
|
|
103
110
|
|
|
104
|
-
const positions:
|
|
105
|
-
|
|
106
|
-
const resAllDf1:
|
|
107
|
-
new
|
|
108
|
-
new
|
|
109
|
-
new
|
|
110
|
-
new
|
|
111
|
-
new
|
|
112
|
-
new
|
|
113
|
-
new
|
|
114
|
-
new
|
|
115
|
-
new
|
|
111
|
+
const positions: PI[] = wlViewer['positions'];
|
|
112
|
+
|
|
113
|
+
const resAllDf1: PI[] = [
|
|
114
|
+
new PI(0, '1', {'-': new PMI(3)}),
|
|
115
|
+
new PI(1, '2', {'T': new PMI(3)}),
|
|
116
|
+
new PI(2, '3', {'-': new PMI(3)}),
|
|
117
|
+
new PI(3, '4', {'-': new PMI(3)}),
|
|
118
|
+
new PI(4, '5', {'C': new PMI(3)}),
|
|
119
|
+
new PI(5, '6', {'-': new PMI(2), 'C': new PMI(1)}),
|
|
120
|
+
new PI(6, '7', {'G': new PMI(3)}),
|
|
121
|
+
new PI(7, '8', {'T': new PMI(3)}),
|
|
122
|
+
new PI(8, '9', {'-': new PMI(3)}),
|
|
116
123
|
];
|
|
117
124
|
|
|
118
125
|
expect(positions.length, resAllDf1.length);
|
|
@@ -131,38 +138,94 @@ ATC-G-TTGC--
|
|
|
131
138
|
|
|
132
139
|
const seqCol: DG.Column = df.getCol('seq');
|
|
133
140
|
seqCol.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
134
|
-
seqCol.setTag(DG.TAGS.UNITS,
|
|
135
|
-
seqCol.setTag(
|
|
136
|
-
seqCol.setTag(
|
|
141
|
+
seqCol.setTag(DG.TAGS.UNITS, NOTATION.FASTA);
|
|
142
|
+
seqCol.setTag(bioTAGS.alphabet, ALPHABET.DNA);
|
|
143
|
+
seqCol.setTag(bioTAGS.aligned, 'SEQ.MSA');
|
|
137
144
|
|
|
138
|
-
const wlViewer:
|
|
139
|
-
{'skipEmptyPositions': true})) as
|
|
145
|
+
const wlViewer: WebLogoViewer = (await df.plot.fromType('WebLogo',
|
|
146
|
+
{'skipEmptyPositions': true})) as WebLogoViewer;
|
|
140
147
|
tv.dockManager.dock(wlViewer.root, DG.DOCK_TYPE.DOWN);
|
|
141
148
|
|
|
142
149
|
tvList.push(tv);
|
|
143
150
|
dfList.push(df);
|
|
144
151
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
new
|
|
149
|
-
new
|
|
150
|
-
new
|
|
151
|
-
new
|
|
152
|
-
new
|
|
153
|
-
new
|
|
154
|
-
new
|
|
155
|
-
new
|
|
156
|
-
new
|
|
152
|
+
const resPosList: PI[] = wlViewer['positions'];
|
|
153
|
+
|
|
154
|
+
const tgtPosList: PI[] = [
|
|
155
|
+
new PI(0, '1', {'A': new PMI(2), '-': new PMI(3)}),
|
|
156
|
+
new PI(1, '2', {'T': new PMI(5)}),
|
|
157
|
+
new PI(2, '3', {'C': new PMI(5)}),
|
|
158
|
+
new PI(4, '5', {'G': new PMI(5)}),
|
|
159
|
+
new PI(5, '6', {'-': new PMI(3), 'C': new PMI(2)}),
|
|
160
|
+
new PI(6, '7', {'T': new PMI(5)}),
|
|
161
|
+
new PI(7, '8', {'T': new PMI(5)}),
|
|
162
|
+
new PI(8, '9', {'G': new PMI(5)}),
|
|
163
|
+
new PI(9, '10', {'C': new PMI(5)})
|
|
157
164
|
];
|
|
158
165
|
|
|
159
|
-
expect(
|
|
166
|
+
expect(resPosList.length, tgtPosList.length);
|
|
167
|
+
for (let posI = 0; posI < resPosList.length; posI++) {
|
|
168
|
+
const resPos = resPosList[posI];
|
|
169
|
+
const tgtPos = tgtPosList[posI];
|
|
170
|
+
expectPositionInfo(resPos, tgtPos);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
160
173
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
174
|
+
test('count sequences for monomer at position', async () => {
|
|
175
|
+
const df: DG.DataFrame = buildDfWithSeqCol(csvDf1, NOTATION.FASTA, ALPHABET.DNA, 'SEQ.MSA');
|
|
176
|
+
const seqCol: DG.Column = df.getCol('seq');
|
|
177
|
+
|
|
178
|
+
const tv: DG.TableView = grok.shell.addTableView(df);
|
|
179
|
+
|
|
180
|
+
const wlViewer: WebLogoViewer = (await df.plot.fromType('WebLogo', {
|
|
181
|
+
startPositionName: '3',
|
|
182
|
+
endPositionName: '7',
|
|
183
|
+
skipEmptyPositions: true
|
|
184
|
+
})) as WebLogoViewer;
|
|
185
|
+
tv.dockManager.dock(wlViewer.root, DG.DOCK_TYPE.DOWN);
|
|
186
|
+
|
|
187
|
+
tvList.push(tv);
|
|
188
|
+
dfList.push(df);
|
|
189
|
+
|
|
190
|
+
const resPosList: PI[] = wlViewer['positions'];
|
|
191
|
+
const tgtPosList: PI[] = [
|
|
192
|
+
new PI(2, '3', {'C': new PMI(5)}),
|
|
193
|
+
new PI(4, '5', {'G': new PMI(5)}),
|
|
194
|
+
new PI(5, '6', {'-': new PMI(3), 'C': new PMI(2)}),
|
|
195
|
+
new PI(6, '7', {'T': new PMI(5)}),
|
|
196
|
+
];
|
|
197
|
+
|
|
198
|
+
expect(resPosList.length, tgtPosList.length);
|
|
199
|
+
for (let posI = 0; posI < resPosList.length; posI++) {
|
|
200
|
+
const resPos = resPosList[posI];
|
|
201
|
+
const tgtPos = tgtPosList[posI];
|
|
202
|
+
expectPositionInfo(resPos, tgtPos);
|
|
166
203
|
}
|
|
204
|
+
|
|
205
|
+
const splitter: SplitterFunc = wlViewer['splitter']!;
|
|
206
|
+
const atPI1: PI = resPosList[1];
|
|
207
|
+
const countAt1 = countForMonomerAtPosition(df, seqCol, df.filter, splitter, 'G', atPI1);
|
|
208
|
+
expect(countAt1, 5);
|
|
167
209
|
});
|
|
168
210
|
});
|
|
211
|
+
|
|
212
|
+
function expectPositionInfo(actualPos: PI, expectedPos: PI): void {
|
|
213
|
+
expect(actualPos.name, expectedPos.name);
|
|
214
|
+
expectArray(Object.keys(actualPos.freq), Object.keys(expectedPos.freq));
|
|
215
|
+
for (const key in actualPos.freq) {
|
|
216
|
+
//
|
|
217
|
+
expect(actualPos.freq[key].count, expectedPos.freq[key].count);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function buildDfWithSeqCol(csv: string, notation: NOTATION, alphabet: ALPHABET, aligned: string): DG.DataFrame {
|
|
222
|
+
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
223
|
+
|
|
224
|
+
const seqCol: DG.Column = df.getCol('seq');
|
|
225
|
+
seqCol.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
226
|
+
seqCol.setTag(DG.TAGS.UNITS, notation);
|
|
227
|
+
seqCol.setTag(bioTAGS.alphabet, alphabet);
|
|
228
|
+
seqCol.setTag(bioTAGS.aligned, aligned);
|
|
229
|
+
|
|
230
|
+
return df;
|
|
231
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as DG from 'datagrok-api/dg';
|
|
2
|
+
|
|
3
|
+
import {category, expect, test} from '@datagrok-libraries/utils/src/test';
|
|
4
|
+
|
|
5
|
+
category('_first', () => {
|
|
6
|
+
/** The first test of the package to evaluate problems with imports. */
|
|
7
|
+
test('_first', async () => {
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {after, before, category, test} from '@datagrok-libraries/utils/src/test';
|
|
2
|
-
|
|
3
|
-
import * as DG from 'datagrok-api/dg';
|
|
4
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 {after, before, category, test} from '@datagrok-libraries/utils/src/test';
|
|
5
6
|
|
|
6
7
|
import {readDataframe} from './utils';
|
|
7
8
|
import {_testActivityCliffsOpen} from './activity-cliffs-utils';
|
|
@@ -22,8 +23,8 @@ category('activityCliffs', async () => {
|
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
after(async () => {
|
|
25
|
-
for (const
|
|
26
|
-
for (const
|
|
26
|
+
// for (const df of dfList) grok.shell.closeTable(df);
|
|
27
|
+
// for (const view of viewList) view.close();
|
|
27
28
|
});
|
|
28
29
|
|
|
29
30
|
test('activityCliffsOpens', async () => {
|
|
@@ -33,7 +34,7 @@ category('activityCliffs', async () => {
|
|
|
33
34
|
viewList.push(actCliffsTableView);
|
|
34
35
|
|
|
35
36
|
await _testActivityCliffsOpen(actCliffsDf, 57, 'UMAP', 'MSA');
|
|
36
|
-
});
|
|
37
|
+
}, {skipReason: 'GROK-12774'});
|
|
37
38
|
|
|
38
39
|
test('activityCliffsWithEmptyRows', async () => {
|
|
39
40
|
actCliffsDfWithEmptyRows = await readDataframe('tests/sample_MSA_data_empty_vals.csv');
|
|
@@ -42,5 +43,5 @@ category('activityCliffs', async () => {
|
|
|
42
43
|
viewList.push(actCliffsTableViewWithEmptyRows);
|
|
43
44
|
|
|
44
45
|
await _testActivityCliffsOpen(actCliffsDfWithEmptyRows, 57, 'UMAP', 'MSA');
|
|
45
|
-
});
|
|
46
|
+
}, {skipReason: 'GROK-12774'});
|
|
46
47
|
});
|
|
@@ -2,20 +2,28 @@ import * as DG from 'datagrok-api/dg';
|
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
|
|
4
4
|
import {delay, expect} from '@datagrok-libraries/utils/src/test';
|
|
5
|
-
import {_package} from '../package-test';
|
|
6
5
|
import {activityCliffs} from '../package';
|
|
7
6
|
|
|
8
7
|
export async function _testActivityCliffsOpen(df: DG.DataFrame, numberCliffs: number, method: string, colName: string) {
|
|
9
8
|
await grok.data.detectSemanticTypes(df);
|
|
10
9
|
const scatterPlot = await activityCliffs(
|
|
11
|
-
df,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
df, df.getCol(colName), df.getCol('Activity'),
|
|
11
|
+
50, method);
|
|
12
|
+
// const scatterPlot = (await grok.functions.call('Bio:activityCliffs', {
|
|
13
|
+
// table: df, molecules: df.getCol(colName), activities: df.getCol('Activity'),
|
|
14
|
+
// similarity: 50, methodName: method
|
|
15
|
+
// })) as DG.Viewer | undefined;
|
|
16
|
+
|
|
17
|
+
// test scatter plot without activityCliffs passed
|
|
18
|
+
// const scatterPlot = (await df.plot.fromType(DG.VIEWER.SCATTER_PLOT, {})) as DG.Viewer;
|
|
19
|
+
// const libHelper: IMonomerLibHelper = (await grok.functions.call('Bio:getMonomerLibHelper'));
|
|
20
|
+
// const k = 11;
|
|
16
21
|
|
|
17
22
|
expect(scatterPlot != null, true);
|
|
18
23
|
|
|
19
|
-
const cliffsLink = Array.from(scatterPlot!.root.children).
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
const cliffsLink = Array.from(scatterPlot!.root.children).find((el) => {
|
|
25
|
+
const classList: string[] = el.className.split(' ');
|
|
26
|
+
return ['ui-btn', 'ui-btn-ok'].every((reqClassName) => classList.includes(reqClassName));
|
|
27
|
+
});
|
|
28
|
+
expect((cliffsLink as HTMLElement).innerText.toLowerCase(), `${numberCliffs} cliffs`);
|
|
29
|
+
}
|
package/src/tests/bio-tests.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
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
|
-
import * as bio from '@datagrok-libraries/bio';
|
|
5
4
|
|
|
6
5
|
import {after, before, category, test, expect, expectObject} from '@datagrok-libraries/utils/src/test';
|
|
6
|
+
import {
|
|
7
|
+
getAlphabetSimilarity,
|
|
8
|
+
getStats,
|
|
9
|
+
monomerToShort,
|
|
10
|
+
pickUpPalette,
|
|
11
|
+
splitterAsFasta,
|
|
12
|
+
splitterAsHelm,
|
|
13
|
+
} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
14
|
+
import {Nucleotides, NucleotidesPalettes} from '@datagrok-libraries/bio/src/nucleotides';
|
|
15
|
+
import {AminoacidsPalettes} from '@datagrok-libraries/bio/src/aminoacids';
|
|
16
|
+
import {UnknownSeqPalette} from '@datagrok-libraries/bio/src/unknown';
|
|
7
17
|
|
|
8
18
|
category('bio', () => {
|
|
9
19
|
const csvDfN1: string = `seq
|
|
@@ -53,7 +63,7 @@ PEPTIDE1{meI}$$$$
|
|
|
53
63
|
`;
|
|
54
64
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
55
65
|
const seqCol: DG.Column = df.getCol('seq')!;
|
|
56
|
-
const stats =
|
|
66
|
+
const stats = getStats(seqCol, 1, splitterAsHelm);
|
|
57
67
|
|
|
58
68
|
expectObject(stats.freq, {
|
|
59
69
|
'meI': 1
|
|
@@ -72,19 +82,19 @@ PEPTIDE1{meI}$$$$
|
|
|
72
82
|
|
|
73
83
|
category('WebLogo.monomerToShort', () => {
|
|
74
84
|
test('longMonomerSingle', async () => {
|
|
75
|
-
await expect(
|
|
85
|
+
await expect(monomerToShort('S', 5), 'S');
|
|
76
86
|
});
|
|
77
87
|
test('longMonomerShort', async () => {
|
|
78
|
-
await expect(
|
|
88
|
+
await expect(monomerToShort('Short', 5), 'Short');
|
|
79
89
|
});
|
|
80
90
|
test('longMonomerLong56', async () => {
|
|
81
|
-
await expect(
|
|
91
|
+
await expect(monomerToShort('Long56', 5), 'Long5…');
|
|
82
92
|
});
|
|
83
93
|
test('longMonomerComplexFirstPartShort', async () => {
|
|
84
|
-
await expect(
|
|
94
|
+
await expect(monomerToShort('Long-long', 5), 'Long…');
|
|
85
95
|
});
|
|
86
96
|
test('longMonomerComplexFirstPartLong56', async () => {
|
|
87
|
-
await expect(
|
|
97
|
+
await expect(monomerToShort('Long56-long', 5), 'Long5…');
|
|
88
98
|
});
|
|
89
99
|
});
|
|
90
100
|
|
|
@@ -92,7 +102,7 @@ category('WebLogo.monomerToShort', () => {
|
|
|
92
102
|
export async function _testGetStats(csvDfN1: string) {
|
|
93
103
|
const dfN1: DG.DataFrame = DG.DataFrame.fromCsv(csvDfN1);
|
|
94
104
|
const seqCol: DG.Column = dfN1.col('seq')!;
|
|
95
|
-
const stats =
|
|
105
|
+
const stats = getStats(seqCol, 5, splitterAsFasta);
|
|
96
106
|
|
|
97
107
|
expectObject(stats.freq, {
|
|
98
108
|
'A': 4,
|
|
@@ -111,8 +121,8 @@ export async function _testGetAlphabetSimilarity() {
|
|
|
111
121
|
'T': 2048,
|
|
112
122
|
'-': 1000
|
|
113
123
|
};
|
|
114
|
-
const alphabet: Set<string> = new Set(Object.keys(
|
|
115
|
-
const res =
|
|
124
|
+
const alphabet: Set<string> = new Set(Object.keys(Nucleotides.Names));
|
|
125
|
+
const res = getAlphabetSimilarity(freq, alphabet);
|
|
116
126
|
|
|
117
127
|
expect(res > 0.6, true);
|
|
118
128
|
}
|
|
@@ -120,39 +130,38 @@ export async function _testGetAlphabetSimilarity() {
|
|
|
120
130
|
export async function _testPickupPaletteN1(csvDfN1: string) {
|
|
121
131
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csvDfN1);
|
|
122
132
|
const col: DG.Column = df.col('seq')!;
|
|
123
|
-
const cp =
|
|
133
|
+
const cp = pickUpPalette(col);
|
|
124
134
|
|
|
125
|
-
expect(cp instanceof
|
|
135
|
+
expect(cp instanceof NucleotidesPalettes, true);
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
export async function _testPickupPaletteN1e(csvDfN1e: string) {
|
|
129
139
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csvDfN1e);
|
|
130
140
|
const col: DG.Column = df.col('seq')!;
|
|
131
|
-
const cp =
|
|
141
|
+
const cp = pickUpPalette(col);
|
|
132
142
|
|
|
133
|
-
expect(cp instanceof
|
|
143
|
+
expect(cp instanceof NucleotidesPalettes, true);
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
export async function _testPickupPaletteAA1(csvDfAA1: string) {
|
|
137
147
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csvDfAA1);
|
|
138
148
|
const col: DG.Column = df.col('seq')!;
|
|
139
|
-
const cp =
|
|
149
|
+
const cp = pickUpPalette(col);
|
|
140
150
|
|
|
141
|
-
expect(cp instanceof
|
|
151
|
+
expect(cp instanceof AminoacidsPalettes, true);
|
|
142
152
|
}
|
|
143
153
|
|
|
144
154
|
export async function _testPickupPaletteX(csvDfX: string) {
|
|
145
155
|
const df: DG.DataFrame = DG.DataFrame.fromCsv(csvDfX);
|
|
146
156
|
const col: DG.Column = df.col('seq')!;
|
|
147
|
-
const cp =
|
|
157
|
+
const cp = pickUpPalette(col);
|
|
148
158
|
|
|
149
|
-
expect(cp instanceof
|
|
159
|
+
expect(cp instanceof UnknownSeqPalette, true);
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
export async function _testPickupPaletteAA2(dfAA2: DG.DataFrame) {
|
|
153
163
|
const seqCol: DG.Column = dfAA2.col('seq')!;
|
|
154
|
-
const cp =
|
|
164
|
+
const cp = pickUpPalette(seqCol);
|
|
155
165
|
|
|
156
|
-
expect(cp instanceof
|
|
166
|
+
expect(cp instanceof AminoacidsPalettes, true);
|
|
157
167
|
}
|
|
158
|
-
|