@sjcrh/proteinpaint-shared 2.179.0 → 2.180.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/package.json +1 -1
- package/src/terms.js +288 -308
package/package.json
CHANGED
package/src/terms.js
CHANGED
|
@@ -1,329 +1,309 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
INTEGER,
|
|
61
|
-
FLOAT,
|
|
62
|
-
SNP,
|
|
63
|
-
SNP_LIST,
|
|
64
|
-
SNP_LOCUS,
|
|
65
|
-
CONDITION,
|
|
66
|
-
SURVIVAL,
|
|
67
|
-
SAMPLELST,
|
|
68
|
-
METABOLITE_INTENSITY,
|
|
69
|
-
WHOLE_PROTEOME_ABUNDANCE,
|
|
70
|
-
SINGLECELL_CELLTYPE,
|
|
71
|
-
SINGLECELL_GENE_EXPRESSION,
|
|
72
|
-
MULTIVALUE,
|
|
73
|
-
DATE,
|
|
74
|
-
TERM_COLLECTION
|
|
75
|
-
}
|
|
76
|
-
export const dtTermTypes = new Set(dtTerms.map(t => t.type))
|
|
2
|
+
dtgeneexpression,
|
|
3
|
+
dtssgsea,
|
|
4
|
+
dtdnamethylation,
|
|
5
|
+
dtmetaboliteintensity,
|
|
6
|
+
dtwholeproteomeabundance,
|
|
7
|
+
TermTypeGroups,
|
|
8
|
+
dtTerms
|
|
9
|
+
} from "./common.js";
|
|
10
|
+
import { TermTypeGroups as TermTypeGroups2 } from "./common.js";
|
|
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 INTEGER = "integer";
|
|
25
|
+
const METABOLITE_INTENSITY = "metaboliteIntensity";
|
|
26
|
+
const MULTIVALUE = "multivalue";
|
|
27
|
+
const SAMPLELST = "samplelst";
|
|
28
|
+
const SINGLECELL_CELLTYPE = "singleCellCellType";
|
|
29
|
+
const SINGLECELL_GENE_EXPRESSION = "singleCellGeneExpression";
|
|
30
|
+
const SNP = "snp";
|
|
31
|
+
const SNP_LIST = "snplst";
|
|
32
|
+
const SNP_LOCUS = "snplocus";
|
|
33
|
+
const SSGSEA = "ssGSEA";
|
|
34
|
+
const SURVIVAL = "survival";
|
|
35
|
+
const TERM_COLLECTION = "termCollection";
|
|
36
|
+
const WHOLE_PROTEOME_ABUNDANCE = "wholeProteomeAbundance";
|
|
37
|
+
const TermTypes = {
|
|
38
|
+
GENE_VARIANT,
|
|
39
|
+
GENE_EXPRESSION,
|
|
40
|
+
SSGSEA,
|
|
41
|
+
DNA_METHYLATION,
|
|
42
|
+
CATEGORICAL,
|
|
43
|
+
INTEGER,
|
|
44
|
+
FLOAT,
|
|
45
|
+
SNP,
|
|
46
|
+
SNP_LIST,
|
|
47
|
+
SNP_LOCUS,
|
|
48
|
+
CONDITION,
|
|
49
|
+
SURVIVAL,
|
|
50
|
+
SAMPLELST,
|
|
51
|
+
METABOLITE_INTENSITY,
|
|
52
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
53
|
+
SINGLECELL_CELLTYPE,
|
|
54
|
+
SINGLECELL_GENE_EXPRESSION,
|
|
55
|
+
MULTIVALUE,
|
|
56
|
+
DATE,
|
|
57
|
+
TERM_COLLECTION
|
|
58
|
+
};
|
|
59
|
+
const dtTermTypes = new Set(dtTerms.map((t) => t.type));
|
|
77
60
|
for (const dtTermType of dtTermTypes) {
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const NUMERIC_DICTIONARY_TERM = 'numericDictTerm'
|
|
82
|
-
|
|
83
|
-
export const TermTypes2Dt = {
|
|
84
|
-
[GENE_EXPRESSION]: dtgeneexpression,
|
|
85
|
-
[SSGSEA]: dtssgsea,
|
|
86
|
-
[DNA_METHYLATION]: dtdnamethylation,
|
|
87
|
-
[METABOLITE_INTENSITY]: dtmetaboliteintensity,
|
|
88
|
-
[WHOLE_PROTEOME_ABUNDANCE]: dtwholeproteomeabundance
|
|
61
|
+
TermTypes[dtTermType.toUpperCase()] = dtTermType;
|
|
89
62
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
63
|
+
const NUMERIC_DICTIONARY_TERM = "numericDictTerm";
|
|
64
|
+
const TermTypes2Dt = {
|
|
65
|
+
[GENE_EXPRESSION]: dtgeneexpression,
|
|
66
|
+
[SSGSEA]: dtssgsea,
|
|
67
|
+
[DNA_METHYLATION]: dtdnamethylation,
|
|
68
|
+
[METABOLITE_INTENSITY]: dtmetaboliteintensity,
|
|
69
|
+
[WHOLE_PROTEOME_ABUNDANCE]: dtwholeproteomeabundance
|
|
70
|
+
};
|
|
71
|
+
const typeGroup = {
|
|
72
|
+
[CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
73
|
+
[CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
74
|
+
[FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
75
|
+
[INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
76
|
+
[SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
77
|
+
[SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
78
|
+
[DATE]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
79
|
+
[MULTIVALUE]: TermTypeGroups.DICTIONARY_VARIABLES,
|
|
80
|
+
[GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,
|
|
81
|
+
[SNP]: TermTypeGroups.SNP,
|
|
82
|
+
[SNP_LIST]: TermTypeGroups.SNP_LIST,
|
|
83
|
+
[SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,
|
|
84
|
+
[GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,
|
|
85
|
+
[SSGSEA]: TermTypeGroups.SSGSEA,
|
|
86
|
+
[DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,
|
|
87
|
+
[METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,
|
|
88
|
+
[WHOLE_PROTEOME_ABUNDANCE]: TermTypeGroups.WHOLE_PROTEOME_ABUNDANCE,
|
|
89
|
+
[TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,
|
|
90
|
+
[SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,
|
|
91
|
+
[SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION
|
|
92
|
+
};
|
|
93
|
+
const nonDictTypes = /* @__PURE__ */ new Set([
|
|
94
|
+
SNP,
|
|
95
|
+
SNP_LIST,
|
|
96
|
+
SNP_LOCUS,
|
|
97
|
+
GENE_EXPRESSION,
|
|
98
|
+
SSGSEA,
|
|
99
|
+
DNA_METHYLATION,
|
|
100
|
+
GENE_VARIANT,
|
|
101
|
+
METABOLITE_INTENSITY,
|
|
102
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
103
|
+
SINGLECELL_CELLTYPE,
|
|
104
|
+
SINGLECELL_GENE_EXPRESSION
|
|
105
|
+
]);
|
|
128
106
|
for (const dtTermType of dtTermTypes) {
|
|
129
|
-
|
|
107
|
+
nonDictTypes.add(TermTypes[dtTermType.toUpperCase()]);
|
|
130
108
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
])
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const categoricalTypes = new Set([CATEGORICAL, SNP])
|
|
149
|
-
|
|
150
|
-
const singleCellTerms = new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION])
|
|
151
|
-
|
|
152
|
-
export function isSingleCellTerm(term) {
|
|
153
|
-
if (!term) return false
|
|
154
|
-
return singleCellTerms.has(term.type)
|
|
109
|
+
const numericTypes = /* @__PURE__ */ new Set([
|
|
110
|
+
INTEGER,
|
|
111
|
+
FLOAT,
|
|
112
|
+
GENE_EXPRESSION,
|
|
113
|
+
SSGSEA,
|
|
114
|
+
DNA_METHYLATION,
|
|
115
|
+
METABOLITE_INTENSITY,
|
|
116
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
117
|
+
SINGLECELL_GENE_EXPRESSION,
|
|
118
|
+
DATE
|
|
119
|
+
]);
|
|
120
|
+
const annoNumericTypes = /* @__PURE__ */ new Set([INTEGER, FLOAT, DATE]);
|
|
121
|
+
const categoricalTypes = /* @__PURE__ */ new Set([CATEGORICAL, SNP]);
|
|
122
|
+
const singleCellTerms = /* @__PURE__ */ new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION]);
|
|
123
|
+
function isSingleCellTerm(term) {
|
|
124
|
+
if (!term) return false;
|
|
125
|
+
return singleCellTerms.has(term.type);
|
|
155
126
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
127
|
+
function isNumericTerm(term) {
|
|
128
|
+
if (!term) return false;
|
|
129
|
+
return numericTypes.has(term.type);
|
|
159
130
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
131
|
+
function isCategoricalTerm(term) {
|
|
132
|
+
if (!term) return false;
|
|
133
|
+
return categoricalTypes.has(term.type);
|
|
163
134
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return !isNonDictionaryType(type)
|
|
135
|
+
function isDictionaryType(type) {
|
|
136
|
+
return !isNonDictionaryType(type);
|
|
167
137
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return nonDictTypes.has(type)
|
|
138
|
+
function isNonDictionaryType(type) {
|
|
139
|
+
if (!type) throw new Error("Type is not defined");
|
|
140
|
+
return nonDictTypes.has(type);
|
|
172
141
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
default:
|
|
198
|
-
return false
|
|
199
|
-
}
|
|
142
|
+
function equals(t1, t2) {
|
|
143
|
+
if (!t1) throw new Error("First term is not defined ");
|
|
144
|
+
if (!t2) throw new Error("Second term is not defined ");
|
|
145
|
+
if (t1.type !== t2.type) return false;
|
|
146
|
+
if (isDictionaryType(t1.type) && isDictionaryType(t2.type) && t1.type != SAMPLELST) return t1.id === t2.id;
|
|
147
|
+
switch (t1.type) {
|
|
148
|
+
case GENE_EXPRESSION:
|
|
149
|
+
return t1.gene == t2.gene;
|
|
150
|
+
case SSGSEA:
|
|
151
|
+
return t1.id == t2.id;
|
|
152
|
+
case DNA_METHYLATION:
|
|
153
|
+
return t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
|
|
154
|
+
case METABOLITE_INTENSITY:
|
|
155
|
+
case WHOLE_PROTEOME_ABUNDANCE:
|
|
156
|
+
return t1.name == t2.name;
|
|
157
|
+
case GENE_VARIANT:
|
|
158
|
+
return t1.gene == t2.gene || t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
|
|
159
|
+
// TO DO: Add more cases
|
|
160
|
+
// case SNP_LIST:
|
|
161
|
+
// case SNP_LOCUS:
|
|
162
|
+
// case SAMPLELST:
|
|
163
|
+
default:
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
200
166
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
(b.startinclusive && value == b.start) ||
|
|
215
|
-
(b.stopinclusive && value == b.stop)
|
|
216
|
-
)
|
|
217
|
-
return bin
|
|
167
|
+
function getBin(lst, value) {
|
|
168
|
+
let bin = lst.findIndex(
|
|
169
|
+
(b) => b.startunbounded && value < b.stop || b.startunbounded && b.stopinclusive && value == b.stop
|
|
170
|
+
);
|
|
171
|
+
if (bin == -1)
|
|
172
|
+
bin = lst.findIndex(
|
|
173
|
+
(b) => b.stopunbounded && value > b.start || b.stopunbounded && b.startinclusive && value == b.start
|
|
174
|
+
);
|
|
175
|
+
if (bin == -1)
|
|
176
|
+
bin = lst.findIndex(
|
|
177
|
+
(b) => value > b.start && value < b.stop || b.startinclusive && value == b.start || b.stopinclusive && value == b.stop
|
|
178
|
+
);
|
|
179
|
+
return bin;
|
|
218
180
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const key = Object.keys(term.values)[0]
|
|
231
|
-
const sampleId = term.values[key].list[0]?.sampleId
|
|
232
|
-
if (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId)
|
|
233
|
-
else return DEFAULT_SAMPLE_TYPE
|
|
234
|
-
}
|
|
235
|
-
// samplelst or non dict terms
|
|
236
|
-
return DEFAULT_SAMPLE_TYPE //later own term needs to know what type annotates based on the samples
|
|
181
|
+
function getSampleType(term, ds) {
|
|
182
|
+
if (!term) return null;
|
|
183
|
+
if (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE;
|
|
184
|
+
if (term.id) return ds.cohort.termdb.term2SampleType.get(term.id);
|
|
185
|
+
if (term.type == "samplelst") {
|
|
186
|
+
const key = Object.keys(term.values)[0];
|
|
187
|
+
const sampleId = term.values[key].list[0]?.sampleId;
|
|
188
|
+
if (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId);
|
|
189
|
+
else return DEFAULT_SAMPLE_TYPE;
|
|
190
|
+
}
|
|
191
|
+
return DEFAULT_SAMPLE_TYPE;
|
|
237
192
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
return null //no parent found
|
|
193
|
+
function getParentType(types, ds) {
|
|
194
|
+
if (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null;
|
|
195
|
+
const ids = Array.from(types);
|
|
196
|
+
if (!ids || ids.length == 0) return null;
|
|
197
|
+
for (const id of ids) {
|
|
198
|
+
const typeObj = ds.cohort.termdb.sampleTypes[id];
|
|
199
|
+
if (!typeObj) continue;
|
|
200
|
+
if (typeObj.parent_id == null) return id;
|
|
201
|
+
if (ids.includes(typeObj.parent_id)) continue;
|
|
202
|
+
else return typeObj.parent_id;
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
252
205
|
}
|
|
253
|
-
|
|
254
|
-
//Returns human readable label for each term type; label is just for printing and not computing
|
|
255
206
|
const typeMap = {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
return typeMap[type] || 'Unknown term type'
|
|
207
|
+
categorical: "Categorical",
|
|
208
|
+
condition: "Condition",
|
|
209
|
+
float: "Numerical",
|
|
210
|
+
integer: "Numerical",
|
|
211
|
+
geneExpression: "Gene Expression",
|
|
212
|
+
ssGSEA: "Geneset Expression",
|
|
213
|
+
dnaMethylation: "DNA Methylation",
|
|
214
|
+
geneVariant: "Gene Variant",
|
|
215
|
+
metaboliteIntensity: "Metabolite Intensity",
|
|
216
|
+
wholeProteomeAbundance: "Whole Proteome Abundance",
|
|
217
|
+
multivalue: "Multi Value",
|
|
218
|
+
singleCellGeneExpression: "Single Cell, Gene Expression",
|
|
219
|
+
singleCellCellType: "Single Cell, Cell Type",
|
|
220
|
+
snplocus: "SNP Locus",
|
|
221
|
+
snp: "SNP",
|
|
222
|
+
snplst: "SNP List",
|
|
223
|
+
numericDictTerm: "Numeric Dictionary Term",
|
|
224
|
+
termCollection: "Term Collection"
|
|
225
|
+
};
|
|
226
|
+
function termType2label(type) {
|
|
227
|
+
return typeMap[type] || "Unknown term type";
|
|
278
228
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return date
|
|
229
|
+
function getDateFromNumber(value) {
|
|
230
|
+
const year = Math.floor(value);
|
|
231
|
+
const january1st = new Date(year, 0, 1);
|
|
232
|
+
const totalDays = getDaysInYear(year);
|
|
233
|
+
const time = Math.round((value - year) * totalDays) * oneDayTime;
|
|
234
|
+
const date = new Date(january1st.getTime() + time);
|
|
235
|
+
return date;
|
|
287
236
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
*/
|
|
296
|
-
const oneDayTime = 24 * 60 * 60 * 1000
|
|
297
|
-
|
|
298
|
-
export function getDateStrFromNumber(value) {
|
|
299
|
-
const date = getDateFromNumber(value)
|
|
300
|
-
|
|
301
|
-
//Omit day to deidentify the patients
|
|
302
|
-
return date.toLocaleDateString('en-US', {
|
|
303
|
-
year: 'numeric',
|
|
304
|
-
month: 'long'
|
|
305
|
-
})
|
|
237
|
+
const oneDayTime = 24 * 60 * 60 * 1e3;
|
|
238
|
+
function getDateStrFromNumber(value) {
|
|
239
|
+
const date = getDateFromNumber(value);
|
|
240
|
+
return date.toLocaleDateString("en-US", {
|
|
241
|
+
year: "numeric",
|
|
242
|
+
month: "long"
|
|
243
|
+
});
|
|
306
244
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
//represents the fraction of the year that has elapsed.
|
|
311
|
-
export function getNumberFromDateStr(str) {
|
|
312
|
-
const date = new Date(str)
|
|
313
|
-
return getNumberFromDate(date)
|
|
245
|
+
function getNumberFromDateStr(str) {
|
|
246
|
+
const date = new Date(str);
|
|
247
|
+
return getNumberFromDate(date);
|
|
314
248
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
return year + decimal
|
|
249
|
+
function getNumberFromDate(date) {
|
|
250
|
+
const year = date.getFullYear();
|
|
251
|
+
const january1st = new Date(year, 0, 1);
|
|
252
|
+
const diffDays = (date.getTime() - january1st.getTime()) / oneDayTime;
|
|
253
|
+
const daysTotal = getDaysInYear(year);
|
|
254
|
+
const decimal = diffDays / daysTotal;
|
|
255
|
+
return year + decimal;
|
|
323
256
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
return days
|
|
257
|
+
function getDaysInYear(year) {
|
|
258
|
+
const isLeap = new Date(year, 1, 29).getMonth() === 1;
|
|
259
|
+
const days = isLeap ? 366 : 365;
|
|
260
|
+
return days;
|
|
329
261
|
}
|
|
262
|
+
export {
|
|
263
|
+
CATEGORICAL,
|
|
264
|
+
CONDITION,
|
|
265
|
+
DATE,
|
|
266
|
+
DEFAULT_SAMPLE_TYPE,
|
|
267
|
+
DNA_METHYLATION,
|
|
268
|
+
FLOAT,
|
|
269
|
+
GENE_EXPRESSION,
|
|
270
|
+
GENE_VARIANT,
|
|
271
|
+
INTEGER,
|
|
272
|
+
METABOLITE_INTENSITY,
|
|
273
|
+
MULTIVALUE,
|
|
274
|
+
NUMERIC_DICTIONARY_TERM,
|
|
275
|
+
NumericModes,
|
|
276
|
+
ROOT_SAMPLE_TYPE,
|
|
277
|
+
SAMPLELST,
|
|
278
|
+
SINGLECELL_CELLTYPE,
|
|
279
|
+
SINGLECELL_GENE_EXPRESSION,
|
|
280
|
+
SNP,
|
|
281
|
+
SNP_LIST,
|
|
282
|
+
SNP_LOCUS,
|
|
283
|
+
SSGSEA,
|
|
284
|
+
SURVIVAL,
|
|
285
|
+
TERM_COLLECTION,
|
|
286
|
+
TermTypeGroups2 as TermTypeGroups,
|
|
287
|
+
TermTypes,
|
|
288
|
+
TermTypes2Dt,
|
|
289
|
+
WHOLE_PROTEOME_ABUNDANCE,
|
|
290
|
+
annoNumericTypes,
|
|
291
|
+
dtTermTypes,
|
|
292
|
+
equals,
|
|
293
|
+
getBin,
|
|
294
|
+
getDateFromNumber,
|
|
295
|
+
getDateStrFromNumber,
|
|
296
|
+
getDaysInYear,
|
|
297
|
+
getNumberFromDate,
|
|
298
|
+
getNumberFromDateStr,
|
|
299
|
+
getParentType,
|
|
300
|
+
getSampleType,
|
|
301
|
+
isCategoricalTerm,
|
|
302
|
+
isDictionaryType,
|
|
303
|
+
isNonDictionaryType,
|
|
304
|
+
isNumericTerm,
|
|
305
|
+
isSingleCellTerm,
|
|
306
|
+
numericTypes,
|
|
307
|
+
termType2label,
|
|
308
|
+
typeGroup
|
|
309
|
+
};
|