@datagrok/peptides 0.0.1 → 0.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.
package/tsconfig.json CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  /* Basic Options */
6
6
  // "incremental": true, /* Enable incremental compilation */
7
- "target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
8
- "module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
- // "lib": [], /* Specify library files to be included in the compilation. */
10
- "allowJs": true, /* Allow javascript files to be compiled. */
7
+ "target": "es2018", /* 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"], /* Specify library files to be included in the compilation. */
10
+ // "allowJs": true, /* Allow javascript files to be compiled. */
11
11
  // "checkJs": true, /* Report errors in .js files. */
12
12
  // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
13
13
  // "declaration": true, /* Generates corresponding '.d.ts' file. */
14
14
  // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
15
15
  // "sourceMap": true, /* Generates corresponding '.map' file. */
16
16
  // "outFile": "./", /* Concatenate and emit output to single file. */
17
- "outDir": "./dist", /* Redirect output structure to the directory. */
17
+ // "outDir": "./", /* Redirect output structure to the directory. */
18
18
  // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
19
19
  // "composite": true, /* Enable project compilation */
20
20
  // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
@@ -26,7 +26,7 @@
26
26
 
27
27
  /* Strict Type-Checking Options */
28
28
  "strict": true, /* Enable all strict type-checking options. */
29
- "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
29
+ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
30
30
  // "strictNullChecks": true, /* Enable strict null checks. */
31
31
  // "strictFunctionTypes": true, /* Enable strict checking of function types. */
32
32
  // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
@@ -40,11 +40,10 @@
40
40
  // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
41
41
  // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42
42
  // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
43
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an 'override' modifier. */
44
43
  // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */
45
44
 
46
45
  /* Module Resolution Options */
47
- "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
46
+ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
48
47
  // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
49
48
  // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
50
49
  // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
@@ -56,17 +55,17 @@
56
55
  // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
57
56
 
58
57
  /* Source Map Options */
59
- // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
60
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
61
- // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
62
- // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
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. */
63
62
 
64
63
  /* Experimental Options */
65
64
  // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
66
65
  // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
67
66
 
68
67
  /* Advanced Options */
69
- "skipLibCheck": true, /* Skip type checking of declaration files. */
68
+ "skipLibCheck": true, /* Skip type checking of declaration files. */
70
69
  "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
71
70
  }
72
71
  }
