@datagrok/bio 2.11.33 → 2.11.35

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.
@@ -8,90 +8,13 @@ import {MonomerLibManager} from '../monomer-lib/lib-manager';
8
8
  import {ALL_MONOMERS, CYCLIZATION_TYPE, TRANSFORMATION_TYPE} from './const';
9
9
  import {addTransformedColumn} from './transformation';
10
10
  import * as rxjs from 'rxjs';
11
- import {MetaData} from './types';
11
+ //import {MetaData} from './types';
12
12
 
13
13
  export function getPolyToolDialog(): DG.Dialog {
14
- function getMonomerList(cyclizationType: CYCLIZATION_TYPE): string[] {
15
- if (cyclizationType === cyclizationTypes[0]) {
16
- return [ALL_MONOMERS].concat(
17
- monomerLib.getMonomerSymbolsByType(HELM_POLYMER_TYPE.PEPTIDE)
18
- );
19
- }
20
- if (cyclizationType === cyclizationTypes[1]) {
21
- return [ALL_MONOMERS].concat(
22
- monomerLib.getMonomerSymbolsByRGroup(3, HELM_POLYMER_TYPE.PEPTIDE)
23
- );
24
- }
25
- return ['C'];
26
- }
27
-
28
- function updateMonomerList(): void {
29
- if (cyclizationTypeChoice.value === CYCLIZATION_TYPE.NCys) {
30
- monomerList1 = getMonomerList(CYCLIZATION_TYPE.NO);
31
- monomerList2 = getMonomerList(CYCLIZATION_TYPE.NCys);
32
- } else {
33
- monomerList1 = getMonomerList(cyclizationTypeChoice.value as CYCLIZATION_TYPE);
34
- monomerList2 = [...monomerList1];
35
- }
36
-
37
- leftTerminalChoice = ui.choiceInput(
38
- 'R1:', monomerList1[0], monomerList1, () => { onRGroupValueChange.next(); }
39
- );
40
- rightTerminalChoice = ui.choiceInput('R2:', monomerList2[0], monomerList2, () => { onRGroupValueChange.next(); });
41
- onRGroupValueChange.next();
42
- ui.empty(terminalControls);
43
- [leftTerminalChoice, rightTerminalChoice].forEach((el) => { terminalControls.appendChild(el.root); });
44
- }
45
-
46
- function updateMeta() {
47
- meta.cyclizationType = cyclizationTypeChoice.value!;
48
- meta.leftTerminal = leftTerminalChoice.value!;
49
- meta.rightTerminal = rightTerminalChoice.value!;
50
- meta.transformationType = transformationChoice.value!;
51
- }
52
-
53
-
54
- const onCyclizationChoice = new rxjs.Subject<string>();
55
- const onRGroupValueChange = new rxjs.Subject<string>();
56
- onCyclizationChoice.subscribe(() => {
57
- meta.cyclizationType = cyclizationTypeChoice.value!;
58
- updateMonomerList();
59
- });
60
- onRGroupValueChange.subscribe(() => {
61
- meta.rightTerminal = rightTerminalChoice.value!;
62
- meta.leftTerminal = leftTerminalChoice.value!;
63
- });
64
-
65
- const meta = {} as MetaData;
66
- const transformations = [TRANSFORMATION_TYPE.CYCLIZATION];
67
- const transformationChoice = ui.choiceInput(
68
- 'Modification', transformations[0], transformations, () => meta.transformationType = transformationChoice.value!
69
- );
70
-
71
- const cyclizationTypes = [CYCLIZATION_TYPE.NO, CYCLIZATION_TYPE.R3, CYCLIZATION_TYPE.NCys];
72
- const cyclizationTypeChoice = ui.choiceInput(
73
- 'Type', cyclizationTypes[2], cyclizationTypes, () => { onCyclizationChoice.next(); }
74
- );
75
-
76
- const monomerLib = MonomerLibManager.instance.getBioLib();
77
- let monomerList1: string[] = [];
78
- let monomerList2: string[] = [];
79
- let leftTerminalChoice = ui.choiceInput(
80
- 'R1:', monomerList1[0], monomerList1, () => {
81
- meta.leftTerminal = leftTerminalChoice.value!;
82
- }
83
- );
84
- let rightTerminalChoice = ui.choiceInput('R2:', monomerList2[0], monomerList2, () => {
85
- meta.rightTerminal = rightTerminalChoice.value!;
86
- });
87
- const terminalControls = ui.divV([leftTerminalChoice.root, rightTerminalChoice.root]);
88
- updateMonomerList();
89
-
90
- updateMeta();
91
-
14
+ //const monomerLib = MonomerLibManager.instance.getBioLib();
92
15
  const targetColumns = grok.shell.t.columns.bySemTypeAll(DG.SEMTYPE.MACROMOLECULE);
93
16
  if (!targetColumns)
94
- throw new Error('No dataframe with maceomolecule columns open');
17
+ throw new Error('No dataframe with macromolecule columns open');
95
18
 
96
19
  const targetColumnInput = ui.columnInput(
97
20
  'Column', grok.shell.t, targetColumns[0], null,
@@ -101,12 +24,46 @@ export function getPolyToolDialog(): DG.Dialog {
101
24
  const generateHelmChoiceInput = ui.boolInput('Get HELM', true);
102
25
  ui.tooltip.bind(generateHelmChoiceInput.root, 'Add HELM column');
103
26
 
27
+ let rulesTable: DG.DataFrame = DG.DataFrame.create();
28
+
29
+ const ruleFileInput = ui.button('ADD RULES', () => {
30
+ DG.Utils.openFile({
31
+ accept: '.csv',
32
+ open: async (selectedFile) => {
33
+ const content = await selectedFile.text();
34
+ rulesTable = DG.DataFrame.fromCsv(content);
35
+ //console.log(df.toCsv());
36
+ },
37
+ });
38
+ });
39
+ // dialog.addButton(
40
+ // 'Add',
41
+ // () => eventManager.addLibraryFile(),
42
+ // undefined,
43
+ // 'Upload new HELM monomer library'
44
+ // );
45
+
46
+
47
+ // const ruleFileInput = DG.Utils.openFile({
48
+ // accept: '.csv',
49
+ // open: async (selectedFile) => {
50
+ // const content = await selectedFile.text();
51
+ // const name = selectedFile.name;
52
+ // const df = DG.DataFrame.fromCsv(content);
53
+
54
+ // console.log(df.toCsv());
55
+ // },
56
+ // });
57
+
58
+ //grok.data.files.openTable('Samples:Files/chem/smiles_10K_with_activities.csv')
59
+ // const file = await loadFileAsText(tableName);
60
+ // const df = DG.DataFrame.fromCsv(file);
61
+ // df.name = tableName.replace('.csv', '');
62
+
104
63
  const div = ui.div([
105
64
  targetColumnInput,
106
- transformationChoice,
107
- cyclizationTypeChoice,
108
- terminalControls,
109
65
  generateHelmChoiceInput,
66
+ ruleFileInput
110
67
  ]);
111
68
 
112
69
  const dialog = ui.dialog('Poly Tool')
@@ -117,7 +74,7 @@ export function getPolyToolDialog(): DG.Dialog {
117
74
  grok.shell.warning('No marcomolecule column chosen!');
118
75
  return;
119
76
  }
120
- addTransformedColumn(molCol!, meta, generateHelmChoiceInput.value!);
77
+ addTransformedColumn(molCol!, rulesTable!, generateHelmChoiceInput.value!);
121
78
  }
122
79
  );
123
80
 
@@ -3,13 +3,7 @@ import * as grok from 'datagrok-api/grok';
3
3
  import * as ui from 'datagrok-api/ui';
4
4
  import * as DG from 'datagrok-api/dg';
5
5
 
6
- import {NOTATION, ALIGNMENT, ALPHABET} from '@datagrok-libraries/bio/src/utils/macromolecule';
7
-
8
- export function addCommonTags(col: DG.Column):void {
9
- col.setTag('quality', DG.SEMTYPE.MACROMOLECULE);
10
- col.setTag('aligned', ALIGNMENT.SEQ);
11
- col.setTag('alphabet', ALPHABET.PT);
12
- }
6
+ import {ALPHABET, ALIGNMENT, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
13
7
 
14
8
  export function _setPeptideColumn(col: DG.Column): void {
15
9
  addCommonTags(col);
@@ -18,3 +12,9 @@ export function _setPeptideColumn(col: DG.Column): void {
18
12
  // col.setTag('cell.renderer', 'sequence');
19
13
  }
20
14
 
15
+ function addCommonTags(col: DG.Column<any>) {
16
+ col.setTag('quality', DG.SEMTYPE.MACROMOLECULE);
17
+ col.setTag('aligned', ALIGNMENT.SEQ);
18
+ col.setTag('alphabet', ALPHABET.PT);
19
+ }
20
+
@@ -110,7 +110,7 @@ export class HelmBioFilter extends BioFilterBase<BioFilterProps> /* implements I
110
110
 
111
111
  applyProps() {
112
112
  if (!this.helmEditor) return; // helmEditor is not created, the filter is not in dom yet
113
- this.helmEditor.editor.setHelm(this.props.substructure);
113
+ this.updateFilterPanel(this.props.substructure);
114
114
  }
115
115
 
116
116
  get filterPanel() {
@@ -1,20 +0,0 @@
1
- import {TRANSFORMATION_TYPE, CYCLIZATION_TYPE} from './const';
2
-
3
- export type MetaData = {
4
- leftTerminal: string,
5
- rightTerminal: string,
6
- transformationType: TRANSFORMATION_TYPE,
7
- cyclizationType: CYCLIZATION_TYPE,
8
- }
9
-
10
- export type ConnectionData = {
11
- monomerPosition: number,
12
- attachmentPoint: number,
13
- }
14
-
15
- export type PolyToolLib = {
16
- 'Short Name': string,
17
- 'Medium Name': string,
18
- 'SMILES': string,
19
- 'Synonyms': string
20
- }