@sjcrh/proteinpaint-shared 2.188.1 → 2.190.0
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/README.md +14 -10
- package/dist/src/bulk.cnv.d.ts +2 -0
- package/dist/src/bulk.cnv.js +1 -1
- package/dist/src/bulk.cnv.js.map +3 -3
- package/dist/src/bulk.d.ts +56 -0
- package/dist/src/bulk.del.d.ts +2 -0
- package/dist/src/bulk.del.js +2 -2
- package/dist/src/bulk.del.js.map +3 -3
- package/dist/src/bulk.itd.d.ts +2 -0
- package/dist/src/bulk.itd.js +2 -2
- package/dist/src/bulk.itd.js.map +3 -3
- package/dist/src/bulk.js +1 -2
- package/dist/src/bulk.js.map +3 -3
- package/dist/src/bulk.snv.d.ts +2 -0
- package/dist/src/bulk.snv.js +3 -3
- package/dist/src/bulk.snv.js.map +3 -3
- package/dist/src/bulk.sv.d.ts +3 -0
- package/dist/src/bulk.sv.js +1 -1
- package/dist/src/bulk.sv.js.map +3 -3
- package/dist/src/bulk.svjson.d.ts +2 -0
- package/dist/src/bulk.svjson.js +3 -3
- package/dist/src/bulk.svjson.js.map +3 -3
- package/dist/src/bulk.trunc.d.ts +2 -0
- package/dist/src/bulk.trunc.js +1 -1
- package/dist/src/bulk.trunc.js.map +3 -3
- package/dist/src/clustering.d.ts +10 -0
- package/dist/src/clustering.js.map +1 -1
- package/dist/src/common.d.ts +431 -0
- package/dist/src/common.js +62 -22
- package/dist/src/common.js.map +3 -3
- package/dist/src/compute.percentile.d.ts +1 -0
- package/dist/src/compute.percentile.js.map +1 -1
- package/dist/src/fetch-helpers.d.ts +10 -0
- package/dist/src/fetch-helpers.js +17 -18
- package/dist/src/fetch-helpers.js.map +3 -3
- package/dist/src/fileSize.d.ts +1 -0
- package/dist/src/fileSize.js.map +1 -1
- package/dist/src/hash.d.ts +1 -0
- package/dist/src/hash.js.map +1 -1
- package/dist/src/helpers.d.ts +14 -0
- package/dist/src/helpers.js +3 -4
- package/dist/src/helpers.js.map +3 -3
- package/dist/src/index.d.ts +1 -2
- package/dist/src/index.js +1 -2
- package/dist/src/index.js.map +2 -2
- package/dist/src/mds3tk.d.ts +6 -0
- package/dist/src/mds3tk.js.map +3 -3
- package/dist/src/roundValue.d.ts +14 -0
- package/dist/src/roundValue.js.map +1 -1
- package/dist/src/scatter.d.ts +8 -0
- package/dist/src/scatter.js +17 -0
- package/dist/src/scatter.js.map +7 -0
- package/dist/src/termdb.bins.d.ts +5 -0
- package/dist/src/termdb.bins.js +1 -1
- package/dist/src/termdb.bins.js.map +3 -3
- package/dist/src/termdb.initbinconfig.d.ts +1 -0
- package/dist/src/termdb.initbinconfig.js +1 -1
- package/dist/src/termdb.initbinconfig.js.map +3 -3
- package/dist/src/termdb.usecase.d.ts +2 -0
- package/dist/src/termdb.usecase.js.map +3 -3
- package/dist/src/terms.d.ts +29 -52
- package/dist/src/terms.js +71 -56
- package/dist/src/terms.js.map +3 -3
- package/dist/src/tree.d.ts +1 -0
- package/dist/src/tree.js.map +3 -3
- package/dist/src/vcf.ann.d.ts +1 -0
- package/dist/src/vcf.ann.js +1 -2
- package/dist/src/vcf.ann.js.map +3 -3
- package/dist/src/vcf.csq.d.ts +1 -0
- package/dist/src/vcf.csq.js +1 -2
- package/dist/src/vcf.csq.js.map +3 -3
- package/dist/src/vcf.d.ts +2 -0
- package/dist/src/vcf.info.d.ts +1 -0
- package/dist/src/vcf.info.js.map +1 -1
- package/dist/src/vcf.js +47 -42
- package/dist/src/vcf.js.map +4 -4
- package/dist/src/vcf.type.d.ts +1 -0
- package/dist/src/vcf.type.js.map +1 -1
- package/package.json +21 -20
- package/constants/AiHisto.ts +0 -27
- package/constants/README.md +0 -11
- package/devTs.ts +0 -3
- package/dist/constants/AiHisto.d.ts +0 -23
- package/dist/constants/AiHisto.js +0 -31
- package/dist/constants/AiHisto.js.map +0 -7
- package/dist/src/aiHisto.d.ts +0 -5
- package/dist/src/aiHisto.js +0 -15
- package/dist/src/aiHisto.js.map +0 -7
package/dist/src/terms.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Term } from '#types';
|
|
2
|
+
export { GENE_VARIANT, GENE_EXPRESSION, ISOFORM_EXPRESSION, SSGSEA, DNA_METHYLATION, CATEGORICAL, INTEGER, FLOAT, SNP, SNP_LIST, SNP_LOCUS, CONDITION, SURVIVAL, SAMPLELST, METABOLITE_INTENSITY, PROTEOME_ABUNDANCE, SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION, MULTIVALUE, DATE, TERM_COLLECTION, TermTypes } from '#types';
|
|
2
3
|
export { TermTypeGroups } from './common.js';
|
|
3
4
|
export declare const ROOT_SAMPLE_TYPE = 1;
|
|
4
5
|
export declare const DEFAULT_SAMPLE_TYPE = 2;
|
|
@@ -6,65 +7,40 @@ export declare const NumericModes: {
|
|
|
6
7
|
continuous: string;
|
|
7
8
|
discrete: string;
|
|
8
9
|
};
|
|
9
|
-
export declare const CATEGORICAL = "categorical";
|
|
10
|
-
export declare const CONDITION = "condition";
|
|
11
|
-
export declare const DATE = "date";
|
|
12
|
-
export declare const DNA_METHYLATION = "dnaMethylation";
|
|
13
|
-
export declare const FLOAT = "float";
|
|
14
|
-
export declare const GENE_VARIANT = "geneVariant";
|
|
15
|
-
export declare const GENE_EXPRESSION = "geneExpression";
|
|
16
|
-
export declare const ISOFORM_EXPRESSION = "isoformExpression";
|
|
17
|
-
export declare const INTEGER = "integer";
|
|
18
|
-
export declare const METABOLITE_INTENSITY = "metaboliteIntensity";
|
|
19
|
-
export declare const MULTIVALUE = "multivalue";
|
|
20
|
-
export declare const SAMPLELST = "samplelst";
|
|
21
|
-
export declare const SINGLECELL_CELLTYPE = "singleCellCellType";
|
|
22
|
-
export declare const SINGLECELL_GENE_EXPRESSION = "singleCellGeneExpression";
|
|
23
|
-
export declare const SNP = "snp";
|
|
24
|
-
export declare const SNP_LIST = "snplst";
|
|
25
|
-
export declare const SNP_LOCUS = "snplocus";
|
|
26
|
-
export declare const SSGSEA = "ssGSEA";
|
|
27
|
-
export declare const SURVIVAL = "survival";
|
|
28
|
-
export declare const TERM_COLLECTION = "termCollection";
|
|
29
|
-
export declare const PROTEOME_ABUNDANCE = "proteomeAbundance";
|
|
30
|
-
export declare const PROTEOME_DAP = "proteomeDAP";
|
|
31
|
-
export declare const TermTypes: {
|
|
32
|
-
[key: string]: string;
|
|
33
|
-
};
|
|
34
10
|
export declare const dtTermTypes: Set<string>;
|
|
35
11
|
export declare const NUMERIC_DICTIONARY_TERM = "numericDictTerm";
|
|
36
12
|
export declare const TermTypes2Dt: {
|
|
37
|
-
geneExpression:
|
|
38
|
-
ssGSEA:
|
|
39
|
-
dnaMethylation:
|
|
40
|
-
metaboliteIntensity:
|
|
41
|
-
proteomeAbundance:
|
|
13
|
+
geneExpression: number;
|
|
14
|
+
ssGSEA: number;
|
|
15
|
+
dnaMethylation: number;
|
|
16
|
+
metaboliteIntensity: number;
|
|
17
|
+
proteomeAbundance: number;
|
|
42
18
|
};
|
|
43
19
|
export declare const typeGroup: {
|
|
44
|
-
categorical:
|
|
45
|
-
condition:
|
|
46
|
-
float:
|
|
47
|
-
integer:
|
|
48
|
-
samplelst:
|
|
49
|
-
survival:
|
|
50
|
-
date:
|
|
51
|
-
multivalue:
|
|
52
|
-
geneVariant:
|
|
53
|
-
snp:
|
|
54
|
-
snplst:
|
|
55
|
-
snplocus:
|
|
56
|
-
geneExpression:
|
|
57
|
-
isoformExpression:
|
|
58
|
-
ssGSEA:
|
|
59
|
-
dnaMethylation:
|
|
60
|
-
metaboliteIntensity:
|
|
61
|
-
proteomeAbundance:
|
|
62
|
-
termCollection:
|
|
63
|
-
singleCellCellType:
|
|
64
|
-
singleCellGeneExpression:
|
|
20
|
+
categorical: string;
|
|
21
|
+
condition: string;
|
|
22
|
+
float: string;
|
|
23
|
+
integer: string;
|
|
24
|
+
samplelst: string;
|
|
25
|
+
survival: string;
|
|
26
|
+
date: string;
|
|
27
|
+
multivalue: string;
|
|
28
|
+
geneVariant: string;
|
|
29
|
+
snp: string;
|
|
30
|
+
snplst: string;
|
|
31
|
+
snplocus: string;
|
|
32
|
+
geneExpression: string;
|
|
33
|
+
isoformExpression: string;
|
|
34
|
+
ssGSEA: string;
|
|
35
|
+
dnaMethylation: string;
|
|
36
|
+
metaboliteIntensity: string;
|
|
37
|
+
proteomeAbundance: string;
|
|
38
|
+
termCollection: string;
|
|
39
|
+
singleCellCellType: string;
|
|
40
|
+
singleCellGeneExpression: string;
|
|
65
41
|
};
|
|
66
42
|
export declare const numericTypes: Set<string>;
|
|
67
|
-
export declare const
|
|
43
|
+
export declare const dictionaryNumericTypes: Set<string>;
|
|
68
44
|
export declare function isSingleCellTerm(term: any): boolean;
|
|
69
45
|
export declare function isNumericTerm(term: Term): boolean;
|
|
70
46
|
export declare function isCategoricalTerm(term: Term): boolean;
|
|
@@ -75,6 +51,7 @@ export declare function equals(t1: any, t2: any): boolean;
|
|
|
75
51
|
export declare function getBin(lst: any[], value: number): number;
|
|
76
52
|
export declare function getSampleType(term: any, ds: any): any;
|
|
77
53
|
export declare function getParentType(types: Set<string>, ds: any): any;
|
|
54
|
+
export declare function isParentType(term: any, ds: any): boolean;
|
|
78
55
|
export declare function termType2label(type: string): string;
|
|
79
56
|
export declare function getDateFromNumber(value: number): Date;
|
|
80
57
|
export declare function getDateStrFromNumber(value: number): string;
|
package/dist/src/terms.js
CHANGED
|
@@ -7,36 +7,7 @@ import {
|
|
|
7
7
|
TermTypeGroups,
|
|
8
8
|
dtTerms
|
|
9
9
|
} from "./common.js";
|
|
10
|
-
import {
|
|
11
|
-
const ROOT_SAMPLE_TYPE = 1;
|
|
12
|
-
const DEFAULT_SAMPLE_TYPE = 2;
|
|
13
|
-
const NumericModes = {
|
|
14
|
-
continuous: "continuous",
|
|
15
|
-
discrete: "discrete"
|
|
16
|
-
};
|
|
17
|
-
const CATEGORICAL = "categorical";
|
|
18
|
-
const CONDITION = "condition";
|
|
19
|
-
const DATE = "date";
|
|
20
|
-
const DNA_METHYLATION = "dnaMethylation";
|
|
21
|
-
const FLOAT = "float";
|
|
22
|
-
const GENE_VARIANT = "geneVariant";
|
|
23
|
-
const GENE_EXPRESSION = "geneExpression";
|
|
24
|
-
const ISOFORM_EXPRESSION = "isoformExpression";
|
|
25
|
-
const INTEGER = "integer";
|
|
26
|
-
const METABOLITE_INTENSITY = "metaboliteIntensity";
|
|
27
|
-
const MULTIVALUE = "multivalue";
|
|
28
|
-
const SAMPLELST = "samplelst";
|
|
29
|
-
const SINGLECELL_CELLTYPE = "singleCellCellType";
|
|
30
|
-
const SINGLECELL_GENE_EXPRESSION = "singleCellGeneExpression";
|
|
31
|
-
const SNP = "snp";
|
|
32
|
-
const SNP_LIST = "snplst";
|
|
33
|
-
const SNP_LOCUS = "snplocus";
|
|
34
|
-
const SSGSEA = "ssGSEA";
|
|
35
|
-
const SURVIVAL = "survival";
|
|
36
|
-
const TERM_COLLECTION = "termCollection";
|
|
37
|
-
const PROTEOME_ABUNDANCE = "proteomeAbundance";
|
|
38
|
-
const PROTEOME_DAP = "proteomeDAP";
|
|
39
|
-
const TermTypes = {
|
|
10
|
+
import {
|
|
40
11
|
GENE_VARIANT,
|
|
41
12
|
GENE_EXPRESSION,
|
|
42
13
|
ISOFORM_EXPRESSION,
|
|
@@ -57,7 +28,39 @@ const TermTypes = {
|
|
|
57
28
|
SINGLECELL_GENE_EXPRESSION,
|
|
58
29
|
MULTIVALUE,
|
|
59
30
|
DATE,
|
|
60
|
-
TERM_COLLECTION
|
|
31
|
+
TERM_COLLECTION,
|
|
32
|
+
TermTypes
|
|
33
|
+
} from "#types";
|
|
34
|
+
import {
|
|
35
|
+
GENE_VARIANT as GENE_VARIANT2,
|
|
36
|
+
GENE_EXPRESSION as GENE_EXPRESSION2,
|
|
37
|
+
ISOFORM_EXPRESSION as ISOFORM_EXPRESSION2,
|
|
38
|
+
SSGSEA as SSGSEA2,
|
|
39
|
+
DNA_METHYLATION as DNA_METHYLATION2,
|
|
40
|
+
CATEGORICAL as CATEGORICAL2,
|
|
41
|
+
INTEGER as INTEGER2,
|
|
42
|
+
FLOAT as FLOAT2,
|
|
43
|
+
SNP as SNP2,
|
|
44
|
+
SNP_LIST as SNP_LIST2,
|
|
45
|
+
SNP_LOCUS as SNP_LOCUS2,
|
|
46
|
+
CONDITION as CONDITION2,
|
|
47
|
+
SURVIVAL as SURVIVAL2,
|
|
48
|
+
SAMPLELST as SAMPLELST2,
|
|
49
|
+
METABOLITE_INTENSITY as METABOLITE_INTENSITY2,
|
|
50
|
+
PROTEOME_ABUNDANCE as PROTEOME_ABUNDANCE2,
|
|
51
|
+
SINGLECELL_CELLTYPE as SINGLECELL_CELLTYPE2,
|
|
52
|
+
SINGLECELL_GENE_EXPRESSION as SINGLECELL_GENE_EXPRESSION2,
|
|
53
|
+
MULTIVALUE as MULTIVALUE2,
|
|
54
|
+
DATE as DATE2,
|
|
55
|
+
TERM_COLLECTION as TERM_COLLECTION2,
|
|
56
|
+
TermTypes as TermTypes2
|
|
57
|
+
} from "#types";
|
|
58
|
+
import { TermTypeGroups as TermTypeGroups2 } from "./common.js";
|
|
59
|
+
const ROOT_SAMPLE_TYPE = 1;
|
|
60
|
+
const DEFAULT_SAMPLE_TYPE = 2;
|
|
61
|
+
const NumericModes = {
|
|
62
|
+
continuous: "continuous",
|
|
63
|
+
discrete: "discrete"
|
|
61
64
|
};
|
|
62
65
|
const dtTermTypes = new Set(dtTerms.map((t) => t.type));
|
|
63
66
|
for (const dtTermType of dtTermTypes) {
|
|
@@ -123,7 +126,7 @@ const numericTypes = /* @__PURE__ */ new Set([
|
|
|
123
126
|
SINGLECELL_GENE_EXPRESSION,
|
|
124
127
|
DATE
|
|
125
128
|
]);
|
|
126
|
-
const
|
|
129
|
+
const dictionaryNumericTypes = /* @__PURE__ */ new Set([INTEGER, FLOAT, DATE]);
|
|
127
130
|
const categoricalTypes = /* @__PURE__ */ new Set([CATEGORICAL, SNP]);
|
|
128
131
|
const singleCellTerms = /* @__PURE__ */ new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION]);
|
|
129
132
|
function isSingleCellTerm(term) {
|
|
@@ -215,6 +218,18 @@ function getParentType(types, ds) {
|
|
|
215
218
|
}
|
|
216
219
|
return null;
|
|
217
220
|
}
|
|
221
|
+
function isParentType(term, ds) {
|
|
222
|
+
if (!ds.cohort.termdb.hasSampleAncestry) return false;
|
|
223
|
+
const sampleType = getSampleType(term, ds);
|
|
224
|
+
if (!sampleType) throw "sample type is not defined";
|
|
225
|
+
const sampleTypeObj = ds.cohort.termdb.sampleTypes[sampleType];
|
|
226
|
+
if (!sampleTypeObj) throw "invalid sample type";
|
|
227
|
+
if (Number.isInteger(sampleTypeObj.parent_id)) {
|
|
228
|
+
return false;
|
|
229
|
+
} else {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
218
233
|
const typeMap = {
|
|
219
234
|
categorical: "Categorical",
|
|
220
235
|
condition: "Condition",
|
|
@@ -274,36 +289,35 @@ function getDaysInYear(year) {
|
|
|
274
289
|
return days;
|
|
275
290
|
}
|
|
276
291
|
export {
|
|
277
|
-
CATEGORICAL,
|
|
278
|
-
CONDITION,
|
|
279
|
-
DATE,
|
|
292
|
+
CATEGORICAL2 as CATEGORICAL,
|
|
293
|
+
CONDITION2 as CONDITION,
|
|
294
|
+
DATE2 as DATE,
|
|
280
295
|
DEFAULT_SAMPLE_TYPE,
|
|
281
|
-
DNA_METHYLATION,
|
|
282
|
-
FLOAT,
|
|
283
|
-
GENE_EXPRESSION,
|
|
284
|
-
GENE_VARIANT,
|
|
285
|
-
INTEGER,
|
|
286
|
-
ISOFORM_EXPRESSION,
|
|
287
|
-
METABOLITE_INTENSITY,
|
|
288
|
-
MULTIVALUE,
|
|
296
|
+
DNA_METHYLATION2 as DNA_METHYLATION,
|
|
297
|
+
FLOAT2 as FLOAT,
|
|
298
|
+
GENE_EXPRESSION2 as GENE_EXPRESSION,
|
|
299
|
+
GENE_VARIANT2 as GENE_VARIANT,
|
|
300
|
+
INTEGER2 as INTEGER,
|
|
301
|
+
ISOFORM_EXPRESSION2 as ISOFORM_EXPRESSION,
|
|
302
|
+
METABOLITE_INTENSITY2 as METABOLITE_INTENSITY,
|
|
303
|
+
MULTIVALUE2 as MULTIVALUE,
|
|
289
304
|
NUMERIC_DICTIONARY_TERM,
|
|
290
305
|
NumericModes,
|
|
291
|
-
PROTEOME_ABUNDANCE,
|
|
292
|
-
PROTEOME_DAP,
|
|
306
|
+
PROTEOME_ABUNDANCE2 as PROTEOME_ABUNDANCE,
|
|
293
307
|
ROOT_SAMPLE_TYPE,
|
|
294
|
-
SAMPLELST,
|
|
295
|
-
SINGLECELL_CELLTYPE,
|
|
296
|
-
SINGLECELL_GENE_EXPRESSION,
|
|
297
|
-
SNP,
|
|
298
|
-
SNP_LIST,
|
|
299
|
-
SNP_LOCUS,
|
|
300
|
-
SSGSEA,
|
|
301
|
-
SURVIVAL,
|
|
302
|
-
TERM_COLLECTION,
|
|
308
|
+
SAMPLELST2 as SAMPLELST,
|
|
309
|
+
SINGLECELL_CELLTYPE2 as SINGLECELL_CELLTYPE,
|
|
310
|
+
SINGLECELL_GENE_EXPRESSION2 as SINGLECELL_GENE_EXPRESSION,
|
|
311
|
+
SNP2 as SNP,
|
|
312
|
+
SNP_LIST2 as SNP_LIST,
|
|
313
|
+
SNP_LOCUS2 as SNP_LOCUS,
|
|
314
|
+
SSGSEA2 as SSGSEA,
|
|
315
|
+
SURVIVAL2 as SURVIVAL,
|
|
316
|
+
TERM_COLLECTION2 as TERM_COLLECTION,
|
|
303
317
|
TermTypeGroups2 as TermTypeGroups,
|
|
304
|
-
TermTypes,
|
|
318
|
+
TermTypes2 as TermTypes,
|
|
305
319
|
TermTypes2Dt,
|
|
306
|
-
|
|
320
|
+
dictionaryNumericTypes,
|
|
307
321
|
dtTermTypes,
|
|
308
322
|
equals,
|
|
309
323
|
getBin,
|
|
@@ -319,6 +333,7 @@ export {
|
|
|
319
333
|
isNonDictionaryType,
|
|
320
334
|
isNumTermCollection,
|
|
321
335
|
isNumericTerm,
|
|
336
|
+
isParentType,
|
|
322
337
|
isSingleCellTerm,
|
|
323
338
|
numericTypes,
|
|
324
339
|
termType2label,
|
package/dist/src/terms.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/terms.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Term } from '#types'\nimport {\n\tdtgeneexpression,\n\tdtssgsea,\n\tdtdnamethylation,\n\tdtmetaboliteintensity,\n\tdtproteomeabundance,\n\tTermTypeGroups,\n\tdtTerms\n} from './common.js'\n\n// moved TermTypeGroups to `server/src/common.js`, so now has to re-export\nexport { TermTypeGroups } from './common.js'\n\n/*\nFor datasets with multiple types of samples the ROOT_SAMPLE_TYPE is used to represent the root sample type, for example, \nthe type patient, that has one or more samples associated to it. This should be the id used as sample_type, when generating the db to identify the root samples\nin sampleidmap or the terms annotating root samples in the terms table.\nThe samples associated to a patient have annotations that are specific to a timepoint, for example, the age of the patient,\nthe doses of the drugs the patient was taking at the time of the data collection, etc. These annotations are associated to a sample.\n*/\nexport const ROOT_SAMPLE_TYPE = 1\n\n//For datasets with one sample type the DEFAULT_SAMPLE_TYPE is used to represent the sample type\nexport const DEFAULT_SAMPLE_TYPE = 2\n\nexport const NumericModes = {\n\tcontinuous: 'continuous',\n\tdiscrete: 'discrete'\n}\n\nexport const CATEGORICAL = 'categorical'\nexport const CONDITION = 'condition'\nexport const DATE = 'date'\nexport const DNA_METHYLATION = 'dnaMethylation'\nexport const FLOAT = 'float'\nexport const GENE_VARIANT = 'geneVariant'\nexport const GENE_EXPRESSION = 'geneExpression'\nexport const ISOFORM_EXPRESSION = 'isoformExpression'\nexport const INTEGER = 'integer'\nexport const METABOLITE_INTENSITY = 'metaboliteIntensity'\nexport const MULTIVALUE = 'multivalue'\nexport const SAMPLELST = 'samplelst'\nexport const SINGLECELL_CELLTYPE = 'singleCellCellType'\nexport const SINGLECELL_GENE_EXPRESSION = 'singleCellGeneExpression'\nexport const SNP = 'snp'\nexport const SNP_LIST = 'snplst'\nexport const SNP_LOCUS = 'snplocus'\nexport const SSGSEA = 'ssGSEA'\nexport const SURVIVAL = 'survival'\nexport const TERM_COLLECTION = 'termCollection'\nexport const PROTEOME_ABUNDANCE = 'proteomeAbundance'\nexport const PROTEOME_DAP = 'proteomeDAP'\n\n//Term types should be used gradually using these constants instead of hardcoding the values,\n// eg: type == CATEGORICAL instead of type == 'categorical'\nexport const TermTypes: { [key: string]: string } = {\n\tGENE_VARIANT,\n\tGENE_EXPRESSION,\n\tISOFORM_EXPRESSION,\n\tSSGSEA,\n\tDNA_METHYLATION,\n\tCATEGORICAL,\n\tINTEGER,\n\tFLOAT,\n\tSNP,\n\tSNP_LIST,\n\tSNP_LOCUS,\n\tCONDITION,\n\tSURVIVAL,\n\tSAMPLELST,\n\tMETABOLITE_INTENSITY,\n\tPROTEOME_ABUNDANCE,\n\tSINGLECELL_CELLTYPE,\n\tSINGLECELL_GENE_EXPRESSION,\n\tMULTIVALUE,\n\tDATE,\n\tTERM_COLLECTION\n}\nexport const dtTermTypes: Set<string> = new Set(dtTerms.map((t: any) => t.type))\nfor (const dtTermType of dtTermTypes) {\n\tTermTypes[dtTermType.toUpperCase()] = dtTermType\n}\n\nexport const NUMERIC_DICTIONARY_TERM = 'numericDictTerm'\n\nexport const TermTypes2Dt = {\n\t[GENE_EXPRESSION]: dtgeneexpression,\n\t[SSGSEA]: dtssgsea,\n\t[DNA_METHYLATION]: dtdnamethylation,\n\t[METABOLITE_INTENSITY]: dtmetaboliteintensity,\n\t[PROTEOME_ABUNDANCE]: dtproteomeabundance\n}\n\n// maps term type to group (as is shown as toggles in search ui)\nexport const typeGroup = {\n\t[CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[DATE]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[MULTIVALUE]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,\n\t[SNP]: TermTypeGroups.SNP,\n\t[SNP_LIST]: TermTypeGroups.SNP_LIST,\n\t[SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,\n\t[GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,\n\t[ISOFORM_EXPRESSION]: TermTypeGroups.ISOFORM_EXPRESSION,\n\t[SSGSEA]: TermTypeGroups.SSGSEA,\n\t[DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,\n\t[METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,\n\t[PROTEOME_ABUNDANCE]: TermTypeGroups.PROTEOME_ABUNDANCE,\n\t[TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,\n\t[SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,\n\t[SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION\n}\n\nconst nonDictTypes = new Set([\n\tSNP,\n\tSNP_LIST,\n\tSNP_LOCUS,\n\tGENE_EXPRESSION,\n\tISOFORM_EXPRESSION,\n\tSSGSEA,\n\tDNA_METHYLATION,\n\tGENE_VARIANT,\n\tMETABOLITE_INTENSITY,\n\tPROTEOME_ABUNDANCE,\n\tSINGLECELL_CELLTYPE,\n\tSINGLECELL_GENE_EXPRESSION\n])\n\nfor (const dtTermType of dtTermTypes) {\n\tnonDictTypes.add(TermTypes[dtTermType.toUpperCase()])\n}\n\nexport const numericTypes = new Set([\n\tINTEGER,\n\tFLOAT,\n\tGENE_EXPRESSION,\n\tISOFORM_EXPRESSION,\n\tSSGSEA,\n\tDNA_METHYLATION,\n\tMETABOLITE_INTENSITY,\n\tPROTEOME_ABUNDANCE,\n\tSINGLECELL_GENE_EXPRESSION,\n\tDATE\n])\n\n// available termdb numeric table names used as anno_<term.type>,\n// for example anno_integer, anno_float, anno_date\nexport const annoNumericTypes = new Set([INTEGER, FLOAT, DATE])\n\nconst categoricalTypes = new Set([CATEGORICAL, SNP])\n\nconst singleCellTerms = new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION])\n\nexport function isSingleCellTerm(term: any) {\n\tif (!term) return false\n\treturn singleCellTerms.has(term.type)\n}\nexport function isNumericTerm(term: Term) {\n\tif (!term) return false\n\treturn numericTypes.has(term.type)\n}\nexport function isCategoricalTerm(term: Term) {\n\tif (!term) return false\n\treturn categoricalTypes.has(term.type)\n}\n\nexport function isDictionaryType(type: string) {\n\treturn !isNonDictionaryType(type)\n}\n\nexport function isNonDictionaryType(type: string) {\n\tif (!type) throw new Error('Type is not defined')\n\treturn nonDictTypes.has(type)\n}\n\nexport function isNumTermCollection(term: Term) {\n\tif (!term || !term.type) throw new Error('Term or term type is not defined')\n\t//Enable this check when memberType is added to term collection\n\t// return term.type === TERM_COLLECTION && term.memberType == 'numeric'\n\treturn term.type === TERM_COLLECTION\n}\n\nexport function equals(t1: any, t2: any) {\n\tif (!t1) throw new Error('First term is not defined ')\n\tif (!t2) throw new Error('Second term is not defined ')\n\tif (t1.type !== t2.type) return false //term types are different\n\tif (isDictionaryType(t1.type) && isDictionaryType(t2.type) && t1.type != SAMPLELST) return t1.id === t2.id\n\tswitch (t1.type) {\n\t\tcase GENE_EXPRESSION:\n\t\t\treturn t1.gene == t2.gene\n\t\tcase ISOFORM_EXPRESSION:\n\t\t\treturn t1.isoform == t2.isoform\n\t\tcase SSGSEA:\n\t\t\treturn t1.id == t2.id\n\t\tcase DNA_METHYLATION:\n\t\t\treturn t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop\n\t\tcase METABOLITE_INTENSITY:\n\t\tcase PROTEOME_ABUNDANCE:\n\t\t\treturn t1.name == t2.name\n\t\tcase GENE_VARIANT:\n\t\t\treturn t1.gene == t2.gene || (t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop)\n\n\t\t// TO DO: Add more cases\n\t\t// case SNP_LIST:\n\t\t// case SNP_LOCUS:\n\t\t// case SAMPLELST:\n\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getBin(lst: any[], value: number) {\n\tlet bin = lst.findIndex(\n\t\tb => (b.startunbounded && value < b.stop) || (b.startunbounded && b.stopinclusive && value == b.stop)\n\t)\n\tif (bin == -1)\n\t\tbin = lst.findIndex(\n\t\t\tb => (b.stopunbounded && value > b.start) || (b.stopunbounded && b.startinclusive && value == b.start)\n\t\t)\n\tif (bin == -1)\n\t\tbin = lst.findIndex(\n\t\t\tb =>\n\t\t\t\t(value > b.start && value < b.stop) ||\n\t\t\t\t(b.startinclusive && value == b.start) ||\n\t\t\t\t(b.stopinclusive && value == b.stop)\n\t\t)\n\treturn bin\n}\n//Terms may have a sample type associated to them, in datasets with multiple types of samples.\n//For example the gender is associated to the patient while the age is associated to the type sample. This function is used\n//for example when calling getData or getFilter, to return either the parent or the child samples, depending on the use case.\nexport function getSampleType(term: any, ds: any) {\n\tif (!term) return null\n\t//non dict terms annotate only samples, eg: gene expression, metabolite intensity, gene variant.\n\t//Their sample type is the default sample type that may or may not have a parent type, depending on the dataset\n\tif (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE\n\t//dictionary terms may annotate different types of samples, eg: patient and sample or mouse and crop.\n\tif (term.id) return ds.cohort.termdb.term2SampleType.get(term.id)\n\tif (term.type == 'samplelst') {\n\t\tconst key = Object.keys(term.values)[0]\n\t\tconst sampleId = term.values[key].list[0]?.sampleId\n\t\tif (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId)\n\t\telse return DEFAULT_SAMPLE_TYPE\n\t}\n\t// samplelst or non dict terms\n\treturn DEFAULT_SAMPLE_TYPE //later own term needs to know what type annotates based on the samples\n}\n\nexport function getParentType(types: Set<string>, ds: any) {\n\tif (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null //dataset only has one type of sample\n\tconst ids = Array.from(types)\n\tif (!ids || ids.length == 0) return null\n\tfor (const id of ids) {\n\t\tconst typeObj = ds.cohort.termdb.sampleTypes[id]\n\t\tif (!typeObj) continue\n\t\tif (typeObj.parent_id == null) return id //this is the root type\n\t\t//if my parent is in the list, then I am not the parent\n\t\tif (ids.includes(typeObj.parent_id)) continue\n\t\telse return typeObj.parent_id //my parent is not in the list, so I am the parent\n\t}\n\treturn null //no parent found\n}\n\n//Returns human readable label for each term type; label is just for printing and not computing\nconst typeMap: { [key: string]: string } = {\n\tcategorical: 'Categorical',\n\tcondition: 'Condition',\n\tfloat: 'Numerical',\n\tinteger: 'Numerical',\n\tgeneExpression: 'Gene Expression',\n\tisoformExpression: 'Isoform Expression',\n\tssGSEA: 'Geneset Expression',\n\tdnaMethylation: 'DNA Methylation',\n\tgeneVariant: 'Gene Variant',\n\tmetaboliteIntensity: 'Metabolite Intensity',\n\tproteomeAbundance: 'Proteome Abundance',\n\tproteomeDAP: 'Proteome DAP',\n\tmultivalue: 'Multi Value',\n\tsingleCellGeneExpression: 'Single Cell, Gene Expression',\n\tsingleCellCellType: 'Single Cell, Cell Type',\n\tsnplocus: 'SNP Locus',\n\tsnp: 'SNP',\n\tsnplst: 'SNP List',\n\tnumericDictTerm: 'Numeric Dictionary Term',\n\ttermCollection: 'Term Collection'\n}\n\nexport function termType2label(type: string) {\n\treturn typeMap[type] || 'Unknown term type'\n}\n\nexport function getDateFromNumber(value: number) {\n\tconst year = Math.floor(value)\n\tconst january1st = new Date(year, 0, 1)\n\tconst totalDays = getDaysInYear(year)\n\tconst time = Math.round((value - year) * totalDays) * oneDayTime\n\tconst date = new Date(january1st.getTime() + time)\n\treturn date\n}\n/*\nValue is a decimal year.\nA decimal year is a way of expressing a date or time period as a year with a decimal part, where the decimal portion \nrepresents the fraction of the year that has elapsed. \nExample:\n2025.0 represents the beginning of the year 2025. \n2025.5 represents the middle of the year 2025. \n */\nconst oneDayTime = 24 * 60 * 60 * 1000\n\nexport function getDateStrFromNumber(value: number) {\n\tconst date = getDateFromNumber(value)\n\n\t//Omit day to deidentify the patients\n\treturn date.toLocaleDateString('en-US', {\n\t\tyear: 'numeric',\n\t\tmonth: 'long'\n\t})\n}\n\n//The value returned is a decimal year\n//A decimal year is a way of expressing a date or time period as a year with a decimal part, where the decimal portion\n//represents the fraction of the year that has elapsed.\nexport function getNumberFromDateStr(str: string) {\n\tconst date = new Date(str)\n\treturn getNumberFromDate(date)\n}\n\nexport function getNumberFromDate(date: Date) {\n\tconst year = date.getFullYear()\n\tconst january1st: Date = new Date(year, 0, 1)\n\tconst diffDays = (date.getTime() - january1st.getTime()) / oneDayTime\n\tconst daysTotal = getDaysInYear(year)\n\tconst decimal = diffDays / daysTotal\n\treturn year + decimal\n}\n\nexport function getDaysInYear(year: number) {\n\tconst isLeap = new Date(year, 1, 29).getMonth() === 1\n\tconst days = isLeap ? 366 : 365\n\treturn days\n}\n"],
|
|
5
|
-
"mappings": "AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;
|
|
6
|
-
"names": ["TermTypeGroups"]
|
|
4
|
+
"sourcesContent": ["import type { Term } from '#types'\nimport {\n\tdtgeneexpression,\n\tdtssgsea,\n\tdtdnamethylation,\n\tdtmetaboliteintensity,\n\tdtproteomeabundance,\n\tTermTypeGroups,\n\tdtTerms\n} from './common.js'\nimport {\n\tGENE_VARIANT,\n\tGENE_EXPRESSION,\n\tISOFORM_EXPRESSION,\n\tSSGSEA,\n\tDNA_METHYLATION,\n\tCATEGORICAL,\n\tINTEGER,\n\tFLOAT,\n\tSNP,\n\tSNP_LIST,\n\tSNP_LOCUS,\n\tCONDITION,\n\tSURVIVAL,\n\tSAMPLELST,\n\tMETABOLITE_INTENSITY,\n\tPROTEOME_ABUNDANCE,\n\tSINGLECELL_CELLTYPE,\n\tSINGLECELL_GENE_EXPRESSION,\n\tMULTIVALUE,\n\tDATE,\n\tTERM_COLLECTION,\n\tTermTypes\n} from '#types'\n\n// legacy support - comsumers should import directly from #types (aka @sjcrh/proteinpaint-types)\nexport {\n\tGENE_VARIANT,\n\tGENE_EXPRESSION,\n\tISOFORM_EXPRESSION,\n\tSSGSEA,\n\tDNA_METHYLATION,\n\tCATEGORICAL,\n\tINTEGER,\n\tFLOAT,\n\tSNP,\n\tSNP_LIST,\n\tSNP_LOCUS,\n\tCONDITION,\n\tSURVIVAL,\n\tSAMPLELST,\n\tMETABOLITE_INTENSITY,\n\tPROTEOME_ABUNDANCE,\n\tSINGLECELL_CELLTYPE,\n\tSINGLECELL_GENE_EXPRESSION,\n\tMULTIVALUE,\n\tDATE,\n\tTERM_COLLECTION,\n\tTermTypes\n} from '#types'\n\n// moved TermTypeGroups to `server/src/common.js`, so now has to re-export\nexport { TermTypeGroups } from './common.js'\n\n/*\nFor datasets with multiple types of samples the ROOT_SAMPLE_TYPE is used to represent the root sample type, for example, \nthe type patient, that has one or more samples associated to it. This should be the id used as sample_type, when generating the db to identify the root samples\nin sampleidmap or the terms annotating root samples in the terms table.\nThe samples associated to a patient have annotations that are specific to a timepoint, for example, the age of the patient,\nthe doses of the drugs the patient was taking at the time of the data collection, etc. These annotations are associated to a sample.\n*/\nexport const ROOT_SAMPLE_TYPE = 1\n\n//For datasets with one sample type the DEFAULT_SAMPLE_TYPE is used to represent the sample type\nexport const DEFAULT_SAMPLE_TYPE = 2\n\nexport const NumericModes = {\n\tcontinuous: 'continuous',\n\tdiscrete: 'discrete'\n}\n\nexport const dtTermTypes: Set<string> = new Set(dtTerms.map((t: any) => t.type))\nfor (const dtTermType of dtTermTypes) {\n\tTermTypes[dtTermType.toUpperCase()] = dtTermType\n}\n\nexport const NUMERIC_DICTIONARY_TERM = 'numericDictTerm'\n\nexport const TermTypes2Dt = {\n\t[GENE_EXPRESSION]: dtgeneexpression,\n\t[SSGSEA]: dtssgsea,\n\t[DNA_METHYLATION]: dtdnamethylation,\n\t[METABOLITE_INTENSITY]: dtmetaboliteintensity,\n\t[PROTEOME_ABUNDANCE]: dtproteomeabundance\n}\n\n// maps term type to group (as is shown as toggles in search ui)\nexport const typeGroup = {\n\t[CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[DATE]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[MULTIVALUE]: TermTypeGroups.DICTIONARY_VARIABLES,\n\t[GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,\n\t[SNP]: TermTypeGroups.SNP,\n\t[SNP_LIST]: TermTypeGroups.SNP_LIST,\n\t[SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,\n\t[GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,\n\t[ISOFORM_EXPRESSION]: TermTypeGroups.ISOFORM_EXPRESSION,\n\t[SSGSEA]: TermTypeGroups.SSGSEA,\n\t[DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,\n\t[METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,\n\t[PROTEOME_ABUNDANCE]: TermTypeGroups.PROTEOME_ABUNDANCE,\n\t[TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,\n\t[SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,\n\t[SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION\n}\n\nconst nonDictTypes = new Set([\n\tSNP,\n\tSNP_LIST,\n\tSNP_LOCUS,\n\tGENE_EXPRESSION,\n\tISOFORM_EXPRESSION,\n\tSSGSEA,\n\tDNA_METHYLATION,\n\tGENE_VARIANT,\n\tMETABOLITE_INTENSITY,\n\tPROTEOME_ABUNDANCE,\n\tSINGLECELL_CELLTYPE,\n\tSINGLECELL_GENE_EXPRESSION\n])\n\nfor (const dtTermType of dtTermTypes) {\n\tnonDictTypes.add(TermTypes[dtTermType.toUpperCase()])\n}\n\nexport const numericTypes = new Set([\n\tINTEGER,\n\tFLOAT,\n\tGENE_EXPRESSION,\n\tISOFORM_EXPRESSION,\n\tSSGSEA,\n\tDNA_METHYLATION,\n\tMETABOLITE_INTENSITY,\n\tPROTEOME_ABUNDANCE,\n\tSINGLECELL_GENE_EXPRESSION,\n\tDATE\n])\n\n// dictionary numeric term types, exists in db tables, exclude non-dictionary term types\nexport const dictionaryNumericTypes = new Set([INTEGER, FLOAT, DATE])\n\nconst categoricalTypes = new Set([CATEGORICAL, SNP])\n\nconst singleCellTerms = new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION])\n\nexport function isSingleCellTerm(term: any) {\n\tif (!term) return false\n\treturn singleCellTerms.has(term.type)\n}\nexport function isNumericTerm(term: Term) {\n\tif (!term) return false\n\treturn numericTypes.has(term.type)\n}\nexport function isCategoricalTerm(term: Term) {\n\tif (!term) return false\n\treturn categoricalTypes.has(term.type)\n}\n\nexport function isDictionaryType(type: string) {\n\treturn !isNonDictionaryType(type)\n}\n\nexport function isNonDictionaryType(type: string) {\n\tif (!type) throw new Error('Type is not defined')\n\treturn nonDictTypes.has(type)\n}\n\nexport function isNumTermCollection(term: Term) {\n\tif (!term || !term.type) throw new Error('Term or term type is not defined')\n\t//Enable this check when memberType is added to term collection\n\t// return term.type === TERM_COLLECTION && term.memberType == 'numeric'\n\treturn term.type === TERM_COLLECTION\n}\n\nexport function equals(t1: any, t2: any) {\n\tif (!t1) throw new Error('First term is not defined ')\n\tif (!t2) throw new Error('Second term is not defined ')\n\tif (t1.type !== t2.type) return false //term types are different\n\tif (isDictionaryType(t1.type) && isDictionaryType(t2.type) && t1.type != SAMPLELST) return t1.id === t2.id\n\tswitch (t1.type) {\n\t\tcase GENE_EXPRESSION:\n\t\t\treturn t1.gene == t2.gene\n\t\tcase ISOFORM_EXPRESSION:\n\t\t\treturn t1.isoform == t2.isoform\n\t\tcase SSGSEA:\n\t\t\treturn t1.id == t2.id\n\t\tcase DNA_METHYLATION:\n\t\t\treturn t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop\n\t\tcase METABOLITE_INTENSITY:\n\t\tcase PROTEOME_ABUNDANCE:\n\t\t\treturn t1.name == t2.name\n\t\tcase GENE_VARIANT:\n\t\t\treturn t1.gene == t2.gene || (t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop)\n\n\t\t// TO DO: Add more cases\n\t\t// case SNP_LIST:\n\t\t// case SNP_LOCUS:\n\t\t// case SAMPLELST:\n\n\t\tdefault:\n\t\t\treturn false\n\t}\n}\n\nexport function getBin(lst: any[], value: number) {\n\tlet bin = lst.findIndex(\n\t\tb => (b.startunbounded && value < b.stop) || (b.startunbounded && b.stopinclusive && value == b.stop)\n\t)\n\tif (bin == -1)\n\t\tbin = lst.findIndex(\n\t\t\tb => (b.stopunbounded && value > b.start) || (b.stopunbounded && b.startinclusive && value == b.start)\n\t\t)\n\tif (bin == -1)\n\t\tbin = lst.findIndex(\n\t\t\tb =>\n\t\t\t\t(value > b.start && value < b.stop) ||\n\t\t\t\t(b.startinclusive && value == b.start) ||\n\t\t\t\t(b.stopinclusive && value == b.stop)\n\t\t)\n\treturn bin\n}\n//Terms may have a sample type associated to them, in datasets with multiple types of samples.\n//For example the gender is associated to the patient while the age is associated to the type sample. This function is used\n//for example when calling getData or getFilter, to return either the parent or the child samples, depending on the use case.\nexport function getSampleType(term: any, ds: any) {\n\tif (!term) return null\n\t//non dict terms annotate only samples, eg: gene expression, metabolite intensity, gene variant.\n\t//Their sample type is the default sample type that may or may not have a parent type, depending on the dataset\n\tif (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE\n\t//dictionary terms may annotate different types of samples, eg: patient and sample or mouse and crop.\n\tif (term.id) return ds.cohort.termdb.term2SampleType.get(term.id)\n\tif (term.type == 'samplelst') {\n\t\tconst key = Object.keys(term.values)[0]\n\t\tconst sampleId = term.values[key].list[0]?.sampleId\n\t\tif (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId)\n\t\telse return DEFAULT_SAMPLE_TYPE\n\t}\n\t// samplelst or non dict terms\n\treturn DEFAULT_SAMPLE_TYPE //later own term needs to know what type annotates based on the samples\n}\n\nexport function getParentType(types: Set<string>, ds: any) {\n\tif (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null //dataset only has one type of sample\n\tconst ids = Array.from(types)\n\tif (!ids || ids.length == 0) return null\n\tfor (const id of ids) {\n\t\tconst typeObj = ds.cohort.termdb.sampleTypes[id]\n\t\tif (!typeObj) continue\n\t\tif (typeObj.parent_id == null) return id //this is the root type\n\t\t//if my parent is in the list, then I am not the parent\n\t\tif (ids.includes(typeObj.parent_id)) continue\n\t\telse return typeObj.parent_id //my parent is not in the list, so I am the parent\n\t}\n\treturn null //no parent found\n}\n\n// whether the term annotates parent samples\nexport function isParentType(term: any, ds: any) {\n\tif (!ds.cohort.termdb.hasSampleAncestry) return false\n\tconst sampleType = getSampleType(term, ds)\n\tif (!sampleType) throw 'sample type is not defined'\n\tconst sampleTypeObj = ds.cohort.termdb.sampleTypes[sampleType]\n\tif (!sampleTypeObj) throw 'invalid sample type'\n\tif (Number.isInteger(sampleTypeObj.parent_id)) {\n\t\t// sample type has parent, so it is child sample type\n\t\treturn false\n\t} else {\n\t\t// sample type does not have parent, so it is parent sample type\n\t\treturn true\n\t}\n}\n\n//Returns human readable label for each term type; label is just for printing and not computing\nconst typeMap: { [key: string]: string } = {\n\tcategorical: 'Categorical',\n\tcondition: 'Condition',\n\tfloat: 'Numerical',\n\tinteger: 'Numerical',\n\tgeneExpression: 'Gene Expression',\n\tisoformExpression: 'Isoform Expression',\n\tssGSEA: 'Geneset Expression',\n\tdnaMethylation: 'DNA Methylation',\n\tgeneVariant: 'Gene Variant',\n\tmetaboliteIntensity: 'Metabolite Intensity',\n\tproteomeAbundance: 'Proteome Abundance',\n\tproteomeDAP: 'Proteome DAP',\n\tmultivalue: 'Multi Value',\n\tsingleCellGeneExpression: 'Single Cell, Gene Expression',\n\tsingleCellCellType: 'Single Cell, Cell Type',\n\tsnplocus: 'SNP Locus',\n\tsnp: 'SNP',\n\tsnplst: 'SNP List',\n\tnumericDictTerm: 'Numeric Dictionary Term',\n\ttermCollection: 'Term Collection'\n}\n\nexport function termType2label(type: string) {\n\treturn typeMap[type] || 'Unknown term type'\n}\n\nexport function getDateFromNumber(value: number) {\n\tconst year = Math.floor(value)\n\tconst january1st = new Date(year, 0, 1)\n\tconst totalDays = getDaysInYear(year)\n\tconst time = Math.round((value - year) * totalDays) * oneDayTime\n\tconst date = new Date(january1st.getTime() + time)\n\treturn date\n}\n/*\nValue is a decimal year.\nA decimal year is a way of expressing a date or time period as a year with a decimal part, where the decimal portion \nrepresents the fraction of the year that has elapsed. \nExample:\n2025.0 represents the beginning of the year 2025. \n2025.5 represents the middle of the year 2025. \n */\nconst oneDayTime = 24 * 60 * 60 * 1000\n\nexport function getDateStrFromNumber(value: number) {\n\tconst date = getDateFromNumber(value)\n\n\t//Omit day to deidentify the patients\n\treturn date.toLocaleDateString('en-US', {\n\t\tyear: 'numeric',\n\t\tmonth: 'long'\n\t})\n}\n\n//The value returned is a decimal year\n//A decimal year is a way of expressing a date or time period as a year with a decimal part, where the decimal portion\n//represents the fraction of the year that has elapsed.\nexport function getNumberFromDateStr(str: string) {\n\tconst date = new Date(str)\n\treturn getNumberFromDate(date)\n}\n\nexport function getNumberFromDate(date: Date) {\n\tconst year = date.getFullYear()\n\tconst january1st: Date = new Date(year, 0, 1)\n\tconst diffDays = (date.getTime() - january1st.getTime()) / oneDayTime\n\tconst daysTotal = getDaysInYear(year)\n\tconst decimal = diffDays / daysTotal\n\treturn year + decimal\n}\n\nexport function getDaysInYear(year: number) {\n\tconst isLeap = new Date(year, 1, 29).getMonth() === 1\n\tconst days = isLeap ? 366 : 365\n\treturn days\n}\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAGP;AAAA,EACC,gBAAAA;AAAA,EACA,mBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,8BAAAC;AAAA,EACA,cAAAC;AAAA,EACA,QAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,aAAAC;AAAA,OACM;AAGP,SAAS,kBAAAC,uBAAsB;AASxB,MAAM,mBAAmB;AAGzB,MAAM,sBAAsB;AAE5B,MAAM,eAAe;AAAA,EAC3B,YAAY;AAAA,EACZ,UAAU;AACX;AAEO,MAAM,cAA2B,IAAI,IAAI,QAAQ,IAAI,CAAC,MAAW,EAAE,IAAI,CAAC;AAC/E,WAAW,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": ["GENE_VARIANT", "GENE_EXPRESSION", "ISOFORM_EXPRESSION", "SSGSEA", "DNA_METHYLATION", "CATEGORICAL", "INTEGER", "FLOAT", "SNP", "SNP_LIST", "SNP_LOCUS", "CONDITION", "SURVIVAL", "SAMPLELST", "METABOLITE_INTENSITY", "PROTEOME_ABUNDANCE", "SINGLECELL_CELLTYPE", "SINGLECELL_GENE_EXPRESSION", "MULTIVALUE", "DATE", "TERM_COLLECTION", "TermTypes", "TermTypeGroups"]
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function stratinput(lst: any, levels: any): any[];
|
package/dist/src/tree.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/tree.
|
|
4
|
-
"sourcesContent": ["/*\ninput:\n1. list of leaf nodes, e.g. mutation cases, each with a set of key-value pairs\n2. levels of hierarchy in an ordered list\n each item: { k, full }\n \"k\" and \"full\" are two attribute keys\n\noutput:\na list of items, as input for d3-hierarchy.stratify\none item for each child-parent relationship in the hierarchy\n{\n\tid:\n\tparentId:\n\tlst:\n\tvalue:\n\tname:\n\tfull:\n\tid0:\n\tv0:\n\tid1:\n\tv1:\n\tid2:\n\tv2:\n}\n\nstrange issue: https://github.com/stjude/proteinpaint/commit/c36004d47d4374d2ade719c6ef9e2b848f0850dc\nusing Map for lp, nodes etc will cause memory issue, thus the use of simple objects\n\nto-do: verify this works after a reorg\n*/\n\nconst hardcode_root = 'root'\nconst hierarchy_spacer = '...'\n\nexport function stratinput(lst, levels) {\n\tconst lp = Object.create(null)\n\t// leaf to parent\n\t// k: HM...BALL...sub\n\t// v: HM...BALL\n\n\tconst nodes = Object.create(null)\n\t/*\n\tk: string id of node, e.g. HM...BALL\n\tv: node\n\t\t.full\n\t\t.lst[]\n\t\t\titems from input\n\t*/\n\n\tconst size = Object.create(null)\n\t// only increment size to leaf nodes, so that root.sum() will work\n\t// k: string id of a node, e.g. HM...BALL\n\t// v: number of items\n\n\tfor (const m of lst) {\n\t\tfor (const [i, lev] of levels.entries()) {\n\t\t\tconst thisv = getkey(m, i, levels)\n\t\t\tconst pav = getkey(m, i - 1, levels)\n\n\t\t\t// as mutations can come as {\"subtype\":\"\"}\n\t\t\t// in the sunburst chart at the subtype level, this mutation should not be counted\n\t\t\t// thus the test with !m[lev.k] rather than !(lev.k in m)\n\t\t\tif (!m[lev.k]) {\n\t\t\t\t// stop at this level\n\t\t\t\t// add count to prev level\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsize[pav] += 1\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlp[thisv] = pav\n\t\t\tif (!(thisv in size)) {\n\t\t\t\tsize[thisv] = 0\n\t\t\t}\n\t\t\tif (!(thisv in nodes)) {\n\t\t\t\tconst n = {\n\t\t\t\t\tlst: []\n\t\t\t\t}\n\t\t\t\tif (lev.full) {\n\t\t\t\t\tn.full = m[lev.full]\n\t\t\t\t}\n\n\t\t\t\tn.id0 = levels[0].k\n\t\t\t\tn.v0 = m[levels[0].k]\n\t\t\t\tif (i == 1) {\n\t\t\t\t\tn.id1 = levels[1].k\n\t\t\t\t\tn.v1 = m[levels[1].k]\n\t\t\t\t}\n\t\t\t\tif (i == 2) {\n\t\t\t\t\tn.id2 = levels[2].k\n\t\t\t\t\tn.v1 = m[levels[2].k]\n\t\t\t\t}\n\n\t\t\t\tnodes[thisv] = n\n\t\t\t}\n\t\t\tnodes[thisv].lst.push(m)\n\t\t\tif (i == levels.length - 1) {\n\t\t\t\tsize[thisv] += 1\n\t\t\t}\n\t\t}\n\t}\n\n\tconst nlst = [{ id: hardcode_root, name: hardcode_root }]\n\n\tfor (const chid in lp) {\n\t\tconst paid = lp[chid]\n\t\tconst n = nodes[chid]\n\t\tconst fields = chid.split(hierarchy_spacer)\n\t\tnlst.push({\n\t\t\tid: chid,\n\t\t\tparentId: paid,\n\t\t\tlst: n.lst,\n\t\t\tvalue: size[chid],\n\t\t\tname: fields[fields.length - 1], // show this instead of chid\n\t\t\tfull: n.full,\n\t\t\tid0: n.id0,\n\t\t\tv0: n.v0,\n\t\t\tid1: n.id1,\n\t\t\tv1: n.v1,\n\t\t\tid2: n.id2,\n\t\t\tv2: n.v2\n\t\t})\n\t}\n\treturn nlst\n}\n\nfunction getkey(m, i, levels) {\n\t// if i is 0, return 'root'\n\tconst klst = [hardcode_root]\n\tfor (let j = 0; j < i; j++) {\n\t\tklst.push(m[levels[j].k])\n\t}\n\tif (i >= 0) {\n\t\tklst.push(m[levels[i].k])\n\t}\n\treturn klst.join(hierarchy_spacer)\n}\n"],
|
|
5
|
-
"mappings": "AA+BA,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AAElB,SAAS,WAAW,KAAK,QAAQ;AACvC,QAAM,KAAK,uBAAO,OAAO,IAAI;AAK7B,QAAM,QAAQ,uBAAO,OAAO,IAAI;AAShC,QAAM,OAAO,uBAAO,OAAO,IAAI;AAK/B,aAAW,KAAK,KAAK;AACpB,eAAW,CAAC,GAAG,GAAG,KAAK,OAAO,QAAQ,GAAG;AACxC,YAAM,QAAQ,OAAO,GAAG,GAAG,MAAM;AACjC,YAAM,MAAM,OAAO,GAAG,IAAI,GAAG,MAAM;AAKnC,UAAI,CAAC,EAAE,IAAI,CAAC,GAAG;AAGd,YAAI,IAAI,GAAG;AACV,eAAK,GAAG,KAAK;AAAA,QACd;AACA;AAAA,MACD;AAEA,SAAG,KAAK,IAAI;AACZ,UAAI,EAAE,SAAS,OAAO;AACrB,aAAK,KAAK,IAAI;AAAA,MACf;AACA,UAAI,EAAE,SAAS,QAAQ;AACtB,cAAM,
|
|
3
|
+
"sources": ["../../src/tree.ts"],
|
|
4
|
+
"sourcesContent": ["/*\ninput:\n1. list of leaf nodes, e.g. mutation cases, each with a set of key-value pairs\n2. levels of hierarchy in an ordered list\n each item: { k, full }\n \"k\" and \"full\" are two attribute keys\n\noutput:\na list of items, as input for d3-hierarchy.stratify\none item for each child-parent relationship in the hierarchy\n{\n\tid:\n\tparentId:\n\tlst:\n\tvalue:\n\tname:\n\tfull:\n\tid0:\n\tv0:\n\tid1:\n\tv1:\n\tid2:\n\tv2:\n}\n\nstrange issue: https://github.com/stjude/proteinpaint/commit/c36004d47d4374d2ade719c6ef9e2b848f0850dc\nusing Map for lp, nodes etc will cause memory issue, thus the use of simple objects\n\nto-do: verify this works after a reorg\n*/\n\nconst hardcode_root = 'root'\nconst hierarchy_spacer = '...'\n\nexport function stratinput(lst, levels) {\n\tconst lp = Object.create(null)\n\t// leaf to parent\n\t// k: HM...BALL...sub\n\t// v: HM...BALL\n\n\tconst nodes = Object.create(null)\n\t/*\n\tk: string id of node, e.g. HM...BALL\n\tv: node\n\t\t.full\n\t\t.lst[]\n\t\t\titems from input\n\t*/\n\n\tconst size = Object.create(null)\n\t// only increment size to leaf nodes, so that root.sum() will work\n\t// k: string id of a node, e.g. HM...BALL\n\t// v: number of items\n\n\tfor (const m of lst) {\n\t\tfor (const [i, lev] of levels.entries()) {\n\t\t\tconst thisv = getkey(m, i, levels)\n\t\t\tconst pav = getkey(m, i - 1, levels)\n\n\t\t\t// as mutations can come as {\"subtype\":\"\"}\n\t\t\t// in the sunburst chart at the subtype level, this mutation should not be counted\n\t\t\t// thus the test with !m[lev.k] rather than !(lev.k in m)\n\t\t\tif (!m[lev.k]) {\n\t\t\t\t// stop at this level\n\t\t\t\t// add count to prev level\n\t\t\t\tif (i > 0) {\n\t\t\t\t\tsize[pav] += 1\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\tlp[thisv] = pav\n\t\t\tif (!(thisv in size)) {\n\t\t\t\tsize[thisv] = 0\n\t\t\t}\n\t\t\tif (!(thisv in nodes)) {\n\t\t\t\tconst n: Record<string, any> = {\n\t\t\t\t\tlst: []\n\t\t\t\t}\n\t\t\t\tif (lev.full) {\n\t\t\t\t\tn.full = m[lev.full]\n\t\t\t\t}\n\n\t\t\t\tn.id0 = levels[0].k\n\t\t\t\tn.v0 = m[levels[0].k]\n\t\t\t\tif (i == 1) {\n\t\t\t\t\tn.id1 = levels[1].k\n\t\t\t\t\tn.v1 = m[levels[1].k]\n\t\t\t\t}\n\t\t\t\tif (i == 2) {\n\t\t\t\t\tn.id2 = levels[2].k\n\t\t\t\t\tn.v1 = m[levels[2].k]\n\t\t\t\t}\n\n\t\t\t\tnodes[thisv] = n\n\t\t\t}\n\t\t\tnodes[thisv].lst.push(m)\n\t\t\tif (i == levels.length - 1) {\n\t\t\t\tsize[thisv] += 1\n\t\t\t}\n\t\t}\n\t}\n\n\tconst nlst: any[] = [{ id: hardcode_root, name: hardcode_root }]\n\n\tfor (const chid in lp) {\n\t\tconst paid = lp[chid]\n\t\tconst n = nodes[chid]\n\t\tconst fields = chid.split(hierarchy_spacer)\n\t\tnlst.push({\n\t\t\tid: chid,\n\t\t\tparentId: paid,\n\t\t\tlst: n.lst,\n\t\t\tvalue: size[chid],\n\t\t\tname: fields[fields.length - 1], // show this instead of chid\n\t\t\tfull: n.full,\n\t\t\tid0: n.id0,\n\t\t\tv0: n.v0,\n\t\t\tid1: n.id1,\n\t\t\tv1: n.v1,\n\t\t\tid2: n.id2,\n\t\t\tv2: n.v2\n\t\t})\n\t}\n\treturn nlst\n}\n\nfunction getkey(m, i, levels) {\n\t// if i is 0, return 'root'\n\tconst klst = [hardcode_root]\n\tfor (let j = 0; j < i; j++) {\n\t\tklst.push(m[levels[j].k])\n\t}\n\tif (i >= 0) {\n\t\tklst.push(m[levels[i].k])\n\t}\n\treturn klst.join(hierarchy_spacer)\n}\n"],
|
|
5
|
+
"mappings": "AA+BA,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;AAElB,SAAS,WAAW,KAAK,QAAQ;AACvC,QAAM,KAAK,uBAAO,OAAO,IAAI;AAK7B,QAAM,QAAQ,uBAAO,OAAO,IAAI;AAShC,QAAM,OAAO,uBAAO,OAAO,IAAI;AAK/B,aAAW,KAAK,KAAK;AACpB,eAAW,CAAC,GA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AAK,EAAE;AAAA,MACP,OAAO,KAAK,IAAI;AAAA,MAChB,MAAM,OAAO,OAAO,SAAS,CAAC;AAAA;AAAA,MAC9B,MAAM,EAAE;AAAA,MACR,KAAK,EAAE;AAAA,MACP,IAAI,EAAE;AAAA,MACN,KAAK,EAAE;AAAA,MACP,IAAI,EAAE;AAAA,MACN,KAAK,EAAE;AAAA,MACP,IAAI,EAAE;AAAA,IACP,CAAC;AAAA,EACF;AACA,SAAO;AACR;AAEA,SAAS,OAAO,GAAG,GAAG,QAAQ;AAE7B,QAAM,OAAO,CAAC,aAAa;AAC3B,WAAS,IAAI,GAAG,IAAI,GAAG,KAAK;AAC3B,SAAK,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;AAAA,EACzB;AACA,MAAI,KAAK,GAAG;AACX,SAAK,KAAK,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;AAAA,EACzB;AACA,SAAO,KAAK,KAAK,gBAAgB;AAClC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parse_ANN(str: any, header: any, m: any): true | null;
|
package/dist/src/vcf.ann.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { vepinfo } from "./common.js";
|
|
1
|
+
import { vepinfo, dtsnvindel, mclassnonstandard } from "./common.js";
|
|
2
2
|
function parse_ANN(str, header, m) {
|
|
3
3
|
if (!header) {
|
|
4
4
|
return null;
|
|
@@ -45,7 +45,6 @@ function parse_ANN(str, header, m) {
|
|
|
45
45
|
o._mname = o["HGVS.p"];
|
|
46
46
|
} else if (o["HGVS.c"]) {
|
|
47
47
|
o._mname = o["HGVS.c"];
|
|
48
|
-
} else {
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
return true;
|
package/dist/src/vcf.ann.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/vcf.ann.
|
|
4
|
-
"sourcesContent": ["import { vepinfo } from './common.js'\n\nexport function parse_ANN(str, header, m) {\n\t// snpEff\n\tif (!header) {\n\t\treturn null\n\t}\n\tfor (const thisannotation of str.split(',')) {\n\t\tconst lst = thisannotation.replace(/&/g, ',').split('|')\n\n\t\tconst o = {}\n\n\t\tfor (let i = 0; i < header.length; i++) {\n\t\t\tif (lst[i]) {\n\t\t\t\to[header[i].name] = lst[i]\n\t\t\t}\n\t\t}\n\t\tif (!o.Allele) {\n\t\t\tcontinue\n\t\t}\n\t\tlet allele = null\n\t\tfor (const a of m.alleles) {\n\t\t\tif (a.allele == o.Allele) {\n\t\t\t\tallele = a\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (!allele) {\n\t\t\t// cannot match to allele!!!\n\t\t\tcontinue\n\t\t}\n\t\tif (!allele.ann) {\n\t\t\tallele.ann = []\n\t\t}\n\t\tallele.ann.push(o)\n\t\to._gene = o.Gene_Name\n\t\t// isoform\n\t\tif (o.Feature_Type && o.Feature_Type == 'transcript' && o.Feature_ID) {\n\t\t\to._isoform = o.Feature_ID.split('.')[0]\n\t\t}\n\t\t// class\n\t\tif (o.Annotation) {\n\t\t\tconst [dt, cls, rank] = vepinfo(o.Annotation)\n\t\t\to._dt = dt\n\t\t\to._class = cls\n\t\t\to._csqrank = rank\n\t\t} else {\n\t\t\t// FIXME\n\t\t\to._dt = dtsnvindel\n\t\t\to._class = mclassnonstandard\n\t\t}\n\t\t// mname\n\t\tif (o['HGVS.p']) {\n\t\t\t//o._mname=decodeURIComponent(o.HGVSp.substr(o.HGVSp.indexOf(':')+1))\n\t\t\to._mname = o['HGVS.p']\n\t\t} else if (o['HGVS.c']) {\n\t\t\to._mname = o['HGVS.c']\n\t\t}
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
3
|
+
"sources": ["../../src/vcf.ann.ts"],
|
|
4
|
+
"sourcesContent": ["import { vepinfo, dtsnvindel, mclassnonstandard } from './common.js'\n\nexport function parse_ANN(str, header, m) {\n\t// snpEff\n\tif (!header) {\n\t\treturn null\n\t}\n\tfor (const thisannotation of str.split(',')) {\n\t\tconst lst = thisannotation.replace(/&/g, ',').split('|')\n\n\t\tconst o: Record<string, any> = {}\n\n\t\tfor (let i = 0; i < header.length; i++) {\n\t\t\tif (lst[i]) {\n\t\t\t\to[header[i].name] = lst[i]\n\t\t\t}\n\t\t}\n\t\tif (!o.Allele) {\n\t\t\tcontinue\n\t\t}\n\t\tlet allele: any = null\n\t\tfor (const a of m.alleles) {\n\t\t\tif (a.allele == o.Allele) {\n\t\t\t\tallele = a\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (!allele) {\n\t\t\t// cannot match to allele!!!\n\t\t\tcontinue\n\t\t}\n\t\tif (!allele.ann) {\n\t\t\tallele.ann = []\n\t\t}\n\t\tallele.ann.push(o)\n\t\to._gene = o.Gene_Name\n\t\t// isoform\n\t\tif (o.Feature_Type && o.Feature_Type == 'transcript' && o.Feature_ID) {\n\t\t\to._isoform = o.Feature_ID.split('.')[0]\n\t\t}\n\t\t// class\n\t\tif (o.Annotation) {\n\t\t\tconst [dt, cls, rank] = vepinfo(o.Annotation)\n\t\t\to._dt = dt\n\t\t\to._class = cls\n\t\t\to._csqrank = rank\n\t\t} else {\n\t\t\t// FIXME\n\t\t\to._dt = dtsnvindel\n\t\t\to._class = mclassnonstandard\n\t\t}\n\t\t// mname\n\t\tif (o['HGVS.p']) {\n\t\t\t//o._mname=decodeURIComponent(o.HGVSp.substr(o.HGVSp.indexOf(':')+1))\n\t\t\to._mname = o['HGVS.p']\n\t\t} else if (o['HGVS.c']) {\n\t\t\to._mname = o['HGVS.c']\n\t\t}\n\t}\n\treturn true\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,YAAY,yBAAyB;AAEhD,SAAS,UAAU,KAAK,QAAQ,GAAG;AAEzC,MAAI,CAAC,QAAQ;AACZ,WAAO;AAAA,EACR;AACA,aAAW,kBAAkB,IAAI,MA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@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { vepinfo } from "./common.js";
|
|
1
|
+
import { vepinfo, dtsnvindel, mclassnonstandard } from "./common.js";
|
|
2
2
|
function parse_CSQ(str, header, m) {
|
|
3
3
|
if (!header) {
|
|
4
4
|
return null;
|
|
@@ -71,7 +71,6 @@ function parse_CSQ(str, header, m) {
|
|
|
71
71
|
o._mname = o.HGVSc.substr(o.HGVSc.indexOf(":") + 1);
|
|
72
72
|
} else if (o.Existing_variation) {
|
|
73
73
|
o._name = o.Existing_variation;
|
|
74
|
-
} else {
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
return true;
|
package/dist/src/vcf.csq.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/vcf.csq.
|
|
4
|
-
"sourcesContent": ["import { vepinfo } from './common.js'\n/*\nparse csq field from a variant line, not header\nCSQ header must have already been parsed\n\nstr: the csq value for a vcf line\nheader: [ // something like this\n { name: 'Allele' },\n { name: 'Consequence' },\n { name: 'IMPACT' },\n { name: 'SYMBOL' },\n { name: 'Gene' },\n { name: 'Feature_type' },\n { name: 'Feature' },\n { name: 'BIOTYPE' },\n { name: 'EXON' },\n { name: 'INTRON' },\n { name: 'HGVSc' },\n { name: 'HGVSp' },\n { name: 'cDNA_position' },\n { name: 'CDS_position' },\n { name: 'Protein_position' },\n { name: 'Amino_acids' },\n { name: 'Codons' },\n { name: 'Existing_variation' },\n { name: 'DISTANCE' },\n { name: 'STRAND' },\n { name: 'FLAGS' },\n { name: 'SYMBOL_SOURCE' },\n { name: 'HGNC_ID' },\n { name: 'CANONICAL' },\n { name: 'REFSEQ_MATCH' },\n { name: 'GIVEN_REF' },\n { name: 'USED_REF' },\n { name: 'BAM_EDIT' },\n { name: 'HGVS_OFFSET' },\n { name: 'CLIN_SIG' },\n { name: 'SOMATIC' },\n { name: 'PHENO' }\n]\n\nm: {\n\tmlst[ {} ]\n\t\t.allele_original\n\t\t.csq[ {} ] // parse_CSQ will add this array to this allele\n\t\t\t._class\n\t\t\t._csqrank\n\t\t\t._dt\n\t\t\t._gene\n\t\t\t._isoform\n\t\t\t._mname\n}\n\n*/\n\nexport function parse_CSQ(str, header, m) {\n\tif (!header) {\n\t\treturn null\n\t}\n\tfor (const thisannotation of str.split(',')) {\n\t\tconst lst = thisannotation.replace(/&/g, ',').split('|')\n\n\t\tconst o = {}\n\n\t\tfor (let i = 0; i < header.length; i++) {\n\t\t\tif (lst[i]) {\n\t\t\t\to[header[i].name] = lst[i]\n\t\t\t}\n\t\t}\n\t\tif (!o.Allele) {\n\t\t\tcontinue\n\t\t}\n\t\tlet allele = null\n\n\t\t//////////////////////////////////////\n\t\t// NOTE\n\t\t// mds2delete\n\t\t// m.alleles[] is based on old vcf parsing and may delete?\n\t\t// latest spec is m.mlst[]\n\t\t//////////////////////////////////////\n\n\t\tfor (const a of m.mlst || m.alleles) {\n\t\t\tif (a.allele_original == o.Allele) {\n\t\t\t\tallele = a\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (!allele) {\n\t\t\tif (o.Allele == '-') {\n\t\t\t\t// deletion\n\t\t\t\tif (m.mlst) {\n\t\t\t\t\tif (m.mlst.length == 1) {\n\t\t\t\t\t\tallele = m.mlst[0]\n\t\t\t\t\t}\n\t\t\t\t} else if (m.alleles) {\n\t\t\t\t\tif (m.alleles.length == 1) {\n\t\t\t\t\t\tallele = m.alleles[0]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const a of m.mlst || m.alleles) {\n\t\t\t\t\tif (a.allele_original.substr(1) == o.Allele) {\n\t\t\t\t\t\t// insertion, without first padding base\n\t\t\t\t\t\tallele = a\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!allele) {\n\t\t\t\t// cannot match to allele!!!\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif (!allele.csq) {\n\t\t\tallele.csq = []\n\t\t}\n\t\tallele.csq.push(o)\n\n\t\t// gene\n\t\to._gene = o.SYMBOL || o.Gene\n\n\t\t// isoform\n\t\tif (o.Feature_type && o.Feature_type == 'Transcript') {\n\t\t\to._isoform = o.Feature.split('.')[0] // remove version\n\t\t} else {\n\t\t\to._isoform = o._gene\n\t\t}\n\n\t\t// class\n\t\tif (o.Consequence) {\n\t\t\tconst [dt, cls, rank] = vepinfo(o.Consequence)\n\t\t\to._dt = dt\n\t\t\to._class = cls\n\t\t\to._csqrank = rank\n\t\t} else {\n\t\t\t// FIXME\n\t\t\to._dt = dtsnvindel\n\t\t\to._class = mclassnonstandard\n\t\t}\n\t\t// mname\n\t\tif (o.HGVSp) {\n\t\t\to._mname = decodeURIComponent(o.HGVSp.substr(o.HGVSp.indexOf(':') + 1))\n\t\t} else if (o.Protein_position && o.Amino_acids) {\n\t\t\to._mname = decodeURIComponent(o.Protein_position + o.Amino_acids)\n\t\t} else if (o.HGVSc) {\n\t\t\to._mname = o.HGVSc.substr(o.HGVSc.indexOf(':') + 1)\n\t\t} else if (o.Existing_variation) {\n\t\t\to._name = o.Existing_variation\n\t\t}
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
3
|
+
"sources": ["../../src/vcf.csq.ts"],
|
|
4
|
+
"sourcesContent": ["import { vepinfo, dtsnvindel, mclassnonstandard } from './common.js'\n/*\nparse csq field from a variant line, not header\nCSQ header must have already been parsed\n\nstr: the csq value for a vcf line\nheader: [ // something like this\n { name: 'Allele' },\n { name: 'Consequence' },\n { name: 'IMPACT' },\n { name: 'SYMBOL' },\n { name: 'Gene' },\n { name: 'Feature_type' },\n { name: 'Feature' },\n { name: 'BIOTYPE' },\n { name: 'EXON' },\n { name: 'INTRON' },\n { name: 'HGVSc' },\n { name: 'HGVSp' },\n { name: 'cDNA_position' },\n { name: 'CDS_position' },\n { name: 'Protein_position' },\n { name: 'Amino_acids' },\n { name: 'Codons' },\n { name: 'Existing_variation' },\n { name: 'DISTANCE' },\n { name: 'STRAND' },\n { name: 'FLAGS' },\n { name: 'SYMBOL_SOURCE' },\n { name: 'HGNC_ID' },\n { name: 'CANONICAL' },\n { name: 'REFSEQ_MATCH' },\n { name: 'GIVEN_REF' },\n { name: 'USED_REF' },\n { name: 'BAM_EDIT' },\n { name: 'HGVS_OFFSET' },\n { name: 'CLIN_SIG' },\n { name: 'SOMATIC' },\n { name: 'PHENO' }\n]\n\nm: {\n\tmlst[ {} ]\n\t\t.allele_original\n\t\t.csq[ {} ] // parse_CSQ will add this array to this allele\n\t\t\t._class\n\t\t\t._csqrank\n\t\t\t._dt\n\t\t\t._gene\n\t\t\t._isoform\n\t\t\t._mname\n}\n\n*/\n\nexport function parse_CSQ(str, header, m) {\n\tif (!header) {\n\t\treturn null\n\t}\n\tfor (const thisannotation of str.split(',')) {\n\t\tconst lst = thisannotation.replace(/&/g, ',').split('|')\n\n\t\tconst o: Record<string, any> = {}\n\n\t\tfor (let i = 0; i < header.length; i++) {\n\t\t\tif (lst[i]) {\n\t\t\t\to[header[i].name] = lst[i]\n\t\t\t}\n\t\t}\n\t\tif (!o.Allele) {\n\t\t\tcontinue\n\t\t}\n\t\tlet allele: any = null\n\n\t\t//////////////////////////////////////\n\t\t// NOTE\n\t\t// mds2delete\n\t\t// m.alleles[] is based on old vcf parsing and may delete?\n\t\t// latest spec is m.mlst[]\n\t\t//////////////////////////////////////\n\n\t\tfor (const a of m.mlst || m.alleles) {\n\t\t\tif (a.allele_original == o.Allele) {\n\t\t\t\tallele = a\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif (!allele) {\n\t\t\tif (o.Allele == '-') {\n\t\t\t\t// deletion\n\t\t\t\tif (m.mlst) {\n\t\t\t\t\tif (m.mlst.length == 1) {\n\t\t\t\t\t\tallele = m.mlst[0]\n\t\t\t\t\t}\n\t\t\t\t} else if (m.alleles) {\n\t\t\t\t\tif (m.alleles.length == 1) {\n\t\t\t\t\t\tallele = m.alleles[0]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfor (const a of m.mlst || m.alleles) {\n\t\t\t\t\tif (a.allele_original.substr(1) == o.Allele) {\n\t\t\t\t\t\t// insertion, without first padding base\n\t\t\t\t\t\tallele = a\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!allele) {\n\t\t\t\t// cannot match to allele!!!\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\tif (!allele.csq) {\n\t\t\tallele.csq = []\n\t\t}\n\t\tallele.csq.push(o)\n\n\t\t// gene\n\t\to._gene = o.SYMBOL || o.Gene\n\n\t\t// isoform\n\t\tif (o.Feature_type && o.Feature_type == 'Transcript') {\n\t\t\to._isoform = o.Feature.split('.')[0] // remove version\n\t\t} else {\n\t\t\to._isoform = o._gene\n\t\t}\n\n\t\t// class\n\t\tif (o.Consequence) {\n\t\t\tconst [dt, cls, rank] = vepinfo(o.Consequence)\n\t\t\to._dt = dt\n\t\t\to._class = cls\n\t\t\to._csqrank = rank\n\t\t} else {\n\t\t\t// FIXME\n\t\t\to._dt = dtsnvindel\n\t\t\to._class = mclassnonstandard\n\t\t}\n\t\t// mname\n\t\tif (o.HGVSp) {\n\t\t\to._mname = decodeURIComponent(o.HGVSp.substr(o.HGVSp.indexOf(':') + 1))\n\t\t} else if (o.Protein_position && o.Amino_acids) {\n\t\t\to._mname = decodeURIComponent(o.Protein_position + o.Amino_acids)\n\t\t} else if (o.HGVSc) {\n\t\t\to._mname = o.HGVSc.substr(o.HGVSc.indexOf(':') + 1)\n\t\t} else if (o.Existing_variation) {\n\t\t\to._name = o.Existing_variation\n\t\t}\n\t}\n\treturn true\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,YAAY,yBAAyB;AAuDhD,SAAS,UAAU,KAAK,QAAQ,GAAG;AACzC,MAAI,CAAC,QAAQ;AACZ,WAAO;AAAA,EACR;AACA,aAAW,kB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W,EAAE;AAAA,IAChB;AAGA,QAAI,EAAE,aAAa;AAClB,YAAM,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,EAAE,WAAW;AAC7C,QAAE,MAAM;AACR,QAAE,SAAS;AACX,QAAE,WAAW;AAAA,IACd,OAAO;AAEN,QAAE,MAAM;AACR,QAAE,SAAS;AAAA,IACZ;AAEA,QAAI,EAAE,OAAO;AACZ,QAAE,SAAS,mBAAmB,EAAE,MAAM,OAAO,EAAE,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC;AAAA,IACvE,WAAW,EAAE,oBAAoB,EAAE,aAAa;AAC/C,QAAE,SAAS,mBAAmB,EAAE,mBAAmB,EAAE,WAAW;AAAA,IACjE,WAAW,EAAE,OAAO;AACnB,QAAE,SAAS,EAAE,MAAM,OAAO,EAAE,MAAM,QAAQ,GAAG,IAAI,CAAC;AAAA,IACnD,WAAW,EAAE,oBAAoB;AAChC,QAAE,QAAQ,EAAE;AAAA,IACb;AAAA,EACD;AACA,SAAO;AACR;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dissect_INFO(str: any): {};
|
package/dist/src/vcf.info.js.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/vcf.info.
|
|
3
|
+
"sources": ["../../src/vcf.info.ts"],
|
|
4
4
|
"sourcesContent": ["/*\nto parse a variant line, not header\n\ncannot simply slice by /[;=]/, but read char by char\ncase CLNVI=Breast_Cancer_Information_Core__(BRCA2):745-4&base_change=C_to_G;\ncase k1=v1;DB;k2=v2;\n*/\nexport function dissect_INFO(str) {\n\t//let findequal=true\n\tlet findsemicolon = false\n\tlet findequalorsemicolon = true\n\n\tlet i = 0\n\tlet idx = 0\n\n\tconst k2v = {}\n\tlet lastkey\n\n\twhile (i < str.length) {\n\t\tconst c = str[i]\n\t\tif (findequalorsemicolon) {\n\t\t\tif (c == '=') {\n\t\t\t\tfindsemicolon = true\n\t\t\t\tfindequalorsemicolon = false\n\t\t\t\tlastkey = str.substring(idx, i)\n\t\t\t\tidx = i + 1\n\t\t\t} else if (c == ';') {\n\t\t\t\t// should be a flag\n\t\t\t\tk2v[str.substring(idx, i)] = 1\n\t\t\t\tidx = i + 1\n\t\t\t}\n\t\t} else if (findsemicolon && c == ';') {\n\t\t\tfindequalorsemicolon = true\n\t\t\tfindsemicolon = false\n\t\t\tk2v[lastkey] = str.substring(idx, i)\n\t\t\tlastkey = null\n\t\t\tidx = i + 1\n\t\t}\n\t\ti++\n\t}\n\n\tconst remainstr = str.substr(idx, i)\n\tif (lastkey) {\n\t\tk2v[lastkey] = remainstr\n\t} else {\n\t\tk2v[remainstr] = 1\n\t}\n\n\treturn k2v\n}\n"],
|
|
5
5
|
"mappings": "AAOO,SAAS,aAAa,KAAK;AAEjC,MAAI,gBAAgB;AACpB,MAAI,uBAAuB;AAE3B,MAAI,IAAI;AACR,MAAI,MAAM;AAEV,QAAM,MAAM,CAAC;AACb,MAAI;AAEJ,SAAO,IAAI,IAAI,QAAQ;AACtB,UAAM,IAAI,IAAI,CAAC;AACf,QAAI,sBAAsB;AACzB,UAAI,KAAK,KAAK;AACb,wBAAgB;AAChB,+BAAuB;AACvB,kBAAU,IAAI,UAAU,KAAK,CAAC;AAC9B,cAAM,IAAI;AAAA,MACX,WAAW,KAAK,KAAK;AAEpB,YAAI,IAAI,UAAU,KAAK,CAAC,CAAC,IAAI;AAC7B,cAAM,IAAI;AAAA,MACX;AAAA,IACD,WAAW,iBAAiB,KAAK,KAAK;AACrC,6BAAuB;AACvB,sBAAgB;AAChB,UAAI,OAAO,IAAI,IAAI,UAAU,KAAK,CAAC;AACnC,gBAAU;AACV,YAAM,IAAI;AAAA,IACX;AACA;AAAA,EACD;AAEA,QAAM,YAAY,IAAI,OAAO,KAAK,CAAC;AACnC,MAAI,SAAS;AACZ,QAAI,OAAO,IAAI;AAAA,EAChB,OAAO;AACN,QAAI,SAAS,IAAI;AAAA,EAClB;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": []
|