@sjcrh/proteinpaint-shared 2.187.0 → 2.188.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/README.md +10 -2
  2. package/constants/AiHisto.ts +27 -0
  3. package/constants/README.md +11 -0
  4. package/devTs.ts +3 -0
  5. package/dist/constants/AiHisto.d.ts +23 -0
  6. package/dist/constants/AiHisto.js +31 -0
  7. package/dist/constants/AiHisto.js.map +7 -0
  8. package/dist/src/aiHisto.d.ts +5 -0
  9. package/dist/src/aiHisto.js +15 -0
  10. package/dist/src/aiHisto.js.map +7 -0
  11. package/dist/src/bulk.cnv.js +83 -0
  12. package/dist/src/bulk.cnv.js.map +7 -0
  13. package/dist/src/bulk.del.js +119 -0
  14. package/dist/src/bulk.del.js.map +7 -0
  15. package/dist/src/bulk.itd.js +119 -0
  16. package/dist/src/bulk.itd.js.map +7 -0
  17. package/dist/src/bulk.js +183 -0
  18. package/dist/src/bulk.js.map +7 -0
  19. package/dist/src/bulk.snv.js +175 -0
  20. package/dist/src/bulk.snv.js.map +7 -0
  21. package/dist/src/bulk.sv.js +266 -0
  22. package/dist/src/bulk.sv.js.map +7 -0
  23. package/dist/src/bulk.svjson.js +151 -0
  24. package/dist/src/bulk.svjson.js.map +7 -0
  25. package/dist/src/bulk.trunc.js +122 -0
  26. package/dist/src/bulk.trunc.js.map +7 -0
  27. package/dist/src/clustering.js +71 -0
  28. package/dist/src/clustering.js.map +7 -0
  29. package/dist/src/common.js +1302 -0
  30. package/dist/src/common.js.map +7 -0
  31. package/dist/src/compute.percentile.js +10 -0
  32. package/dist/src/compute.percentile.js.map +7 -0
  33. package/dist/src/doc.d.ts +7 -0
  34. package/dist/src/doc.js +10 -0
  35. package/dist/src/doc.js.map +7 -0
  36. package/dist/src/fetch-helpers.js +177 -0
  37. package/dist/src/fetch-helpers.js.map +7 -0
  38. package/dist/src/fileSize.js +10 -0
  39. package/dist/src/fileSize.js.map +7 -0
  40. package/dist/src/filter.d.ts +62 -0
  41. package/dist/src/filter.js +194 -0
  42. package/dist/src/filter.js.map +7 -0
  43. package/dist/src/hash.js +20 -0
  44. package/dist/src/hash.js.map +7 -0
  45. package/dist/src/helpers.js +66 -0
  46. package/dist/src/helpers.js.map +7 -0
  47. package/dist/src/index.d.ts +26 -0
  48. package/dist/src/index.js +27 -0
  49. package/dist/src/index.js.map +7 -0
  50. package/dist/src/joinUrl.d.ts +1 -0
  51. package/dist/src/joinUrl.js +17 -0
  52. package/dist/src/joinUrl.js.map +7 -0
  53. package/dist/src/mds3tk.js +64 -0
  54. package/dist/src/mds3tk.js.map +7 -0
  55. package/dist/src/roundValue.js +57 -0
  56. package/dist/src/roundValue.js.map +7 -0
  57. package/dist/src/termdb.bins.js +272 -0
  58. package/dist/src/termdb.bins.js.map +7 -0
  59. package/dist/src/termdb.initbinconfig.js +79 -0
  60. package/dist/src/termdb.initbinconfig.js.map +7 -0
  61. package/dist/src/termdb.usecase.js +239 -0
  62. package/dist/src/termdb.usecase.js.map +7 -0
  63. package/dist/src/terms.d.ts +83 -0
  64. package/dist/src/terms.js +327 -0
  65. package/dist/src/terms.js.map +7 -0
  66. package/dist/src/time.d.ts +9 -0
  67. package/dist/src/time.js +23 -0
  68. package/dist/src/time.js.map +7 -0
  69. package/dist/src/tree.js +82 -0
  70. package/dist/src/tree.js.map +7 -0
  71. package/dist/src/urljson.d.ts +8 -0
  72. package/dist/src/urljson.js +31 -0
  73. package/dist/src/urljson.js.map +7 -0
  74. package/dist/src/vcf.ann.js +56 -0
  75. package/dist/src/vcf.ann.js.map +7 -0
  76. package/dist/src/vcf.csq.js +82 -0
  77. package/dist/src/vcf.csq.js.map +7 -0
  78. package/dist/src/vcf.info.js +40 -0
  79. package/dist/src/vcf.info.js.map +7 -0
  80. package/dist/src/vcf.js +439 -0
  81. package/dist/src/vcf.js.map +7 -0
  82. package/dist/src/vcf.type.js +17 -0
  83. package/dist/src/vcf.type.js.map +7 -0
  84. package/package.json +20 -11
  85. package/src/bulk.cnv.js +0 -86
  86. package/src/bulk.del.js +0 -124
  87. package/src/bulk.itd.js +0 -123
  88. package/src/bulk.js +0 -197
  89. package/src/bulk.snv.js +0 -271
  90. package/src/bulk.sv.js +0 -276
  91. package/src/bulk.svjson.js +0 -164
  92. package/src/bulk.trunc.js +0 -132
  93. package/src/clustering.js +0 -66
  94. package/src/common.js +0 -1608
  95. package/src/compute.percentile.js +0 -11
  96. package/src/doc.js +0 -6
  97. package/src/fetch-helpers.js +0 -323
  98. package/src/fileSize.js +0 -6
  99. package/src/filter.js +0 -221
  100. package/src/hash.js +0 -21
  101. package/src/helpers.js +0 -88
  102. package/src/index.js +0 -26
  103. package/src/joinUrl.js +0 -14
  104. package/src/mds3tk.js +0 -100
  105. package/src/roundValue.js +0 -94
  106. package/src/termdb.bins.js +0 -456
  107. package/src/termdb.initbinconfig.js +0 -130
  108. package/src/termdb.usecase.js +0 -344
  109. package/src/terms.js +0 -341
  110. package/src/time.js +0 -22
  111. package/src/tree.js +0 -138
  112. package/src/urljson.js +0 -41
  113. package/src/vcf.ann.js +0 -62
  114. package/src/vcf.csq.js +0 -153
  115. package/src/vcf.info.js +0 -50
  116. package/src/vcf.js +0 -654
  117. package/src/vcf.type.js +0 -24
