@datagrok/bio 2.20.1 → 2.20.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/CHANGELOG.md +5 -0
- package/detectors.js +10 -6
- 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 +1 -1
- package/src/package.ts +10 -0
- package/src/widgets/to-atomic-level-widget.ts +79 -0
- package/test-console-output-1.log +7361 -0
- package/test-record-1.mp4 +0 -0
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"name": "Leonid Stolbov",
|
|
6
6
|
"email": "lstolbov@datagrok.ai"
|
|
7
7
|
},
|
|
8
|
-
"version": "2.20.
|
|
8
|
+
"version": "2.20.2",
|
|
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",
|
package/src/package.ts
CHANGED
|
@@ -71,6 +71,8 @@ import {getMolColumnFromHelm} from './utils/helm-to-molfile/utils';
|
|
|
71
71
|
import {MonomerManager} from './utils/monomer-lib/monomer-manager/monomer-manager';
|
|
72
72
|
import {calculateScoresWithEmptyValues} from './utils/calculate-scores';
|
|
73
73
|
import {SeqHelper} from './utils/seq-helper/seq-helper';
|
|
74
|
+
import {_toAtomicLevel} from '@datagrok-libraries/bio/src/monomer-works/to-atomic-level';
|
|
75
|
+
import {toAtomicLevelWidget} from './widgets/to-atomic-level-widget';
|
|
74
76
|
|
|
75
77
|
export const _package = new BioPackage(/*{debug: true}/**/);
|
|
76
78
|
|
|
@@ -639,6 +641,14 @@ export async function toAtomicLevelAction(seqCol: DG.Column) {
|
|
|
639
641
|
func.prepare({table: seqCol.dataFrame, seqCol: seqCol}).edit();
|
|
640
642
|
}
|
|
641
643
|
|
|
644
|
+
//name: Molecular Structure
|
|
645
|
+
//tags: panel, bio, widgets
|
|
646
|
+
//input: semantic_value sequence { semType: Macromolecule }
|
|
647
|
+
//output: widget result
|
|
648
|
+
export async function toAtomicLevelPanel(sequence: DG.SemanticValue): Promise<DG.Widget> {
|
|
649
|
+
return toAtomicLevelWidget(sequence);
|
|
650
|
+
}
|
|
651
|
+
|
|
642
652
|
//top-menu: Bio | Analyze | MSA...
|
|
643
653
|
//name: MSA
|
|
644
654
|
//description: Performs multiple sequence alignment
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
5
|
+
import {_package, getSeqHelper, toAtomicLevel} from '../package';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export async function toAtomicLevelWidget(sequence: DG.SemanticValue): Promise<DG.Widget> {
|
|
9
|
+
const errorDiv = ui.divText('');
|
|
10
|
+
const errorWidget = DG.Widget.fromRoot(errorDiv);
|
|
11
|
+
try {
|
|
12
|
+
if (!sequence || !sequence.value) {
|
|
13
|
+
errorDiv.innerText = 'No sequence provided';
|
|
14
|
+
return errorWidget;
|
|
15
|
+
}
|
|
16
|
+
if (!sequence.cell || !sequence.cell.dart || !sequence.cell.dataFrame || !sequence.cell.column) {
|
|
17
|
+
errorDiv.innerText = 'Atomic level conversion requeires a sequence column';
|
|
18
|
+
return errorWidget;
|
|
19
|
+
}
|
|
20
|
+
const supportedUnits: string[] = [NOTATION.FASTA, NOTATION.SEPARATOR, NOTATION.HELM];
|
|
21
|
+
//todo: add support for custom notations
|
|
22
|
+
if (!supportedUnits.includes(sequence.cell.column.meta.units?.toLowerCase() ?? '')) {
|
|
23
|
+
errorDiv.innerText = 'Unsupported sequence notation. please use Bio | Polytool | Convert';
|
|
24
|
+
return errorWidget;
|
|
25
|
+
}
|
|
26
|
+
const seqHelper = await getSeqHelper();
|
|
27
|
+
const seqSh = seqHelper.getSeqHandler(sequence.cell.column);
|
|
28
|
+
if (!seqSh) {
|
|
29
|
+
errorDiv.innerText = 'No sequence handler found';
|
|
30
|
+
return errorWidget;
|
|
31
|
+
}
|
|
32
|
+
if ((seqSh.getSplitted(sequence.cell.rowIndex, 50)?.length ?? 100) > 40) {
|
|
33
|
+
errorDiv.innerText = 'Maximum number of monomers is 40';
|
|
34
|
+
return errorWidget;
|
|
35
|
+
}
|
|
36
|
+
const singleValCol = DG.Column.fromStrings('singleVal', [sequence.value]);
|
|
37
|
+
const sDf = DG.DataFrame.fromColumns([singleValCol]);
|
|
38
|
+
// copy over all the tags
|
|
39
|
+
Object.entries(sequence.cell.column.tags).forEach(([key, value]) => {
|
|
40
|
+
singleValCol.setTag(key, value as string);
|
|
41
|
+
});
|
|
42
|
+
await toAtomicLevel(sDf, singleValCol, sequence.cell.column.meta.units === NOTATION.HELM, false);
|
|
43
|
+
if (sDf.columns.length < 2) {
|
|
44
|
+
errorDiv.innerText = 'No structure generated';
|
|
45
|
+
return errorWidget;
|
|
46
|
+
}
|
|
47
|
+
const molCol = sDf.columns.byIndex(1);
|
|
48
|
+
const molfile = molCol.get(0);
|
|
49
|
+
if (!molfile) {
|
|
50
|
+
errorDiv.innerText = 'No structure generated';
|
|
51
|
+
return errorWidget;
|
|
52
|
+
}
|
|
53
|
+
molCol.semType = DG.SEMTYPE.MOLECULE;
|
|
54
|
+
const molSemanticValue = DG.SemanticValue.fromTableCell(sDf.cell(0, molCol.name));
|
|
55
|
+
const panel = ui.panels.infoPanel(molSemanticValue);
|
|
56
|
+
let molPanel: DG.Widget | null = null;
|
|
57
|
+
if (panel)
|
|
58
|
+
molPanel = DG.Widget.fromRoot(panel.root);
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const root = grok.chem.drawMolecule(molfile, 300, 300, false);
|
|
62
|
+
root.style.cursor = 'pointer';
|
|
63
|
+
ui.tooltip.bind(root, 'Click to expand');
|
|
64
|
+
root.onclick = () => {
|
|
65
|
+
const width = window.innerWidth - 200;
|
|
66
|
+
const height = window.innerHeight - 200;
|
|
67
|
+
const bigMol = grok.chem.drawMolecule(molfile, width, height, false);
|
|
68
|
+
ui.dialog({title: 'Molecule'}).add(bigMol).showModal(true);
|
|
69
|
+
};
|
|
70
|
+
if (molPanel)
|
|
71
|
+
molPanel.root.prepend(root);
|
|
72
|
+
return molPanel ?? DG.Widget.fromRoot(root);
|
|
73
|
+
} catch (e) {
|
|
74
|
+
_package.logger.error(e);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
errorDiv.innerText = 'No Structure generated';
|
|
78
|
+
return errorWidget;
|
|
79
|
+
}
|