@datagrok/helm 2.1.4 → 2.1.6
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/dist/package.js +69 -97
- package/package.json +3 -3
- package/src/package.ts +28 -60
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datagrok/helm",
|
|
3
3
|
"friendlyName": "Helm",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.6",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Oleksandra Serhiienko",
|
|
7
7
|
"email": "oserhiienko@datagrok.ai"
|
|
8
8
|
},
|
|
9
|
-
"description": "",
|
|
9
|
+
"description": "Provides support for HELM notation (importing, detecting, rendering, conversion). [Learn more](https://github.com/datagrok-ai/public/blob/master/packages/Helm/README.md)",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@datagrok-libraries/bio": "^5.22.
|
|
11
|
+
"@datagrok-libraries/bio": "^5.22.1",
|
|
12
12
|
"@datagrok-libraries/utils": "^1.19.1",
|
|
13
13
|
"cash-dom": "^8.1.1",
|
|
14
14
|
"datagrok-api": "^1.10.2",
|
package/src/package.ts
CHANGED
|
@@ -93,15 +93,23 @@ export function helmCellRenderer(): HelmCellRenderer {
|
|
|
93
93
|
return new HelmCellRenderer();
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
function checkMonomersAndOpenWebEditor(cell?: DG.Cell, value?: string, units?: string) {
|
|
97
|
+
const cellValue = typeof units === 'undefined' ? cell.value : value;
|
|
98
|
+
const monomers = findMonomers(cellValue);
|
|
99
|
+
if (monomers.size == 0)
|
|
100
|
+
webEditor(cell, value, units);
|
|
101
|
+
else
|
|
102
|
+
grok.shell.warning(`Monomers ${Array.from(monomers).join(', ')} are absent! <br/>` +
|
|
103
|
+
`Please, upload the monomer library! <br/>` +
|
|
104
|
+
`<a href="https://datagrok.ai/help/domains/bio/macromolecules" target="_blank">Learn more</a>`);
|
|
105
|
+
}
|
|
106
|
+
|
|
96
107
|
//tags: cellEditor
|
|
97
|
-
//description: Macromolecule
|
|
108
|
+
//description: Macromolecule
|
|
98
109
|
//input: grid_cell cell
|
|
110
|
+
//meta.columnTags: quality=Macromolecule, units=helm
|
|
99
111
|
export function editMoleculeCell(cell: DG.GridCell): void {
|
|
100
|
-
|
|
101
|
-
if (cell.gridColumn.column.tags[DG.TAGS.UNITS] === 'helm' && monomers.size === 0)
|
|
102
|
-
webEditor(cell);
|
|
103
|
-
else
|
|
104
|
-
grok.shell.warning(`Monomers ${Array.from(monomers).join(', ')} are absent!`);
|
|
112
|
+
checkMonomersAndOpenWebEditor(cell.cell, undefined, undefined);
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
//name: Open Helm Web Editor
|
|
@@ -110,9 +118,10 @@ export function editMoleculeCell(cell: DG.GridCell): void {
|
|
|
110
118
|
//input: string mol { semType: Macromolecule }
|
|
111
119
|
export function openEditor(mol: string): void {
|
|
112
120
|
let df = grok.shell.tv.grid.dataFrame;
|
|
113
|
-
let
|
|
121
|
+
let col = df.columns.bySemType('Macromolecule');
|
|
122
|
+
let converter = new NotationConverter(col);
|
|
114
123
|
const resStr = converter.convertStringToHelm(mol, '/');
|
|
115
|
-
|
|
124
|
+
checkMonomersAndOpenWebEditor(df.currentCell, resStr, col.getTag(DG.TAGS.UNITS));
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
//name: Properties
|
|
@@ -141,8 +150,10 @@ export async function propertiesPanel(helmString: string) {
|
|
|
141
150
|
);
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
function webEditor(cell?: DG.
|
|
153
|
+
function webEditor(cell?: DG.Cell, value?: string, units?: string) {
|
|
145
154
|
let view = ui.div();
|
|
155
|
+
let df = grok.shell.tv.grid.dataFrame;
|
|
156
|
+
let converter = new NotationConverter(df.columns.bySemType('Macromolecule'));
|
|
146
157
|
org.helm.webeditor.MolViewer.molscale = 0.8;
|
|
147
158
|
let app = new scil.helm.App(view, {
|
|
148
159
|
showabout: false,
|
|
@@ -167,8 +178,8 @@ function webEditor(cell?: DG.GridCell, value?: string) {
|
|
|
167
178
|
app.structureview.resize(sizes.rightwidth, sizes.bottomheight + app.toolbarheight);
|
|
168
179
|
app.mex.resize(sizes.topheight - 80);
|
|
169
180
|
setTimeout(function() {
|
|
170
|
-
if (typeof
|
|
171
|
-
app.canvas.helm.setSequence(cell.
|
|
181
|
+
if (typeof units === 'undefined') {
|
|
182
|
+
app.canvas.helm.setSequence(cell.value, 'HELM');
|
|
172
183
|
} else {
|
|
173
184
|
app.canvas.helm.setSequence(value, 'HELM');
|
|
174
185
|
}
|
|
@@ -177,59 +188,16 @@ function webEditor(cell?: DG.GridCell, value?: string) {
|
|
|
177
188
|
ui.dialog({showHeader: false, showFooter: true})
|
|
178
189
|
.add(view)
|
|
179
190
|
.onOK(() => {
|
|
180
|
-
|
|
181
|
-
|
|
191
|
+
let helmValue = app.canvas.getHelm(true).replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
|
|
192
|
+
if (typeof units === 'undefined') {
|
|
193
|
+
cell.value = helmValue;
|
|
194
|
+
} else {
|
|
195
|
+
let convertedRes = converter.convertHelmToFastaSeparator(helmValue, units);
|
|
196
|
+
cell.value = convertedRes;
|
|
182
197
|
}
|
|
183
198
|
}).show({modal: true, fullScreen: true});
|
|
184
199
|
}
|
|
185
200
|
|
|
186
|
-
async function accessServer(url: string, key: string) {
|
|
187
|
-
const params: RequestInit = {
|
|
188
|
-
method: 'GET',
|
|
189
|
-
headers: {
|
|
190
|
-
'Accept': 'application/json',
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
const response = await fetch(url, params);
|
|
194
|
-
const json = await response.json();
|
|
195
|
-
return json[key];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
//name: helmToFasta
|
|
199
|
-
//input: string helmString {semType: Macromolecule}
|
|
200
|
-
//output: string res
|
|
201
|
-
export async function helmToFasta(helmString: string) {
|
|
202
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Produce/${helmString}`;
|
|
203
|
-
return await accessServer(url, 'FastaFile');
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
//name: helmToRNA
|
|
207
|
-
//description: converts to rna analogue sequence
|
|
208
|
-
//input: string helmString {semType: Macromolecule}
|
|
209
|
-
//output: string res
|
|
210
|
-
export async function helmToRNA(helmString: string) {
|
|
211
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Convert/RNA/${helmString}`;
|
|
212
|
-
return await accessServer(url, 'Sequence');
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
//name: helmToPeptide
|
|
216
|
-
//description: converts to peptide analogue sequence
|
|
217
|
-
//input: string helmString {semType: Macromolecule}
|
|
218
|
-
//output: string res
|
|
219
|
-
export async function helmToPeptide(helmString: string) {
|
|
220
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Convert/PEPTIDE/${helmString}`;
|
|
221
|
-
return await accessServer(url, 'Sequence');
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
//name: helmToSmiles
|
|
225
|
-
//description: converts to smiles
|
|
226
|
-
//input: string helmString {semType: Macromolecule}
|
|
227
|
-
//output: string smiles {semType: Molecule}
|
|
228
|
-
export async function helmToSmiles(helmString: string) {
|
|
229
|
-
const url = `http://localhost:8081/WebService/service/SMILES/${helmString}`;
|
|
230
|
-
return await accessServer(url, 'SMILES');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
201
|
function getRS(smiles: string) {
|
|
234
202
|
const newS = smiles.match(/(?<=\[)[^\][]*(?=])/gm);
|
|
235
203
|
const res = {};
|