@datagrok/bio 2.4.50 → 2.4.52
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/detectors.js +19 -10
- 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/package.json +2 -2
- package/scripts/sequence_generator.py +0 -0
- package/src/package.ts +10 -0
- package/src/tests/detectors-benchmark-tests.ts +9 -11
- package/src/tests/renderers-monomer-placer.ts +20 -19
- package/src/utils/cell-renderer-consts.ts +14 -1
- package/src/utils/cell-renderer.ts +22 -29
- package/src/widgets/representations.ts +17 -7
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "Leonid Stolbov",
|
|
6
6
|
"email": "lstolbov@datagrok.ai"
|
|
7
7
|
},
|
|
8
|
-
"version": "2.4.
|
|
8
|
+
"version": "2.4.52",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@biowasm/aioli": "^3.1.0",
|
|
25
|
-
"@datagrok-libraries/bio": "^5.32.
|
|
25
|
+
"@datagrok-libraries/bio": "^5.32.8",
|
|
26
26
|
"@datagrok-libraries/chem-meta": "^1.0.1",
|
|
27
27
|
"@datagrok-libraries/ml": "^6.3.39",
|
|
28
28
|
"@datagrok-libraries/tutorials": "^1.3.2",
|
|
File without changes
|
package/src/package.ts
CHANGED
|
@@ -614,6 +614,16 @@ export function importFasta(fileContent: string): DG.DataFrame [] {
|
|
|
614
614
|
const ffh = new FastaFileHandler(fileContent);
|
|
615
615
|
return ffh.importFasta();
|
|
616
616
|
}
|
|
617
|
+
//name: importBam
|
|
618
|
+
//description: Opens Bam file
|
|
619
|
+
//tags: file-handler
|
|
620
|
+
//meta.ext: bam, bai
|
|
621
|
+
//input: string fileContent
|
|
622
|
+
//output: list tables
|
|
623
|
+
export function importBam(fileContent: string): DG.DataFrame [] {
|
|
624
|
+
console.log(fileContent);
|
|
625
|
+
return [];
|
|
626
|
+
}
|
|
617
627
|
|
|
618
628
|
//top-menu: Bio | Convert...
|
|
619
629
|
//name: convertDialog
|
|
@@ -39,17 +39,15 @@ category('detectorsBenchmark', () => {
|
|
|
39
39
|
|
|
40
40
|
test('separatorDnaShorts50Few50', async () => {
|
|
41
41
|
detectMacromoleculeBenchmark(10, NOTATION.SEPARATOR, ALPHABET.DNA, 50, 50, '/');
|
|
42
|
-
}
|
|
42
|
+
});
|
|
43
43
|
|
|
44
44
|
test('separatorDnaShorts50Many1E6', async () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{ /* skipReason: 'slow transmit large dataset to detector' */});
|
|
45
|
+
detectMacromoleculeBenchmark(10, NOTATION.SEPARATOR, ALPHABET.DNA, 50, 1E6, '/');
|
|
46
|
+
});
|
|
48
47
|
|
|
49
48
|
test('separatorDnaLong1e6Few50', async () => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{skipReason: '#1192'});
|
|
49
|
+
detectMacromoleculeBenchmark(10, NOTATION.SEPARATOR, ALPHABET.DNA, 1E6, 50, '/');
|
|
50
|
+
});
|
|
53
51
|
|
|
54
52
|
async function detectMacromoleculeBenchmark(
|
|
55
53
|
maxET: number, notation: NOTATION, alphabet: ALPHABET, length: number, count: number, separator?: string,
|
|
@@ -128,10 +126,10 @@ category('detectorsBenchmark', () => {
|
|
|
128
126
|
|
|
129
127
|
function checkDetectorRes(col: DG.Column, tgt: TgtType): void {
|
|
130
128
|
const uh = UnitsHandler.getOrCreate(col);
|
|
131
|
-
expect(col.semType
|
|
132
|
-
expect(uh.notation
|
|
133
|
-
expect(uh.alphabet
|
|
134
|
-
expect(uh.separator
|
|
129
|
+
expect(col.semType === tgt.semType, true);
|
|
130
|
+
expect(uh.notation === tgt.notation, true);
|
|
131
|
+
expect(uh.alphabet === tgt.alphabet, true);
|
|
132
|
+
expect(uh.separator === tgt.separator, true);
|
|
135
133
|
}
|
|
136
134
|
});
|
|
137
135
|
|
|
@@ -3,7 +3,7 @@ import * as DG from 'datagrok-api/dg';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
|
|
5
5
|
import {_package} from '../package-test';
|
|
6
|
-
import {
|
|
6
|
+
import {category, test} from '@datagrok-libraries/utils/src/test';
|
|
7
7
|
import {MonomerPlacer} from '@datagrok-libraries/bio/src/utils/cell-renderer-monomer-placer';
|
|
8
8
|
import {monomerToShort} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
9
9
|
import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
@@ -22,13 +22,14 @@ category('renderers: monomerPlacer', () => {
|
|
|
22
22
|
'id3,mon1-M-mon3-mon4-mon5-MON8-N9\n', //
|
|
23
23
|
testList: [
|
|
24
24
|
{src: {row: 0, x: -1}, tgt: {pos: null}},
|
|
25
|
-
{src: {row: 1, x: 0}, tgt: {pos:
|
|
26
|
-
{src: {row: 1, x:
|
|
25
|
+
{src: {row: 1, x: 0}, tgt: {pos: null}},
|
|
26
|
+
{src: {row: 1, x: 5}, tgt: {pos: 0}},
|
|
27
|
+
{src: {row: 1, x: 6}, tgt: {pos: 0}},
|
|
27
28
|
{src: {row: 1, x: 26}, tgt: {pos: 1}},
|
|
28
29
|
{src: {row: 1, x: 170}, tgt: {pos: 6}},
|
|
29
|
-
{src: {row: 1, x: 208}, tgt: {pos:
|
|
30
|
-
{src: {row: 2, x: 170}, tgt: {pos:
|
|
31
|
-
{src: {row: 2, x: 175}, tgt: {pos:
|
|
30
|
+
{src: {row: 1, x: 208}, tgt: {pos: 7}},
|
|
31
|
+
{src: {row: 2, x: 170}, tgt: {pos: 5}},
|
|
32
|
+
{src: {row: 2, x: 175}, tgt: {pos: 5}},
|
|
32
33
|
]
|
|
33
34
|
},
|
|
34
35
|
splitterMsa: {
|
|
@@ -41,13 +42,13 @@ category('renderers: monomerPlacer', () => {
|
|
|
41
42
|
'id3,mon1-M-mon3-mon4-mon5---MON8-N9\n', //
|
|
42
43
|
testList: [
|
|
43
44
|
{src: {row: 0, x: -1}, tgt: {pos: null}},
|
|
44
|
-
{src: {row: 1, x: 0}, tgt: {pos:
|
|
45
|
-
{src: {row: 1, x: 1}, tgt: {pos:
|
|
46
|
-
{src: {row: 1, x: 26}, tgt: {pos:
|
|
47
|
-
{src: {row: 1, x: 170}, tgt: {pos:
|
|
48
|
-
{src: {row: 1, x: 227}, tgt: {pos:
|
|
49
|
-
{src: {row: 2, x: 220}, tgt: {pos:
|
|
50
|
-
{src: {row: 2, x: 227}, tgt: {pos:
|
|
45
|
+
{src: {row: 1, x: 0}, tgt: {pos: null}},
|
|
46
|
+
{src: {row: 1, x: 1}, tgt: {pos: null}},
|
|
47
|
+
{src: {row: 1, x: 26}, tgt: {pos: 0}},
|
|
48
|
+
{src: {row: 1, x: 170}, tgt: {pos: 4}},
|
|
49
|
+
{src: {row: 1, x: 227}, tgt: {pos: 5}},
|
|
50
|
+
{src: {row: 2, x: 220}, tgt: {pos: 5}},
|
|
51
|
+
{src: {row: 2, x: 227}, tgt: {pos: 5}},
|
|
51
52
|
]
|
|
52
53
|
},
|
|
53
54
|
fastaMsa: {
|
|
@@ -61,13 +62,13 @@ id3,QHIRE--LT
|
|
|
61
62
|
`,
|
|
62
63
|
testList: [
|
|
63
64
|
{src: {row: 1, x: -1}, tgt: {pos: null}},
|
|
64
|
-
{src: {row: 1, x: 0}, tgt: {pos:
|
|
65
|
-
{src: {row: 1, x: 1}, tgt: {pos:
|
|
66
|
-
{src: {row: 1, x: 19}, tgt: {pos:
|
|
65
|
+
{src: {row: 1, x: 0}, tgt: {pos: null}},
|
|
66
|
+
{src: {row: 1, x: 1}, tgt: {pos: null}},
|
|
67
|
+
{src: {row: 1, x: 19}, tgt: {pos: 0}},
|
|
67
68
|
{src: {row: 1, x: 170}, tgt: {pos: 8}},
|
|
68
|
-
{src: {row: 1, x: 171}, tgt: {pos:
|
|
69
|
+
{src: {row: 1, x: 171}, tgt: {pos: 8}},
|
|
69
70
|
{src: {row: 2, x: 170}, tgt: {pos: 8}},
|
|
70
|
-
{src: {row: 2, x:
|
|
71
|
+
{src: {row: 2, x: 181}, tgt: {pos: null}},
|
|
71
72
|
]
|
|
72
73
|
},
|
|
73
74
|
};
|
|
@@ -78,7 +79,7 @@ id3,QHIRE--LT
|
|
|
78
79
|
await grok.data.detectSemanticTypes(df);
|
|
79
80
|
const seqCol: DG.Column = df.getCol('seq');
|
|
80
81
|
|
|
81
|
-
const monLength: number =
|
|
82
|
+
const monLength: number = 3;
|
|
82
83
|
const charWidth: number = 7;
|
|
83
84
|
const sepWidth: number = 12;
|
|
84
85
|
const colTemp: MonomerPlacer = new MonomerPlacer(null, seqCol, () => {
|
|
@@ -8,15 +8,28 @@ export enum MonomerWidthMode {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const enum Tags {
|
|
11
|
-
|
|
11
|
+
RendererSettingsChanged = '.mm.cellRenderer.settingsChanged',
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export const rendererSettingsChangedState = {
|
|
15
|
+
true: '1',
|
|
16
|
+
false: '0',
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
export const enum Temps {
|
|
15
20
|
monomerWidth = '.mm.cellRenderer.monomerWidth',
|
|
16
21
|
maxMonomerLength = '.mm.cellRenderer.maxMonomerLength',
|
|
17
22
|
colorCode = '.mm.cellRenderer.colorCode',
|
|
18
23
|
compareWithCurrent = '.mm.cellRenderer.compareWithCurrent',
|
|
19
24
|
highlightDifference = '.mm.cellRenderer.highlightDifference',
|
|
25
|
+
gapLength = '.mm.cellRenderer.gapLength',
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const enum tempTAGS {
|
|
29
|
+
referenceSequence = 'reference-sequence',
|
|
30
|
+
currentWord = 'current-word',
|
|
31
|
+
monomerWidth = 'monomer-width',
|
|
32
|
+
bioSeqCol = 'bio-seqCol',
|
|
20
33
|
}
|
|
21
34
|
|
|
22
35
|
// export const MacromoleculeCellRendererDefaults = new class {
|
|
@@ -7,10 +7,8 @@ import {printLeftOrCentered, DrawStyle} from '@datagrok-libraries/bio/src/utils/
|
|
|
7
7
|
import * as C from './constants';
|
|
8
8
|
import {MonomerPlacer} from '@datagrok-libraries/bio/src/utils/cell-renderer-monomer-placer';
|
|
9
9
|
import {
|
|
10
|
-
ALIGNMENT, ALPHABET,
|
|
11
10
|
getPaletteByType,
|
|
12
11
|
getSplitter,
|
|
13
|
-
getSplitterForColumn,
|
|
14
12
|
monomerToShort,
|
|
15
13
|
MonomerToShortFunc,
|
|
16
14
|
NOTATION,
|
|
@@ -20,22 +18,8 @@ import {
|
|
|
20
18
|
import {SeqPalette} from '@datagrok-libraries/bio/src/seq-palettes';
|
|
21
19
|
import {UnknownSeqPalettes} from '@datagrok-libraries/bio/src/unknown';
|
|
22
20
|
import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
import { HELM_POLYMER_TYPE } from '@datagrok-libraries/bio/src/utils/const';
|
|
26
|
-
import { MonomerLib } from './monomer-lib';
|
|
27
|
-
import { IMonomerLib } from '@datagrok-libraries/bio/src/types';
|
|
28
|
-
|
|
29
|
-
const enum tempTAGS {
|
|
30
|
-
referenceSequence = 'reference-sequence',
|
|
31
|
-
currentWord = 'current-word',
|
|
32
|
-
monomerWidth = 'monomer-width',
|
|
33
|
-
bioSeqCol = 'bio-seqCol',
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const enum rndrTAGS {
|
|
37
|
-
calculatedCellRender = '.calculatedCellRender',
|
|
38
|
-
}
|
|
21
|
+
import {Temps as mmcrTemps, Tags as mmcrTags,
|
|
22
|
+
tempTAGS, rendererSettingsChangedState} from '../utils/cell-renderer-consts';
|
|
39
23
|
|
|
40
24
|
type TempType = { [tagName: string]: any };
|
|
41
25
|
|
|
@@ -85,7 +69,7 @@ export class MacromoleculeSequenceCellRenderer extends DG.GridCellRenderer {
|
|
|
85
69
|
// return;
|
|
86
70
|
|
|
87
71
|
const tableCol: DG.Column = gridCell.cell.column;
|
|
88
|
-
const tableColTemp: TempType = tableCol.temp;
|
|
72
|
+
//const tableColTemp: TempType = tableCol.temp;
|
|
89
73
|
const seqColTemp: MonomerPlacer = tableCol.temp[tempTAGS.bioSeqCol];
|
|
90
74
|
if (!seqColTemp) return; // Can do nothing without precalculated data
|
|
91
75
|
|
|
@@ -105,10 +89,10 @@ export class MacromoleculeSequenceCellRenderer extends DG.GridCellRenderer {
|
|
|
105
89
|
const monomerSymbol: string = seqMonList[left];
|
|
106
90
|
const tooltipElements: HTMLElement[] = [ui.div(monomerSymbol)];
|
|
107
91
|
const monomer = seqColTemp.getMonomer(monomerSymbol);
|
|
108
|
-
if(monomer) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
92
|
+
if (monomer) {
|
|
93
|
+
const options = {autoCrop: true, autoCropMargin: 0, suppressChiralText: true};
|
|
94
|
+
const monomerSVG = grok.chem.svgMol(monomer.smiles, undefined, undefined, options);
|
|
95
|
+
tooltipElements.push(monomerSVG);
|
|
112
96
|
}
|
|
113
97
|
ui.tooltip.show(ui.divV(tooltipElements), e.x + 16, e.y + 16);
|
|
114
98
|
} else {
|
|
@@ -130,9 +114,10 @@ export class MacromoleculeSequenceCellRenderer extends DG.GridCellRenderer {
|
|
|
130
114
|
*/
|
|
131
115
|
render(
|
|
132
116
|
g: CanvasRenderingContext2D, x: number, y: number, w: number, h: number, gridCell: DG.GridCell,
|
|
133
|
-
|
|
117
|
+
_cellStyle: DG.GridCellStyle
|
|
134
118
|
): void {
|
|
135
|
-
let
|
|
119
|
+
let gapLength = 0;
|
|
120
|
+
const msaGapLength = 8;
|
|
136
121
|
let maxLengthOfMonomer = 8;
|
|
137
122
|
|
|
138
123
|
// TODO: Store temp data to GridColumn
|
|
@@ -144,9 +129,9 @@ export class MacromoleculeSequenceCellRenderer extends DG.GridCellRenderer {
|
|
|
144
129
|
// Cell renderer settings
|
|
145
130
|
const tempMonomerWidth: string | null = tableColTemp[tempTAGS.monomerWidth];
|
|
146
131
|
const monomerWidth: string = (tempMonomerWidth != null) ? tempMonomerWidth : 'short';
|
|
147
|
-
if (monomerWidth === 'short')
|
|
132
|
+
if (monomerWidth === 'short')
|
|
148
133
|
maxLengthOfMonomer = tableColTemp[mmcrTemps.maxMonomerLength] ?? _package.properties.maxMonomerLength;
|
|
149
|
-
|
|
134
|
+
|
|
150
135
|
|
|
151
136
|
let seqColTemp: MonomerPlacer = tableCol.temp[tempTAGS.bioSeqCol];
|
|
152
137
|
if (!seqColTemp) {
|
|
@@ -155,16 +140,24 @@ export class MacromoleculeSequenceCellRenderer extends DG.GridCellRenderer {
|
|
|
155
140
|
const uh = UnitsHandler.getOrCreate(tableCol);
|
|
156
141
|
return {
|
|
157
142
|
unitsHandler: uh,
|
|
158
|
-
monomerCharWidth: 7, separatorWidth: !uh.isMsa() ?
|
|
143
|
+
monomerCharWidth: 7, separatorWidth: !uh.isMsa() ? gapLength : msaGapLength,
|
|
159
144
|
monomerToShort: monomerToShortFunction, monomerLengthLimit: maxLengthOfMonomer,
|
|
160
145
|
monomerLib: getBioLib()
|
|
161
146
|
};
|
|
162
147
|
});
|
|
163
148
|
}
|
|
164
149
|
|
|
150
|
+
if (tableCol.tags[mmcrTags.RendererSettingsChanged] === rendererSettingsChangedState.true) {
|
|
151
|
+
gapLength = tableColTemp[mmcrTemps.gapLength] as number ?? gapLength;
|
|
152
|
+
// this event means that the mm renderer settings have changed, particularly monomer representation and max width.
|
|
153
|
+
seqColTemp.setMonomerLengthLimit(maxLengthOfMonomer);
|
|
154
|
+
seqColTemp.setSeparatorWidth(seqColTemp.isMsa() ? msaGapLength : gapLength);
|
|
155
|
+
tableCol.setTag(mmcrTags.RendererSettingsChanged, rendererSettingsChangedState.false);
|
|
156
|
+
}
|
|
157
|
+
|
|
165
158
|
const [maxLengthWords, maxLengthWordsSum]: [number[], number[]] =
|
|
166
159
|
seqColTemp.getCellMonomerLengths(gridCell.tableRowIndex!);
|
|
167
|
-
const
|
|
160
|
+
const _maxIndex = maxLengthWords.length;
|
|
168
161
|
|
|
169
162
|
// Store updated seqColTemp to the col temp
|
|
170
163
|
if (seqColTemp.updated) tableColTemp[tempTAGS.bioSeqCol] = seqColTemp;
|
|
@@ -2,7 +2,8 @@ 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
|
import {getMolfilesFromSingleSeq} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
5
|
-
import {Tags as mmcrTags, Temps as mmcrTemps, MonomerWidthMode
|
|
5
|
+
import {Tags as mmcrTags, Temps as mmcrTemps, MonomerWidthMode,
|
|
6
|
+
tempTAGS, rendererSettingsChangedState} from '../utils/cell-renderer-consts';
|
|
6
7
|
import {_package} from '../package';
|
|
7
8
|
|
|
8
9
|
|
|
@@ -19,11 +20,11 @@ export function getMacromoleculeColumnPropertyPanel(col: DG.Column): DG.Widget {
|
|
|
19
20
|
columnsSet.delete(col.name);
|
|
20
21
|
|
|
21
22
|
const monomerWidth = ui.choiceInput('Monomer width',
|
|
22
|
-
(col?.temp[
|
|
23
|
-
[
|
|
23
|
+
(col?.temp[tempTAGS.monomerWidth] != null) ? col.temp[tempTAGS.monomerWidth] : MonomerWidthMode.short,
|
|
24
|
+
[MonomerWidthMode.short, MonomerWidthMode.long],
|
|
24
25
|
(s: string) => {
|
|
25
|
-
col.temp[
|
|
26
|
-
col.setTag(mmcrTags.
|
|
26
|
+
col.temp[tempTAGS.monomerWidth] = s;
|
|
27
|
+
col.setTag(mmcrTags.RendererSettingsChanged, rendererSettingsChangedState.true);
|
|
27
28
|
col.dataFrame.fireValuesChanged();
|
|
28
29
|
});
|
|
29
30
|
monomerWidth.setTooltip(
|
|
@@ -34,13 +35,21 @@ export function getMacromoleculeColumnPropertyPanel(col: DG.Column): DG.Widget {
|
|
|
34
35
|
col.temp[mmcrTemps.maxMonomerLength] ?? _package.properties.maxMonomerLength,
|
|
35
36
|
(value: number) => {
|
|
36
37
|
col.temp[mmcrTemps.maxMonomerLength] = value;
|
|
37
|
-
col.setTag(mmcrTags.
|
|
38
|
+
col.setTag(mmcrTags.RendererSettingsChanged, rendererSettingsChangedState.true);
|
|
38
39
|
col.dataFrame.fireValuesChanged();
|
|
39
40
|
});
|
|
40
41
|
maxMonomerLength.setTooltip(
|
|
41
42
|
`The max length of monomer name displayed without shortening in '${MonomerWidthMode.short}' monomer width mode.`
|
|
42
43
|
);
|
|
43
44
|
|
|
45
|
+
const gapLengthInput = ui.intInput('Monomer gap size', col.temp[mmcrTemps.gapLength] ?? 0,
|
|
46
|
+
(value: number) => {
|
|
47
|
+
col.temp[mmcrTemps.gapLength] = value;
|
|
48
|
+
col.setTag(mmcrTags.RendererSettingsChanged, rendererSettingsChangedState.true);
|
|
49
|
+
col.dataFrame.fireValuesChanged();
|
|
50
|
+
});
|
|
51
|
+
gapLengthInput.setTooltip('The size of Gap between monomers (in pixels)');
|
|
52
|
+
|
|
44
53
|
const colorCode = ui.boolInput('Color code',
|
|
45
54
|
(col?.temp['color-code'] != null) ? col.temp['color-code'] : true,
|
|
46
55
|
(v: boolean) => {
|
|
@@ -68,8 +77,9 @@ export function getMacromoleculeColumnPropertyPanel(col: DG.Column): DG.Widget {
|
|
|
68
77
|
const rdKitInputs = ui.inputs([
|
|
69
78
|
monomerWidth,
|
|
70
79
|
maxMonomerLength,
|
|
71
|
-
|
|
80
|
+
gapLengthInput,
|
|
72
81
|
referenceSequence,
|
|
82
|
+
colorCode,
|
|
73
83
|
compareWithCurrent,
|
|
74
84
|
]);
|
|
75
85
|
|