@datagrok/bio 2.1.12 → 2.4.2

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.
Files changed (59) hide show
  1. package/README.md +11 -12
  2. package/css/helm.css +10 -0
  3. package/detectors.js +83 -59
  4. package/dist/package-test.js +2 -13168
  5. package/dist/package-test.js.map +1 -0
  6. package/dist/package.js +2 -10560
  7. package/dist/package.js.map +1 -0
  8. package/dockerfiles/Dockerfile +86 -0
  9. package/files/icons/composition-analysis.svg +17 -0
  10. package/files/icons/sequence-diversity-viewer.svg +4 -0
  11. package/files/icons/sequence-similarity-viewer.svg +4 -0
  12. package/files/icons/vdregions-viewer.svg +22 -0
  13. package/files/icons/weblogo-viewer.svg +7 -0
  14. package/files/tests/testUrl.csv +11 -0
  15. package/files/tests/toAtomicLevelTest.csv +4 -0
  16. package/package.json +24 -25
  17. package/src/analysis/sequence-activity-cliffs.ts +11 -9
  18. package/src/analysis/sequence-search-base-viewer.ts +2 -1
  19. package/src/analysis/sequence-similarity-viewer.ts +3 -3
  20. package/src/analysis/sequence-space.ts +2 -1
  21. package/src/calculations/monomerLevelMols.ts +4 -4
  22. package/src/package-test.ts +9 -2
  23. package/src/package.ts +215 -131
  24. package/src/substructure-search/substructure-search.ts +19 -16
  25. package/src/tests/Palettes-test.ts +1 -1
  26. package/src/tests/WebLogo-positions-test.ts +113 -57
  27. package/src/tests/_first-tests.ts +9 -0
  28. package/src/tests/activity-cliffs-tests.ts +8 -7
  29. package/src/tests/activity-cliffs-utils.ts +17 -9
  30. package/src/tests/bio-tests.ts +4 -5
  31. package/src/tests/checkInputColumn-tests.ts +1 -1
  32. package/src/tests/converters-test.ts +52 -17
  33. package/src/tests/detectors-benchmark-tests.ts +3 -2
  34. package/src/tests/detectors-tests.ts +177 -172
  35. package/src/tests/fasta-export-tests.ts +1 -1
  36. package/src/tests/monomer-libraries-tests.ts +34 -0
  37. package/src/tests/pepsea-tests.ts +21 -0
  38. package/src/tests/renderers-test.ts +21 -19
  39. package/src/tests/sequence-space-test.ts +6 -4
  40. package/src/tests/similarity-diversity-tests.ts +4 -4
  41. package/src/tests/splitters-test.ts +4 -5
  42. package/src/tests/substructure-filters-tests.ts +23 -1
  43. package/src/tests/utils/sequences-generators.ts +1 -1
  44. package/src/tests/utils.ts +2 -1
  45. package/src/tests/viewers.ts +16 -0
  46. package/src/utils/cell-renderer.ts +88 -35
  47. package/src/utils/constants.ts +7 -6
  48. package/src/utils/convert.ts +8 -2
  49. package/src/utils/monomer-lib.ts +174 -0
  50. package/src/utils/multiple-sequence-alignment.ts +44 -20
  51. package/src/utils/pepsea.ts +78 -0
  52. package/src/utils/save-as-fasta.ts +2 -1
  53. package/src/utils/ui-utils.ts +15 -3
  54. package/src/viewers/vd-regions-viewer.ts +113 -72
  55. package/src/viewers/web-logo-viewer.ts +1031 -0
  56. package/src/widgets/bio-substructure-filter.ts +38 -24
  57. package/tsconfig.json +71 -72
  58. package/webpack.config.js +4 -11
  59. package/dist/vendors-node_modules_datagrok-libraries_ml_src_workers_dimensionality-reducer_js.js +0 -9039
@@ -13,15 +13,16 @@ import {helmSubstructureSearch, linearSubstructureSearch} from '../substructure-
13
13
  import {Subject, Subscription} from 'rxjs';
14
14
  import * as C from '../utils/constants';