package/webpack.config.js CHANGED
@@ -3,19 +3,19 @@ const path = require('path');
3
3
  module.exports = {
4
4
  mode: 'development',
5
5
  entry: {
6
- package: './src/package.ts'
6
+ package: './src/package.ts',
7
7
  },
8
8
  module: {
9
9
  rules: [
10
10
  {
11
- test: /\.tsx?$/,
11
+ test: /\.ts?$/,
12
12
  use: 'ts-loader',
13
13
  exclude: /node_modules/,
14
14
  },
15
15
  ],
16
16
  },
17
17
  resolve: {
18
- extensions: ['.tsx', '.ts', '.js'],
18
+ extensions: ['.tsx', '.js', '.ts'],
19
19
  },
20
20
  devtool: 'inline-source-map',
21
21
  externals: {
@@ -24,7 +24,7 @@ module.exports = {
24
24
  'datagrok-api/ui': 'ui',
25
25
  'openchemlib/full.js': 'OCL',
26
26
  'rxjs': 'rxjs',
27
- 'rxjs/operators': 'rxjs.operators'
27
+ 'rxjs/operators': 'rxjs.operators',
28
28
  },
29
29
  output: {
30
30
  filename: '[name].js',
@@ -1,42 +0,0 @@
1
- import * as DG from 'datagrok-api/dg';
2
-
3
- export function splitAlignedPeptides(peptideColumn: DG.Column) {
4
- let splitPeptidesArray: string[][] = [];
5
- let isFirstRun = true;
6
- let splitted: string[];
7
-
8
- for (const peptideStr of peptideColumn.toList()) {
9
- splitted = peptideStr.split('-');
10
-
11
- if (isFirstRun) {
12
- for (let i = 0; i < splitted.length; i++) {
13
- splitPeptidesArray.push([]);
14
- }
15
- isFirstRun = false;
16
- }
17
-
18
- splitted.forEach((value, index) => {
19
- splitPeptidesArray[index].push(value === '' ? '-' : value);
20
- });
21
- }
22
-
23
- //create column names list
24
- let columnNames = ['N'];
25
- columnNames = columnNames.concat(splitPeptidesArray.map((_, index) => `${index + 1 < 10 ? 0 : ''}${index +1 }`));
26
- columnNames.push('C');
27
-
28
- // filter out the columns with the same values
29
- splitPeptidesArray = splitPeptidesArray.filter((positionArray, index) => {
30
- const isRetained = new Set(positionArray).size > 1;
31
- if (!isRetained) {
32
- columnNames.splice(index, 1);
33
- }
34
- return isRetained;
35
- });
36
-
37
- const columnsArray = splitPeptidesArray.map((positionArray, index) => {
38
- return DG.Column.fromList('string', columnNames[index], positionArray);
39
- });
40
-
41
- return DG.DataFrame.fromColumns(columnsArray);
42
- }
package/src/utils/misc.ts DELETED
@@ -1,101 +0,0 @@
1
- //@ts-ignore: no types
2
- import * as jStat from 'jstat';
3
-
4
- type testStats = {
5
- 'p-value': number,
6
- 'Mean difference'?: number,
7
- 'Median difference'?: number,
8
- 'p-value more': number,
9
- 'p-value less': number,
10
- };
11
-
12
- export function tTest(arr1: number[], arr2: number[], alpha=0.05, devKnown=false, devEqual=false): testStats {
13
- const m1: number = jStat.mean(arr1);
14
- const m2: number = jStat.mean(arr2);
15
- const v1: number = jStat.variance(arr1);
16
- const v2: number = jStat.variance(arr2);
17
- const n1 = arr1.length;
18
- const n2 = arr2.length;
19
-
20
- let wv1;
21
- let wv2;
22
- let wv;
23
- let Z;
24
- let K;
25
- let pMore;
26
- let pLess;
27
- let pTot;
28
-
29
- if (!devKnown) {
30
- if (!devEqual) {
31
- wv1 = v1 / n1;
32
- wv2 = v2 / n2;
33
- Z = (m1 - m2) / Math.sqrt(wv1 + wv2);
34
- K = Math.pow((wv1 + wv2), 2) / (wv1 * wv1 / (n1 - 1) + wv2 * wv2 / (n2 - 1));
35
-
36
- pLess = jStat.studentt.cdf(Z, K);
37
- pMore = 1 - pLess;
38
- pTot = 2 * (pLess < pMore ? pLess : pMore);
39
- } else {
40
- K = n1 + n2 - 2;
41
- wv = (v1 * (n1 - 1) + v2 * (n2 - 1)) / K;
42
- Z = Math.sqrt(n1 * n2 / (n1 + n2)) * (m1 - m2) / wv;
43
-
44
- pMore = 1 - jStat.studentt.cdf(Z, K);
45
- pLess = jStat.studentt.cdf(Z, K);
46
- pTot = 2 * (pLess < pMore ? pLess : pMore);
47
- }
48
- } else {
49
- wv1 = v1 / n1;
50
- wv2 = v2 / n2;
51
- Z = (m1 - m2) / Math.sqrt(wv1 + wv2);
52
-
53
- pLess = jStat.normal.pdf(Z, 0, 1);
54
- pMore = 1 - pLess;
55
- pTot = 2 * (pLess < pMore ? pLess : pMore);
56
- }
57
- return {'p-value': pTot, 'Mean difference': m1 - m2, 'p-value more': pMore, 'p-value less': pLess};
58
- }
59
-
60
- export function uTest(x: number[], y: number[], continuity=true): testStats {
61
- const xy = x.concat(y);
62
- const n1 = x.length;
63
- const n2 = y.length;
64
- const med1 = jStat.median(x);
65
- const med2 = jStat.median(y);
66
-
67
- const ranks = jStat.rank(xy);
68
-
69
- const R1 = jStat.sum(ranks.slice(0, n1));
70
- const U1 = R1 - n1 * (n1 + 1) / 2;
71
- const U2 = n1 * n2 - U1;
72
- const U = U1 > U2 ? U1 : U2;
73
-
74
- const mu = n1 * n2 / 2;
75
- const n = n1 + n2;
76
-
77
- const tieTerm = _tieTerm(ranks);
78
- const s = Math.sqrt(n1 * n2 / 12 * ((n + 1) - tieTerm / (n* (n - 1))));
79
-
80
- let numerator = U - mu;
81
-
82
- if (continuity) {
83
- numerator -= 0.5;
84
- }
85
-
86
- const z = numerator / s;
87
-
88
- const p = 2 * (1 - jStat.normal.cdf(z, 0, 1));
89
-
90
- return {'p-value': p, 'Median difference': med1 - med2, 'p-value more': p, 'p-value less': p};
91
- }
92
-
93
- function _tieTerm(ranks: number[]): number {
94
- const ties: {[key: number]: number} = {};
95
-
96
- ranks.forEach((num) => {
97
- ties[num] = (ties[num] || 0) + 1;
98
- });
99
-
100
- return jStat.sum(Object.values(ties));
101
- }