@datagrok/bio 2.11.5 → 2.11.7

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.
@@ -0,0 +1,44 @@
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
+
5
+
6
+ import {_package} from '../package';
7
+ import {delay} from '@datagrok-libraries/utils/src/test';
8
+
9
+ type IDetectorReport = { categoriesSample: any[], rejectReason: string };
10
+
11
+ type IDetectorDebugStore = { last: IDetectorReport };
12
+
13
+ export async function detectMacromoleculeProbeDo(
14
+ csv: string, colName: string | undefined, probeCount: number
15
+ ): Promise<void> {
16
+ const pi = DG.TaskBarProgressIndicator.create(`detectMacromolecule probe ...`);
17
+ try {
18
+ let progressLast = 0;
19
+ const store: IDetectorDebugStore = await grok.functions.call('Bio:detectMacromoleculeEnableStore');
20
+ let failCount: number = 0;
21
+ for (let i = 0; i < probeCount; ++i) {
22
+ const df: DG.DataFrame = DG.DataFrame.fromCsv(csv);
23
+ const seqCol = colName ? df.getCol(colName) : df.columns.byIndex(0);
24
+
25
+ const detectRes: string = await grok.functions.call('Bio:detectMacromolecule', {col: seqCol});
26
+ if (detectRes !== DG.SEMTYPE.MACROMOLECULE) {
27
+ ++failCount;
28
+ console.warn(`Reject reason: ${store.last.rejectReason}`);
29
+ }
30
+ const progress = i / probeCount;
31
+ if ((progress - progressLast) >= 0.1) {
32
+ progressLast = progress;
33
+ pi.update(100 * progress, `detectMacromolecule probe ${failCount}/${i}/${probeCount} ...`);
34
+ await delay(0);
35
+ }
36
+ }
37
+ if (failCount > 0)
38
+ grok.shell.warning(`detectMacromolecule failed ${failCount} / ${probeCount}`);
39
+ else
40
+ grok.shell.info(`detectMacromolecule success ${probeCount}`);
41
+ } finally {
42
+ pi.close();
43
+ }
44
+ }