15
15
  import {updateDivInnerHTML} from '../utils/ui-utils';
16
- import {NOTATION} from '@datagrok-libraries/bio';
17
- import { delay } from '@datagrok-libraries/utils/src/test';
16
+ import {TAGS as bioTAGS, NOTATION} from '@datagrok-libraries/bio/src/utils/macromolecule';
17
+ import {delay} from '@datagrok-libraries/utils/src/test';
18
+ import {debounceTime} from 'rxjs/operators';
18
19
 
19
20
  export class BioSubstructureFilter extends DG.Filter {
20
21
  bioFilter: FastaFilter | SeparatorFilter | HelmFilter | null = null;
21
22
  bitset: DG.BitSet | null = null;
22
23
  loader: HTMLDivElement = ui.loader();
23
24
  onBioFilterChangedSubs?: Subscription;
24
- notation: string | undefined = '';
25
+ notation: string | undefined = undefined;
25
26
 
26
27
  get calculating(): boolean { return this.loader.style.display == 'initial'; }
27
28
 
@@ -39,6 +40,20 @@ export class BioSubstructureFilter extends DG.Filter {
39
40
  return !this.calculating && this.bitset != null;
40
41
  }
41
42
 
43
+ get _debounceTime(): number {
44
+ if (this.column == null)
45
+ return 1000;
46
+ const length = this.column.length;
47
+ const minLength = 500;
48
+ const maxLength = 10000;
49
+ const msecMax = 1000;
50
+ if (length < minLength) return 0;
51
+ if (length > maxLength) return msecMax;
52
+ return Math.floor(msecMax * ((length - minLength) / (maxLength - minLength)));
53
+ }
54
+
55
+ //column name setter overload
56
+
42
57
  constructor() {
43
58
  super();
44
59
  this.root = ui.divV([]);
@@ -48,16 +63,18 @@ export class BioSubstructureFilter extends DG.Filter {
48
63
  attach(dataFrame: DG.DataFrame): void {
49
64
  super.attach(dataFrame);
50
65
  this.column = dataFrame.columns.bySemType(DG.SEMTYPE.MACROMOLECULE);
51
- this.columnName = this.column?.name;
52
- this.notation = this.column?.getTag(DG.TAGS.UNITS);
66
+ this.columnName ??= this.column?.name;
67
+ this.notation ??= this.column?.getTag(DG.TAGS.UNITS);
53
68
  this.bioFilter = this.notation === NOTATION.FASTA ?
54
69
  new FastaFilter() : this.notation === NOTATION.SEPARATOR ?
55
- new SeparatorFilter(this.column!.getTag(C.TAGS.SEPARATOR)) : new HelmFilter();
70
+ new SeparatorFilter(this.column!.getTag(bioTAGS.separator)) : new HelmFilter();
56
71
  this.root.appendChild(this.bioFilter!.filterPanel);
57
72
  this.root.appendChild(this.loader);
58
73
 
59
74
  this.onBioFilterChangedSubs?.unsubscribe();
60
- const onChangedEvent: any = this.bioFilter.onChanged;
75
+
76
+ let onChangedEvent: any = this.bioFilter.onChanged;
77
+ onChangedEvent = onChangedEvent.pipe(debounceTime(this._debounceTime));
61
78
  this.onBioFilterChangedSubs = onChangedEvent.subscribe(async (_: any) => await this._onInputChanged());
62
79
  }
63
80
 
@@ -79,7 +96,7 @@ export class BioSubstructureFilter extends DG.Filter {
79
96
 
80
97
  /** Override to load filter state. */
81
98
  applyState(state: any): void {
82
- super.applyState(state);
99
+ super.applyState(state); //column, columnName
83
100
  if (state.bioSubstructure)
84
101
  this.bioFilter!.substructure = state.bioSubstructure;
85
102
 
@@ -133,12 +150,14 @@ abstract class BioFilterBase {
133
150
  }
134
151
 
135
152
  class FastaFilter extends BioFilterBase {
136
- substructureInput: DG.InputBase<string> = ui.stringInput('', '', () => {
137
- this.onChanged.next();
138
- }, {placeholder: 'Substructure'});
153
+ readonly substructureInput: DG.InputBase<string>;
139
154
 
140
155
  constructor() {
141
156
  super();
157
+
158
+ this.substructureInput = ui.stringInput('', '', () => {
159
+ this.onChanged.next();
160
+ }, {placeholder: 'Substructure'});
142
161
  }
143
162
 
144
163
  get filterPanel() {
@@ -159,13 +178,15 @@ class FastaFilter extends BioFilterBase {
159
178
  }
160
179
 
161
180
  export class SeparatorFilter extends FastaFilter {
162
- separatorInput: DG.InputBase<string> = ui.stringInput('', '', () => {
163
- this.onChanged.next();
164
- }, {placeholder: 'Separator'});
181
+ readonly separatorInput: DG.InputBase<string>;
165
182
  colSeparator = '';
166
183
 
167
184
  constructor(separator: string) {
168
185
  super();
186
+
187
+ this.separatorInput = ui.stringInput('', '', () => {
188
+ this.onChanged.next();
189
+ }, {placeholder: 'Separator'});
169
190
  this.colSeparator = separator;
170
191
  this.separatorInput.value = separator;
171
192
  }
@@ -212,7 +233,8 @@ export class HelmFilter extends BioFilterBase {
212
233
  ui.dialog({showHeader: false, showFooter: true})
213
234
  .add(editorDiv)
214
235
  .onOK(() => {
215
- const helmString = webEditor.canvas.getHelm(true).replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
236
+ const helmString = webEditor.canvas.getHelm(true)
237
+ .replace(/<\/span>/g, '').replace(/<span style='background:#bbf;'>/g, '');
216
238
  this.helmSubstructure = helmString;
217
239
  this.updateFilterPanel(this.substructure);
218
240
  setTimeout(() => { this.onChanged.next(); }, 10);
@@ -242,15 +264,7 @@ export class HelmFilter extends BioFilterBase {
242
264
  this._filterPanel.parentElement!.clientWidth;
243
265
  const height = width / 2;
244
266
  if (!helmString) {
245
- const editDivStyle = {style: {
246
- width: `${width}px`,
247
- height: `${height/2}px`,
248
- textAlign: 'center',
249
- verticalAlign: 'middle',
250
- lineHeight: `${height/2}px`,
251
- border: '1px solid #dbdcdf'
252
- }};
253
- const editDiv = ui.divText('Click to edit', editDivStyle);
267
+ const editDiv = ui.divText('Click to edit', 'helm-substructure-filter');
254
268
  updateDivInnerHTML(this._filterPanel, editDiv);
255
269
  } else {
256
270
  updateDivInnerHTML(this._filterPanel, this.helmEditor.host);
package/tsconfig.json CHANGED
@@ -1,74 +1,73 @@
1
1
  {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Basic Options */
6
- // "incremental": true, /* Enable incremental compilation */
7
- "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8
- "module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
- "lib": ["es2020", "dom", "ES2021.String"], /* Specify library files to be included in the compilation. */
10
- // "allowJs": true, /* Allow javascript files to be compiled. */
11
- // "checkJs": true, /* Report errors in .js files. */
12
- // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
13
- // "declaration": true, /* Generates corresponding '.d.ts' file. */
14
- // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
- // "sourceMap": true, /* Generates corresponding '.map' file. */
16
- // "outFile": "./", /* Concatenate and emit output to single file. */
17
- // "outDir": "./", /* Redirect output structure to the directory. */
18
- // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19
- // "composite": true, /* Enable project compilation */
20
- // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21
- // "removeComments": true, /* Do not emit comments to output. */
22
- // "noEmit": true, /* Do not emit outputs. */
23
- // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24
- // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25
- // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26
-
27
- /* Strict Type-Checking Options */
28
- "strict": true, /* Enable all strict type-checking options. */
29
- // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30
- // "strictNullChecks": true, /* Enable strict null checks. */
31
- // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32
- // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33
- // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
34
- // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35
- // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36
-
37
- /* Additional Checks */
38
- // "noUnusedLocals": true, /* Report errors on unused locals. */
39
- // "noUnusedParameters": true, /* Report errors on unused parameters. */
40
- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41
- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
43
- // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
44
-
45
- /* Module Resolution Options */
46
- "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
47
- // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
48
- // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
49
- // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
50
- // "typeRoots": [], /* List of folders to include type definitions from. */
51
- // "types": [], /* Type declaration files to be included in compilation. */
52
- // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
53
- "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
54
- // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
55
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
56
-
57
- /* Source Map Options */
58
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
59
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
61
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
62
-
63
- /* Experimental Options */
64
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
65
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
66
-
67
- /* Advanced Options */
68
- "skipLibCheck": false, /* Skip type checking of declaration files. */
69
- "forceConsistentCasingInFileNames": true,
70
- /* Disallow inconsistently-cased references to the same file. */
71
- //"jsx": "react"
72
- }
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+
5
+ /* Basic Options */
6
+ // "incremental": true, /* Enable incremental compilation */
7
+ "target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8
+ "module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
+ "lib": ["es2020", "dom", "ES2021.String"], /* Specify library files to be included in the compilation. */
10
+ // "allowJs": true, /* Allow javascript files to be compiled. */
11
+ // "checkJs": true, /* Report errors in .js files. */
12
+ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
13
+ // "declaration": true, /* Generates corresponding '.d.ts' file. */
14
+ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
+ "sourceMap": true, /* Generates corresponding '.map' file. */
16
+ // "outFile": "./", /* Concatenate and emit output to single file. */
17
+ // "outDir": "./", /* Redirect output structure to the directory. */
18
+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19
+ // "composite": true, /* Enable project compilation */
20
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
21
+ // "removeComments": true, /* Do not emit comments to output. */
22
+ // "noEmit": true, /* Do not emit outputs. */
23
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24
+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25
+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26
+
27
+ /* Strict Type-Checking Options */
28
+ "strict": true, /* Enable all strict type-checking options. */
29
+ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30
+ // "strictNullChecks": true, /* Enable strict null checks. */
31
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
33
+ "strictPropertyInitialization": false, /* Enable strict checking of property initialization in classes. */
34
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
35
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
36
+
37
+ /* Additional Checks */
38
+ // "noUnusedLocals": true, /* Report errors on unused locals. */
39
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
40
+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42
+ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
43
+ // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
44
+
45
+ /* Module Resolution Options */
46
+ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
47
+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
48
+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
49
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
50
+ // "typeRoots": [], /* List of folders to include type definitions from. */
51
+ // "types": [], /* Type declaration files to be included in compilation. */
52
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
53
+ "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
54
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
55
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
56
+
57
+ /* Source Map Options */
58
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
61
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
62
+
63
+ /* Experimental Options */
64
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
65
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
66
+
67
+ /* Advanced Options */
68
+ "skipLibCheck": false, /* Skip type checking of declaration files. */
69
+ "forceConsistentCasingInFileNames": true,
70
+ /* Disallow inconsistently-cased references to the same file. */
71
+ //"jsx": "react"
73
72
  }
74
-
73
+ }
package/webpack.config.js CHANGED
@@ -17,19 +17,12 @@ module.exports = {
17
17
  },
18
18
  module: {
19
19
  rules: [
20
- {
21
- test: /\.ts(x?)$/,
22
- use: 'ts-loader',
23
- exclude: /node_modules/,
24
- },
25
- {
26
- test: /\.css$/,
27
- use: ['style-loader', 'css-loader'],
28
- exclude: /node_modules/,
29
- },
20
+ {test: /\.js$/, enforce: 'pre', use: ['source-map-loader'], exclude: /node_modules/},
21
+ {test: /\.ts(x?)$/, use: 'ts-loader', exclude: /node_modules/},
22
+ {test: /\.css$/, use: ['style-loader', 'css-loader']},
30
23
  ],
31
24
  },
32
- devtool: 'inline-source-map',
25
+ devtool: 'source-map',
33
26
  externals: {
34
27
  'datagrok-api/dg': 'DG',
35
28
  'datagrok-api/grok': 'grok',