@datagrok/bio 2.11.7 → 2.11.10
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/CHANGELOG.md +3 -0
- package/dist/361.js +1 -1
- package/dist/361.js.map +1 -1
- package/dist/381.js +1 -1
- package/dist/381.js.map +1 -1
- package/dist/44.js +2 -0
- package/dist/44.js.map +1 -0
- package/dist/770.js +1 -1
- package/dist/770.js.map +1 -1
- package/dist/79.js +1 -1
- package/dist/79.js.map +1 -1
- package/dist/868.js +1 -1
- package/dist/868.js.map +1 -1
- package/dist/931.js +3 -0
- package/dist/931.js.map +1 -0
- package/dist/package-test.js +1 -1
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/files/data/sample_HELM_50.csv +51 -0
- package/files/tests/{to-atomic-level-dna-output.csv → to-atomic-level-dna-fasta-output.csv} +6616 -6626
- package/files/tests/{to-atomic-level-msa-output.csv → to-atomic-level-msa-separator-output.csv} +1429 -1440
- package/files/tests/{to-atomic-level-peptides-output.csv → to-atomic-level-peptides-fasta-output.csv} +13341 -13405
- package/files/tests/to-atomic-level-pt-fasta-2.mol +45 -0
- package/package.json +6 -6
- package/src/analysis/sequence-space.ts +16 -9
- package/src/package.ts +27 -12
- package/src/substructure-search/substructure-search.ts +10 -7
- package/src/tests/activity-cliffs-tests.ts +28 -12
- package/src/tests/monomer-libraries-tests.ts +21 -5
- package/src/tests/renderers-test.ts +0 -62
- package/src/tests/scoring.ts +29 -8
- package/src/tests/substructure-filters-tests.ts +29 -24
- package/src/tests/to-atomic-level-tests.ts +75 -43
- package/src/tests/utils.ts +9 -2
- package/src/utils/monomer-lib.ts +30 -42
- package/src/widgets/bio-substructure-filter.ts +3 -0
- package/dist/172.js +0 -2
- package/dist/172.js.map +0 -1
- package/dist/196.js +0 -3
- package/dist/196.js.map +0 -1
- /package/dist/{196.js.LICENSE.txt → 931.js.LICENSE.txt} +0 -0
|
@@ -3,13 +3,20 @@ 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
|
|
6
|
+
import wu from 'wu';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {before, after, category, test, expectArray, expect} from '@datagrok-libraries/utils/src/test';
|
|
9
9
|
import {_toAtomicLevel} from '@datagrok-libraries/bio/src/monomer-works/to-atomic-level';
|
|
10
10
|
import {IMonomerLib} from '@datagrok-libraries/bio/src/types/index';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import {ALPHABET, NOTATION, TAGS as bioTAGS} from '@datagrok-libraries/bio/src/utils/macromolecule';
|
|
12
|
+
import {getMonomerLibHelper, IMonomerLibHelper} from '@datagrok-libraries/bio/src/monomer-works/monomer-utils';
|
|
13
|
+
import {
|
|
14
|
+
getUserLibSettings, LibSettings, setUserLibSettings, setUserLibSettingsForTests
|
|
15
|
+
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
16
|
+
import {UnitsHandler} from '@datagrok-libraries/bio/src/utils/units-handler';
|
|
17
|
+
|
|
18
|
+
import {toAtomicLevel} from '../package';
|
|
19
|
+
import {_package} from '../package-test';
|
|
13
20
|
|
|
14
21
|
const appPath = 'System:AppData/Bio';
|
|
15
22
|
const fileSource = new DG.FileSource(appPath);
|
|
@@ -27,9 +34,9 @@ const inputPath: { [k: string]: string } = {
|
|
|
27
34
|
};
|
|
28
35
|
|
|
29
36
|
const outputPath: { [k: string]: string } = {
|
|
30
|
-
PT: 'tests/to-atomic-level-peptides-output.csv',
|
|
31
|
-
DNA: 'tests/to-atomic-level-dna-output.csv',
|
|
32
|
-
MSA: 'tests/to-atomic-level-msa-output.csv',
|
|
37
|
+
PT: 'tests/to-atomic-level-peptides-fasta-output.csv',
|
|
38
|
+
DNA: 'tests/to-atomic-level-dna-fasta-output.csv',
|
|
39
|
+
MSA: 'tests/to-atomic-level-msa-separator-output.csv',
|
|
33
40
|
};
|
|
34
41
|
|
|
35
42
|
const inputColName = 'sequence';
|
|
@@ -41,24 +48,24 @@ category('toAtomicLevel', async () => {
|
|
|
41
48
|
|
|
42
49
|
let monomerLibHelper: IMonomerLibHelper;
|
|
43
50
|
/** Backup actual user's monomer libraries settings */
|
|
44
|
-
let
|
|
51
|
+
let userLibSettings: LibSettings;
|
|
45
52
|
|
|
46
53
|
before(async () => {
|
|
47
54
|
monomerLibHelper = await getMonomerLibHelper();
|
|
48
|
-
|
|
55
|
+
userLibSettings = await getUserLibSettings();
|
|
49
56
|
// Clear settings to test default
|
|
50
|
-
await
|
|
57
|
+
await setUserLibSettingsForTests();
|
|
51
58
|
await monomerLibHelper.loadLibraries(true);
|
|
52
59
|
|
|
53
60
|
for (const key in testNames) {
|
|
54
|
-
sourceDf[key] = await fileSource.
|
|
61
|
+
sourceDf[key] = DG.DataFrame.fromCsv((await fileSource.readAsText(inputPath[key])).replace(/\n$/, ''));
|
|
55
62
|
await grok.data.detectSemanticTypes(sourceDf[key]);
|
|
56
|
-
targetDf[key] = await fileSource.
|
|
63
|
+
targetDf[key] = DG.DataFrame.fromCsv((await fileSource.readAsText(outputPath[key])).replace(/\n$/, ''));
|
|
57
64
|
}
|
|
58
65
|
});
|
|
59
66
|
|
|
60
67
|
after(async () => {
|
|
61
|
-
await
|
|
68
|
+
await setUserLibSettings(userLibSettings);
|
|
62
69
|
await monomerLibHelper.loadLibraries(true);
|
|
63
70
|
});
|
|
64
71
|
|
|
@@ -67,15 +74,15 @@ category('toAtomicLevel', async () => {
|
|
|
67
74
|
await toAtomicLevel(source, inputCol, false);
|
|
68
75
|
const obtainedCol = source.getCol(outputColName);
|
|
69
76
|
const expectedCol = target.getCol(outputColName);
|
|
70
|
-
const obtainedArray =
|
|
71
|
-
const expectedArray =
|
|
77
|
+
const obtainedArray: string[] = wu(obtainedCol.values()).map((mol) => polishMolfile(mol)).toArray();
|
|
78
|
+
const expectedArray: string[] = wu(expectedCol.values()).map((mol) => polishMolfile(mol)).toArray();
|
|
72
79
|
expectArray(obtainedArray, expectedArray);
|
|
73
80
|
}
|
|
74
81
|
|
|
75
82
|
for (const key in testNames) {
|
|
76
83
|
test(`${testNames[key]}`, async () => {
|
|
77
84
|
await getTestResult(sourceDf[key], targetDf[key]);
|
|
78
|
-
}
|
|
85
|
+
});
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
enum csvTests {
|
|
@@ -93,38 +100,38 @@ category('toAtomicLevel', async () => {
|
|
|
93
100
|
|
|
94
101
|
const csvData: { [key in csvTests]: string } = {
|
|
95
102
|
[csvTests.fastaDna]: `seq
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
ACGTCACGTC
|
|
104
|
+
CAGTGTCAGTGT
|
|
105
|
+
TTCAACTTCAAC`,
|
|
99
106
|
[csvTests.fastaRna]: `seq
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
ACGUCACGUC
|
|
108
|
+
CAGUGUCAGUGU
|
|
109
|
+
UUCAACUUCAAC`,
|
|
103
110
|
[csvTests.fastaPt]: `seq
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
111
|
+
FWPHEYFWPHEY
|
|
112
|
+
YNRQWYVYNRQWYV
|
|
113
|
+
MKPSEYVMKPSEYV`,
|
|
107
114
|
[csvTests.separatorDna]: `seq
|
|
108
|
-
A/C/G/T/C
|
|
109
|
-
C/A/G/T/G/T
|
|
110
|
-
T/T/C/A/A/C`,
|
|
115
|
+
A/C/G/T/C/A/C/G/T/C
|
|
116
|
+
C/A/G/T/G/T/C/A/G/T/G/T
|
|
117
|
+
T/T/C/A/A/C/T/T/C/A/A/C`,
|
|
111
118
|
[csvTests.separatorRna]: `seq
|
|
112
|
-
A*C*G*U*C
|
|
113
|
-
C*A*G*U*G*U
|
|
114
|
-
U*U*C*A*A*C`,
|
|
119
|
+
A*C*G*U*C*A*C*G*U*C
|
|
120
|
+
C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2}$$$`,
|
|
132
|
+
PEPTIDE1{meI.D-gGlu.Aca.N.T.dE.Thr_PO3H2.Aca.D.Thr_PO3H2.Aca.D}$$$
|
|
133
|
+
PEPTIDE1{meI.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$
|
|
134
|
+
PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2.Thr_PO3H2.Aca.Tyr_PO3H2}$$$`,
|
|
128
135
|
};
|
|
129
136
|
|
|
130
137
|
/** Also detects semantic types
|
|
@@ -134,7 +141,7 @@ PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$`,
|
|
|
134
141
|
async function readCsv(key: csvTests): Promise<DG.DataFrame> {
|
|
135
142
|
// Always recreate test data frame from CSV for reproducible detector behavior in tests.
|
|
136
143
|
const csv: string = csvData[key];
|
|
137
|
-
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
|
|
144
|
+
const df: DG.DataFrame = DG.DataFrame.fromCsv(csv.replace(/\n$/, ''));
|
|
138
145
|
await grok.data.detectSemanticTypes(df);
|
|
139
146
|
return df;
|
|
140
147
|
}
|
|
@@ -170,10 +177,35 @@ PEPTIDE1{Lys_Boc.hHis.Aca.Cys_SEt.T.dK.Thr_PO3H2.Aca.Tyr_PO3H2}$$$`,
|
|
|
170
177
|
test('helm', async () => {
|
|
171
178
|
await _testToAtomicLevel(await readCsv(csvTests.helm), 'seq', monomerLibHelper);
|
|
172
179
|
});
|
|
180
|
+
|
|
181
|
+
test('ptFasta2', async () => {
|
|
182
|
+
const srcCsv: string = `seq\nAR`;
|
|
183
|
+
const tgtMol: string = await _package.files.readAsText('tests/to-atomic-level-pt-fasta-2.mol');
|
|
184
|
+
|
|
185
|
+
const srcDf = DG.DataFrame.fromCsv(srcCsv);
|
|
186
|
+
const seqCol = srcDf.getCol('seq');
|
|
187
|
+
seqCol.semType = DG.SEMTYPE.MACROMOLECULE;
|
|
188
|
+
seqCol.setTag(DG.TAGS.UNITS, NOTATION.FASTA);
|
|
189
|
+
seqCol.setTag(bioTAGS.alphabet, ALPHABET.PT);
|
|
190
|
+
const uh = UnitsHandler.getOrCreate(seqCol);
|
|
191
|
+
const resCol = (await _testToAtomicLevel(srcDf, 'seq', monomerLibHelper))!;
|
|
192
|
+
expect(polishMolfile(resCol.get(0)), polishMolfile(tgtMol));
|
|
193
|
+
});
|
|
173
194
|
});
|
|
174
195
|
|
|
175
|
-
async function _testToAtomicLevel(
|
|
196
|
+
async function _testToAtomicLevel(
|
|
197
|
+
df: DG.DataFrame, seqColName: string = 'seq', monomerLibHelper: IMonomerLibHelper
|
|
198
|
+
): Promise<DG.Column | null> {
|
|
176
199
|
const seqCol: DG.Column<string> = df.getCol(seqColName);
|
|
177
200
|
const monomerLib: IMonomerLib = monomerLibHelper.getBioLib();
|
|
178
|
-
const
|
|
201
|
+
const res = await _toAtomicLevel(df, seqCol, monomerLib);
|
|
202
|
+
if (res.warnings.length > 0)
|
|
203
|
+
_package.logger.warning(`_toAtomicLevel() warnings ${res.warnings.join('\n')}`);
|
|
204
|
+
return res.col;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function polishMolfile(mol: string): string {
|
|
208
|
+
return mol.replaceAll('\r\n', '\n')
|
|
209
|
+
.replace(/\n$/, '')
|
|
210
|
+
.split('\n').map((l) => l.trimEnd()).join('\n');
|
|
179
211
|
}
|
package/src/tests/utils.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
|
|
4
|
+
import {delay, expect, testEvent} from '@datagrok-libraries/utils/src/test';
|
|
5
|
+
|
|
4
6
|
import {_package} from '../package-test';
|
|
5
|
-
import {delay, expect} from '@datagrok-libraries/utils/src/test';
|
|
6
7
|
|
|
7
8
|
export async function loadFileAsText(name: string): Promise<string> {
|
|
8
9
|
return await _package.files.readAsText(name);
|
|
@@ -24,7 +25,7 @@ export async function createTableView(tableName: string): Promise<DG.TableView>
|
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
|
-
* Tests if a table has non
|
|
28
|
+
* Tests if a table has non-zero rows and columns.
|
|
28
29
|
*
|
|
29
30
|
* @param {DG.DataFrame} table Target table. */
|
|
30
31
|
export function _testTableIsNotEmpty(table: DG.DataFrame): void {
|
|
@@ -38,3 +39,9 @@ export async function awaitContainerStart(ms: number = 10000): Promise<void> {
|
|
|
38
39
|
if (pepseaContainer.status !== 'started' && pepseaContainer.status !== 'checking')
|
|
39
40
|
await delay(ms);
|
|
40
41
|
}
|
|
42
|
+
|
|
43
|
+
export async function awaitGrid(grid: DG.Grid, timeout: number = 5000): Promise<void> {
|
|
44
|
+
await delay(0);
|
|
45
|
+
await testEvent(grid.onAfterDrawContent, () => {},
|
|
46
|
+
() => { grid.invalidate(); }, timeout);
|
|
47
|
+
}
|
package/src/utils/monomer-lib.ts
CHANGED
|
@@ -5,7 +5,11 @@ import * as DG from 'datagrok-api/dg';
|
|
|
5
5
|
import {Observable, Subject} from 'rxjs';
|
|
6
6
|
|
|
7
7
|
import {IMonomerLib, Monomer} from '@datagrok-libraries/bio/src/types/index';
|
|
8
|
+
import {
|
|
9
|
+
LibSettings, getUserLibSettings, setUserLibSettings, LIB_PATH
|
|
10
|
+
} from '@datagrok-libraries/bio/src/monomer-works/lib-settings';
|
|
8
11
|
import {MolfileHandler} from '@datagrok-libraries/chem-meta/src/parsing-utils/molfile-handler';
|
|
12
|
+
import {PolyToolMonomerLibHandler} from '@datagrok-libraries/bio/src/utils/poly-tool/monomer-lib-handler';
|
|
9
13
|
import {
|
|
10
14
|
createJsonMonomerLibFromSdf,
|
|
11
15
|
IMonomerLibHelper,
|
|
@@ -16,17 +20,6 @@ import {
|
|
|
16
20
|
|
|
17
21
|
import {_package} from '../package';
|
|
18
22
|
|
|
19
|
-
import {PolyToolMonomerLibHandler} from '@datagrok-libraries/bio/src/utils/poly-tool/monomer-lib-handler';
|
|
20
|
-
|
|
21
|
-
// -- Monomer libraries --
|
|
22
|
-
export const LIB_STORAGE_NAME = 'Libraries';
|
|
23
|
-
export const LIB_PATH = 'System:AppData/Bio/libraries/';
|
|
24
|
-
export const LIB_DEFAULT: { [fileName: string]: string } = {'HELMCoreLibrary.json': 'HELMCoreLibrary.json'};
|
|
25
|
-
|
|
26
|
-
/** Type for user settings of monomer library set to use. */
|
|
27
|
-
export type LibSettings = {
|
|
28
|
-
exclude: string[],
|
|
29
|
-
}
|
|
30
23
|
|
|
31
24
|
export async function getLibFileNameList(): Promise<string[]> {
|
|
32
25
|
// list files recursively because permissions are available for folders only
|
|
@@ -38,30 +31,6 @@ export async function getLibFileNameList(): Promise<string[]> {
|
|
|
38
31
|
return res;
|
|
39
32
|
}
|
|
40
33
|
|
|
41
|
-
let userLibSettingsPromise: Promise<void> = Promise.resolve();
|
|
42
|
-
|
|
43
|
-
export async function getUserLibSettings(): Promise<LibSettings> {
|
|
44
|
-
let res: LibSettings;
|
|
45
|
-
userLibSettingsPromise = userLibSettingsPromise.then(async () => {
|
|
46
|
-
const resStr: string = await grok.dapi.userDataStorage.getValue(LIB_STORAGE_NAME, 'Settings', true);
|
|
47
|
-
res = resStr ? JSON.parse(resStr) : {exclude: []};
|
|
48
|
-
|
|
49
|
-
// Fix empty object returned in case there is no settings stored for user
|
|
50
|
-
res.exclude = res.exclude instanceof Array ? res.exclude : [];
|
|
51
|
-
console.debug(`Bio: getUserLibSettings()\n${JSON.stringify(res, undefined, 2)}`);
|
|
52
|
-
});
|
|
53
|
-
await userLibSettingsPromise;
|
|
54
|
-
return res!;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export async function setUserLibSetting(value: LibSettings): Promise<void> {
|
|
58
|
-
userLibSettingsPromise = userLibSettingsPromise.then(async () => {
|
|
59
|
-
console.debug(`Bio: setUserLibSettings()\n${JSON.stringify(value, undefined, 2)}`);
|
|
60
|
-
await grok.dapi.userDataStorage.postValue(LIB_STORAGE_NAME, 'Settings', JSON.stringify(value), true);
|
|
61
|
-
});
|
|
62
|
-
await userLibSettingsPromise;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
34
|
export async function manageFiles() {
|
|
66
35
|
const a = ui.dialog({title: 'Manage files'})
|
|
67
36
|
//@ts-ignore
|
|
@@ -88,7 +57,7 @@ export async function getLibraryPanelUI(): Promise<DG.Widget> {
|
|
|
88
57
|
// Unchecked library add to excluded list
|
|
89
58
|
if (!settings.exclude.includes(libFileName)) settings.exclude.push(libFileName);
|
|
90
59
|
}
|
|
91
|
-
|
|
60
|
+
setUserLibSettings(settings).then(async () => {
|
|
92
61
|
await MonomerLibHelper.instance.loadLibraries(true); // from libraryPanel()
|
|
93
62
|
grok.shell.info('Monomer library user settings saved.');
|
|
94
63
|
});
|
|
@@ -199,6 +168,9 @@ export class MonomerLib implements IMonomerLib {
|
|
|
199
168
|
}
|
|
200
169
|
}
|
|
201
170
|
|
|
171
|
+
type MonomerLibWindowType = Window & { $monomerLibHelper: MonomerLibHelper };
|
|
172
|
+
declare const window: MonomerLibWindowType;
|
|
173
|
+
|
|
202
174
|
export class MonomerLibHelper implements IMonomerLibHelper {
|
|
203
175
|
private readonly _monomerLib: MonomerLib = new MonomerLib({});
|
|
204
176
|
|
|
@@ -229,7 +201,8 @@ export class MonomerLibHelper implements IMonomerLibHelper {
|
|
|
229
201
|
getUserLibSettings(),
|
|
230
202
|
]);
|
|
231
203
|
const filteredLibFnList = libFileNameList
|
|
232
|
-
.filter((libFileName) => !settings.exclude.includes(libFileName))
|
|
204
|
+
.filter((libFileName) => !settings.exclude.includes(libFileName))
|
|
205
|
+
.filter((libFileName) => settings.explicit.length > 0 ? settings.explicit.includes(libFileName) : true);
|
|
233
206
|
const libs: IMonomerLib[] = await Promise.all(filteredLibFnList
|
|
234
207
|
.map((libFileName) => {
|
|
235
208
|
//TODO handle whether files are in place
|
|
@@ -277,12 +250,13 @@ export class MonomerLibHelper implements IMonomerLibHelper {
|
|
|
277
250
|
// todo: replace by DataFrame's method after update of js-api
|
|
278
251
|
function toJson(df: DG.DataFrame): any[] {
|
|
279
252
|
return Array.from({length: df.rowCount}, (_, idx) =>
|
|
280
|
-
df.columns.names().reduce((entry: {[key: string]: any}, colName) => {
|
|
253
|
+
df.columns.names().reduce((entry: { [key: string]: any }, colName) => {
|
|
281
254
|
entry[colName] = df.get(colName, idx);
|
|
282
255
|
return entry;
|
|
283
256
|
}, {})
|
|
284
257
|
);
|
|
285
258
|
}
|
|
259
|
+
|
|
286
260
|
const df = await fileSource.readCsv(fileName);
|
|
287
261
|
const json = toJson(df);
|
|
288
262
|
const polyToolMonomerLib = new PolyToolMonomerLibHandler(json);
|
|
@@ -307,11 +281,25 @@ export class MonomerLibHelper implements IMonomerLibHelper {
|
|
|
307
281
|
return new MonomerLib(monomers);
|
|
308
282
|
}
|
|
309
283
|
|
|
310
|
-
|
|
311
|
-
|
|
284
|
+
/** Reset user settings to the specified library. WARNING: clears user * settings */
|
|
285
|
+
public async selectSpecifiedLibraries(libFileNameList: string[]): Promise<void> {
|
|
286
|
+
const invalidNames = await this.getInvalidFileNames(libFileNameList);
|
|
287
|
+
if (invalidNames.length > 0)
|
|
288
|
+
throw new Error(`Cannot select libraries ${invalidNames}: no such library in the list`);
|
|
289
|
+
const settings = await getUserLibSettings();
|
|
290
|
+
settings.exclude = (await getLibFileNameList()).filter((fileName) => !libFileNameList.includes(fileName));
|
|
291
|
+
await setUserLibSettings(settings);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
private async getInvalidFileNames(libFileNameList: string[]): Promise<string[]> {
|
|
295
|
+
const availableFileNames = await getLibFileNameList();
|
|
296
|
+
const invalidNames = libFileNameList.filter((fileName) => !availableFileNames.includes(fileName));
|
|
297
|
+
return invalidNames;
|
|
298
|
+
}
|
|
312
299
|
|
|
300
|
+
// -- Instance singleton --
|
|
313
301
|
public static get instance(): MonomerLibHelper {
|
|
314
|
-
if (!
|
|
315
|
-
return
|
|
302
|
+
if (!window.$monomerLibHelper) window.$monomerLibHelper = new MonomerLibHelper();
|
|
303
|
+
return window.$monomerLibHelper;
|
|
316
304
|
}
|
|
317
305
|
}
|
|
@@ -16,6 +16,8 @@ import {TAGS as bioTAGS, NOTATION} from '@datagrok-libraries/bio/src/utils/macro
|
|
|
16
16
|
import {delay} from '@datagrok-libraries/utils/src/test';
|
|
17
17
|
import {debounceTime} from 'rxjs/operators';
|
|
18
18
|
|
|
19
|
+
import {_package} from '../package-test';
|
|
20
|
+
|
|
19
21
|
export class BioSubstructureFilter extends DG.Filter {
|
|
20
22
|
bioFilter: BioFilterBase | null = null;
|
|
21
23
|
bitset: DG.BitSet | null = null;
|
|
@@ -118,6 +120,7 @@ export class BioSubstructureFilter extends DG.Filter {
|
|
|
118
120
|
* that would simply apply the bitset synchronously.
|
|
119
121
|
*/
|
|
120
122
|
async _onInputChanged(): Promise<void> {
|
|
123
|
+
_package.logger.debug('Bio: BioSubstructureFilter._onInputChanged(), start');
|
|
121
124
|
if (!this.isFiltering) {
|
|
122
125
|
this.bitset = null;
|
|
123
126
|
this.dataFrame?.rows.requestFilter();
|
package/dist/172.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkbio=self.webpackChunkbio||[]).push([[172],{489:(t,e,n)=>{n.d(e,{U:()=>s.U,o:()=>s.o});var s=n(5540)},5540:(t,e,n)=>{n.d(e,{U:()=>s,o:()=>o});var s,r=n(779),i=n(458),h=n(6683);!function(t){t.HAMMING="Hamming",t.LEVENSHTEIN="Levenshtein",t.NEEDLEMANN_WUNSCH="Needlemann-Wunsch",t.MONOMER_CHEMICAL_DISTANCE="Monomer chemical distance"}(s||(s={}));const o={[s.HAMMING]:r.j,[s.LEVENSHTEIN]:i.r,[s.NEEDLEMANN_WUNSCH]:h.n,[s.MONOMER_CHEMICAL_DISTANCE]:r.j}},9657:(t,e,n)=>{n.d(e,{Z:()=>s});class s{constructor(t,e=!1){if(this._length=0,this._version=0,this._updateLevel=0,this._selectedCount=0,this._selectedCountVersion=-1,this._selectedIndexesVersion=-1,this._versionedName="",this._versionedNameVersion=-1,this.SHRINK_THRESHOLD=256,"number"==typeof t){const n=t,r=s._createBuffer(n);if(e)for(let t=0;t<r.length;t++)r[t]=-1;this._data=r,this._length=n}else{if(!(t instanceof Uint32Array))throw new Error("Invalid constructor");this._data=t,this._length=e}}getRawData(){return this._data}assureGoez(t,e){if(t<0)throw new Error(`${e} should be greater than zero`)}assureInRange(t,e,n,s){if(t<e||t>n)throw new Error(`Argument ${s} (${t}) out of range (${e}, ${n})`)}copy(t,e,n){for(let s=0;s<n;s++)e[s]=t[s]}copyFrom(t){if(this._length!=t._length)throw new Error(`Lengths differ (${this._length} != ${t._length})`);this.copy(t._data,this._data,this.lengthInInts),this._version++}get length(){return this._length}get buffer(){return this._data}set buffer(t){this._data=t,this._version++}get version(){return this._version}set version(t){this._version=t}incrementVersion(t=!0){this._version++}get lengthInInts(){return Math.floor((this._length+31)/32)}get versionedName(){return this._version==this._versionedNameVersion?this._versionedName:""}set versionedName(t){this._versionedName=t,this._versionedNameVersion=this._version}get self(){return this}setLength(t){if(t<0)throw new Error("should be >= 0");if(t==this._length)return;const e=Math.floor((t+31)/32);if(e>this._data.length||e+this.SHRINK_THRESHOLD<this._data.length){const t=new Uint32Array(e);this.copy(this._data,t,e>this._data.length?this._data.length:e),this._data=t}t>this._length&&(this._length%32>0&&(this._data[this.lengthInInts-1]&=(1<<(this._length%32&31))-1),this._data.fill(0,this.lengthInInts,e)),this._length=t,this._version++}static fromAnd(t,e){if(t._length!=e._length)throw new Error(`Lengths differ (${t._length} != ${e._length})`);const n=new s(t._length);n._length=t._length,n._data=s._createBuffer(n._length),n._version=0;const r=t.lengthInInts;for(let s=0;s<r;s++)n._data[s]=t._data[s]&e._data[s];return n}static _createBuffer(t){return new Uint32Array(Math.floor((t+31)/32))}static fromValues(t){const e=new s(t.length);e._version=0;for(let n=0;n<e._length;n++)t[n]&&(e._data[Math.floor(n/32)]|=1<<(n%32&31));return e}static fromSeq(t,e){const n=new s(t);for(let s=0;s<t;++s)n.setBit(s,e(s));return n._version=0,n}static fromString(t){return s.fromSeq(t.length,(e=>"1"==t.charAt(e)))}static fromUint32Array(t,e){const n=new s(t);return n._data=e,n}static fromBytes(t){const e=t.length,n=new s(8*e);n._data=new Uint32Array(Math.floor((e+3)/4)),n._length=8*e;let r=0,i=0;for(;e-i>=4;)n._data[r++]=255&t[i]|(255&t[i+1])<<8|(255&t[i+2])<<16|(255&t[i+3])<<24,i+=4;return e-i==3&&(n._data[r]=(255&t[i+2])<<16),e-i==2&&(n._data[r]|=(255&t[i+1])<<8),e-i==1&&(n._data[r]|=255&t[i]),n._version=0,n}toString(){return`${this._length} bits, ${this.countBits(!0)} set`}equals(t){if(this==t)return!0;if(null==t)return!1;if(this._length!=t._length)return!1;if(0==this._length)return!0;for(let e=0;e<this._data.length-1;e++)if(this._data[e]!=t._data[e])return!1;for(let e=8*(this._data.length-1);e<this._length;e++)if(this.getBit(e)!=t.getBit(e))return!1;return!0}clone(){const t=new s(0,!1);return t._data=Uint32Array.from(this._data),t._length=this._length,t._version=this._version,t}init(t,e){this.setAll(!1,!1);for(let e=0;e<this._length;e++)t(e)&&(this._data[Math.floor(e/32)]|=1<<(e%32&31));return this.incrementVersion(e),this}invert(t=!0){for(let t=0;t<this._data.length;t++)this._data[t]^=-1;this.incrementVersion(t)}setAll(t,e=!1){const n=t?-1:0,s=this.lengthInInts;for(let t=0;t<s;t++)this._data[t]=n;this.incrementVersion(e)}setIndexes(t,e=!0,n=!0,s=!0){n&&this.setAll(!e,!1);for(const n of t)this.setFast(n,e);this.incrementVersion(s)}everyIndex(t,e=!0){for(const n of t)if(this.getBit(n)!=e)return!1;return!0}anyIndex(t,e=!0){for(const n of t)if(this.getBit(n)==e)return!0;return!1}setWhere(t,e=!0,n=!0,s=!0,r=!0){if(n&&r&&this.setAll(!e,!1),r)for(let n=0;n<this._length;n++)t(n)&&this.setFast(n,e);else for(let n=0;n<this._length;n++)this.setFast(n,t(n)?e:!e);this.incrementVersion(s)}getRange(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let s=t;s<e;++s)n.push(this.getBit(s));return s.fromValues(n)}getRangeAsList(t,e){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length,"to");const n=[];for(let s=t;s<e;++s)n.push(this.getBit(s));return n}setRange(t,e,n,s=!0){this.assureInRange(t,0,this._length-1,"from"),this.assureInRange(e,0,this._length-1,"to");const r=Math.min(t,e),i=Math.max(t,e);if(n)for(let t=r;t<=i;t++)this.setTrue(t);else for(let t=r;t<=i;t++)this.setFalse(t);return this.incrementVersion(s),this}setRandom(t,e,n=!0){if(t<0||t>this._length)throw new Error("n must be >= 0 && <= Count");t>this._length/2&&this.setRandom(this._length-t,!e),this.setAll(!e);for(let n=0;n<t;){const t=Math.floor(Math.random()*this._length);this.getBit(t)!=e&&(this.setFast(t,e),n++)}this.incrementVersion(n)}and(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]&=t._data[e];return this.incrementVersion(e),this}andNot(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");const n=this.lengthInInts;for(let e=0;e<n;e++)this._data[e]&=~t._data[e];return this.incrementVersion(e),this}notAnd(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]=~this._data[e]&t._data[e];return this.incrementVersion(e),this}not(t=!0){for(let t=0,e=this.lengthInInts;t<e;t++)this._data[t]=~this._data[t];return this.incrementVersion(t),this}or(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]|=t._data[e];return this.incrementVersion(e),this}xor(t,e=!0){if(this._length!=t._length)throw new Error("Array lengths differ.");for(let e=0,n=this.lengthInInts;e<n;e++)this._data[e]^=t._data[e];return this.incrementVersion(e),this}insertAt(t,e,n=!1){if(this.assureInRange(t,0,this._length,"pos"),0==e)return;const s=this._length;this.setLength(this._length+e);for(let n=s-1;n>=t;n--)this.setBit(n+e,this.getBit(n));for(let s=t;s<t+e;s++)this.setBit(s,n)}removeAt(t,e=1){if(e<0)throw new Error("n cannot be negative");if(this.assureInRange(t,0,this._length-e,"pos"),this.contains(!0))for(let n=t;n<this._length-e;n++)this.setBit(n,this.getBit(n+e));this.setLength(this._length-e)}removeByMask(t,e=!0){if(this._length!=t.length)throw new Error("length != mask.length");if(t==this)this.setLength(t.countBits(!e)),this.setAll(!e);else{let n=0;for(let s=-1;-1!=(s=t.findNext(s,!e));)this.setFast(n++,this.getBit(s));this._length=n,this._version++}return this}getBit(t){return 0!=(this._data[Math.floor(t/32)]&1<<(31&t))}setBit(t,e,n=!0){this.setFast(t,e),this._version++}setFast(t,e){e?this._data[Math.floor(t/32)]|=1<<(31&t):this._data[Math.floor(t/32)]&=~(1<<(31&t))}setTrue(t){this._data[Math.floor(t/32)]|=1<<(31&t)}setFalse(t){this._data[Math.floor(t/32)]&=~(1<<(31&t))}trueCount(){return this.countBits(!0)}falseCount(){return this.countBits(!1)}countBits(t){if(0==this._length)return 0;if(this._selectedCountVersion!=this._version){this._selectedCount=0;const t=this.lengthInInts;let e=0;for(;e<t-1;e++)for(let t=this._data[e];0!=t;t>>>=8)this._selectedCount+=s._onBitCount[255&t];let n=this._data[e];const r=31&this._length;for(0!=r&&(n&=~(4294967295<<r));0!=n;n>>>=8)this._selectedCount+=s._onBitCount[255&n];this._selectedCountVersion=this._version}return t?this._selectedCount:this._length-this._selectedCount}countWhere(t){let e=0;if(this.trueCount()==this._length)for(let n=0;n<this._length;n++)e+=t(n)?1:0;else for(let n=-1;-1!=(n=this.findNext(n,!0));)e+=t(n)?1:0;return e}andWithCountBits(t,e){if(0==this._length)return 0;let n=0;const r=this.lengthInInts;let i=0;for(;i<r-1;i++)for(let e=this._data[i]&t._data[i];0!=e;e>>>=8)n+=s._onBitCount[255&e];let h=this._data[i]&t._data[i];const o=31&this._length;for(0!=o&&(h&=~(4294967295<<o));0!=h;h>>>=8)n+=s._onBitCount[255&h];return e?n:this._length-n}clear(){this.setLength(0)}contains(t){return this.findNext(-1,t)>=0}get allTrue(){return this.countBits(!0)==this._length}get allFalse(){return this.countBits(!1)==this._length}get anyTrue(){return this.countBits(!0)>0}get anyFalse(){return this.countBits(!1)>0}findNext(t,e=!0){if(this.assureInRange(t,-1,this._length,"index"),t>=this._length-1)return-1;let n=31&(t=t<0?0:t+1);const r=this.lengthInInts;for(let i=Math.floor(t/32);i<r;i++){let r=e?this._data[i]:~this._data[i];if(0!=n)r&=4294967295<<n&4294967295,n=0;else if(!e&&-4294967296==r)continue;for(let e=0;0!=r;e+=8,r>>>=8){const n=s._firstOnBit[255&r];if(n>=0)return(t=n+32*i+e)>=this._length?-1:t}}return-1}findPrev(t,e=!0){if(0==t)return-1;this.assureInRange(t,-1,this._length,"index");let n=1+(t=t<0?this._length-1:t-1)&31;for(let r=Math.floor(t/32);r>=0;r--){let t=e?this._data[r]:~this._data[r];0!=n&&(t&=~(4294967295<<n),n=0);for(let e=24;0!=t;e-=8,t<<=8){const n=s._lastOnBit[t>>>24];if(n>=0)return n+32*r+e}}return-1}}s._onBitCount=Int8Array.from([0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,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6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7])},3659:(t,e,n)=>{n.d(e,{OW:()=>s});class s extends Float32Array{}},3979:(t,e)=>{e.H$=void 0,e.H$=function(t,e,n){var s=function(t,e,n){if(0===t.length||0===e.length)return 0;if(n&&!n.caseSensitive&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e)return 1;for(var s=0,r=t.length,i=e.length,h=Math.floor(Math.max(r,i)/2)-1,o=new Array(r),a=new Array(i),l=0;l<r;l++)for(var _=Math.max(0,l-h);_<=Math.min(i,l+h+1);_++)if(!o[l]&&!a[_]&&t[l]===e[_]){++s,o[l]=a[_]=!0;break}if(0===s)return 0;var f=0,g=0;for(l=0;l<r;l++)if(o[l]){for(;!a[g];)g++;t.charAt(l)!==e.charAt(g++)&&f++}return(s/r+s/i+(s-(f/=2))/s)/3}(t,e,n),r=0;if(s>.7){for(var i=Math.min(t.length,e.length),h=0;t[h]===e[h]&&h<4&&h<i;)++r,h++;s+=.1*r*(1-s)}return s}}}]);
|
|
2
|
-
//# sourceMappingURL=172.js.map
|