@datagrok/sequence-translator 1.0.17 → 1.1.4
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/.eslintrc.json +4 -3
- package/CHANGELOG.md +36 -0
- package/detectors.js +8 -0
- package/dist/package-test.js +2 -73079
- package/dist/package-test.js.map +1 -0
- package/dist/package.js +2 -72284
- package/dist/package.js.map +1 -0
- package/files/axolabs-style.json +97 -0
- package/files/codes-to-symbols.json +67 -0
- package/files/formats-to-helm.json +63 -0
- package/files/linkers.json +22 -0
- package/files/monomer-lib.json +1142 -0
- package/link-bio +7 -0
- package/package.json +30 -31
- package/scripts/build-monomer-lib.py +391 -122
- package/src/demo/demo-st-ui.ts +71 -0
- package/src/demo/handle-error.ts +12 -0
- package/src/model/axolabs/axolabs-tab.ts +111 -0
- package/src/model/axolabs/const.ts +33 -0
- package/src/{axolabs-tab → model/axolabs}/draw-svg.ts +1 -1
- package/src/{axolabs-tab → model/axolabs}/helpers.ts +7 -5
- package/src/model/const.ts +18 -0
- package/src/model/data-loading-utils/const.ts +8 -0
- package/src/model/data-loading-utils/json-loader.ts +38 -0
- package/src/model/data-loading-utils/types.ts +30 -0
- package/src/model/format-translation/const.ts +8 -0
- package/src/model/format-translation/conversion-utils.ts +49 -0
- package/src/model/format-translation/format-converter.ts +109 -0
- package/src/model/helpers.ts +12 -0
- package/src/model/monomer-lib/const.ts +3 -0
- package/src/model/monomer-lib/lib-wrapper.ts +119 -0
- package/src/model/parsing-validation/format-detector.ts +57 -0
- package/src/model/parsing-validation/sequence-validator.ts +52 -0
- package/src/model/sequence-to-structure-utils/const.ts +1 -0
- package/src/{utils/structures-works → model/sequence-to-structure-utils}/mol-transformations.ts +33 -41
- package/src/model/sequence-to-structure-utils/monomer-code-parser.ts +92 -0
- package/src/model/sequence-to-structure-utils/sdf-tab.ts +97 -0
- package/src/model/sequence-to-structure-utils/sequence-to-molfile.ts +409 -0
- package/src/package-test.ts +3 -1
- package/src/package.ts +113 -91
- package/src/tests/const.ts +24 -0
- package/src/tests/formats-support.ts +40 -0
- package/src/tests/formats-to-helm.ts +53 -0
- package/src/tests/helm-to-nucleotides.ts +28 -0
- package/src/view/const/main-tab.ts +3 -0
- package/src/view/const/view.ts +10 -0
- package/src/view/css/axolabs-tab.css +1 -0
- package/src/view/css/colored-text-input.css +27 -0
- package/src/view/css/main-tab.css +46 -0
- package/src/view/css/sdf-tab.css +39 -0
- package/src/view/monomer-lib-viewer/viewer.ts +22 -0
- package/src/view/tabs/axolabs.ts +719 -0
- package/src/view/tabs/main.ts +174 -0
- package/src/view/tabs/sdf.ts +193 -0
- package/src/view/utils/app-info-dialog.ts +18 -0
- package/src/view/utils/colored-input/colored-text-input.ts +56 -0
- package/src/view/utils/colored-input/input-painters.ts +44 -0
- package/src/view/utils/draw-molecule.ts +86 -0
- package/src/view/utils/molecule-img.ts +106 -0
- package/src/view/view.ts +127 -0
- package/tsconfig.json +12 -18
- package/webpack.config.js +17 -4
- package/README.md +0 -84
- package/css/style.css +0 -18
- package/img/Sequence Translator Axolabs.png +0 -0
- package/jest.config.js +0 -33
- package/setup-unlink-clean.cmd +0 -14
- package/setup-unlink-clean.sh +0 -21
- package/setup.cmd +0 -14
- package/setup.sh +0 -37
- package/src/__jest__/remote.test.ts +0 -77
- package/src/__jest__/test-node.ts +0 -97
- package/src/apps/oligo-sd-file-app.ts +0 -58
- package/src/autostart/calculations.ts +0 -40
- package/src/autostart/constants.ts +0 -37
- package/src/autostart/registration.ts +0 -306
- package/src/axolabs-tab/axolabs-tab.ts +0 -873
- package/src/axolabs-tab/define-pattern.ts +0 -874
- package/src/hardcode-to-be-eliminated/ICDs.ts +0 -3
- package/src/hardcode-to-be-eliminated/IDPs.ts +0 -3
- package/src/hardcode-to-be-eliminated/const.ts +0 -5
- package/src/hardcode-to-be-eliminated/constants.ts +0 -101
- package/src/hardcode-to-be-eliminated/converters.ts +0 -323
- package/src/hardcode-to-be-eliminated/map.ts +0 -720
- package/src/hardcode-to-be-eliminated/salts.ts +0 -2
- package/src/hardcode-to-be-eliminated/sources.ts +0 -3
- package/src/hardcode-to-be-eliminated/users.ts +0 -3
- package/src/main-tab/main-tab.ts +0 -210
- package/src/sdf-tab/sdf-tab.ts +0 -163
- package/src/sdf-tab/sequence-codes-tools.ts +0 -347
- package/src/tests/smiles-tests.ts +0 -458
- package/src/utils/const.ts +0 -0
- package/src/utils/helpers.ts +0 -28
- package/src/utils/parse.ts +0 -27
- package/src/utils/sdf-add-columns.ts +0 -118
- package/src/utils/sdf-save-table.ts +0 -56
- package/src/utils/structures-works/draw-molecule.ts +0 -84
- package/src/utils/structures-works/from-monomers.ts +0 -266
- package/test-SequenceTranslator-6288c2fbe346-695b7b55.html +0 -259
- package/vendors/openchemlib-full.js +0 -293
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import * as grok from 'datagrok-api/grok';
|
|
2
|
-
import * as ui from 'datagrok-api/ui';
|
|
3
|
-
import * as DG from 'datagrok-api/dg';
|
|
4
|
-
import {_package} from '../package';
|
|
5
|
-
import {FileSource} from 'datagrok-api/dg';
|
|
6
|
-
|
|
7
|
-
export class OligoSdFileApp {
|
|
8
|
-
df!: DG.DataFrame;
|
|
9
|
-
|
|
10
|
-
constructor() {}
|
|
11
|
-
|
|
12
|
-
async init(srcDf?: DG.DataFrame): Promise<void> {
|
|
13
|
-
let dataDf: DG.DataFrame;
|
|
14
|
-
if (srcDf) {
|
|
15
|
-
dataDf = srcDf;
|
|
16
|
-
} else {
|
|
17
|
-
const dfFn: string = 'System:AppData/SequenceTranslator/test input_Nov28_Duplex_dimer.xlsx';
|
|
18
|
-
dataDf = await this.loadData(dfFn);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
this.setData(dataDf);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async loadData(dfFn: string): Promise<DG.DataFrame> {
|
|
25
|
-
//
|
|
26
|
-
const dataDf: DG.DataFrame = await grok.data.files.openTable(dfFn);
|
|
27
|
-
return dataDf;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async setData(df: DG.DataFrame): Promise<void> {
|
|
31
|
-
if (this.viewed) {
|
|
32
|
-
await this.destroyView();
|
|
33
|
-
this.viewed = false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
this.df = df;
|
|
37
|
-
|
|
38
|
-
if (!this.viewed) {
|
|
39
|
-
await this.buildView();
|
|
40
|
-
this.viewed = true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private viewed: boolean = false;
|
|
45
|
-
private tView?: DG.TableView;
|
|
46
|
-
|
|
47
|
-
async destroyView(): Promise<void> {
|
|
48
|
-
this.tView!.close();
|
|
49
|
-
delete this.tView;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async buildView(): Promise<void> {
|
|
53
|
-
console.debug('SequenceTranslator: OligoSdFileApp.buildView() ');
|
|
54
|
-
|
|
55
|
-
this.tView = grok.shell.addTableView(this.df);
|
|
56
|
-
this.tView.path = this.tView.basePath = 'func/SequenceTranslator.oligoSdFileApp';
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as DG from 'datagrok-api/dg';
|
|
2
|
-
|
|
3
|
-
import {sortByStringLengthInDescendingOrder} from '../utils/helpers';
|
|
4
|
-
import {MODIFICATIONS} from '../hardcode-to-be-eliminated/map';
|
|
5
|
-
|
|
6
|
-
export function saltMass(
|
|
7
|
-
saltNames: string[], saltsMolWeightList: number[], equivalentsCol: DG.Column, i: number, saltCol: DG.Column
|
|
8
|
-
): number {
|
|
9
|
-
const saltRowIndex = saltNames.indexOf(saltCol.get(i));
|
|
10
|
-
return (
|
|
11
|
-
saltRowIndex == -1 || saltsMolWeightList[saltRowIndex] == DG.FLOAT_NULL || equivalentsCol.get(i) == DG.INT_NULL
|
|
12
|
-
) ?
|
|
13
|
-
DG.FLOAT_NULL :
|
|
14
|
-
saltsMolWeightList[saltRowIndex] * equivalentsCol.get(i);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function saltMolWeigth(
|
|
18
|
-
saltNamesList: string[], saltCol: DG.Column, saltsMolWeightList: number[], i: number
|
|
19
|
-
): number {
|
|
20
|
-
const saltRowIndex = saltNamesList.indexOf(saltCol.get(i));
|
|
21
|
-
return (saltRowIndex == -1) ? DG.FLOAT_NULL : saltsMolWeightList[saltRowIndex];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function batchMolWeight(compoundMolWeightCol: DG.Column, saltMassCol: DG.Column, i: number): number {
|
|
25
|
-
return (compoundMolWeightCol.getString(i) == '' || saltMassCol.getString(i) == '') ?
|
|
26
|
-
DG.FLOAT_NULL :
|
|
27
|
-
compoundMolWeightCol.get(i) + saltMassCol.get(i);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function molecularWeight(sequence: string, weightsObj: { [index: string]: number }): number {
|
|
31
|
-
const codes = sortByStringLengthInDescendingOrder(Object.keys(weightsObj)).concat(Object.keys(MODIFICATIONS));
|
|
32
|
-
let weight = 0;
|
|
33
|
-
let i = 0;
|
|
34
|
-
while (i < sequence.length) {
|
|
35
|
-
const matchedCode = codes.find((s) => s == sequence.slice(i, i + s.length))!;
|
|
36
|
-
weight += weightsObj[sequence.slice(i, i + matchedCode.length)];
|
|
37
|
-
i += matchedCode.length;
|
|
38
|
-
}
|
|
39
|
-
return weight - 61.97;
|
|
40
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export const SEQUENCE_TYPES = {
|
|
2
|
-
SENSE_STRAND: 'SS',
|
|
3
|
-
ANTISENSE_STRAND: 'AS',
|
|
4
|
-
DUPLEX: 'Duplex',
|
|
5
|
-
TRIPLEX: 'Triplex',
|
|
6
|
-
DIMER: 'Dimer',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const COL_NAMES = {
|
|
10
|
-
CHEMISTRY: 'Chemistry',
|
|
11
|
-
NUMBER: 'Number',
|
|
12
|
-
TYPE: 'Type',
|
|
13
|
-
CHEMISTRY_NAME: 'Chemistry Name',
|
|
14
|
-
INTERNAL_COMPOUND_ID: 'Internal compound ID',
|
|
15
|
-
IDP: 'IDP',
|
|
16
|
-
SEQUENCE: 'Sequence',
|
|
17
|
-
COMPOUND_NAME: 'Compound Name',
|
|
18
|
-
COMPOUND_COMMENTS: 'Compound Comments',
|
|
19
|
-
SALT: 'Salt',
|
|
20
|
-
EQUIVALENTS: 'Equivalents',
|
|
21
|
-
PURITY: 'Purity',
|
|
22
|
-
COMPOUND_MOL_WEIGHT: 'Cpd MW',
|
|
23
|
-
SALT_MOL_WEIGHT: 'Salt MW',
|
|
24
|
-
SALT_MASS: 'Salt mass',
|
|
25
|
-
BATCH_MOL_WEIGHT: 'Batch MW',
|
|
26
|
-
SOURCE: 'Source',
|
|
27
|
-
ICD: 'ICD',
|
|
28
|
-
OWNER: 'Owner',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const GENERATED_COL_NAMES = [
|
|
32
|
-
COL_NAMES.COMPOUND_NAME,
|
|
33
|
-
COL_NAMES.COMPOUND_COMMENTS,
|
|
34
|
-
COL_NAMES.COMPOUND_MOL_WEIGHT,
|
|
35
|
-
COL_NAMES.SALT_MASS,
|
|
36
|
-
COL_NAMES.BATCH_MOL_WEIGHT,
|
|
37
|
-
];
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import * as grok from 'datagrok-api/grok';
|
|
2
|
-
import * as ui from 'datagrok-api/ui';
|
|
3
|
-
import * as DG from 'datagrok-api/dg';
|
|
4
|
-
import {
|
|
5
|
-
siRnaBioSpringToGcrs, siRnaAxolabsToGcrs, gcrsToNucleotides, asoGapmersBioSpringToGcrs, gcrsToMermade12,
|
|
6
|
-
siRnaNucleotidesToGcrs
|
|
7
|
-
} from '../hardcode-to-be-eliminated/converters';
|
|
8
|
-
import {weightsObj, SYNTHESIZERS} from '../hardcode-to-be-eliminated/map';
|
|
9
|
-
import {SEQUENCE_TYPES, COL_NAMES, GENERATED_COL_NAMES} from './constants';
|
|
10
|
-
import {saltMass, saltMolWeigth, molecularWeight, batchMolWeight} from './calculations';
|
|
11
|
-
import {isValidSequence} from '../sdf-tab/sequence-codes-tools';
|
|
12
|
-
import {sequenceToMolV3000} from '../utils/structures-works/from-monomers';
|
|
13
|
-
import {linkStrandsV3000} from '../utils/structures-works/mol-transformations';
|
|
14
|
-
import {stringify, download, removeEmptyRows, differenceOfTwoArrays} from '../utils/helpers';
|
|
15
|
-
|
|
16
|
-
import {SALTS_CSV} from '../hardcode-to-be-eliminated/salts';
|
|
17
|
-
import {USERS_CSV} from '../hardcode-to-be-eliminated/users';
|
|
18
|
-
import {ICDS} from '../hardcode-to-be-eliminated/ICDs';
|
|
19
|
-
import {SOURCES} from '../hardcode-to-be-eliminated/sources';
|
|
20
|
-
import {IDPS} from '../hardcode-to-be-eliminated/IDPs';
|
|
21
|
-
|
|
22
|
-
import {sdfAddColumns} from '../utils/sdf-add-columns';
|
|
23
|
-
import {sdfSaveTable} from '../utils/sdf-save-table';
|
|
24
|
-
|
|
25
|
-
const enum PREFIXES {
|
|
26
|
-
AS = 'AS',
|
|
27
|
-
SS = 'SS',
|
|
28
|
-
AS1 = 'AS1',
|
|
29
|
-
AS2 = 'AS2'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const enum SEQ_TYPE {
|
|
33
|
-
AS = 'AS',
|
|
34
|
-
SS = 'SS',
|
|
35
|
-
DUPLEX = 'Duplex',
|
|
36
|
-
DIMER = 'Dimer',
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Computable categories of sequence types */
|
|
40
|
-
const enum SEQ_TYPE_CATEGORY {
|
|
41
|
-
AS_OR_SS,
|
|
42
|
-
DUPLEX,
|
|
43
|
-
DIMER,
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Map between types and their categories inferrable from 'Sequence' column */
|
|
47
|
-
const typeCategoryMap = {
|
|
48
|
-
[SEQ_TYPE.AS]: SEQ_TYPE_CATEGORY.AS_OR_SS,
|
|
49
|
-
[SEQ_TYPE.SS]: SEQ_TYPE_CATEGORY.AS_OR_SS,
|
|
50
|
-
[SEQ_TYPE.DIMER]: SEQ_TYPE_CATEGORY.DIMER,
|
|
51
|
-
[SEQ_TYPE.DUPLEX]: SEQ_TYPE_CATEGORY.DUPLEX,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
/** Style used for cells in 'Type' column */
|
|
55
|
-
const typeColCellStyle = {
|
|
56
|
-
'display': 'flex',
|
|
57
|
-
'justify-content': 'center',
|
|
58
|
-
'align-items': 'center',
|
|
59
|
-
'text-color': 'var(--grey-5)', // --grey-6 does not match other cells
|
|
60
|
-
'width': '100%',
|
|
61
|
-
'height': '100%',
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const pinkBackground = {
|
|
65
|
-
'background-color': '#ff8080',
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/** Style used for a cell with invalid value */
|
|
69
|
-
const typeColErrorStyle = Object.assign({}, pinkBackground, typeColCellStyle);
|
|
70
|
-
|
|
71
|
-
export function sdfHandleErrorUI(msgPrefix: string, df: DG.DataFrame, rowI: number, err: any) {
|
|
72
|
-
const errStr: string = err.toString();
|
|
73
|
-
const errMsg: string = msgPrefix + `row #${rowI + 1}, name: '${df.get('Chemistry Name', rowI)}', ` +
|
|
74
|
-
`type: ${df.get('Type', rowI)} error: ${errStr}.`;
|
|
75
|
-
grok.shell.warning(errMsg);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/** Determine the category of the value specified in 'Types' column */
|
|
79
|
-
function getActualTypeClass(actualType: string): SEQ_TYPE_CATEGORY {
|
|
80
|
-
if (Object.keys(typeCategoryMap).includes(actualType))
|
|
81
|
-
return typeCategoryMap[actualType as SEQ_TYPE];
|
|
82
|
-
else
|
|
83
|
-
throw new Error('Some types in \'Types\' column are invalid ');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function isASorSS(splittedLines: string[][]): boolean {
|
|
87
|
-
return splittedLines.length === 1 && splittedLines[0].length === 1;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** Check whether the number of lines and prefixes in the 'Sequence' string
|
|
91
|
-
* are valid */
|
|
92
|
-
function verifyPrefixes(splittedLines: string[][], allowedPrefixes: Set<PREFIXES>, allowedLength: number): boolean {
|
|
93
|
-
const lengthCriterion = splittedLines.length === allowedLength;
|
|
94
|
-
let prefixCriterion = true;
|
|
95
|
-
for (const line of splittedLines) {
|
|
96
|
-
const prefix = line[0];
|
|
97
|
-
prefixCriterion &&= (allowedPrefixes.has(prefix as PREFIXES));
|
|
98
|
-
}
|
|
99
|
-
return lengthCriterion && prefixCriterion;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function isDuplex(splittedLines: string[][]): boolean {
|
|
103
|
-
const allowedPrefixes = new Set([PREFIXES.SS, PREFIXES.AS]);
|
|
104
|
-
return verifyPrefixes(splittedLines, allowedPrefixes, 2);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function isDimer(splittedLines: string[][]): boolean {
|
|
108
|
-
const allowedPrefixes = new Set([PREFIXES.SS, PREFIXES.AS1, PREFIXES.AS2]);
|
|
109
|
-
return verifyPrefixes(splittedLines, allowedPrefixes, 3);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function inferTypeClassFromSequence(seq: string): SEQ_TYPE_CATEGORY {
|
|
113
|
-
const lines = seq.split('\n');
|
|
114
|
-
const splittedLines = [];
|
|
115
|
-
for (const line of lines)
|
|
116
|
-
splittedLines.push(line.split(' '));
|
|
117
|
-
if (isASorSS(splittedLines))
|
|
118
|
-
return SEQ_TYPE_CATEGORY.AS_OR_SS;
|
|
119
|
-
else if (isDuplex(splittedLines))
|
|
120
|
-
return SEQ_TYPE_CATEGORY.DUPLEX;
|
|
121
|
-
else if (isDimer(splittedLines))
|
|
122
|
-
return SEQ_TYPE_CATEGORY.DIMER;
|
|
123
|
-
else
|
|
124
|
-
throw new Error('Some cells in \'Sequence\' column have wrong formatting');
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/** Compare type specified in 'Type' column to that computed from 'Sequence' column */
|
|
128
|
-
function validateType(actualType: string, seq: string): boolean {
|
|
129
|
-
if (actualType === '' && seq === '')
|
|
130
|
-
return true;
|
|
131
|
-
else
|
|
132
|
-
return getActualTypeClass(actualType) === inferTypeClassFromSequence(seq);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function oligoSdFileGrid(view: DG.TableView): void {
|
|
136
|
-
const typeColName = 'Type';
|
|
137
|
-
const seqColName = 'Sequence';
|
|
138
|
-
const grid = view.grid;
|
|
139
|
-
const df = view.dataFrame;
|
|
140
|
-
const typeCol = df.getCol(typeColName);
|
|
141
|
-
grid.columns.byName(typeColName)!.cellType = 'html';
|
|
142
|
-
const seqCol = df.getCol(seqColName);
|
|
143
|
-
grid.onCellPrepare((gridCell: DG.GridCell) => {
|
|
144
|
-
if (gridCell.isTableCell && gridCell.gridColumn.column!.name === typeColName) {
|
|
145
|
-
let isValidType = false;
|
|
146
|
-
let formattingError = false;
|
|
147
|
-
try {
|
|
148
|
-
isValidType = validateType(gridCell.cell.value, seqCol.get(gridCell.tableRow!.idx));
|
|
149
|
-
} catch {
|
|
150
|
-
formattingError = true;
|
|
151
|
-
}
|
|
152
|
-
const el = ui.div(
|
|
153
|
-
gridCell.cell.value, isValidType ? {style: typeColCellStyle} : {style: typeColErrorStyle}
|
|
154
|
-
);
|
|
155
|
-
gridCell.style.element = el;
|
|
156
|
-
const msg = formattingError ? 'Sequence pattern or Type value has wrong formatting' :
|
|
157
|
-
'Input in Type column doesn\'t match the Sequence pattern';
|
|
158
|
-
if (!isValidType)
|
|
159
|
-
ui.tooltip.bind(el, msg);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function autostartOligoSdFileSubscription() {
|
|
165
|
-
grok.events.onViewAdded.subscribe((v: any) => {
|
|
166
|
-
if (v.type === DG.VIEW_TYPE.TABLE_VIEW) {
|
|
167
|
-
if (v.dataFrame.columns.contains(COL_NAMES.TYPE)) {
|
|
168
|
-
oligoSdFileGrid(v);
|
|
169
|
-
oligoSdFile(v.dataFrame);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Should be removed after fixing bug https://github.com/datagrok-ai/public/issues/808
|
|
173
|
-
grok.events.onContextMenu.subscribe((args) => {
|
|
174
|
-
if (!(args.args.context instanceof DG.Grid)) return;
|
|
175
|
-
const grid: DG.Grid = args.args.context as DG.Grid;
|
|
176
|
-
const menu: DG.Menu = args.args.menu;
|
|
177
|
-
|
|
178
|
-
const seqCol = grid.table.currentCol; // /^[fsACGUacgu]{6,}$/
|
|
179
|
-
if (DG.Detector.sampleCategories(seqCol,
|
|
180
|
-
(s) => /(\(invabasic\)|\(GalNAc-2-JNJ\)|A|U|G|C){6,}$/.test(s))) {
|
|
181
|
-
menu.item('Convert raw nucleotides to GCRS', () => {
|
|
182
|
-
grid.table.columns.addNewString(seqCol.name + ' to GCRS').init((i: number) => {
|
|
183
|
-
return siRnaNucleotidesToGcrs(seqCol.get(i));
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
} else if (DG.Detector.sampleCategories(seqCol,
|
|
187
|
-
(s) => /(\(invabasic\)|\(GalNAc-2-JNJ\)|f|s|A|C|G|U|a|c|g|u){6,}$/.test(s))) {
|
|
188
|
-
menu.item('Convert Axolabs to GCRS', () => {
|
|
189
|
-
grid.table.columns.addNewString(seqCol.name + ' to GCRS').init((i: number) => {
|
|
190
|
-
return siRnaAxolabsToGcrs(seqCol.get(i));
|
|
191
|
-
});
|
|
192
|
-
}); // /^[fmpsACGU]{6,}$/
|
|
193
|
-
} else if (DG.Detector.sampleCategories(seqCol,
|
|
194
|
-
(s) => /(\(invabasic\)|\(GalNAc-2-JNJ\)|f|m|ps|A|C|G|U){6,}$/.test(s)) ||
|
|
195
|
-
DG.Detector.sampleCategories(seqCol, (s) => /^(?=.*moe)(?=.*5mC)(?=.*ps){6,}/.test(s))) {
|
|
196
|
-
menu.item('Convert GCRS to raw', () => {
|
|
197
|
-
grid.table.columns.addNewString(seqCol.name + ' to raw').init((i: number) => {
|
|
198
|
-
return gcrsToNucleotides(seqCol.get(i));
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
menu.item('Convert GCRS to MM12', () => {
|
|
202
|
-
grid.table.columns.addNewString(seqCol.name + ' to MM12').init((i: number) => {
|
|
203
|
-
return gcrsToMermade12(seqCol.get(i));
|
|
204
|
-
});
|
|
205
|
-
}); // /^[*56789ATGC]{6,}$/
|
|
206
|
-
} else if (DG.Detector.sampleCategories(seqCol,
|
|
207
|
-
(s) => /(\(invabasic\)|\(GalNAc-2-JNJ\)|\*|5|6|7|8|9|A|T|G|C){6,}$/.test(s))) {
|
|
208
|
-
menu.item('Convert Biospring to GCRS', () => {
|
|
209
|
-
const seqCol = grid.table.currentCol;
|
|
210
|
-
grid.table.columns.addNewString(seqCol.name + ' to GCRS').init((i: number) => {
|
|
211
|
-
return asoGapmersBioSpringToGcrs(seqCol.get(i));
|
|
212
|
-
});
|
|
213
|
-
}); // /^[*1-8]{6,}$/
|
|
214
|
-
} else if (DG.Detector.sampleCategories(seqCol,
|
|
215
|
-
(s) => /(\(invabasic\)|\(GalNAc-2-JNJ\)|\*|1|2|3|4|5|6|7|8){6,}$/.test(s))) {
|
|
216
|
-
menu.item('Convert Biospring to GCRS', () => {
|
|
217
|
-
grid.table.columns.addNewString(seqCol.name + ' to GCRS').init((i: number) => {
|
|
218
|
-
return siRnaBioSpringToGcrs(seqCol.get(i));
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export function oligoSdFile(table: DG.DataFrame) {
|
|
228
|
-
const saltsDf = DG.DataFrame.fromCsv(SALTS_CSV);
|
|
229
|
-
const usersDf = DG.DataFrame.fromCsv(USERS_CSV);
|
|
230
|
-
const sourcesDf = DG.DataFrame.fromCsv(SOURCES);
|
|
231
|
-
const icdsDf = DG.DataFrame.fromCsv(ICDS);
|
|
232
|
-
const idpsDf = DG.DataFrame.fromCsv(IDPS);
|
|
233
|
-
|
|
234
|
-
const saltCol = table.getCol(COL_NAMES.SALT);
|
|
235
|
-
const equivalentsCol = table.getCol(COL_NAMES.EQUIVALENTS);
|
|
236
|
-
|
|
237
|
-
const saltsMolWeightList: number[] = saltsDf.getCol('MOLWEIGHT').toList();
|
|
238
|
-
const saltNamesList: string[] = saltsDf.getCol('DISPLAY').toList();
|
|
239
|
-
|
|
240
|
-
let newDf: DG.DataFrame | undefined = undefined;
|
|
241
|
-
|
|
242
|
-
const d = ui.div([
|
|
243
|
-
ui.icons.edit(() => {
|
|
244
|
-
d.innerHTML = '';
|
|
245
|
-
if (table.getCol(COL_NAMES.IDP).type != DG.COLUMN_TYPE.STRING)
|
|
246
|
-
table.changeColumnType(COL_NAMES.IDP, DG.COLUMN_TYPE.STRING);
|
|
247
|
-
d.append(
|
|
248
|
-
ui.divH([
|
|
249
|
-
ui.button('Add columns',
|
|
250
|
-
() => {
|
|
251
|
-
newDf = sdfAddColumns(table, saltNamesList, saltsMolWeightList,
|
|
252
|
-
(rowI, err) => { sdfHandleErrorUI('Error on ', table, rowI, err); });
|
|
253
|
-
grok.shell.getTableView(newDf.name).grid.columns.setOrder(Object.values(COL_NAMES));
|
|
254
|
-
},
|
|
255
|
-
`Add columns: '${GENERATED_COL_NAMES.join(`', '`)}'`),
|
|
256
|
-
ui.bigButton('Save SDF', () => {
|
|
257
|
-
const df: DG.DataFrame = newDf ?? table;
|
|
258
|
-
sdfSaveTable(df,
|
|
259
|
-
(rowI, err) => { sdfHandleErrorUI('Skip ', df, rowI, err); });
|
|
260
|
-
}, 'Save SD file'),
|
|
261
|
-
])
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
const view = grok.shell.getTableView(table.name);
|
|
265
|
-
view.grid.setOptions({rowHeight: 45});
|
|
266
|
-
view.dataFrame.getCol(COL_NAMES.TYPE).setTag(DG.TAGS.CHOICES, stringify(Object.values(SEQUENCE_TYPES)));
|
|
267
|
-
view.dataFrame.getCol(COL_NAMES.OWNER).setTag(DG.TAGS.CHOICES, stringify(usersDf.columns.byIndex(0).toList()));
|
|
268
|
-
view.dataFrame.getCol(COL_NAMES.SALT).setTag(DG.TAGS.CHOICES, stringify(saltsDf.columns.byIndex(0).toList()));
|
|
269
|
-
view.dataFrame.getCol(COL_NAMES.SOURCE).setTag(DG.TAGS.CHOICES, stringify(sourcesDf.columns.byIndex(0).toList()));
|
|
270
|
-
view.dataFrame.getCol(COL_NAMES.ICD).setTag(DG.TAGS.CHOICES, stringify(icdsDf.columns.byIndex(0).toList()));
|
|
271
|
-
view.dataFrame.getCol(COL_NAMES.IDP).setTag(DG.TAGS.CHOICES, stringify(idpsDf.columns.byIndex(0).toList()));
|
|
272
|
-
|
|
273
|
-
grok.events.onContextMenu.subscribe((args) => {
|
|
274
|
-
if (!(args.args.context instanceof DG.Grid)) return;
|
|
275
|
-
const grid: DG.Grid = args.args.context as DG.Grid;
|
|
276
|
-
const menu: DG.Menu = args.args.menu;
|
|
277
|
-
|
|
278
|
-
if ([COL_NAMES.TYPE, COL_NAMES.OWNER, COL_NAMES.SALT, COL_NAMES.SOURCE, COL_NAMES.ICD, COL_NAMES.IDP]
|
|
279
|
-
.includes(grid.table.currentCol.name)) {
|
|
280
|
-
menu.item('Fill Column With Value', () => {
|
|
281
|
-
const v = grid.table.currentCell.value;
|
|
282
|
-
grid.table.currentCell.column.init(v);
|
|
283
|
-
for (let i = 0; i < view.dataFrame.rowCount; i++)
|
|
284
|
-
updateCalculatedColumns(view.dataFrame, i);
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
view.dataFrame.onDataChanged.subscribe(() => {
|
|
290
|
-
const colName = view.dataFrame.currentCol.name;
|
|
291
|
-
if ([COL_NAMES.SALT, COL_NAMES.EQUIVALENTS, COL_NAMES.SALT_MOL_WEIGHT].includes(colName))
|
|
292
|
-
updateCalculatedColumns(view.dataFrame, view.dataFrame.currentRowIdx);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
function updateCalculatedColumns(t: DG.DataFrame, i: number): void {
|
|
296
|
-
const smValue = saltMass(saltNamesList, saltsMolWeightList, equivalentsCol, i, saltCol);
|
|
297
|
-
t.getCol(COL_NAMES.SALT_MASS).set(i, smValue, false);
|
|
298
|
-
const smwValue = saltMolWeigth(saltNamesList, saltCol, saltsMolWeightList, i);
|
|
299
|
-
t.getCol(COL_NAMES.SALT_MOL_WEIGHT).set(i, smwValue, false);
|
|
300
|
-
const bmw = batchMolWeight(t.getCol(COL_NAMES.COMPOUND_MOL_WEIGHT), t.getCol(COL_NAMES.SALT_MASS), i);
|
|
301
|
-
t.getCol(COL_NAMES.BATCH_MOL_WEIGHT).set(i, bmw, false);
|
|
302
|
-
}
|
|
303
|
-
}),
|
|
304
|
-
]);
|
|
305
|
-
grok.shell.v.setRibbonPanels([[d]]);
|
|
306
|
-
}
|