@datagrok/sequence-translator 1.3.5 → 1.3.10
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 +37 -0
- package/detectors.js +32 -0
- 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 +10 -6
- package/src/apps/common/view/components/colored-input/style.css +3 -2
- package/src/apps/pattern/model/const.ts +8 -5
- package/src/apps/pattern/model/data-manager.ts +44 -16
- package/src/apps/pattern/model/event-bus.ts +2 -0
- package/src/apps/pattern/model/translator.ts +45 -8
- package/src/apps/pattern/model/types.ts +8 -6
- package/src/apps/pattern/view/components/bulk-convert/column-input.ts +4 -10
- package/src/apps/pattern/view/components/bulk-convert/table-input.ts +5 -8
- package/src/apps/pattern/view/components/edit-block-controls.ts +6 -15
- package/src/apps/pattern/view/components/load-block-controls.ts +11 -10
- package/src/apps/pattern/view/components/numeric-label-visibility-controls.ts +4 -5
- package/src/apps/pattern/view/components/right-section.ts +50 -1
- package/src/apps/pattern/view/components/strand-editor/header-controls.ts +2 -2
- package/src/apps/pattern/view/components/strand-editor/strand-controls.ts +2 -2
- package/src/apps/pattern/view/components/terminal-modification-editor.ts +1 -1
- package/src/apps/pattern/view/components/translation-examples-block.ts +1 -1
- package/src/apps/pattern/view/ui.ts +1 -1
- package/src/apps/structure/view/ui.ts +5 -5
- package/src/apps/translator/view/ui.ts +15 -27
- package/src/package.ts +52 -11
- package/src/plugins/mermade.ts +1 -1
- package/src/polytool/pt-conversion.ts +2 -2
- package/src/polytool/pt-dialog.ts +99 -18
- package/src/polytool/pt-enumeration-chem.ts +105 -0
- package/src/polytool/pt-enumeration-helm.ts +22 -0
- package/src/polytool/pt-ui.ts +25 -0
- package/src/polytool/utils.ts +34 -3
- package/src/utils/context-menu.ts +57 -0
- package/src/utils/err-info.ts +13 -0
- package/webpack.config.js +2 -4
- package/src/polytool/pt-enumeration.ts +0 -141
package/webpack.config.js
CHANGED
|
@@ -2,9 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const packageName = path.parse(require('./package.json').name).name.toLowerCase().replace(/-/g, '');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
|
-
cache: {
|
|
6
|
-
type: 'filesystem',
|
|
7
|
-
},
|
|
5
|
+
cache: {type: 'filesystem'},
|
|
8
6
|
mode: 'development',
|
|
9
7
|
entry: {
|
|
10
8
|
package: ['./src/package.ts'],
|
|
@@ -12,7 +10,7 @@ module.exports = {
|
|
|
12
10
|
filename: 'package-test.js',
|
|
13
11
|
library: {type: 'var', name: `${packageName}_test`},
|
|
14
12
|
import: './src/package-test.ts',
|
|
15
|
-
}
|
|
13
|
+
},
|
|
16
14
|
},
|
|
17
15
|
resolve: {
|
|
18
16
|
extensions: ['.ts', '.tsx', '.wasm', '.mjs', '.js', '.json'],
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import * as ui from 'datagrok-api/ui';
|
|
2
|
-
import * as grok from 'datagrok-api/grok';
|
|
3
|
-
import * as DG from 'datagrok-api/dg';
|
|
4
|
-
|
|
5
|
-
import {IHelmHelper, getHelmHelper} from '@datagrok-libraries/bio/src/helm/helm-helper';
|
|
6
|
-
import {IHelmWebEditor} from '@datagrok-libraries/bio/src/helm/types';
|
|
7
|
-
import '@datagrok-libraries/bio/src/types/helm';
|
|
8
|
-
import '@datagrok-libraries/bio/src/types/jsdraw2';
|
|
9
|
-
import * as org from 'org';
|
|
10
|
-
import $ from 'cash-dom';
|
|
11
|
-
import {Unsubscribable, fromEvent} from 'rxjs';
|
|
12
|
-
import {IMonomerLibFileManager, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
13
|
-
import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule/consts';
|
|
14
|
-
|
|
15
|
-
import {Chain} from './pt-conversion';
|
|
16
|
-
|
|
17
|
-
const LIB_PATH = 'System:AppData/Bio/monomer-libraries/';
|
|
18
|
-
const PT_HELM_EXAMPLE = 'PEPTIDE1{[R].[F].[T].[G].[H].[F].[G].[A].[A].[Y].[P].[E].[NH2]}$$$$';
|
|
19
|
-
|
|
20
|
-
export async function getLibrariesList(): Promise<string[]> {
|
|
21
|
-
const monomerLibHelper: IMonomerLibHelper = await grok.functions.call('Bio:getMonomerLibHelper', {});
|
|
22
|
-
const monomerFileManager: IMonomerLibFileManager = await monomerLibHelper.getFileManager();
|
|
23
|
-
return monomerFileManager.getValidLibraryPaths();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function getEnumeration(helmString: string, helmSelections: number[], screenLibrary: string):
|
|
27
|
-
Promise<string[]> {
|
|
28
|
-
const variableMonomers = await getAvaialableMonomers(screenLibrary);
|
|
29
|
-
const chain: Chain = Chain.fromHelm(helmString);
|
|
30
|
-
const size = helmSelections.length*variableMonomers.length;
|
|
31
|
-
const enumerations = new Array<string>(size);
|
|
32
|
-
|
|
33
|
-
for (let i = 0; i < helmSelections.length; i++) {
|
|
34
|
-
for (let j = 0; j < variableMonomers.length; j++)
|
|
35
|
-
enumerations[i*variableMonomers.length + j] = chain.getHelmChanged(helmSelections[i], variableMonomers[j]);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return enumerations;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class HelmInput {
|
|
42
|
-
webEditorHost: HTMLDivElement | null;
|
|
43
|
-
webEditorApp: org.helm.IWebEditorApp | null;
|
|
44
|
-
helmHelper: IHelmHelper;
|
|
45
|
-
editor: IHelmWebEditor;
|
|
46
|
-
subs: Unsubscribable[];
|
|
47
|
-
|
|
48
|
-
helmString: string = PT_HELM_EXAMPLE;
|
|
49
|
-
helmSelection: number[];
|
|
50
|
-
|
|
51
|
-
constructor(
|
|
52
|
-
helmHelper: IHelmHelper, editor: IHelmWebEditor) {
|
|
53
|
-
this.helmHelper = helmHelper;
|
|
54
|
-
this.editor = editor;
|
|
55
|
-
|
|
56
|
-
this.webEditorHost = null;
|
|
57
|
-
this.webEditorApp = null;
|
|
58
|
-
const subs: Unsubscribable[] = [];
|
|
59
|
-
|
|
60
|
-
subs.push(fromEvent<MouseEvent>(editor.host, 'click').subscribe(() => {
|
|
61
|
-
this.webEditorHost = ui.div();
|
|
62
|
-
//TODO: use not hh, but anything from editor.getHelm(true)
|
|
63
|
-
this.webEditorApp = helmHelper.createWebEditorApp(this.webEditorHost, this.getHelmString());
|
|
64
|
-
const dlg = ui.dialog({showHeader: false, showFooter: true})
|
|
65
|
-
.add(this.webEditorHost!)
|
|
66
|
-
.onOK(() => {
|
|
67
|
-
try {
|
|
68
|
-
const webEditorValue = this.webEditorApp!.canvas.getHelm(true)
|
|
69
|
-
.replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
|
|
70
|
-
editor.editor.setHelm(webEditorValue);
|
|
71
|
-
this.helmString = webEditorValue;
|
|
72
|
-
this.helmSelection = [];
|
|
73
|
-
|
|
74
|
-
//@ts-ignore
|
|
75
|
-
const selection = this.webEditorApp?.canvas.helm.jsd.m.atoms;
|
|
76
|
-
for (let i = 0; i < selection.length; i++) {
|
|
77
|
-
if (selection[i].selected)
|
|
78
|
-
this.helmSelection.push(i);
|
|
79
|
-
}
|
|
80
|
-
} catch (err: any) {
|
|
81
|
-
//this.logger.error(err);
|
|
82
|
-
} finally {
|
|
83
|
-
$(this.webEditorHost).empty();
|
|
84
|
-
this.webEditorHost = null;
|
|
85
|
-
this.webEditorApp = null;
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
.onCancel(() => {
|
|
89
|
-
$(this.webEditorHost).empty();
|
|
90
|
-
this.webEditorHost = null;
|
|
91
|
-
this.webEditorApp = null;
|
|
92
|
-
})
|
|
93
|
-
.show({modal: true, fullScreen: true});
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
static async init() {
|
|
98
|
-
const helmHelper = await getHelmHelper();
|
|
99
|
-
|
|
100
|
-
const editor = helmHelper.createHelmWebEditor();
|
|
101
|
-
editor.host.style.width = '200px';
|
|
102
|
-
editor.host.style.height = '100px';
|
|
103
|
-
editor.host.style.paddingLeft = '40px';
|
|
104
|
-
|
|
105
|
-
const cell = grok.shell.tv.dataFrame.currentCell;
|
|
106
|
-
|
|
107
|
-
if (cell.column.semType === DG.SEMTYPE.MACROMOLECULE && cell.column.tags[DG.TAGS.UNITS] === NOTATION.HELM)
|
|
108
|
-
editor.editor.setHelm(cell.value);
|
|
109
|
-
else
|
|
110
|
-
editor.editor.setHelm(PT_HELM_EXAMPLE);
|
|
111
|
-
|
|
112
|
-
return new HelmInput(helmHelper, editor);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
getHelmString(): string {
|
|
116
|
-
return this.helmString;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
getHelmSelections() {
|
|
120
|
-
return this.helmSelection;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
setHelmString(helm: string): void {
|
|
124
|
-
this.helmString = helm;
|
|
125
|
-
this.editor.editor.setHelm(helm);
|
|
126
|
-
this.helmSelection = [];
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
getDiv(): HTMLDivElement {
|
|
130
|
-
const title = ui.divText('Macromolecule', {style: {paddingTop: '43px', color: 'var(--grey-4)'}});
|
|
131
|
-
|
|
132
|
-
return ui.divH([title, this.editor.host], {style: {paddingLeft: '48px'}});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async function getAvaialableMonomers(screenLibrary: string): Promise<string[]> {
|
|
137
|
-
const monomerLibHelper: IMonomerLibHelper = await grok.functions.call('Bio:getMonomerLibHelper', {});
|
|
138
|
-
const monomerLib = await monomerLibHelper.readLibrary(LIB_PATH, screenLibrary);
|
|
139
|
-
//NOTICE: works with Peptides only
|
|
140
|
-
return monomerLib.getMonomerSymbolsByType('PEPTIDE');
|
|
141
|
-
}
|