@@ -0,0 +1,239 @@
1
+ import {
2
+ TermTypes,
3
+ isNumericTerm,
4
+ SINGLECELL_CELLTYPE,
5
+ SINGLECELL_GENE_EXPRESSION,
6
+ ISOFORM_EXPRESSION
7
+ } from "./terms.js";
8
+ const graphableTypes = /* @__PURE__ */ new Set([
9
+ "categorical",
10
+ "integer",
11
+ "float",
12
+ "condition",
13
+ "survival",
14
+ "snplst",
15
+ "snplocus",
16
+ "geneVariant",
17
+ "samplelst",
18
+ "geneExpression",
19
+ ISOFORM_EXPRESSION,
20
+ "dtcnv",
21
+ "dtsnvindel",
22
+ "dtfusion",
23
+ "dtsv",
24
+ "date",
25
+ TermTypes.SSGSEA,
26
+ TermTypes.DNA_METHYLATION,
27
+ TermTypes.METABOLITE_INTENSITY,
28
+ TermTypes.PROTEOME_ABUNDANCE,
29
+ SINGLECELL_GENE_EXPRESSION,
30
+ SINGLECELL_CELLTYPE,
31
+ TermTypes.SNP,
32
+ TermTypes.TERM_COLLECTION
33
+ ]);
34
+ function isUsableTerm(term, _usecase, termdbConfig, ds) {
35
+ const usecase = _usecase || {};
36
+ if (typeof ds?.usecase?.[usecase.target] == "function") {
37
+ return ds.usecase[usecase.target](term, usecase);
38
+ }
39
+ const uses = /* @__PURE__ */ new Set();
40
+ const child_types = term.child_types || [];
41
+ switch (usecase.target) {
42
+ case "barchart":
43
+ case "violin":
44
+ case "boxplot":
45
+ case "summary":
46
+ if (term.type && term.type !== "survival") uses.add("plot");
47
+ if (hasAllowedChildTypes(child_types, ["survival"])) uses.add("branch");
48
+ return uses;
49
+ case "summaryInput":
50
+ if (usecase.detail === "term2" || usecase.detail == "term0") {
51
+ if (term.type && term.type !== "survival") uses.add("plot");
52
+ if (hasAllowedChildTypes(child_types, ["survival"])) uses.add("branch");
53
+ return uses;
54
+ } else {
55
+ if (graphableTypes.has(term.type)) uses.add("plot");
56
+ if (!term.isleaf) uses.add("branch");
57
+ return uses;
58
+ }
59
+ case "matrix":
60
+ if (term.type) uses.add("plot");
61
+ if (!term.isleaf) uses.add("branch");
62
+ return uses;
63
+ case "table":
64
+ if (usecase.detail == "term") uses.add("plot");
65
+ if (child_types.length > 1) uses.add("branch");
66
+ return uses;
67
+ case "sampleScatter":
68
+ if (usecase.detail == "numeric") {
69
+ if (isNumericTerm(term)) {
70
+ uses.add("plot");
71
+ }
72
+ if (hasNumericChild(child_types)) uses.add("branch");
73
+ } else {
74
+ if (graphableTypes.has(term.type)) uses.add("plot");
75
+ if (!term.isleaf) uses.add("branch");
76
+ }
77
+ return uses;
78
+ case "runChart2":
79
+ if (usecase.detail == "date" || usecase.detail == "xtw") {
80
+ if (term.type == "date") {
81
+ uses.add("plot");
82
+ }
83
+ if (child_types.includes("date")) uses.add("branch");
84
+ } else if (usecase.detail == "numeric") {
85
+ if (isNumericTerm(term) && term.type != "date") {
86
+ uses.add("plot");
87
+ }
88
+ if (hasNumericChild(child_types)) uses.add("branch");
89
+ } else {
90
+ if (graphableTypes.has(term.type)) uses.add("plot");
91
+ if (!term.isleaf) uses.add("branch");
92
+ }
93
+ return uses;
94
+ case "numericDictTermCluster":
95
+ if (!usecase.detail?.exclude?.includes(term.id)) {
96
+ if (isNumericTerm(term)) {
97
+ uses.add("plot");
98
+ }
99
+ if (hasNumericChild(child_types)) {
100
+ uses.add("branch");
101
+ }
102
+ }
103
+ return uses;
104
+ case "termCollections":
105
+ if (usecase.detail?.termIds?.includes(term.id)) uses.add("plot");
106
+ if (usecase.detail?.branchIds?.includes(term.id)) uses.add("branch");
107
+ return uses;
108
+ case "profileForms":
109
+ if (!term.isleaf) {
110
+ const ancestors = term.id.split("__").length;
111
+ if (ancestors == 3) {
112
+ uses.add("plot");
113
+ } else if (ancestors < 3) uses.add("branch");
114
+ }
115
+ return uses;
116
+ case "profileForms2": {
117
+ if (term.isleaf) return uses;
118
+ const allowed = termdbConfig?.plotConfigByCohort?.[usecase.cohort]?.profileForms2?.domains;
119
+ if (!allowed) return uses;
120
+ const ancestors = term.id.split("__").length;
121
+ const subtype = usecase.subtype;
122
+ if (ancestors == 3) {
123
+ if (allowed.find((d) => d.id === term.id)?.plotTypes?.includes(subtype)) uses.add("plot");
124
+ } else if (ancestors < 3) {
125
+ const prefix = term.id + "__";
126
+ if (allowed.some((d) => d.id.startsWith(prefix) && d.plotTypes.includes(subtype))) {
127
+ uses.add("branch");
128
+ }
129
+ }
130
+ return uses;
131
+ }
132
+ // case 'boxplot':
133
+ // if (term.type == 'float' || term.type == 'integer') uses.add('plot')
134
+ // if (usecase.detail === 'term2' && hasNumericChild(child_types)) uses.add('branch')
135
+ // return uses
136
+ case "cuminc":
137
+ if (usecase.detail == "term") {
138
+ if (term.type == "condition") uses.add("plot");
139
+ if (child_types.includes("condition")) uses.add("branch");
140
+ return uses;
141
+ }
142
+ if (usecase.detail === "term2" || usecase.detail == "term0") {
143
+ if (term.type && term.type != "condition" && term.type != "survival") uses.add("plot");
144
+ if (hasAllowedChildTypes(child_types, ["condition", "survival"])) uses.add("branch");
145
+ return uses;
146
+ }
147
+ return uses;
148
+ case "survival":
149
+ if (usecase.detail == "term") {
150
+ if (term.type == "survival") uses.add("plot");
151
+ if (child_types.includes("survival")) uses.add("branch");
152
+ return uses;
153
+ }
154
+ if (usecase.detail === "term2" || usecase.detail == "term0") {
155
+ if (term.type && term.type != "survival") uses.add("plot");
156
+ if (hasAllowedChildTypes(child_types, ["survival"])) uses.add("branch");
157
+ return uses;
158
+ }
159
+ return uses;
160
+ case "regression":
161
+ if (usecase.detail == "outcome") {
162
+ if (usecase.regressionType == "linear") {
163
+ if (term.type == "float" || term.type == "integer") uses.add("plot");
164
+ if (hasNumericChild(child_types)) uses.add("branch");
165
+ return uses;
166
+ }
167
+ if (usecase.regressionType == "logistic") {
168
+ if (term.type && term.type != "survival") uses.add("plot");
169
+ if (hasAllowedChildTypes(child_types, ["survival"])) uses.add("branch");
170
+ return uses;
171
+ } else if (usecase.regressionType == "cox") {
172
+ if (term.type == "condition" || term.type == "survival") uses.add("plot");
173
+ if (child_types.includes("condition") || child_types.includes("survival")) uses.add("branch");
174
+ return uses;
175
+ }
176
+ }
177
+ if (usecase.detail == "independent") {
178
+ if (term.type == "float" || term.type == "integer" || term.type == "categorical" || term.type == "samplelst")
179
+ uses.add("plot");
180
+ if (hasChildTypes(child_types, ["categorical", "float", "integer"])) uses.add("branch");
181
+ return uses;
182
+ }
183
+ return uses;
184
+ case "filter": {
185
+ const exlst = termdbConfig?.excludedTermtypeByTarget?.filter;
186
+ if (exlst) {
187
+ if (graphableTypes.has(term.type) && !exlst.includes(term.type)) uses.add("plot");
188
+ if (child_types.find((t) => !exlst.includes(t))) uses.add("branch");
189
+ return uses;
190
+ }
191
+ if (graphableTypes.has(term.type)) uses.add("plot");
192
+ if (!term.isleaf) uses.add("branch");
193
+ return uses;
194
+ }
195
+ case "correlationVolcano":
196
+ if (usecase.detail == "numeric") {
197
+ if (isNumericTerm(term)) {
198
+ uses.add("plot");
199
+ }
200
+ if (hasNumericChild(child_types)) uses.add("branch");
201
+ } else {
202
+ if (graphableTypes.has(term.type)) uses.add("plot");
203
+ if (!term.isleaf) uses.add("branch");
204
+ }
205
+ return uses;
206
+ case "proteinView":
207
+ if (term.type == TermTypes.PROTEOME_ABUNDANCE) uses.add("plot");
208
+ if (child_types.includes(TermTypes.PROTEOME_ABUNDANCE)) uses.add("branch");
209
+ return uses;
210
+ default:
211
+ if (graphableTypes.has(term.type)) uses.add("plot");
212
+ if (!term.isleaf) uses.add("branch");
213
+ return uses;
214
+ }
215
+ }
216
+ function hasAllowedChildTypes(child_types, excluded_types) {
217
+ if (!child_types.length) {
218
+ return false;
219
+ }
220
+ if (!excluded_types?.length) {
221
+ return true;
222
+ }
223
+ if (child_types.some((type) => !excluded_types.includes(type))) {
224
+ return true;
225
+ }
226
+ }
227
+ function hasNumericChild(child_types) {
228
+ return child_types.includes("float") || child_types.includes("integer");
229
+ }
230
+ function hasChildTypes(child_types, expected_types) {
231
+ for (const a of expected_types) {
232
+ if (child_types.includes(a)) return true;
233
+ }
234
+ }
235
+ export {
236
+ graphableTypes,
237
+ isUsableTerm
238
+ };
239
+ //# sourceMappingURL=termdb.usecase.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/termdb.usecase.js"],
4
+ "sourcesContent": ["import {\n\tTermTypes,\n\tisNumericTerm,\n\tSINGLECELL_CELLTYPE,\n\tSINGLECELL_GENE_EXPRESSION,\n\tISOFORM_EXPRESSION\n} from './terms.js'\n\nexport const graphableTypes = new Set([\n\t'categorical',\n\t'integer',\n\t'float',\n\t'condition',\n\t'survival',\n\t'snplst',\n\t'snplocus',\n\t'geneVariant',\n\t'samplelst',\n\t'geneExpression',\n\tISOFORM_EXPRESSION,\n\t'dtcnv',\n\t'dtsnvindel',\n\t'dtfusion',\n\t'dtsv',\n\t'date',\n\tTermTypes.SSGSEA,\n\tTermTypes.DNA_METHYLATION,\n\tTermTypes.METABOLITE_INTENSITY,\n\tTermTypes.PROTEOME_ABUNDANCE,\n\tSINGLECELL_GENE_EXPRESSION,\n\tSINGLECELL_CELLTYPE,\n\tTermTypes.SNP,\n\tTermTypes.TERM_COLLECTION\n])\n\n/*\nisUsableTerm() will\n\n\t- centralize the \"allowed term\" logic\n\twhich can be intricate or dataset-specific \n\tfor certain terms or contexts\n\t- make it easy to handle new term types\n\nArguments:\n\n\tterm {}\n\t\t.type: 'categorical', etc.\n\t\t.child_types: []\n\t\n\t_usecase {}\n\t\t.target (REQUIRED): 'barchart', 'regression', etc\n\t\t\t- used as a switch-case \"router\" for additional use-specific logic\n\t\t\t- other parameters, if applicable, are described in the route \"handler\" \n\t\t.detail \n\t\t - a more specific detailed use case\n\t\n\n\ttermdbConfig\n\t\toptional. provides ds overrides on default rules via excludedTermtypeByTarget. for use on client\n\n\tds\n\t\toptional. provides ds overrides when the function runs on backend\n\t\tserver-side dataset object that can supply overrides (in the form of functions) to the use case logic,\n\t\tfor example, to apply role-based allowed term uses or performance-related restrictions\n\t\tto ancestor terms when a use case aggregates too many data points for a given chart type\n\nReturns\n\n\ta Set{} with zero or more of the following strings:\n\t- 'plot' if the term can be used in a plot chartType\n\t- 'branch' if the term can be used only as an expandable tree branch, but not in a plot\n\t- an empty Set means that the term has no valid uses, i.e, it cannot be used either for plotting or as a tree branch\n*/\nexport function isUsableTerm(term, _usecase, termdbConfig, ds) {\n\tconst usecase = _usecase || {}\n\n\t// may apply dataset specific override filter for a use case\n\tif (typeof ds?.usecase?.[usecase.target] == 'function') {\n\t\treturn ds.usecase[usecase.target](term, usecase)\n\t}\n\n\t// if (term.isprivate && !user.roleCanUse(term)) return false\n\n\tconst uses = new Set()\n\t// note: expects term.child_types to be null if term.isleaf == true\n\tconst child_types = term.child_types || []\n\t// default handling\n\tswitch (usecase.target) {\n\t\tcase 'barchart':\n\t\tcase 'violin':\n\t\tcase 'boxplot':\n\t\tcase 'summary':\n\t\t\tif (term.type && term.type !== 'survival') uses.add('plot')\n\t\t\tif (hasAllowedChildTypes(child_types, ['survival'])) uses.add('branch')\n\t\t\treturn uses\n\n\t\tcase 'summaryInput':\n\t\t\tif (usecase.detail === 'term2' || usecase.detail == 'term0') {\n\t\t\t\tif (term.type && term.type !== 'survival') uses.add('plot')\n\t\t\t\tif (hasAllowedChildTypes(child_types, ['survival'])) uses.add('branch')\n\t\t\t\treturn uses\n\t\t\t} else {\n\t\t\t\tif (graphableTypes.has(term.type)) uses.add('plot')\n\t\t\t\tif (!term.isleaf) uses.add('branch')\n\t\t\t\treturn uses\n\t\t\t}\n\n\t\tcase 'matrix':\n\t\t\tif (term.type) uses.add('plot')\n\t\t\tif (!term.isleaf) uses.add('branch')\n\t\t\treturn uses\n\n\t\tcase 'table':\n\t\t\tif (usecase.detail == 'term') uses.add('plot')\n\t\t\tif (child_types.length > 1) uses.add('branch')\n\t\t\treturn uses\n\n\t\tcase 'sampleScatter':\n\t\t\tif (usecase.detail == 'numeric') {\n\t\t\t\tif (isNumericTerm(term)) {\n\t\t\t\t\tuses.add('plot')\n\t\t\t\t}\n\t\t\t\tif (hasNumericChild(child_types)) uses.add('branch')\n\t\t\t}\n\t\t\t// Commenting out for now. May need later for another single\n\t\t\t// cell term. Revisit logic at that time.\n\t\t\t// else if (usecase?.specialCase?.type == 'singleCell') {\n\t\t\t// \t\tif (term.type && term.type.startsWith('singleCell')) {\n\t\t\t// \t\t\tif (term.plot && term.plot == usecase.specialCase?.config.name) {\n\t\t\t// \t\t\t\tuses.add('plot')\n\t\t\t// \t\t\t}\n\t\t\t// \t\t}\n\t\t\t// }\n\t\t\telse {\n\t\t\t\tif (graphableTypes.has(term.type)) uses.add('plot')\n\t\t\t\tif (!term.isleaf) uses.add('branch')\n\t\t\t}\n\t\t\treturn uses\n\t\tcase 'runChart2':\n\t\t\tif (usecase.detail == 'date' || usecase.detail == 'xtw') {\n\t\t\t\tif (term.type == 'date') {\n\t\t\t\t\tuses.add('plot')\n\t\t\t\t}\n\t\t\t\tif (child_types.includes('date')) uses.add('branch')\n\t\t\t} else if (usecase.detail == 'numeric') {\n\t\t\t\tif (isNumericTerm(term) && term.type != 'date') {\n\t\t\t\t\tuses.add('plot')\n\t\t\t\t}\n\t\t\t\tif (hasNumericChild(child_types)) uses.add('branch')\n\t\t\t} else {\n\t\t\t\tif (graphableTypes.has(term.type)) uses.add('plot')\n\t\t\t\tif (!term.isleaf) uses.add('branch')\n\t\t\t}\n\t\t\treturn uses\n\n\t\tcase 'numericDictTermCluster':\n\t\t\tif (!usecase.detail?.exclude?.includes(term.id)) {\n\t\t\t\tif (isNumericTerm(term)) {\n\t\t\t\t\tuses.add('plot')\n\t\t\t\t}\n\t\t\t\tif (hasNumericChild(child_types)) {\n\t\t\t\t\tuses.add('branch')\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn uses\n\n\t\tcase 'termCollections':\n\t\t\tif (usecase.detail?.termIds?.includes(term.id)) uses.add('plot')\n\t\t\tif (usecase.detail?.branchIds?.includes(term.id)) uses.add('branch')\n\t\t\treturn uses\n\n\t\tcase 'profileForms':\n\t\t\tif (!term.isleaf) {\n\t\t\t\tconst ancestors = term.id.split('__').length //depends on using the __ naming convension!\n\t\t\t\tif (ancestors == 3) {\n\t\t\t\t\t// 3rd level term is a domain, we show the templates associated to this domain\n\t\t\t\t\tuses.add('plot')\n\t\t\t\t} else if (ancestors < 3) uses.add('branch')\n\t\t\t}\n\t\t\treturn uses\n\n\t\tcase 'profileForms2': {\n\t\t\t// Picker (forms2.ts makeChartBtnMenu) sets usecase.cohort + usecase.subtype.\n\t\t\t// Reads the per-cohort domains list directly from the dataset config at\n\t\t\t// plotConfigByCohort[cohort].profileForms2.domains \u2014 each entry is { id, plotTypes }.\n\t\t\tif (term.isleaf) return uses\n\t\t\tconst allowed = termdbConfig?.plotConfigByCohort?.[usecase.cohort]?.profileForms2?.domains\n\t\t\tif (!allowed) return uses\n\t\t\tconst ancestors = term.id.split('__').length\n\t\t\tconst subtype = usecase.subtype\n\t\t\tif (ancestors == 3) {\n\t\t\t\tif (allowed.find(d => d.id === term.id)?.plotTypes?.includes(subtype)) uses.add('plot')\n\t\t\t} else if (ancestors < 3) {\n\t\t\t\tconst prefix = term.id + '__'\n\t\t\t\tif (allowed.some(d => d.id.startsWith(prefix) && d.plotTypes.includes(subtype))) {\n\t\t\t\t\tuses.add('branch')\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn uses\n\t\t}\n\n\t\t// case 'boxplot':\n\t\t// \tif (term.type == 'float' || term.type == 'integer') uses.add('plot')\n\t\t// \tif (usecase.detail === 'term2' && hasNumericChild(child_types)) uses.add('branch')\n\t\t// \treturn uses\n\n\t\tcase 'cuminc':\n\t\t\tif (usecase.detail == 'term') {\n\t\t\t\tif (term.type == 'condition') uses.add('plot')\n\t\t\t\tif (child_types.includes('condition')) uses.add('branch')\n\t\t\t\treturn uses\n\t\t\t}\n\t\t\tif (usecase.detail === 'term2' || usecase.detail == 'term0') {\n\t\t\t\tif (term.type && term.type != 'condition' && term.type != 'survival') uses.add('plot')\n\t\t\t\tif (hasAllowedChildTypes(child_types, ['condition', 'survival'])) uses.add('branch')\n\t\t\t\treturn uses\n\t\t\t}\n\t\t\treturn uses\n\n\t\tcase 'survival':\n\t\t\tif (usecase.detail == 'term') {\n\t\t\t\tif (term.type == 'survival') uses.add('plot')\n\t\t\t\tif (child_types.includes('survival')) uses.add('branch')\n\t\t\t\treturn uses\n\t\t\t}\n\t\t\tif (usecase.detail === 'term2' || usecase.detail == 'term0') {\n\t\t\t\tif (term.type && term.type != 'survival') uses.add('plot')\n\t\t\t\tif (hasAllowedChildTypes(child_types, ['survival'])) uses.add('branch')\n\t\t\t\treturn uses\n\t\t\t}\n\t\t\treturn uses\n\n\t\tcase 'regression':\n\t\t\tif (usecase.detail == 'outcome') {\n\t\t\t\tif (usecase.regressionType == 'linear') {\n\t\t\t\t\tif (term.type == 'float' || term.type == 'integer') uses.add('plot')\n\t\t\t\t\tif (hasNumericChild(child_types)) uses.add('branch')\n\t\t\t\t\treturn uses\n\t\t\t\t}\n\t\t\t\tif (usecase.regressionType == 'logistic') {\n\t\t\t\t\tif (term.type && term.type != 'survival') uses.add('plot')\n\t\t\t\t\tif (hasAllowedChildTypes(child_types, ['survival'])) uses.add('branch')\n\t\t\t\t\treturn uses\n\t\t\t\t} else if (usecase.regressionType == 'cox') {\n\t\t\t\t\tif (term.type == 'condition' || term.type == 'survival') uses.add('plot')\n\t\t\t\t\tif (child_types.includes('condition') || child_types.includes('survival')) uses.add('branch')\n\t\t\t\t\treturn uses\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (usecase.detail == 'independent') {\n\t\t\t\tif (term.type == 'float' || term.type == 'integer' || term.type == 'categorical' || term.type == 'samplelst')\n\t\t\t\t\tuses.add('plot')\n\t\t\t\tif (hasChildTypes(child_types, ['categorical', 'float', 'integer'])) uses.add('branch')\n\t\t\t\treturn uses\n\t\t\t}\n\t\t\treturn uses\n\n\t\tcase 'filter': {\n\t\t\t// apply \"exlst\" to other targets as needed\n\t\t\tconst exlst = termdbConfig?.excludedTermtypeByTarget?.filter\n\t\t\tif (exlst) {\n\t\t\t\tif (graphableTypes.has(term.type) && !exlst.includes(term.type)) uses.add('plot')\n\t\t\t\tif (child_types.find(t => !exlst.includes(t))) uses.add('branch') // there's a non-excluded child type, allow branch to show\n\t\t\t\treturn uses\n\t\t\t}\n\t\t\t// no specific rule for filter. use default rules\n\t\t\tif (graphableTypes.has(term.type)) uses.add('plot')\n\t\t\tif (!term.isleaf) uses.add('branch')\n\t\t\treturn uses\n\t\t}\n\n\t\tcase 'correlationVolcano':\n\t\t\tif (usecase.detail == 'numeric') {\n\t\t\t\tif (isNumericTerm(term)) {\n\t\t\t\t\tuses.add('plot')\n\t\t\t\t}\n\t\t\t\tif (hasNumericChild(child_types)) uses.add('branch')\n\t\t\t} else {\n\t\t\t\tif (graphableTypes.has(term.type)) uses.add('plot')\n\t\t\t\tif (!term.isleaf) uses.add('branch')\n\t\t\t}\n\t\t\treturn uses\n\n\t\tcase 'proteinView':\n\t\t\tif (term.type == TermTypes.PROTEOME_ABUNDANCE) uses.add('plot')\n\t\t\tif (child_types.includes(TermTypes.PROTEOME_ABUNDANCE)) uses.add('branch')\n\t\t\treturn uses\n\n\t\tdefault:\n\t\t\tif (graphableTypes.has(term.type)) uses.add('plot')\n\t\t\tif (!term.isleaf) uses.add('branch')\n\t\t\treturn uses\n\t}\n}\n\n// determine if the term has at least one child type that\n// is not excluded\nfunction hasAllowedChildTypes(child_types, excluded_types) {\n\tif (!child_types.length) {\n\t\t// term does not have children\n\t\treturn false\n\t}\n\tif (!excluded_types?.length) {\n\t\t// no excluded types\n\t\treturn true\n\t}\n\tif (child_types.some(type => !excluded_types.includes(type))) {\n\t\t// at least one child type is not excluded\n\t\treturn true\n\t}\n}\n\nfunction hasNumericChild(child_types) {\n\treturn child_types.includes('float') || child_types.includes('integer')\n}\n\nfunction hasChildTypes(child_types, expected_types) {\n\tfor (const a of expected_types) {\n\t\tif (child_types.includes(a)) return true\n\t}\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,MAAM,iBAAiB,oBAAI,IAAI;AAAA,EACrC;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,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,UAAU;AACX,CAAC;AAwCM,SAAS,aAAa,MAAM,UAAU,cAAc,IAAI;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,SAAS,OAAO,KAAK,YAAY,SAAS,SAAS;AACvE;AAEA,SAAS,cAAc,aAAa,gBAAgB;AACnD,aAAW,KAAK,gBAAgB;AAC/B,QAAI,YAAY,SAAS,CAAC,EAAG,QAAO;AAAA,EACrC;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,83 @@
1
+ import type { Term } from '#types';
2
+ export { TermTypeGroups } from './common.js';
3
+ export declare const ROOT_SAMPLE_TYPE = 1;
4
+ export declare const DEFAULT_SAMPLE_TYPE = 2;
5
+ export declare const NumericModes: {
6
+ continuous: string;
7
+ discrete: string;
8
+ };
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
+ export declare const dtTermTypes: Set<string>;
35
+ export declare const NUMERIC_DICTIONARY_TERM = "numericDictTerm";
36
+ export declare const TermTypes2Dt: {
37
+ geneExpression: any;
38
+ ssGSEA: any;
39
+ dnaMethylation: any;
40
+ metaboliteIntensity: any;
41
+ proteomeAbundance: any;
42
+ };
43
+ export declare const typeGroup: {
44
+ categorical: any;
45
+ condition: any;
46
+ float: any;
47
+ integer: any;
48
+ samplelst: any;
49
+ survival: any;
50
+ date: any;
51
+ multivalue: any;
52
+ geneVariant: any;
53
+ snp: any;
54
+ snplst: any;
55
+ snplocus: any;
56
+ geneExpression: any;
57
+ isoformExpression: any;
58
+ ssGSEA: any;
59
+ dnaMethylation: any;
60
+ metaboliteIntensity: any;
61
+ proteomeAbundance: any;
62
+ termCollection: any;
63
+ singleCellCellType: any;
64
+ singleCellGeneExpression: any;
65
+ };
66
+ export declare const numericTypes: Set<string>;
67
+ export declare const annoNumericTypes: Set<string>;
68
+ export declare function isSingleCellTerm(term: any): boolean;
69
+ export declare function isNumericTerm(term: Term): boolean;
70
+ export declare function isCategoricalTerm(term: Term): boolean;
71
+ export declare function isDictionaryType(type: string): boolean;
72
+ export declare function isNonDictionaryType(type: string): boolean;
73
+ export declare function isNumTermCollection(term: Term): boolean;
74
+ export declare function equals(t1: any, t2: any): boolean;
75
+ export declare function getBin(lst: any[], value: number): number;
76
+ export declare function getSampleType(term: any, ds: any): any;
77
+ export declare function getParentType(types: Set<string>, ds: any): any;
78
+ export declare function termType2label(type: string): string;
79
+ export declare function getDateFromNumber(value: number): Date;
80
+ export declare function getDateStrFromNumber(value: number): string;
81
+ export declare function getNumberFromDateStr(str: string): number;
82
+ export declare function getNumberFromDate(date: Date): number;
83
+ export declare function getDaysInYear(year: number): 366 | 365;
@@ -0,0 +1,327 @@
1
+ import {
2
+ dtgeneexpression,
3
+ dtssgsea,
4
+ dtdnamethylation,
5
+ dtmetaboliteintensity,
6
+ dtproteomeabundance,
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 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 = {
40
+ GENE_VARIANT,
41
+ GENE_EXPRESSION,
42
+ ISOFORM_EXPRESSION,
43
+ SSGSEA,
44
+ DNA_METHYLATION,
45
+ CATEGORICAL,
46
+ INTEGER,
47
+ FLOAT,
48
+ SNP,
49
+ SNP_LIST,
50
+ SNP_LOCUS,
51
+ CONDITION,
52
+ SURVIVAL,
53
+ SAMPLELST,
54
+ METABOLITE_INTENSITY,
55
+ PROTEOME_ABUNDANCE,
56
+ SINGLECELL_CELLTYPE,
57
+ SINGLECELL_GENE_EXPRESSION,
58
+ MULTIVALUE,
59
+ DATE,
60
+ TERM_COLLECTION
61
+ };
62
+ const dtTermTypes = new Set(dtTerms.map((t) => t.type));
63
+ for (const dtTermType of dtTermTypes) {
64
+ TermTypes[dtTermType.toUpperCase()] = dtTermType;
65
+ }
66
+ const NUMERIC_DICTIONARY_TERM = "numericDictTerm";
67
+ const TermTypes2Dt = {
68
+ [GENE_EXPRESSION]: dtgeneexpression,
69
+ [SSGSEA]: dtssgsea,
70
+ [DNA_METHYLATION]: dtdnamethylation,
71
+ [METABOLITE_INTENSITY]: dtmetaboliteintensity,
72
+ [PROTEOME_ABUNDANCE]: dtproteomeabundance
73
+ };
74
+ const typeGroup = {
75
+ [CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,
76
+ [CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,
77
+ [FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,
78
+ [INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,
79
+ [SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,
80
+ [SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,
81
+ [DATE]: TermTypeGroups.DICTIONARY_VARIABLES,
82
+ [MULTIVALUE]: TermTypeGroups.DICTIONARY_VARIABLES,
83
+ [GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,
84
+ [SNP]: TermTypeGroups.SNP,
85
+ [SNP_LIST]: TermTypeGroups.SNP_LIST,
86
+ [SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,
87
+ [GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,
88
+ [ISOFORM_EXPRESSION]: TermTypeGroups.ISOFORM_EXPRESSION,
89
+ [SSGSEA]: TermTypeGroups.SSGSEA,
90
+ [DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,
91
+ [METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,
92
+ [PROTEOME_ABUNDANCE]: TermTypeGroups.PROTEOME_ABUNDANCE,
93
+ [TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,
94
+ [SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,
95
+ [SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION
96
+ };
97
+ const nonDictTypes = /* @__PURE__ */ new Set([
98
+ SNP,
99
+ SNP_LIST,
100
+ SNP_LOCUS,
101
+ GENE_EXPRESSION,
102
+ ISOFORM_EXPRESSION,
103
+ SSGSEA,
104
+ DNA_METHYLATION,
105
+ GENE_VARIANT,
106
+ METABOLITE_INTENSITY,
107
+ PROTEOME_ABUNDANCE,
108
+ SINGLECELL_CELLTYPE,
109
+ SINGLECELL_GENE_EXPRESSION
110
+ ]);
111
+ for (const dtTermType of dtTermTypes) {
112
+ nonDictTypes.add(TermTypes[dtTermType.toUpperCase()]);
113
+ }
114
+ const numericTypes = /* @__PURE__ */ new Set([
115
+ INTEGER,
116
+ FLOAT,
117
+ GENE_EXPRESSION,
118
+ ISOFORM_EXPRESSION,
119
+ SSGSEA,
120
+ DNA_METHYLATION,
121
+ METABOLITE_INTENSITY,
122
+ PROTEOME_ABUNDANCE,
123
+ SINGLECELL_GENE_EXPRESSION,
124
+ DATE
125
+ ]);
126
+ const annoNumericTypes = /* @__PURE__ */ new Set([INTEGER, FLOAT, DATE]);
127
+ const categoricalTypes = /* @__PURE__ */ new Set([CATEGORICAL, SNP]);
128
+ const singleCellTerms = /* @__PURE__ */ new Set([SINGLECELL_CELLTYPE, SINGLECELL_GENE_EXPRESSION]);
129
+ function isSingleCellTerm(term) {
130
+ if (!term) return false;
131
+ return singleCellTerms.has(term.type);
132
+ }
133
+ function isNumericTerm(term) {
134
+ if (!term) return false;
135
+ return numericTypes.has(term.type);
136
+ }
137
+ function isCategoricalTerm(term) {
138
+ if (!term) return false;
139
+ return categoricalTypes.has(term.type);
140
+ }
141
+ function isDictionaryType(type) {
142
+ return !isNonDictionaryType(type);
143
+ }
144
+ function isNonDictionaryType(type) {
145
+ if (!type) throw new Error("Type is not defined");
146
+ return nonDictTypes.has(type);
147
+ }
148
+ function isNumTermCollection(term) {
149
+ if (!term || !term.type) throw new Error("Term or term type is not defined");
150
+ return term.type === TERM_COLLECTION;
151
+ }
152
+ function equals(t1, t2) {
153
+ if (!t1) throw new Error("First term is not defined ");
154
+ if (!t2) throw new Error("Second term is not defined ");
155
+ if (t1.type !== t2.type) return false;
156
+ if (isDictionaryType(t1.type) && isDictionaryType(t2.type) && t1.type != SAMPLELST) return t1.id === t2.id;
157
+ switch (t1.type) {
158
+ case GENE_EXPRESSION:
159
+ return t1.gene == t2.gene;
160
+ case ISOFORM_EXPRESSION:
161
+ return t1.isoform == t2.isoform;
162
+ case SSGSEA:
163
+ return t1.id == t2.id;
164
+ case DNA_METHYLATION:
165
+ return t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
166
+ case METABOLITE_INTENSITY:
167
+ case PROTEOME_ABUNDANCE:
168
+ return t1.name == t2.name;
169
+ case GENE_VARIANT:
170
+ return t1.gene == t2.gene || t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop;
171
+ // TO DO: Add more cases
172
+ // case SNP_LIST:
173
+ // case SNP_LOCUS:
174
+ // case SAMPLELST:
175
+ default:
176
+ return false;
177
+ }
178
+ }
179
+ function getBin(lst, value) {
180
+ let bin = lst.findIndex(
181
+ (b) => b.startunbounded && value < b.stop || b.startunbounded && b.stopinclusive && value == b.stop
182
+ );
183
+ if (bin == -1)
184
+ bin = lst.findIndex(
185
+ (b) => b.stopunbounded && value > b.start || b.stopunbounded && b.startinclusive && value == b.start
186
+ );
187
+ if (bin == -1)
188
+ bin = lst.findIndex(
189
+ (b) => value > b.start && value < b.stop || b.startinclusive && value == b.start || b.stopinclusive && value == b.stop
190
+ );
191
+ return bin;
192
+ }
193
+ function getSampleType(term, ds) {
194
+ if (!term) return null;
195
+ if (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE;
196
+ if (term.id) return ds.cohort.termdb.term2SampleType.get(term.id);
197
+ if (term.type == "samplelst") {
198
+ const key = Object.keys(term.values)[0];
199
+ const sampleId = term.values[key].list[0]?.sampleId;
200
+ if (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId);
201
+ else return DEFAULT_SAMPLE_TYPE;
202
+ }
203
+ return DEFAULT_SAMPLE_TYPE;
204
+ }
205
+ function getParentType(types, ds) {
206
+ if (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null;
207
+ const ids = Array.from(types);
208
+ if (!ids || ids.length == 0) return null;
209
+ for (const id of ids) {
210
+ const typeObj = ds.cohort.termdb.sampleTypes[id];
211
+ if (!typeObj) continue;
212
+ if (typeObj.parent_id == null) return id;
213
+ if (ids.includes(typeObj.parent_id)) continue;
214
+ else return typeObj.parent_id;
215
+ }
216
+ return null;
217
+ }
218
+ const typeMap = {
219
+ categorical: "Categorical",
220
+ condition: "Condition",
221
+ float: "Numerical",
222
+ integer: "Numerical",
223
+ geneExpression: "Gene Expression",
224
+ isoformExpression: "Isoform Expression",
225
+ ssGSEA: "Geneset Expression",
226
+ dnaMethylation: "DNA Methylation",
227
+ geneVariant: "Gene Variant",
228
+ metaboliteIntensity: "Metabolite Intensity",
229
+ proteomeAbundance: "Proteome Abundance",
230
+ proteomeDAP: "Proteome DAP",
231
+ multivalue: "Multi Value",
232
+ singleCellGeneExpression: "Single Cell, Gene Expression",
233
+ singleCellCellType: "Single Cell, Cell Type",
234
+ snplocus: "SNP Locus",
235
+ snp: "SNP",
236
+ snplst: "SNP List",
237
+ numericDictTerm: "Numeric Dictionary Term",
238
+ termCollection: "Term Collection"
239
+ };
240
+ function termType2label(type) {
241
+ return typeMap[type] || "Unknown term type";
242
+ }
243
+ function getDateFromNumber(value) {
244
+ const year = Math.floor(value);
245
+ const january1st = new Date(year, 0, 1);
246
+ const totalDays = getDaysInYear(year);
247
+ const time = Math.round((value - year) * totalDays) * oneDayTime;
248
+ const date = new Date(january1st.getTime() + time);
249
+ return date;
250
+ }
251
+ const oneDayTime = 24 * 60 * 60 * 1e3;
252
+ function getDateStrFromNumber(value) {
253
+ const date = getDateFromNumber(value);
254
+ return date.toLocaleDateString("en-US", {
255
+ year: "numeric",
256
+ month: "long"
257
+ });
258
+ }
259
+ function getNumberFromDateStr(str) {
260
+ const date = new Date(str);
261
+ return getNumberFromDate(date);
262
+ }
263
+ function getNumberFromDate(date) {
264
+ const year = date.getFullYear();
265
+ const january1st = new Date(year, 0, 1);
266
+ const diffDays = (date.getTime() - january1st.getTime()) / oneDayTime;
267
+ const daysTotal = getDaysInYear(year);
268
+ const decimal = diffDays / daysTotal;
269
+ return year + decimal;
270
+ }
271
+ function getDaysInYear(year) {
272
+ const isLeap = new Date(year, 1, 29).getMonth() === 1;
273
+ const days = isLeap ? 366 : 365;
274
+ return days;
275
+ }
276
+ export {
277
+ CATEGORICAL,
278
+ CONDITION,
279
+ DATE,
280
+ DEFAULT_SAMPLE_TYPE,
281
+ DNA_METHYLATION,
282
+ FLOAT,
283
+ GENE_EXPRESSION,
284
+ GENE_VARIANT,
285
+ INTEGER,
286
+ ISOFORM_EXPRESSION,
287
+ METABOLITE_INTENSITY,
288
+ MULTIVALUE,
289
+ NUMERIC_DICTIONARY_TERM,
290
+ NumericModes,
291
+ PROTEOME_ABUNDANCE,
292
+ PROTEOME_DAP,
293
+ 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,
303
+ TermTypeGroups2 as TermTypeGroups,
304
+ TermTypes,
305
+ TermTypes2Dt,
306
+ annoNumericTypes,
307
+ dtTermTypes,
308
+ equals,
309
+ getBin,
310
+ getDateFromNumber,
311
+ getDateStrFromNumber,
312
+ getDaysInYear,
313
+ getNumberFromDate,
314
+ getNumberFromDateStr,
315
+ getParentType,
316
+ getSampleType,
317
+ isCategoricalTerm,
318
+ isDictionaryType,
319
+ isNonDictionaryType,
320
+ isNumTermCollection,
321
+ isNumericTerm,
322
+ isSingleCellTerm,
323
+ numericTypes,
324
+ termType2label,
325
+ typeGroup
326
+ };
327
+ //# sourceMappingURL=terms.js.map