@sjcrh/proteinpaint-shared 2.187.0 → 2.188.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.
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
package/src/terms.js DELETED
@@ -1,341 +0,0 @@
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 TermTypes = {
39
- GENE_VARIANT,
40
- GENE_EXPRESSION,
41
- ISOFORM_EXPRESSION,
42
- SSGSEA,
43
- DNA_METHYLATION,
44
- CATEGORICAL,
45
- INTEGER,
46
- FLOAT,
47
- SNP,
48
- SNP_LIST,
49
- SNP_LOCUS,
50
- CONDITION,
51
- SURVIVAL,
52
- SAMPLELST,
53
- METABOLITE_INTENSITY,
54
- PROTEOME_ABUNDANCE,
55
- SINGLECELL_CELLTYPE,
56
- SINGLECELL_GENE_EXPRESSION,
57
- MULTIVALUE,
58
- DATE,
59
- TERM_COLLECTION,
60
- }
61
- const dtTermTypes = new Set(dtTerms.map((t) => t.type))
62
- for (const dtTermType of dtTermTypes) {
63
- TermTypes[dtTermType.toUpperCase()] = dtTermType
64
- }
65
- const NUMERIC_DICTIONARY_TERM = "numericDictTerm"
66
- const TermTypes2Dt = {
67
- [GENE_EXPRESSION]: dtgeneexpression,
68
- [SSGSEA]: dtssgsea,
69
- [DNA_METHYLATION]: dtdnamethylation,
70
- [METABOLITE_INTENSITY]: dtmetaboliteintensity,
71
- [PROTEOME_ABUNDANCE]: dtproteomeabundance,
72
- }
73
- const typeGroup = {
74
- [CATEGORICAL]: TermTypeGroups.DICTIONARY_VARIABLES,
75
- [CONDITION]: TermTypeGroups.DICTIONARY_VARIABLES,
76
- [FLOAT]: TermTypeGroups.DICTIONARY_VARIABLES,
77
- [INTEGER]: TermTypeGroups.DICTIONARY_VARIABLES,
78
- [SAMPLELST]: TermTypeGroups.DICTIONARY_VARIABLES,
79
- [SURVIVAL]: TermTypeGroups.DICTIONARY_VARIABLES,
80
- [DATE]: TermTypeGroups.DICTIONARY_VARIABLES,
81
- [MULTIVALUE]: TermTypeGroups.DICTIONARY_VARIABLES,
82
- [GENE_VARIANT]: TermTypeGroups.MUTATION_CNV_FUSION,
83
- [SNP]: TermTypeGroups.SNP,
84
- [SNP_LIST]: TermTypeGroups.SNP_LIST,
85
- [SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,
86
- [GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,
87
- [ISOFORM_EXPRESSION]: TermTypeGroups.ISOFORM_EXPRESSION,
88
- [SSGSEA]: TermTypeGroups.SSGSEA,
89
- [DNA_METHYLATION]: TermTypeGroups.DNA_METHYLATION,
90
- [METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,
91
- [PROTEOME_ABUNDANCE]: TermTypeGroups.PROTEOME_ABUNDANCE,
92
- [TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION,
93
- [SINGLECELL_CELLTYPE]: TermTypeGroups.SINGLECELL_CELLTYPE,
94
- [SINGLECELL_GENE_EXPRESSION]: TermTypeGroups.SINGLECELL_GENE_EXPRESSION,
95
- }
96
- const nonDictTypes = /* @__PURE__ */ new Set([
97
- SNP,
98
- SNP_LIST,
99
- SNP_LOCUS,
100
- GENE_EXPRESSION,
101
- ISOFORM_EXPRESSION,
102
- SSGSEA,
103
- DNA_METHYLATION,
104
- GENE_VARIANT,
105
- METABOLITE_INTENSITY,
106
- PROTEOME_ABUNDANCE,
107
- SINGLECELL_CELLTYPE,
108
- SINGLECELL_GENE_EXPRESSION,
109
- ])
110
- for (const dtTermType of dtTermTypes) {
111
- nonDictTypes.add(TermTypes[dtTermType.toUpperCase()])
112
- }
113
- const numericTypes = /* @__PURE__ */ new Set([
114
- INTEGER,
115
- FLOAT,
116
- GENE_EXPRESSION,
117
- ISOFORM_EXPRESSION,
118
- SSGSEA,
119
- DNA_METHYLATION,
120
- METABOLITE_INTENSITY,
121
- PROTEOME_ABUNDANCE,
122
- SINGLECELL_GENE_EXPRESSION,
123
- DATE,
124
- ])
125
- const annoNumericTypes = /* @__PURE__ */ new Set([INTEGER, FLOAT, DATE])
126
- const categoricalTypes = /* @__PURE__ */ new Set([CATEGORICAL, SNP])
127
- const singleCellTerms = /* @__PURE__ */ new Set([
128
- SINGLECELL_CELLTYPE,
129
- SINGLECELL_GENE_EXPRESSION,
130
- ])
131
- function isSingleCellTerm(term) {
132
- if (!term) return false
133
- return singleCellTerms.has(term.type)
134
- }
135
- function isNumericTerm(term) {
136
- if (!term) return false
137
- return numericTypes.has(term.type)
138
- }
139
- function isCategoricalTerm(term) {
140
- if (!term) return false
141
- return categoricalTypes.has(term.type)
142
- }
143
- function isDictionaryType(type) {
144
- return !isNonDictionaryType(type)
145
- }
146
- function isNonDictionaryType(type) {
147
- if (!type) throw new Error("Type is not defined")
148
- return nonDictTypes.has(type)
149
- }
150
- function isNumTermCollection(term) {
151
- if (!term || !term.type) throw new Error("Term or term type is not defined")
152
- return term.type === TERM_COLLECTION
153
- }
154
- function equals(t1, t2) {
155
- if (!t1) throw new Error("First term is not defined ")
156
- if (!t2) throw new Error("Second term is not defined ")
157
- if (t1.type !== t2.type) return false
158
- if (
159
- isDictionaryType(t1.type) &&
160
- isDictionaryType(t2.type) &&
161
- t1.type != SAMPLELST
162
- )
163
- return t1.id === t2.id
164
- switch (t1.type) {
165
- case GENE_EXPRESSION:
166
- return t1.gene == t2.gene
167
- case ISOFORM_EXPRESSION:
168
- return t1.isoform == t2.isoform
169
- case SSGSEA:
170
- return t1.id == t2.id
171
- case DNA_METHYLATION:
172
- return t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop
173
- case METABOLITE_INTENSITY:
174
- case PROTEOME_ABUNDANCE:
175
- return t1.name == t2.name
176
- case GENE_VARIANT:
177
- return (
178
- t1.gene == t2.gene ||
179
- (t1.chr == t2.chr && t1.start == t2.start && t1.stop == t2.stop)
180
- )
181
- // TO DO: Add more cases
182
- // case SNP_LIST:
183
- // case SNP_LOCUS:
184
- // case SAMPLELST:
185
- default:
186
- return false
187
- }
188
- }
189
- function getBin(lst, value) {
190
- let bin = lst.findIndex(
191
- (b) =>
192
- (b.startunbounded && value < b.stop) ||
193
- (b.startunbounded && b.stopinclusive && value == b.stop)
194
- )
195
- if (bin == -1)
196
- bin = lst.findIndex(
197
- (b) =>
198
- (b.stopunbounded && value > b.start) ||
199
- (b.stopunbounded && b.startinclusive && value == b.start)
200
- )
201
- if (bin == -1)
202
- bin = lst.findIndex(
203
- (b) =>
204
- (value > b.start && value < b.stop) ||
205
- (b.startinclusive && value == b.start) ||
206
- (b.stopinclusive && value == b.stop)
207
- )
208
- return bin
209
- }
210
- function getSampleType(term, ds) {
211
- if (!term) return null
212
- if (term.type && isNonDictionaryType(term.type)) return DEFAULT_SAMPLE_TYPE
213
- if (term.id) return ds.cohort.termdb.term2SampleType.get(term.id)
214
- if (term.type == "samplelst") {
215
- const key = Object.keys(term.values)[0]
216
- const sampleId = term.values[key].list[0]?.sampleId
217
- if (sampleId) return ds.sampleId2Type.get(Number(sampleId) || sampleId)
218
- else return DEFAULT_SAMPLE_TYPE
219
- }
220
- return DEFAULT_SAMPLE_TYPE
221
- }
222
- function getParentType(types, ds) {
223
- if (Object.keys(ds.cohort.termdb.sampleTypes).length == 0) return null
224
- const ids = Array.from(types)
225
- if (!ids || ids.length == 0) return null
226
- for (const id of ids) {
227
- const typeObj = ds.cohort.termdb.sampleTypes[id]
228
- if (!typeObj) continue
229
- if (typeObj.parent_id == null) return id
230
- if (ids.includes(typeObj.parent_id)) continue
231
- else return typeObj.parent_id
232
- }
233
- return null
234
- }
235
- const typeMap = {
236
- categorical: "Categorical",
237
- condition: "Condition",
238
- float: "Numerical",
239
- integer: "Numerical",
240
- geneExpression: "Gene Expression",
241
- isoformExpression: "Isoform Expression",
242
- ssGSEA: "Geneset Expression",
243
- dnaMethylation: "DNA Methylation",
244
- geneVariant: "Gene Variant",
245
- metaboliteIntensity: "Metabolite Intensity",
246
- proteomeAbundance: "Proteome Abundance",
247
- multivalue: "Multi Value",
248
- singleCellGeneExpression: "Single Cell, Gene Expression",
249
- singleCellCellType: "Single Cell, Cell Type",
250
- snplocus: "SNP Locus",
251
- snp: "SNP",
252
- snplst: "SNP List",
253
- numericDictTerm: "Numeric Dictionary Term",
254
- termCollection: "Term Collection",
255
- }
256
- function termType2label(type) {
257
- return typeMap[type] || "Unknown term type"
258
- }
259
- function getDateFromNumber(value) {
260
- const year = Math.floor(value)
261
- const january1st = new Date(year, 0, 1)
262
- const totalDays = getDaysInYear(year)
263
- const time = Math.round((value - year) * totalDays) * oneDayTime
264
- const date = new Date(january1st.getTime() + time)
265
- return date
266
- }
267
- const oneDayTime = 24 * 60 * 60 * 1e3
268
- function getDateStrFromNumber(value) {
269
- const date = getDateFromNumber(value)
270
- return date.toLocaleDateString("en-US", {
271
- year: "numeric",
272
- month: "long",
273
- })
274
- }
275
- function getNumberFromDateStr(str) {
276
- const date = new Date(str)
277
- return getNumberFromDate(date)
278
- }
279
- function getNumberFromDate(date) {
280
- const year = date.getFullYear()
281
- const january1st = new Date(year, 0, 1)
282
- const diffDays = (date.getTime() - january1st.getTime()) / oneDayTime
283
- const daysTotal = getDaysInYear(year)
284
- const decimal = diffDays / daysTotal
285
- return year + decimal
286
- }
287
- function getDaysInYear(year) {
288
- const isLeap = new Date(year, 1, 29).getMonth() === 1
289
- const days = isLeap ? 366 : 365
290
- return days
291
- }
292
- export {
293
- CATEGORICAL,
294
- CONDITION,
295
- DATE,
296
- DEFAULT_SAMPLE_TYPE,
297
- DNA_METHYLATION,
298
- FLOAT,
299
- GENE_EXPRESSION,
300
- GENE_VARIANT,
301
- INTEGER,
302
- ISOFORM_EXPRESSION,
303
- METABOLITE_INTENSITY,
304
- MULTIVALUE,
305
- NUMERIC_DICTIONARY_TERM,
306
- NumericModes,
307
- PROTEOME_ABUNDANCE,
308
- ROOT_SAMPLE_TYPE,
309
- SAMPLELST,
310
- SINGLECELL_CELLTYPE,
311
- SINGLECELL_GENE_EXPRESSION,
312
- SNP,
313
- SNP_LIST,
314
- SNP_LOCUS,
315
- SSGSEA,
316
- SURVIVAL,
317
- TERM_COLLECTION,
318
- TermTypeGroups2 as TermTypeGroups,
319
- TermTypes,
320
- TermTypes2Dt,
321
- annoNumericTypes,
322
- dtTermTypes,
323
- equals,
324
- getBin,
325
- getDateFromNumber,
326
- getDateStrFromNumber,
327
- getDaysInYear,
328
- getNumberFromDate,
329
- getNumberFromDateStr,
330
- getParentType,
331
- getSampleType,
332
- isCategoricalTerm,
333
- isDictionaryType,
334
- isNonDictionaryType,
335
- isNumTermCollection,
336
- isNumericTerm,
337
- isSingleCellTerm,
338
- numericTypes,
339
- termType2label,
340
- typeGroup,
341
- }
package/src/time.js DELETED
@@ -1,22 +0,0 @@
1
- function formatElapsedTime(ms, precision = 2) {
2
- if (typeof ms !== "number" || isNaN(ms)) {
3
- return typeof ms !== "number"
4
- ? "Invalid time: not a number"
5
- : "Invalid time: NaN"
6
- }
7
- if (!isFinite(ms)) {
8
- return ms > 0 ? "Infinite time" : "-Infinite time"
9
- }
10
- const absMs = Math.abs(ms)
11
- const sign = ms < 0 ? "-" : ""
12
- if (absMs < 1e3) {
13
- return `${sign}${absMs}ms`
14
- }
15
- if (absMs < 6e4) {
16
- return `${sign}${(absMs / 1e3).toFixed(precision)}s`
17
- }
18
- const minutes = Math.floor(absMs / 6e4)
19
- const seconds = ((absMs % 6e4) / 1e3).toFixed(precision)
20
- return `${sign}${minutes}m ${seconds}s`
21
- }
22
- export { formatElapsedTime }
package/src/tree.js DELETED
@@ -1,138 +0,0 @@
1
- /*
2
- input:
3
- 1. list of leaf nodes, e.g. mutation cases, each with a set of key-value pairs
4
- 2. levels of hierarchy in an ordered list
5
- each item: { k, full }
6
- "k" and "full" are two attribute keys
7
-
8
- output:
9
- a list of items, as input for d3-hierarchy.stratify
10
- one item for each child-parent relationship in the hierarchy
11
- {
12
- id:
13
- parentId:
14
- lst:
15
- value:
16
- name:
17
- full:
18
- id0:
19
- v0:
20
- id1:
21
- v1:
22
- id2:
23
- v2:
24
- }
25
-
26
- strange issue: https://github.com/stjude/proteinpaint/commit/c36004d47d4374d2ade719c6ef9e2b848f0850dc
27
- using Map for lp, nodes etc will cause memory issue, thus the use of simple objects
28
-
29
- to-do: verify this works after a reorg
30
- */
31
-
32
- const hardcode_root = "root"
33
- const hierarchy_spacer = "..."
34
-
35
- export function stratinput(lst, levels) {
36
- const lp = Object.create(null)
37
- // leaf to parent
38
- // k: HM...BALL...sub
39
- // v: HM...BALL
40
-
41
- const nodes = Object.create(null)
42
- /*
43
- k: string id of node, e.g. HM...BALL
44
- v: node
45
- .full
46
- .lst[]
47
- items from input
48
- */
49
-
50
- const size = Object.create(null)
51
- // only increment size to leaf nodes, so that root.sum() will work
52
- // k: string id of a node, e.g. HM...BALL
53
- // v: number of items
54
-
55
- for (const m of lst) {
56
- for (const [i, lev] of levels.entries()) {
57
- const thisv = getkey(m, i, levels)
58
- const pav = getkey(m, i - 1, levels)
59
-
60
- // as mutations can come as {"subtype":""}
61
- // in the sunburst chart at the subtype level, this mutation should not be counted
62
- // thus the test with !m[lev.k] rather than !(lev.k in m)
63
- if (!m[lev.k]) {
64
- // stop at this level
65
- // add count to prev level
66
- if (i > 0) {
67
- size[pav] += 1
68
- }
69
- break
70
- }
71
-
72
- lp[thisv] = pav
73
- if (!(thisv in size)) {
74
- size[thisv] = 0
75
- }
76
- if (!(thisv in nodes)) {
77
- const n = {
78
- lst: [],
79
- }
80
- if (lev.full) {
81
- n.full = m[lev.full]
82
- }
83
-
84
- n.id0 = levels[0].k
85
- n.v0 = m[levels[0].k]
86
- if (i == 1) {
87
- n.id1 = levels[1].k
88
- n.v1 = m[levels[1].k]
89
- }
90
- if (i == 2) {
91
- n.id2 = levels[2].k
92
- n.v1 = m[levels[2].k]
93
- }
94
-
95
- nodes[thisv] = n
96
- }
97
- nodes[thisv].lst.push(m)
98
- if (i == levels.length - 1) {
99
- size[thisv] += 1
100
- }
101
- }
102
- }
103
-
104
- const nlst = [{ id: hardcode_root, name: hardcode_root }]
105
-
106
- for (const chid in lp) {
107
- const paid = lp[chid]
108
- const n = nodes[chid]
109
- const fields = chid.split(hierarchy_spacer)
110
- nlst.push({
111
- id: chid,
112
- parentId: paid,
113
- lst: n.lst,
114
- value: size[chid],
115
- name: fields[fields.length - 1], // show this instead of chid
116
- full: n.full,
117
- id0: n.id0,
118
- v0: n.v0,
119
- id1: n.id1,
120
- v1: n.v1,
121
- id2: n.id2,
122
- v2: n.v2,
123
- })
124
- }
125
- return nlst
126
- }
127
-
128
- function getkey(m, i, levels) {
129
- // if i is 0, return 'root'
130
- const klst = [hardcode_root]
131
- for (let j = 0; j < i; j++) {
132
- klst.push(m[levels[j].k])
133
- }
134
- if (i >= 0) {
135
- klst.push(m[levels[i].k])
136
- }
137
- return klst.join(hierarchy_spacer)
138
- }
package/src/urljson.js DELETED
@@ -1,41 +0,0 @@
1
- import { isNumeric } from "./helpers.js"
2
- const reserved = ["false", "true", "null", "undefined"]
3
- const delimiters = ['"', "{", "["]
4
- function encode(rawObject) {
5
- const params = []
6
- for (const [key, value] of Object.entries(rawObject)) {
7
- if (
8
- typeof value == "string" &&
9
- !isNumeric(value) &&
10
- !reserved.includes(value) &&
11
- !delimiters.includes(value[0])
12
- ) {
13
- params.push(`${key}=${encodeURIComponent(value)}`)
14
- } else if (value !== void 0) {
15
- params.push(`${key}=${encodeURIComponent(JSON.stringify(value))}`)
16
- }
17
- }
18
- return params.join("&")
19
- }
20
- function decode(query) {
21
- const encoding = query.encoding
22
- for (const [key, value] of Object.entries(query)) {
23
- if (
24
- encoding == "json" ||
25
- value == "null" || // not new, always been
26
- value == "true" || // NEED TO FIND-REPLACE CODE THAT USES value == 'true'
27
- value == "false" || // NEED TO FIND-REPLACE CODE THAT USES value == 'false'
28
- isNumeric(value) || // NEED TO check
29
- (typeof value == "string" &&
30
- value.startsWith('"') &&
31
- value.endsWith('"')) ||
32
- (typeof value == "string" &&
33
- value.startsWith("{") &&
34
- value.endsWith("}")) ||
35
- (typeof value == "string" && value.startsWith("[") && value.endsWith("]"))
36
- )
37
- query[key] = JSON.parse(value)
38
- }
39
- return query
40
- }
41
- export { decode, encode }
package/src/vcf.ann.js DELETED
@@ -1,62 +0,0 @@
1
- import { vepinfo } from "./common.js"
2
-
3
- export function parse_ANN(str, header, m) {
4
- // snpEff
5
- if (!header) {
6
- return null
7
- }
8
- for (const thisannotation of str.split(",")) {
9
- const lst = thisannotation.replace(/&/g, ",").split("|")
10
-
11
- const o = {}
12
-
13
- for (let i = 0; i < header.length; i++) {
14
- if (lst[i]) {
15
- o[header[i].name] = lst[i]
16
- }
17
- }
18
- if (!o.Allele) {
19
- continue
20
- }
21
- let allele = null
22
- for (const a of m.alleles) {
23
- if (a.allele == o.Allele) {
24
- allele = a
25
- break
26
- }
27
- }
28
- if (!allele) {
29
- // cannot match to allele!!!
30
- continue
31
- }
32
- if (!allele.ann) {
33
- allele.ann = []
34
- }
35
- allele.ann.push(o)
36
- o._gene = o.Gene_Name
37
- // isoform
38
- if (o.Feature_Type && o.Feature_Type == "transcript" && o.Feature_ID) {
39
- o._isoform = o.Feature_ID.split(".")[0]
40
- }
41
- // class
42
- if (o.Annotation) {
43
- const [dt, cls, rank] = vepinfo(o.Annotation)
44
- o._dt = dt
45
- o._class = cls
46
- o._csqrank = rank
47
- } else {
48
- // FIXME
49
- o._dt = dtsnvindel
50
- o._class = mclassnonstandard
51
- }
52
- // mname
53
- if (o["HGVS.p"]) {
54
- //o._mname=decodeURIComponent(o.HGVSp.substr(o.HGVSp.indexOf(':')+1))
55
- o._mname = o["HGVS.p"]
56
- } else if (o["HGVS.c"]) {
57
- o._mname = o["HGVS.c"]
58
- } else {
59
- }
60
- }
61
- return true
62
- }