@datagrok/helm 2.1.5 → 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 +68 -101
- package/package.json +3 -3
- package/src/package.ts +27 -64
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,16 +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
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')
|
|
102
|
-
if (monomers.size == 0)
|
|
103
|
-
webEditor(cell);
|
|
104
|
-
else
|
|
105
|
-
grok.shell.warning(`Monomers ${Array.from(monomers).join(', ')} are absent!`);
|
|
112
|
+
checkMonomersAndOpenWebEditor(cell.cell, undefined, undefined);
|
|
106
113
|
}
|
|
107
114
|
|
|
108
115
|
//name: Open Helm Web Editor
|
|
@@ -111,13 +118,10 @@ export function editMoleculeCell(cell: DG.GridCell): void {
|
|
|
111
118
|
//input: string mol { semType: Macromolecule }
|
|
112
119
|
export function openEditor(mol: string): void {
|
|
113
120
|
let df = grok.shell.tv.grid.dataFrame;
|
|
114
|
-
let
|
|
121
|
+
let col = df.columns.bySemType('Macromolecule');
|
|
122
|
+
let converter = new NotationConverter(col);
|
|
115
123
|
const resStr = converter.convertStringToHelm(mol, '/');
|
|
116
|
-
|
|
117
|
-
if (monomers.size == 0)
|
|
118
|
-
webEditor(undefined, resStr);
|
|
119
|
-
else
|
|
120
|
-
grok.shell.warning(`Monomers ${Array.from(monomers).join(', ')} are absent!`);
|
|
124
|
+
checkMonomersAndOpenWebEditor(df.currentCell, resStr, col.getTag(DG.TAGS.UNITS));
|
|
121
125
|
}
|
|
122
126
|
|
|
123
127
|
//name: Properties
|
|
@@ -146,8 +150,10 @@ export async function propertiesPanel(helmString: string) {
|
|
|
146
150
|
);
|
|
147
151
|
}
|
|
148
152
|
|
|
149
|
-
function webEditor(cell?: DG.
|
|
153
|
+
function webEditor(cell?: DG.Cell, value?: string, units?: string) {
|
|
150
154
|
let view = ui.div();
|
|
155
|
+
let df = grok.shell.tv.grid.dataFrame;
|
|
156
|
+
let converter = new NotationConverter(df.columns.bySemType('Macromolecule'));
|
|
151
157
|
org.helm.webeditor.MolViewer.molscale = 0.8;
|
|
152
158
|
let app = new scil.helm.App(view, {
|
|
153
159
|
showabout: false,
|
|
@@ -172,8 +178,8 @@ function webEditor(cell?: DG.GridCell, value?: string) {
|
|
|
172
178
|
app.structureview.resize(sizes.rightwidth, sizes.bottomheight + app.toolbarheight);
|
|
173
179
|
app.mex.resize(sizes.topheight - 80);
|
|
174
180
|
setTimeout(function() {
|
|
175
|
-
if (typeof
|
|
176
|
-
app.canvas.helm.setSequence(cell.
|
|
181
|
+
if (typeof units === 'undefined') {
|
|
182
|
+
app.canvas.helm.setSequence(cell.value, 'HELM');
|
|
177
183
|
} else {
|
|
178
184
|
app.canvas.helm.setSequence(value, 'HELM');
|
|
179
185
|
}
|
|
@@ -182,59 +188,16 @@ function webEditor(cell?: DG.GridCell, value?: string) {
|
|
|
182
188
|
ui.dialog({showHeader: false, showFooter: true})
|
|
183
189
|
.add(view)
|
|
184
190
|
.onOK(() => {
|
|
185
|
-
|
|
186
|
-
|
|
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;
|
|
187
197
|
}
|
|
188
198
|
}).show({modal: true, fullScreen: true});
|
|
189
199
|
}
|
|
190
200
|
|
|
191
|
-
async function accessServer(url: string, key: string) {
|
|
192
|
-
const params: RequestInit = {
|
|
193
|
-
method: 'GET',
|
|
194
|
-
headers: {
|
|
195
|
-
'Accept': 'application/json',
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
const response = await fetch(url, params);
|
|
199
|
-
const json = await response.json();
|
|
200
|
-
return json[key];
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
//name: helmToFasta
|
|
204
|
-
//input: string helmString {semType: Macromolecule}
|
|
205
|
-
//output: string res
|
|
206
|
-
export async function helmToFasta(helmString: string) {
|
|
207
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Produce/${helmString}`;
|
|
208
|
-
return await accessServer(url, 'FastaFile');
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
//name: helmToRNA
|
|
212
|
-
//description: converts to rna analogue sequence
|
|
213
|
-
//input: string helmString {semType: Macromolecule}
|
|
214
|
-
//output: string res
|
|
215
|
-
export async function helmToRNA(helmString: string) {
|
|
216
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Convert/RNA/${helmString}`;
|
|
217
|
-
return await accessServer(url, 'Sequence');
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
//name: helmToPeptide
|
|
221
|
-
//description: converts to peptide analogue sequence
|
|
222
|
-
//input: string helmString {semType: Macromolecule}
|
|
223
|
-
//output: string res
|
|
224
|
-
export async function helmToPeptide(helmString: string) {
|
|
225
|
-
const url = `http://localhost:8081/WebService/service/Fasta/Convert/PEPTIDE/${helmString}`;
|
|
226
|
-
return await accessServer(url, 'Sequence');
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
//name: helmToSmiles
|
|
230
|
-
//description: converts to smiles
|
|
231
|
-
//input: string helmString {semType: Macromolecule}
|
|
232
|
-
//output: string smiles {semType: Molecule}
|
|
233
|
-
export async function helmToSmiles(helmString: string) {
|
|
234
|
-
const url = `http://localhost:8081/WebService/service/SMILES/${helmString}`;
|
|
235
|
-
return await accessServer(url, 'SMILES');
|
|
236
|
-
}
|
|
237
|
-
|
|
238
201
|
function getRS(smiles: string) {
|
|
239
202
|
const newS = smiles.match(/(?<=\[)[^\][]*(?=])/gm);
|
|
240
203
|
const res = {};
|