@datagrok/bio 2.25.0 → 2.25.1

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
@@ -5,7 +5,7 @@
5
5
  "name": "Davit Rizhinashvili",
6
6
  "email": "drizhinashvili@datagrok.ai"
7
7
  },
8
- "version": "2.25.0",
8
+ "version": "2.25.1",
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",
@@ -44,7 +44,7 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@biowasm/aioli": "^3.1.0",
47
- "@datagrok-libraries/bio": "^5.61.0",
47
+ "@datagrok-libraries/bio": "^5.61.1",
48
48
  "@datagrok-libraries/chem-meta": "^1.2.9",
49
49
  "@datagrok-libraries/math": "^1.2.6",
50
50
  "@datagrok-libraries/ml": "^6.10.6",
@@ -5,7 +5,7 @@ import * as ui from 'datagrok-api/ui';
5
5
  import * as DG from 'datagrok-api/dg';
6
6
 
7
7
  import $ from 'cash-dom';
8
- import {Subject} from 'rxjs';
8
+ import {Subject, Subscription} from 'rxjs';
9
9
 
10
10
  import {
11
11
  getUserLibSettings, setUserLibSettings
@@ -67,10 +67,12 @@ class MonomerLibraryManagerWidget {
67
67
  instance._widget = await instance.createWidget();
68
68
  }
69
69
 
70
+ private _fileUploadSubscription: Subscription | null = null;
70
71
  private async createWidget() {
71
72
  const content = await this.getWidgetContent();
72
73
  const monomerLibHelper = await getMonomerLibHelper();
73
- // eslint-disable-next-line rxjs/no-ignored-subscription
74
+ this._fileUploadSubscription?.unsubscribe();
75
+ this._fileUploadSubscription =
74
76
  monomerLibHelper.fileUploadRequested.subscribe(
75
77
  () => this.promptToAddLibraryFiles()
76
78
  );
@@ -92,14 +94,29 @@ class MonomerLibraryManagerWidget {
92
94
  accept: '.json',
93
95
  open: async (selectedFile) => {
94
96
  const doAdd = async (provider: IMonomerLibProvider) => {
95
- const content = await selectedFile.text();
96
97
  const name = selectedFile.name;
98
+ const existingLibs = await provider.listLibraries();
99
+ // chech if library already exists
100
+ if (existingLibs.includes(name)) {
101
+ const confirm = await new Promise<boolean>((resolve) => {
102
+ ui.dialog('Confirm Library Update')
103
+ .add(ui.divText(`Library '${name}' already exists. Do you want to overwrite it?`))
104
+ .onOK(() => resolve(true))
105
+ .onCancel(() => resolve(false))
106
+ .show();
107
+ });
108
+ if (!confirm)
109
+ return;
110
+ }
111
+
112
+ const content = await selectedFile.text();
97
113
  const progressIndicator = DG.TaskBarProgressIndicator.create(`Adding ${name} as a monomer library`);
98
114
  try {
99
115
  await provider.addOrUpdateLibraryString(name, content);
100
116
  // this.eventManager.updateLibrarySelectionStatus(name, true);
101
117
  } catch (e) {
102
118
  grok.shell.error(`File ${name} is not a valid monomer library, verify it is aligned to HELM JSON schema.`);
119
+ console.error(e);
103
120
  } finally {
104
121
  progressIndicator.close();
105
122
  }
@@ -122,7 +139,7 @@ class MonomerLibraryManagerWidget {
122
139
  .onOK(async () => {
123
140
  const provider = providers.find((p) => p.name === providersInput.value)!; // should not be null
124
141
  await doAdd(provider);
125
- });
142
+ }).show();
126
143
  },
127
144
  });
128
145
  }
@@ -1049,21 +1049,30 @@ function joinToHelm(srcSS: ISeqSplitted, wrappers: string[], isDnaOrRna: boolean
1049
1049
  }
1050
1050
 
1051
1051
  function joinToBiln(srcSS: ISeqSplitted): string {
1052
+ const needsSquareBrackets = (cm: string | null) => {
1053
+ return cm && (cm.includes('-') || cm.includes('*') || cm.includes('[R'));
1054
+ };
1055
+
1052
1056
  if (!srcSS.graphInfo || !((srcSS.graphInfo.connections?.length ?? 0) > 0)) {
1053
1057
  const resOMList: string[] = new Array<string>(srcSS.length);
1054
1058
  for (let posIdx: number = 0; posIdx < srcSS.length; ++posIdx) {
1055
- resOMList[posIdx] = srcSS.getCanonical(posIdx);
1056
- if (resOMList[posIdx]?.includes('-')) // Biln uses '-' as a separator, need to enclose in []
1057
- resOMList[posIdx] = `[${resOMList[posIdx]}]`;
1059
+ const canonical = srcSS.getCanonical(posIdx);
1060
+ if (needsSquareBrackets(canonical)) // Biln uses '-' as a separator, need to enclose in []. also there might be smiles in there, where Rs are represented as '*' or R
1061
+ resOMList[posIdx] = `[${canonical}]`;
1062
+ else
1063
+ resOMList[posIdx] = canonical;
1058
1064
  }
1059
1065
  return resOMList.join('-'); // Biln uses '-' as a separator
1060
1066
  } else { // conversion happens only if there is a graph info
1061
1067
  const disjointSequenceIdxs = srcSS.graphInfo.disjointSeqStarts;
1062
1068
  const allSeqParts = new Array<string>(srcSS.length);
1063
1069
  for (let posIdx = 0; posIdx < srcSS.length; ++posIdx) {
1064
- allSeqParts[posIdx] = srcSS.getCanonical(posIdx);
1065
- if (allSeqParts[posIdx]?.includes('-')) // Biln uses '-' as a separator, need to enclose in []
1066
- allSeqParts[posIdx] = `[${allSeqParts[posIdx]}]`;
1070
+ const canonical = srcSS.getCanonical(posIdx);
1071
+ // allSeqParts[posIdx] = srcSS.getCanonical(posIdx);
1072
+ if (needsSquareBrackets(canonical)) // Biln uses '-' as a separator, need to enclose in []
1073
+ allSeqParts[posIdx] = `[${canonical}]`;
1074
+ else
1075
+ allSeqParts[posIdx] = canonical;
1067
1076
  }
1068
1077
  for (let i = 0; i < srcSS.graphInfo.connections.length; i++) {
1069
1078
  const conn: ISeqConnection = srcSS.graphInfo.connections[i];