@datagrok/sequence-translator 1.3.10 → 1.3.11

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datagrok/sequence-translator",
3
3
  "friendlyName": "Sequence Translator",
4
- "version": "1.3.10",
4
+ "version": "1.3.11",
5
5
  "author": {
6
6
  "name": "Alexey Choposky",
7
7
  "email": "achopovsky@datagrok.ai"
package/src/package.ts CHANGED
@@ -16,12 +16,12 @@ import {demoOligoPatternUI, demoOligoStructureUI, demoOligoTranslatorUI} from '.
16
16
  import {getExternalAppViewFactories} from './plugins/mermade';
17
17
 
18
18
  //polytool specific
19
- import {getPolyToolConversionDialog} from './polytool/pt-dialog';
19
+ import {getPolyToolConversionDialog, polyToolEnumerateHelmUI, polyToolEnumerateChemUI} from './polytool/pt-dialog';
20
20
  import {_setPeptideColumn} from './polytool/utils';
21
21
  import {PolyToolCsvLibHandler} from './polytool/csv-to-json-monomer-lib-converter';
22
22
  import {ITranslationHelper} from './types';
23
- import {polyToolEnumerateHelmUI, polyToolEnumerateChemUI} from './polytool/pt-ui';
24
23
  import {addContextMenuUI} from './utils/context-menu';
24
+ import { NOTATION } from '@datagrok-libraries/bio/src/utils/macromolecule/consts';
25
25
 
26
26
  export const _package: OligoToolkitPackage = new OligoToolkitPackage();
27
27
 
@@ -172,12 +172,12 @@ export async function polyToolEnumerateHelm(): Promise<void> {
172
172
  polyToolEnumerateHelmUI();
173
173
  }
174
174
 
175
- // //top-menu: Bio | Convert | PolyTool-Enumerate Chem
176
- // //name: polyToolEnumerateChem
177
- // //description: Perform cyclization of polymers
178
- // export async function polyToolEnumerateChem(): Promise<void> {
179
- // polyToolEnumerateChemUI();
180
- // }
175
+ //top-menu: Bio | Convert | PolyTool-Enumerate Chem
176
+ //name: polyToolEnumerateChem
177
+ //description: Perform cyclization of polymers
178
+ export async function polyToolEnumerateChem(): Promise<void> {
179
+ polyToolEnumerateChemUI();
180
+ }
181
181
 
182
182
  //name: polyToolColumnChoice
183
183
  //input: dataframe df [Input data table]
@@ -210,28 +210,40 @@ export function addContextMenu(event: DG.EventData): void {
210
210
  // //meta.icon: img/icons/structure.png
211
211
  // //meta.browsePath: PolyTool
212
212
  // //tags: app
213
- // //output: view v
214
- // export async function ptConverterApp(): Promise<DG.ViewBase> {
215
- // const view = await getSpecifiedAppView(APP_NAME.STRUCTURE);
216
- // return view;
213
+ // export async function ptConverterApp(): Promise<void> {
214
+ // const view = grok.shell.v as DG.TableView;
215
+ // const table = view.dataFrame;
216
+ // const colNames = table.columns.names();
217
+ // let covertableName = '';
218
+
219
+ // for (let i = 0; i < colNames.length; i++) {
220
+ // const col = table.columns.byName(colNames[i]);
221
+ // if (col.semType === DG.SEMTYPE.MACROMOLECULE && col.meta.units === NOTATION.SEPARATOR) {
222
+ // covertableName = colNames[i];
223
+ // break;
224
+ // }
225
+ // }
226
+
227
+ // if (covertableName === '')
228
+ // grok.shell.error('To run the app open a view with convertable separator notation for macromolecules');
229
+ // else {
230
+ // const dialog = await getPolyToolConversionDialog();
231
+ // dialog.show();
232
+ // }
217
233
  // }
218
234
 
219
- // //name: PolyTool Enumerator Helm
220
- // //meta.icon: img/icons/structure.png
221
- // //meta.browsePath: PolyTool
222
- // //tags: app
223
- // //output: view v
224
- // export async function ptEnumeratorHelmApp(): Promise<DG.ViewBase> {
225
- // const view = await getSpecifiedAppView(APP_NAME.STRUCTURE);
226
- // return view;
227
- // }
235
+ //name: PolyTool Enumerator Helm
236
+ //meta.icon: img/icons/structure.png
237
+ //meta.browsePath: PolyTool
238
+ //tags: app
239
+ export async function ptEnumeratorHelmApp(): Promise<void> {
240
+ polyToolEnumerateHelmUI();
241
+ }
228
242
 
229
- // //name: PolyTool Enumerator Chem
230
- // //meta.icon: img/icons/structure.png
231
- // //meta.browsePath: PolyTool
232
- // //tags: app
233
- // //output: view v
234
- // export async function ptEnumeratorChemApp(): Promise<DG.ViewBase> {
235
- // const view = await getSpecifiedAppView(APP_NAME.STRUCTURE);
236
- // return view;
237
- // }
243
+ //name: PolyTool Enumerator Chem
244
+ //meta.icon: img/icons/structure.png
245
+ //meta.browsePath: PolyTool
246
+ //tags: app
247
+ export async function ptEnumeratorChemApp(): Promise<void> {
248
+ polyToolEnumerateChemUI();
249
+ }
@@ -28,7 +28,27 @@ const PT_UI_DIALOG_CONVERSION = 'Poly Tool Conversion';
28
28
  const PT_UI_DIALOG_ENUMERATION = 'Poly Tool Enumeration';
29
29
  const PT_UI_RULES_USED = 'Rules used';
30
30
 
31
- export async function getPolyToolConversionDialog(): Promise<DG.Dialog> {
31
+ export function polyToolEnumerateHelmUI(cell?: DG.Cell): void {
32
+ getPolyToolEnumerationHelmDialog(cell)
33
+ .then((dialog) => {
34
+ dialog.show({resizable: true});
35
+ })
36
+ .catch((_err: any) => {
37
+ grok.shell.warning('To run PolyTool Enumeration, sketch the macromolecule and select monomers to vary');
38
+ });
39
+ }
40
+
41
+ export function polyToolEnumerateChemUI(cell?: DG.Cell): void {
42
+ getPolyToolEnumerationChemDialog(cell)
43
+ .then((dialog) => {
44
+ dialog.show({resizable: true});
45
+ })
46
+ .catch((_err: any) => {
47
+ grok.shell.warning('To run PolyTool Enumeration, sketch the molecule and specify the R group to vary');
48
+ });
49
+ }
50
+
51
+ export async function getPolyToolConversionDialog(targetCol?: DG.Column): Promise<DG.Dialog> {
32
52
  const targetColumns = grok.shell.t.columns.bySemTypeAll(DG.SEMTYPE.MACROMOLECULE);
33
53
  if (!targetColumns)
34
54
  throw new Error(PT_ERROR_DATAFRAME);
@@ -38,6 +58,8 @@ export async function getPolyToolConversionDialog(): Promise<DG.Dialog> {
38
58
  filter: (col: DG.Column) => col.semType === DG.SEMTYPE.MACROMOLECULE
39
59
  });
40
60
 
61
+ targetColumnInput.value = targetCol ? targetCol : targetColumnInput.value;
62
+
41
63
  const generateHelmChoiceInput = ui.input.bool(PT_UI_GET_HELM, {value: true});
42
64
  ui.tooltip.bind(generateHelmChoiceInput.root, PT_UI_ADD_HELM);
43
65
 
@@ -82,7 +104,7 @@ export async function getPolyToolConversionDialog(): Promise<DG.Dialog> {
82
104
  return dialog;
83
105
  }
84
106
 
85
- export async function getPolyToolEnumerationHelmDialog(cell?: DG.Cell): Promise<DG.Dialog> {
107
+ async function getPolyToolEnumerationHelmDialog(cell?: DG.Cell): Promise<DG.Dialog> {
86
108
  const [libList, helmHelper] = await Promise.all([
87
109
  getLibrariesList(), getHelmHelper()]);
88
110
 
@@ -137,7 +159,7 @@ export async function getPolyToolEnumerationHelmDialog(cell?: DG.Cell): Promise<
137
159
  return dialog;
138
160
  }
139
161
 
140
- export async function getPolyToolEnumerationChemDialog(cell?: DG.Cell): Promise<DG.Dialog> {
162
+ async function getPolyToolEnumerationChemDialog(cell?: DG.Cell): Promise<DG.Dialog> {
141
163
  const [libList, helmHelper] = await Promise.all([
142
164
  getLibrariesList(), getHelmHelper()]);
143
165
 
@@ -147,9 +169,6 @@ export async function getPolyToolEnumerationChemDialog(cell?: DG.Cell): Promise<
147
169
  // sketcher.setMolFile(col.tags[ALIGN_BY_SCAFFOLD_TAG]);
148
170
  molInput.onChanged.subscribe((_: any) => {
149
171
  molValue = molInput.getMolFile();
150
- // col.tags[ALIGN_BY_SCAFFOLD_TAG] = molFile;
151
- // col.temp[ALIGN_BY_SCAFFOLD_TAG] = molFile;
152
- // col.dataFrame?.fireValuesChanged();
153
172
  });
154
173
  molInput.root.classList.add('ui-input-editor');
155
174
  molInput.root.style.marginTop = '3px';
@@ -29,7 +29,7 @@ export const PT_CHEM_EXAMPLE = `
29
29
  2.4544 0.4877 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
30
30
  -1.8175 -1.9896 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
31
31
  -3.2453 0.4877 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
32
- 3.1670 1.7285 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0
32
+ 3.1670 1.7285 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
33
33
  1.7149 2.5513 0.0000 R# 0 0 0 0 0 0 0 0 0 0 0 0
34
34
  2 1 2 0 0 0 0
35
35
  3 1 1 0 0 0 0
@@ -55,18 +55,15 @@ export const PT_CHEM_EXAMPLE = `
55
55
  14 10 1 0 0 0 0
56
56
  15 21 1 0 0 0 0
57
57
  12 22 1 0 0 0 0
58
- M RGP 2 21 1 22 2
58
+ M RGP 1 22 1
59
59
  M END`;
60
60
 
61
61
  export async function getEnumerationChem(molString: string, screenLibrary: string):
62
62
  Promise<string[]> {
63
+
63
64
  const variableMonomers = await getAvailableMonomers(screenLibrary);
64
65
  const variableMols = await getAvailableMonomerMols(screenLibrary);
65
-
66
- const idx = molString.indexOf('M RGP');
67
- const rCount = parseInt(molString.slice(idx + 6, idx + 9)); //extracting from molfile positions
68
- const size = 1 * variableMonomers.length;
69
- const enumerations = new Array<string>(size);
66
+ const enumerations = new Array<string>(variableMonomers.length);
70
67
 
71
68
  const rdkitModule: RDModule = await grok.functions.call('Chem:getRdKitModule');
72
69
  const molScaffold: RDMol = rdkitModule.get_mol(molString);
@@ -84,22 +81,39 @@ export async function getEnumerationChem(molString: string, screenLibrary: strin
84
81
  molSubst.delete();
85
82
  }
86
83
 
87
- //TODO: get for all R groups
88
- for (let i = 0; i < 1; i++) {
89
- for (let j = 0; j < variableMonomers.length; j++) {
90
- try {
91
- const smiResRaw = `${smiScaffold}.${smilesSubsts[j]}`.replaceAll('[1*]C', 'C([1*])').replaceAll('[1*]c', 'c([1*])').replaceAll('[1*]O', 'O([1*])').replaceAll('[1*]N', 'N([1*])');
92
- const smiRes = `${smiResRaw}`.replaceAll('([1*])', '9').replaceAll('[1*]', '9');
93
- const molRes: RDMol = rdkitModule.get_mol(smiRes);
94
-
95
- enumerations[i * variableMonomers.length + j] = molRes.get_v3Kmolblock();
96
- molRes.delete();
97
- }
98
- catch(err:any) {
99
- enumerations[i * variableMonomers.length + j] = '';
84
+ for (let i = 0; i < variableMonomers.length; i++) {
85
+ let molRes: RDMol | null = null;
86
+ try {
87
+ //TODO: use RDKit linking function when exposed
88
+ const smiResRaw = `${smiScaffold}.${smilesSubsts[i]}`.replaceAll('[1*]C', 'C([1*])').replaceAll('[1*]c', 'c([1*])').replaceAll('[1*]O', 'O([1*])').replaceAll('[1*]N', 'N([1*])');
89
+ const smiRes = `${smiResRaw}`.replaceAll('([1*])', '9').replaceAll('[1*]', '9');
90
+ molRes = rdkitModule.get_mol(smiRes);
91
+ let molV3 = molRes.get_v3Kmolblock();
92
+
93
+
94
+ //TODO: use RDKit when MASS problem is solved
95
+ while(molV3.includes('MASS')) {
96
+
97
+ //MASS=2 VAL=1
98
+ //RGROUPS=(1 2)
99
+ const idx = molV3.indexOf('MASS');
100
+ const rNum = parseInt(molV3.slice(idx + 5, idx + 6));
101
+ const replace = `RGROUPS=(1 ${rNum})`;
102
+ molV3 = molV3.substring(0, idx) + replace + molV3.substring(idx + 12);
100
103
  }
101
- }
104
+
105
+ molV3 = molV3.replaceAll('R ', 'R# ')
106
+
107
+ enumerations[i] = molV3;
108
+ }
109
+ catch(err:any) {
110
+ enumerations[i] = '';
111
+ }
112
+ finally {
113
+ molRes?.delete();
114
+ }
102
115
  }
116
+
103
117
 
104
118
  return enumerations;
105
119
  }
@@ -6,7 +6,7 @@ import {defaultErrorHandler} from './err-info';
6
6
  import {_package, addContextMenu} from '../package';
7
7
  import {SeqHandler} from '@datagrok-libraries/bio/src/utils/seq-handler';
8
8
  import {NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
9
- import {polyToolEnumerateHelmUI} from '../polytool/pt-ui';
9
+ import {polyToolEnumerateHelmUI} from '../polytool/pt-dialog';
10
10
 
11
11
  export type SequenceTranslatorWindowType = Window & {
12
12
  $sequenceTranslator?: {
@@ -1,25 +0,0 @@
1
- import * as grok from 'datagrok-api/grok';
2
- import * as DG from 'datagrok-api/dg';
3
- import * as ui from 'datagrok-api/ui';
4
-
5
- import {getPolyToolEnumerationHelmDialog, getPolyToolEnumerationChemDialog} from './pt-dialog';
6
-
7
- export function polyToolEnumerateHelmUI(cell?: DG.Cell): void {
8
- getPolyToolEnumerationHelmDialog(cell)
9
- .then((dialog) => {
10
- dialog.show({resizable: true});
11
- })
12
- .catch((_err: any) => {
13
- grok.shell.warning('To run PolyTool Enumeration, sketch the macromolecule and select monomers to vary');
14
- });
15
- }
16
-
17
- export function polyToolEnumerateChemUI(cell?: DG.Cell): void {
18
- getPolyToolEnumerationChemDialog(cell)
19
- .then((dialog) => {
20
- dialog.show({resizable: true});
21
- })
22
- .catch((_err: any) => {
23
- grok.shell.warning('To run PolyTool Enumeration, sketch the molecule and specify the R group to vary');
24
- });
25
- }