@sjcrh/proteinpaint-shared 2.186.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 -317
  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,1302 @@
1
+ import { rgb } from "d3-color";
2
+ import * as d3scale from "d3-scale";
3
+ import * as d3 from "d3";
4
+ import { getWrappedTvslst } from "./filter.js";
5
+ class TermTypeGroups {
6
+ static DICTIONARY_VARIABLES = "Dictionary Variables";
7
+ static DNA_METHYLATION = "DNA Methylation";
8
+ static GENE_DEPENDENCY = "Gene Dependency";
9
+ static GENE_EXPRESSION = "Gene Expression";
10
+ static ISOFORM_EXPRESSION = "Isoform Expression";
11
+ static GSEA = "GSEA";
12
+ static METABOLITE_INTENSITY = "Metabolite Intensity";
13
+ static PROTEOME_ABUNDANCE = "Proteome Abundance";
14
+ static MUTATION_CNV_FUSION = "Mutation/CNV/Fusion";
15
+ static MUTATION_SIGNATURE = "Mutation Signature";
16
+ static PROTEIN_EXPRESSION = "Protein Expression";
17
+ static SINGLECELL_CELLTYPE = "Single-cell Cell Type";
18
+ static SINGLECELL_GENE_EXPRESSION = "Single-cell Gene Expression";
19
+ static SNP = "SNP Genotype";
20
+ static SNP_LIST = "SNP List";
21
+ static SNP_LOCUS = "SNP Locus";
22
+ static SPLICE_JUNCTION = "Splice Junction";
23
+ static SSGSEA = "Geneset Expression";
24
+ static TERM_COLLECTION = "Term Collection";
25
+ static VARIANT_GENOTYPE = "Variant Genotype";
26
+ }
27
+ Object.freeze(TermTypeGroups);
28
+ const defaultcolor = rgb("#8AB1D4").darker();
29
+ const default_text_color = rgb("#aaa").darker().darker();
30
+ const exoncolor = "#4F8053";
31
+ const plotColor = "#ce768e";
32
+ const IN_frame = true;
33
+ const OUT_frame = false;
34
+ const dtsnvindel = 1;
35
+ const dtfusionrna = 2;
36
+ const dtgeneexpression = 3;
37
+ const dtcnv = 4;
38
+ const dtsv = 5;
39
+ const dtitd = 6;
40
+ const dtdel = 7;
41
+ const dtnloss = 8;
42
+ const dtcloss = 9;
43
+ const dtloh = 10;
44
+ const dtmetaboliteintensity = 11;
45
+ const dtssgsea = 12;
46
+ const dtdnamethylation = 13;
47
+ const dtproteomeabundance = 14;
48
+ const dt2label = {
49
+ [dtsnvindel]: "SNV/indel",
50
+ [dtfusionrna]: "Fusion RNA",
51
+ [dtcnv]: "CNV",
52
+ [dtsv]: "SV",
53
+ [dtitd]: "ITD",
54
+ [dtdel]: "Deletion",
55
+ [dtnloss]: "N-loss",
56
+ [dtcloss]: "C-loss",
57
+ [dtloh]: "LOH",
58
+ [dtgeneexpression]: "Gene Expression",
59
+ [dtmetaboliteintensity]: "Metabolite Intensity",
60
+ [dtproteomeabundance]: "Proteome Abundance"
61
+ };
62
+ const dt2lesion = {
63
+ [dtsnvindel]: {
64
+ uilabel: "SNV/INDEL (Mutation)",
65
+ lesionTypes: [{ name: "Mutation", lesionType: "mutation", color: "#44AA44" }]
66
+ },
67
+ [dtcnv]: {
68
+ uilabel: "CNV (Copy Number Variation)",
69
+ lesionTypes: [
70
+ { name: "Loss", lesionType: "loss", color: "#4444FF" },
71
+ { name: "Gain", lesionType: "gain", color: "#FF4444" }
72
+ ]
73
+ },
74
+ [dtsv]: {
75
+ uilabel: "SV (Structural Variation)",
76
+ lesionTypes: [{ name: "SV", lesionType: "sv", color: "#9932CC" }]
77
+ },
78
+ [dtfusionrna]: {
79
+ uilabel: "Fusion (RNA Fusion)",
80
+ lesionTypes: [{ name: "Fusion", lesionType: "fusion", color: "#FFA500" }]
81
+ }
82
+ };
83
+ const optionToDt = {
84
+ snvindelOptions: dtsnvindel,
85
+ cnvOptions: dtcnv,
86
+ fusionOptions: dtfusionrna,
87
+ svOptions: dtsv
88
+ };
89
+ const mclass = {
90
+ M: {
91
+ label: "MISSENSE",
92
+ color: "#3987CC",
93
+ dt: dtsnvindel,
94
+ desc: "A sequence variant, that changes one or more bases, resulting in a different amino acid sequence but where the length is preserved",
95
+ key: "M"
96
+ },
97
+ E: { label: "EXON", color: "#bcbd22", dt: dtsnvindel, desc: "A variant in the exon of a non-coding RNA.", key: "E" },
98
+ F: {
99
+ label: "FRAMESHIFT",
100
+ color: "rgb(200, 61, 61)",
101
+ dt: dtsnvindel,
102
+ desc: "A sequence variant which causes a disruption of the translational reading frame, because the number of nucleotides inserted or deleted is not a multiple of three",
103
+ key: "F"
104
+ },
105
+ N: {
106
+ label: "NONSENSE",
107
+ color: "#ff7f0e",
108
+ dt: dtsnvindel,
109
+ desc: "A sequence variant whereby at least one base of a codon is changed, resulting in a premature stop codon, leading to a shortened transcript",
110
+ key: "N"
111
+ },
112
+ S: {
113
+ label: "SILENT",
114
+ color: "#2ca02c",
115
+ dt: dtsnvindel,
116
+ desc: "A sequence variant where there is no resulting change to the encoded amino acid",
117
+ key: "S"
118
+ },
119
+ D: {
120
+ label: "PROTEINDEL",
121
+ color: "rgb(100, 100, 100)",
122
+ dt: dtsnvindel,
123
+ desc: "An inframe non synonymous variant that deletes bases from the coding sequence",
124
+ key: "D"
125
+ },
126
+ I: {
127
+ label: "PROTEININS",
128
+ color: "#8c564b",
129
+ dt: dtsnvindel,
130
+ desc: "An inframe non synonymous variant that inserts bases into in the coding sequence",
131
+ key: "I"
132
+ },
133
+ ProteinAltering: {
134
+ label: "PROTEINALTERING",
135
+ color: "#5a0034",
136
+ dt: dtsnvindel,
137
+ desc: "An inframe complex change to the coding sequence",
138
+ key: "ProteinAltering"
139
+ },
140
+ P: {
141
+ label: "SPLICE_REGION",
142
+ color: "#9467bd",
143
+ dt: dtsnvindel,
144
+ desc: "A sequence variant in which a change has occurred within the region of the splice site, either within 1-3 bases of the exon or 3-8 bases of the intron",
145
+ key: "P"
146
+ },
147
+ L: {
148
+ label: "SPLICE",
149
+ color: "#6633FF",
150
+ dt: dtsnvindel,
151
+ desc: "A variant near an exon edge that may affect splicing functionality",
152
+ key: "L"
153
+ },
154
+ Intron: { label: "INTRON", color: "#656565", dt: dtsnvindel, desc: "An intronic variant.", key: "Intron" },
155
+ StopLost: {
156
+ label: "Stop lost",
157
+ color: "#ff7f0e",
158
+ dt: dtsnvindel,
159
+ desc: "A sequence variant where at least one base of the terminator codon (stop) is changed, resulting in an elongated transcript",
160
+ key: "StopLost"
161
+ },
162
+ StartLost: {
163
+ label: "Start lost",
164
+ color: "#ff7f0e",
165
+ dt: dtsnvindel,
166
+ desc: "A codon variant that changes at least one base of the canonical start codon",
167
+ key: "StartLost"
168
+ },
169
+ // quick fix!! for showing genes that are not tested in samples (e.g. gene panels) in the heatmap
170
+ Blank: { label: "Not tested", color: "#fff", dt: dtsnvindel, desc: "This gene is not tested.", key: "Blank" },
171
+ WT: { label: "Wildtype", color: "#D3D3D3", dt: dtsnvindel, desc: "Wildtype", key: "WT" }
172
+ };
173
+ const mclassitd = "ITD";
174
+ mclass[mclassitd] = {
175
+ label: "ITD",
176
+ color: "#ff70ff",
177
+ dt: dtitd,
178
+ desc: "In-frame internal tandem duplication.",
179
+ key: mclassitd
180
+ };
181
+ const mclassdel = "DEL";
182
+ mclass[mclassdel] = {
183
+ label: "DELETION, intragenic",
184
+ color: "#858585",
185
+ dt: dtdel,
186
+ desc: "Intragenic deletion.",
187
+ key: mclassdel
188
+ };
189
+ const mclassnloss = "NLOSS";
190
+ mclass[mclassnloss] = {
191
+ label: "N-terminus loss",
192
+ color: "#545454",
193
+ dt: dtnloss,
194
+ desc: "N-terminus loss due to translocation",
195
+ key: mclassnloss
196
+ };
197
+ const mclasscloss = "CLOSS";
198
+ mclass[mclasscloss] = {
199
+ label: "C-terminus loss",
200
+ color: "#545454",
201
+ dt: dtcloss,
202
+ desc: "C-terminus loss due to translocation",
203
+ key: mclasscloss
204
+ };
205
+ const mclassutr3 = "Utr3";
206
+ mclass[mclassutr3] = {
207
+ label: "UTR_3",
208
+ color: "#998199",
209
+ dt: dtsnvindel,
210
+ desc: "A variant in the 3' untranslated region.",
211
+ key: mclassutr3
212
+ };
213
+ const mclassutr5 = "Utr5";
214
+ mclass[mclassutr5] = {
215
+ label: "UTR_5",
216
+ color: "#819981",
217
+ dt: dtsnvindel,
218
+ desc: "A variant in the 5' untranslated region.",
219
+ key: mclassutr5
220
+ };
221
+ const mclassnonstandard = "X";
222
+ mclass[mclassnonstandard] = {
223
+ label: "NONSTANDARD",
224
+ color: "black",
225
+ dt: dtsnvindel,
226
+ desc: "A mutation class that either does not match our notation, or is unspecified.",
227
+ key: mclassnonstandard
228
+ };
229
+ const mclassnoncoding = "noncoding";
230
+ mclass[mclassnoncoding] = {
231
+ label: "NONCODING",
232
+ color: "black",
233
+ dt: dtsnvindel,
234
+ desc: "Noncoding mutation.",
235
+ key: mclassnoncoding
236
+ };
237
+ const SOterms = [
238
+ //transcript_ablation // not supported: 1) do not expect this in maf/vcf 2) should be represented as cnv deletion but not the legacy unused value "dtdel"; if needed can reenable
239
+ ["splice_acceptor_variant", "L"],
240
+ ["splice_donor_variant", "L"],
241
+ ["stop_gained", "N"],
242
+ ["frameshift_variant", "F"],
243
+ ["stop_lost", "StopLost"],
244
+ ["start_lost", "StartLost"],
245
+ //transcript_amplification // not supported, should be represented by cnv instead
246
+ ["feature_elongation", mclassnoncoding],
247
+ ["feature_truncation", mclassnoncoding],
248
+ ["inframe_insertion", "I"],
249
+ ["inframe_deletion", "D"],
250
+ ["missense_variant", "M"],
251
+ ["protein_altering_variant", "ProteinAltering"],
252
+ ["splice_donor_5th_base_variant", "P"],
253
+ ["splice_region_variant", "P"],
254
+ ["splice_donor_region_variant", "P"],
255
+ ["splice_polypyrimidine_tract_variant", "P"],
256
+ ["incomplete_terminal_codon_variant", "N"],
257
+ ["start_retained_variant", "S"],
258
+ ["stop_retained_variant", "S"],
259
+ ["synonymous_variant", "S"],
260
+ ["coding_sequence_variant", "E"],
261
+ ["mature_miRNA_variant", "E"],
262
+ ["5_prime_UTR_variant", mclassutr5],
263
+ ["3_prime_UTR_variant", mclassutr3],
264
+ ["non_coding_transcript_exon_variant", "E"],
265
+ ["intron_variant", "Intron"],
266
+ ["NMD_transcript_variant", "F"],
267
+ ["non_coding_transcript_variant", "E"],
268
+ ["coding_transcript_variant", "E"],
269
+ ["upstream_gene_variant", mclassnoncoding],
270
+ ["downstream_gene_variant", mclassnoncoding],
271
+ ["TFBS_ablation", mclassnoncoding],
272
+ ["TFBS_amplification", mclassnoncoding],
273
+ ["TF_binding_site_variant", mclassnoncoding],
274
+ ["regulatory_region_ablation", mclassnoncoding],
275
+ ["regulatory_region_amplification", mclassnoncoding],
276
+ ["regulatory_region_variant", mclassnoncoding],
277
+ ["intergenic_variant", mclassnoncoding],
278
+ ["sequence_variant", mclassnonstandard]
279
+ ];
280
+ const class2SOterm = /* @__PURE__ */ new Map();
281
+ for (const [csq, cls] of SOterms) {
282
+ if (!class2SOterm.has(cls)) class2SOterm.set(cls, []);
283
+ class2SOterm.get(cls).push(csq);
284
+ }
285
+ const SOterm2class = /* @__PURE__ */ new Map();
286
+ for (const [csq, cls] of SOterms) {
287
+ SOterm2class.set(csq, cls);
288
+ }
289
+ function mclasstester(s) {
290
+ switch (s.toLowerCase()) {
291
+ case "missense_mutation":
292
+ return "M";
293
+ case "nonsense_mutation":
294
+ return "N";
295
+ case "splice_site":
296
+ return "L";
297
+ case "splice_region":
298
+ return "P";
299
+ case "rna":
300
+ return mclassnoncoding;
301
+ case "frame_shift_del":
302
+ return "F";
303
+ case "frame_shift_ins":
304
+ return "F";
305
+ case "in_frame_del":
306
+ return "D";
307
+ case "in_frame_ins":
308
+ return "I";
309
+ case "protein_altering_variant":
310
+ return "ProteinAltering";
311
+ case "translation_start_site":
312
+ return mclassnonstandard;
313
+ case "nonstop_mutation":
314
+ return "N";
315
+ case "3'utr":
316
+ return mclassutr3;
317
+ case "3'flank":
318
+ return mclassnoncoding;
319
+ case "5'utr":
320
+ return mclassutr5;
321
+ case "5'flank":
322
+ return mclassnoncoding;
323
+ case "silent":
324
+ return "S";
325
+ case "blank":
326
+ return "Blank";
327
+ default:
328
+ return null;
329
+ }
330
+ }
331
+ const mclassfusionrna = "Fuserna";
332
+ mclass[mclassfusionrna] = {
333
+ label: "Fusion transcript",
334
+ color: "#545454",
335
+ dt: dtfusionrna,
336
+ desc: `Marks the break points leading to fusion transcripts.<br><span style="font-size:150%">&#9680;</span> - 3' end of the break point is fused to the 5' end of another break point in a different gene.<br><span style="font-size:150%">&#9681;</span> - 5' end of the break point is fused to the 3' end of another break point in a different gene.`,
337
+ key: mclassfusionrna
338
+ };
339
+ const mclasssv = "SV";
340
+ mclass[mclasssv] = {
341
+ label: "Structural variation",
342
+ color: "#858585",
343
+ dt: dtsv,
344
+ desc: `<span style="font-size:150%">&#9680;</span> - 3' end of the break point is fused to the 5' end of another break point in a different gene.<br><span style="font-size:150%">&#9681;</span> - 5' end of the break point is fused to the 3' end of another break point in a different gene.`,
345
+ key: mclasssv
346
+ };
347
+ const mclasscnvgain = "CNV_amp";
348
+ mclass[mclasscnvgain] = {
349
+ label: "Copy number gain",
350
+ // TODO change to 'Gain'
351
+ color: "#e9a3c9",
352
+ dt: dtcnv,
353
+ desc: "Copy number gain",
354
+ key: mclasscnvgain
355
+ };
356
+ const mclasscnvloss = "CNV_loss";
357
+ mclass[mclasscnvloss] = {
358
+ label: "Copy number loss",
359
+ color: "#a1d76a",
360
+ dt: dtcnv,
361
+ desc: "Copy number loss",
362
+ key: mclasscnvloss
363
+ };
364
+ const mclasscnvAmp = "CNV_amplification";
365
+ mclass[mclasscnvAmp] = {
366
+ label: "Copy number amplification",
367
+ color: "#ff0000",
368
+ dt: dtcnv,
369
+ desc: "Copy number amplification",
370
+ key: mclasscnvAmp
371
+ };
372
+ const mclasscnvHomozygousDel = "CNV_homozygous_deletion";
373
+ mclass[mclasscnvHomozygousDel] = {
374
+ label: "Copy number homozygous deletion",
375
+ color: "#0000ff",
376
+ dt: dtcnv,
377
+ desc: "Copy number homozygous deletion",
378
+ key: mclasscnvHomozygousDel
379
+ };
380
+ const mclasscnvloh = "CNV_loh";
381
+ mclass[mclasscnvloh] = { label: "LOH", color: "#12EDFC", dt: dtcnv, desc: "Loss of heterozygosity", key: mclasscnvloh };
382
+ const mclasssnv = "snv";
383
+ mclass[mclasssnv] = {
384
+ label: "SNV",
385
+ color: "#92a2d4",
386
+ dt: dtsnvindel,
387
+ desc: "Single nucleotide variation",
388
+ key: mclasssnv
389
+ };
390
+ const mclassmnv = "mnv";
391
+ mclass[mclassmnv] = {
392
+ label: "MNV",
393
+ color: "#92a2d4",
394
+ dt: dtsnvindel,
395
+ desc: "Multiple nucleotide variation",
396
+ key: mclassmnv
397
+ };
398
+ const mclassinsertion = "insertion";
399
+ mclass[mclassinsertion] = {
400
+ label: "Sequence insertion",
401
+ color: "#bd8e91",
402
+ dt: dtsnvindel,
403
+ desc: "Sequence insertion",
404
+ key: mclassinsertion
405
+ };
406
+ const mclassdeletion = "deletion";
407
+ mclass[mclassdeletion] = {
408
+ label: "Sequence deletion",
409
+ color: "#b5a174",
410
+ dt: dtsnvindel,
411
+ desc: "Sequence deletion",
412
+ key: mclassdeletion
413
+ };
414
+ function mds3tkMclass(k) {
415
+ if (k == dtcnv) {
416
+ return {
417
+ color: "#858585",
418
+ label: "CNV",
419
+ desc: "Copy number variation"
420
+ };
421
+ }
422
+ return mclass[k];
423
+ }
424
+ const dt2color = {
425
+ [dtsnvindel]: mclass.M.color
426
+ // general color for snvindel irrespective of class (when class is not available)
427
+ // add new dt as needed
428
+ };
429
+ function applyOverrides(overrides = {}) {
430
+ if (overrides.mclass) {
431
+ for (const key in overrides.mclass) {
432
+ if (!mclass[key]) mclass[key] = {};
433
+ for (const subkey in overrides.mclass[key]) {
434
+ mclass[key][subkey] = overrides.mclass[key][subkey];
435
+ }
436
+ }
437
+ }
438
+ }
439
+ const vepinfo = function(s) {
440
+ const l = s.toLowerCase().split(",");
441
+ let rank = 1;
442
+ if (l.indexOf("transcript_ablation") != -1) {
443
+ return [dtdel, mclassdel, rank];
444
+ }
445
+ rank++;
446
+ if (l.indexOf("splice_acceptor_variant") != -1) return [dtsnvindel, "L", rank];
447
+ rank++;
448
+ if (l.indexOf("splice_donor_variant") != -1) return [dtsnvindel, "L", rank];
449
+ rank++;
450
+ if (l.indexOf("stop_gained") != -1) return [dtsnvindel, "N", rank];
451
+ rank++;
452
+ if (l.indexOf("frameshift_variant") != -1) return [dtsnvindel, "F", rank];
453
+ rank++;
454
+ if (l.indexOf("stop_lost") != -1) return [dtsnvindel, "N", rank];
455
+ rank++;
456
+ if (l.indexOf("start_lost") != -1) return [dtsnvindel, "N", rank];
457
+ rank++;
458
+ if (l.indexOf("transcript_amplification") != -1) {
459
+ return [dtsnvindel, mclassnonstandard, rank];
460
+ }
461
+ rank++;
462
+ if (l.indexOf("inframe_insertion") != -1 || l.indexOf("conservative_inframe_insertion") != -1 || l.indexOf("disruptive_inframe_insertion") != -1)
463
+ return [dtsnvindel, "I", rank];
464
+ rank++;
465
+ if (l.indexOf("inframe_deletion") != -1 || l.indexOf("conservative_inframe_deletion") != -1 || l.indexOf("disruptive_inframe_deletion") != -1)
466
+ return [dtsnvindel, "D", rank];
467
+ rank++;
468
+ if (l.indexOf("missense_variant") != -1) return [dtsnvindel, "M", rank];
469
+ rank++;
470
+ if (l.indexOf("protein_altering_variant") != -1) return [dtsnvindel, "ProteinAltering", rank];
471
+ rank++;
472
+ if (l.indexOf("splice_region_variant") != -1) return [dtsnvindel, "P", rank];
473
+ rank++;
474
+ if (l.indexOf("incomplete_terminal_codon_variant") != -1) return [dtsnvindel, "N", rank];
475
+ rank++;
476
+ if (l.indexOf("stop_retained_variant") != -1) return [dtsnvindel, "S", rank];
477
+ rank++;
478
+ if (l.indexOf("synonymous_variant") != -1) return [dtsnvindel, "S", rank];
479
+ rank++;
480
+ if (l.indexOf("coding_sequence_variant") != -1) return [dtsnvindel, mclassnonstandard, rank];
481
+ rank++;
482
+ if (l.indexOf("mature_mirna_variant") != -1) return [dtsnvindel, "E", rank];
483
+ rank++;
484
+ if (l.indexOf("5_prime_utr_variant") != -1) return [dtsnvindel, mclassutr5, rank];
485
+ rank++;
486
+ if (l.indexOf("3_prime_utr_variant") != -1) return [dtsnvindel, mclassutr3, rank];
487
+ rank++;
488
+ if (l.indexOf("non_coding_transcript_exon_variant") != -1) return [dtsnvindel, "E", rank];
489
+ rank++;
490
+ if (l.indexOf("intron_variant") != -1) return [dtsnvindel, "Intron", rank];
491
+ rank++;
492
+ if (l.indexOf("nmd_transcript_variant") != -1) return [dtsnvindel, "S", rank];
493
+ rank++;
494
+ if (l.indexOf("non_coding_transcript_variant") != -1) return [dtsnvindel, "E", rank];
495
+ rank++;
496
+ if (l.indexOf("upstream_gene_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
497
+ rank++;
498
+ if (l.indexOf("downstream_gene_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
499
+ rank++;
500
+ if (l.indexOf("tfbs_ablation") != -1) return [dtsnvindel, mclassnoncoding, rank];
501
+ rank++;
502
+ if (l.indexOf("tfbs_amplification") != -1) return [dtsnvindel, mclassnoncoding, rank];
503
+ rank++;
504
+ if (l.indexOf("tf_binding_site_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
505
+ rank++;
506
+ if (l.indexOf("regulatory_region_ablation") != -1) return [dtsnvindel, mclassnoncoding, rank];
507
+ rank++;
508
+ if (l.indexOf("regulatory_region_amplification") != -1) return [dtsnvindel, mclassnoncoding, rank];
509
+ rank++;
510
+ if (l.indexOf("feature_elongation") != -1) return [dtsnvindel, mclassnoncoding, rank];
511
+ rank++;
512
+ if (l.indexOf("regulatory_region_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
513
+ rank++;
514
+ if (l.indexOf("feature_truncation") != -1) return [dtsnvindel, mclassnoncoding, rank];
515
+ rank++;
516
+ if (l.indexOf("intergenic_variant") != -1) return [dtsnvindel, mclassnoncoding, rank];
517
+ rank++;
518
+ return [dtsnvindel, mclassnonstandard, rank];
519
+ };
520
+ const germlinelegend = '<circle cx="7" cy="12" r="7" fill="#b1b1b1"></circle><path d="M6.735557395310443e-16,-11A11,11 0 0,1 11,0L9,0A9,9 0 0,0 5.51091059616309e-16,-9Z" transform="translate(7,12)" fill="#858585" stroke="none"></path>';
521
+ const morigin = {};
522
+ const moriginsomatic = "S";
523
+ morigin[moriginsomatic] = {
524
+ label: "Somatic",
525
+ desc: "A variant found only in a tumor sample. The proportion is indicated by lack of any arc.",
526
+ legend: '<circle cx="7" cy="12" r="7" fill="#b1b1b1"></circle>'
527
+ };
528
+ const morigingermline = "G";
529
+ morigin[morigingermline] = {
530
+ label: "Germline",
531
+ desc: "A constitutional variant found in a normal sample. The proportion is indicated by the span of the solid arc within the whole circle.",
532
+ legend: germlinelegend
533
+ };
534
+ morigin.germline = morigin[morigingermline];
535
+ morigin.somatic = morigin[moriginsomatic];
536
+ const moriginrelapse = "R";
537
+ morigin[moriginrelapse] = {
538
+ label: "Relapse",
539
+ desc: "A somatic variant found only in a relapse sample. The proportion is indicated by the span of the hollow arc within the whole circle.",
540
+ legend: '<circle cx="7" cy="12" r="7" fill="#b1b1b1"></circle><path d="M6.735557395310443e-16,-11A11,11 0 0,1 11,0L9,0A9,9 0 0,0 5.51091059616309e-16,-9Z" transform="translate(7,12)" fill="none" stroke="#858585"></path>'
541
+ };
542
+ const morigingermlinepathogenic = "GP";
543
+ morigin[morigingermlinepathogenic] = {
544
+ label: "Germline pathogenic",
545
+ desc: "A constitutional variant with pathogenic allele.",
546
+ legend: germlinelegend
547
+ };
548
+ const morigingermlinenonpathogenic = "GNP";
549
+ morigin[morigingermlinenonpathogenic] = {
550
+ label: "Germline non-pathogenic",
551
+ desc: "A constitutional variant with non-pathogenic allele.",
552
+ legend: germlinelegend,
553
+ hidden: true
554
+ };
555
+ const tkt = {
556
+ usegm: "usegm",
557
+ ds: "dataset",
558
+ bigwig: "bigwig",
559
+ bigwigstranded: "bigwigstranded",
560
+ junction: "junction",
561
+ mdsjunction: "mdsjunction",
562
+ mdssvcnv: "mdssvcnv",
563
+ // replaced by mds3
564
+ mdsexpressionrank: "mdsexpressionrank",
565
+ mdsvcf: "mdsvcf",
566
+ // for snv/indels, currently vcf, may include MAF
567
+ //mdsgeneral:'mdsgeneral', // replaces mdssvcnv ****** not ready yet
568
+ bedj: "bedj",
569
+ pgv: "profilegenevalue",
570
+ bampile: "bampile",
571
+ hicstraw: "hicstraw",
572
+ expressionrank: "expressionrank",
573
+ aicheck: "aicheck",
574
+ ase: "ase",
575
+ mds3: "mds3",
576
+ //
577
+ bedgraphdot: "bedgraphdot",
578
+ bam: "bam",
579
+ ld: "ld"
580
+ };
581
+ function validtkt(what) {
582
+ for (const k in tkt) {
583
+ if (what == tkt[k]) {
584
+ return true;
585
+ }
586
+ }
587
+ return false;
588
+ }
589
+ const mdsvcftype = {
590
+ vcf: "vcf"
591
+ };
592
+ const custommdstktype = {
593
+ vcf: "vcf",
594
+ svcnvitd: "svcnvitd",
595
+ geneexpression: "geneexpression"
596
+ };
597
+ const codon = {
598
+ GCT: "A",
599
+ GCC: "A",
600
+ GCA: "A",
601
+ GCG: "A",
602
+ CGT: "R",
603
+ CGC: "R",
604
+ CGA: "R",
605
+ CGG: "R",
606
+ AGA: "R",
607
+ AGG: "R",
608
+ AAT: "N",
609
+ AAC: "N",
610
+ GAT: "D",
611
+ GAC: "D",
612
+ TGT: "C",
613
+ TGC: "C",
614
+ CAA: "Q",
615
+ CAG: "Q",
616
+ GAA: "E",
617
+ GAG: "E",
618
+ GGT: "G",
619
+ GGC: "G",
620
+ GGA: "G",
621
+ GGG: "G",
622
+ CAT: "H",
623
+ CAC: "H",
624
+ ATT: "I",
625
+ ATC: "I",
626
+ ATA: "I",
627
+ TTA: "L",
628
+ TTG: "L",
629
+ CTT: "L",
630
+ CTC: "L",
631
+ CTA: "L",
632
+ CTG: "L",
633
+ AAA: "K",
634
+ AAG: "K",
635
+ ATG: "M",
636
+ TTT: "F",
637
+ TTC: "F",
638
+ CCT: "P",
639
+ CCC: "P",
640
+ CCA: "P",
641
+ CCG: "P",
642
+ TCT: "S",
643
+ TCC: "S",
644
+ TCA: "S",
645
+ TCG: "S",
646
+ AGT: "S",
647
+ AGC: "S",
648
+ ACT: "T",
649
+ ACC: "T",
650
+ ACA: "T",
651
+ ACG: "T",
652
+ TGG: "W",
653
+ TAT: "Y",
654
+ TAC: "Y",
655
+ GTT: "V",
656
+ GTC: "V",
657
+ GTA: "V",
658
+ GTG: "V"
659
+ };
660
+ const codon_stop = "*";
661
+ function nt2aa(gm) {
662
+ if (!gm.genomicseq) return void 0;
663
+ const enlst = [];
664
+ if (gm.coding) {
665
+ for (const [i, e] of gm.coding.entries()) {
666
+ const s = gm.genomicseq.substr(e[0] - gm.start, e[1] - e[0]);
667
+ if (gm.strand == "-") {
668
+ enlst.push(reversecompliment(s));
669
+ } else {
670
+ enlst.push(s);
671
+ }
672
+ }
673
+ }
674
+ const nt = enlst.join("");
675
+ const pep = [];
676
+ const startntidx = gm.startCodonFrame ? 3 - gm.startCodonFrame : 0;
677
+ for (let i = startntidx; i < nt.length; i += 3) {
678
+ const a = codon[nt.substr(i, 3)];
679
+ pep.push(a || codon_stop);
680
+ }
681
+ gm.cdseq = nt;
682
+ return pep.join("");
683
+ }
684
+ function bplen(len, isfile) {
685
+ if (len >= 1e9) return (len / 1e9).toFixed(1) + " Gb";
686
+ if (len >= 1e7) return Math.ceil(len / 1e6) + " Mb";
687
+ if (len >= 1e6) return (len / 1e6).toFixed(1) + " Mb";
688
+ if (len >= 1e4) return Math.ceil(len / 1e3) + " Kb";
689
+ if (len >= 1e3) return (len / 1e3).toFixed(1) + " Kb";
690
+ return len + (isfile ? "bytes" : " bp");
691
+ }
692
+ const basecolor = {
693
+ A: "#ca0020",
694
+ T: "#f4a582",
695
+ C: "#92c5de",
696
+ G: "#0571b0"
697
+ };
698
+ function basecompliment(nt) {
699
+ switch (nt) {
700
+ case "A":
701
+ return "T";
702
+ case "T":
703
+ return "A";
704
+ case "C":
705
+ return "G";
706
+ case "G":
707
+ return "C";
708
+ case "a":
709
+ return "t";
710
+ case "t":
711
+ return "a";
712
+ case "c":
713
+ return "g";
714
+ case "g":
715
+ return "c";
716
+ default:
717
+ return nt;
718
+ }
719
+ }
720
+ function reversecompliment(s) {
721
+ const tmp = [];
722
+ for (let i = s.length - 1; i >= 0; i--) {
723
+ tmp.push(basecompliment(s[i]));
724
+ }
725
+ return tmp.join("");
726
+ }
727
+ function spliceeventchangegmexon(gm, evt) {
728
+ const gm2 = {
729
+ chr: gm.chr,
730
+ start: gm.start,
731
+ stop: gm.stop,
732
+ strand: gm.strand,
733
+ coding: []
734
+ };
735
+ if (evt.isskipexon || evt.isaltexon) {
736
+ for (let i = 0; i < gm.exon.length; i++) {
737
+ const codingstart = Math.max(gm.codingstart, gm.exon[i][0]);
738
+ const codingstop = Math.min(gm.codingstop, gm.exon[i][1]);
739
+ if (codingstart > codingstop) {
740
+ continue;
741
+ }
742
+ if (evt.skippedexon.indexOf(i) == -1) {
743
+ gm2.coding.push([codingstart, codingstop]);
744
+ } else {
745
+ }
746
+ }
747
+ } else if (evt.a5ss || evt.a3ss) {
748
+ const exons = gm.exon.map((e) => [e[0], e[1]]);
749
+ const forward = gm.strand == "+";
750
+ if (evt.a5ss) {
751
+ if (forward) {
752
+ exons[evt.exon5idx][1] = evt.junctionB.start;
753
+ } else {
754
+ exons[evt.exon5idx + 1][0] = evt.junctionB.stop;
755
+ }
756
+ } else {
757
+ if (forward) {
758
+ exons[evt.exon5idx + 1][0] = evt.junctionB.stop;
759
+ } else {
760
+ exons[evt.exon5idx][1] = evt.junctionB.start;
761
+ }
762
+ }
763
+ for (const e of exons) {
764
+ const codingstart = Math.max(gm.codingstart, e[0]);
765
+ const codingstop = Math.min(gm.codingstop, e[1]);
766
+ if (codingstart > codingstop) {
767
+ continue;
768
+ }
769
+ gm2.coding.push([codingstart, codingstop]);
770
+ }
771
+ }
772
+ return gm2;
773
+ }
774
+ function fasta2gmframecheck(gm, str) {
775
+ const lines = str.split("\n");
776
+ lines.shift();
777
+ gm.genomicseq = lines.join("").toUpperCase();
778
+ const aaseq = nt2aa(gm);
779
+ let thisframe = OUT_frame;
780
+ const stopcodonidx = aaseq.indexOf(codon_stop);
781
+ if (stopcodonidx == aaseq.length - 1) {
782
+ thisframe = IN_frame;
783
+ }
784
+ return thisframe;
785
+ }
786
+ function validate_vcfinfofilter(obj) {
787
+ if (!obj.lst) return ".lst missing";
788
+ if (!Array.isArray(obj.lst)) return "input is not an array";
789
+ for (const set of obj.lst) {
790
+ if (!set.name) return "name missing from a set of .vcfinfofilter.lst";
791
+ if (set.autocategory || set.categories) {
792
+ if (!set.autocategory) {
793
+ for (const k in set.categories) {
794
+ const v = set.categories[k];
795
+ if (!set.autocolor && !v.color)
796
+ return ".color missing for class " + k + " from .categories of set " + set.name;
797
+ if (!v.label) {
798
+ v.label = k;
799
+ }
800
+ }
801
+ }
802
+ if (set.categoryhidden) {
803
+ for (const k in set.categoryhidden) {
804
+ if (!set.categories[k]) return "unknown hidden-by-default category " + k + " from set " + set.name;
805
+ }
806
+ } else {
807
+ set.categoryhidden = {};
808
+ }
809
+ } else if (set.numericfilter) {
810
+ const lst = [];
811
+ for (const v of set.numericfilter) {
812
+ if (typeof v == "number") {
813
+ lst.push({ side: "<", value: v });
814
+ } else {
815
+ lst.push({
816
+ side: v.side || "<",
817
+ value: v.value
818
+ });
819
+ }
820
+ }
821
+ set.numericfilter = lst;
822
+ }
823
+ if (set.altalleleinfo) {
824
+ if (!set.altalleleinfo.key) {
825
+ return ".key missing from .altalleleinfo from set " + set.name;
826
+ }
827
+ } else if (set.locusinfo) {
828
+ if (!set.locusinfo.key) {
829
+ return ".key missing from .locusinfo from set " + set.name;
830
+ }
831
+ } else {
832
+ return "neither .altalleleinfo or .locusinfo is available from set " + set.name;
833
+ }
834
+ }
835
+ }
836
+ function contigNameNoChr(genome, chrlst) {
837
+ for (const n in genome.majorchr) {
838
+ if (chrlst.indexOf(n.replace("chr", "")) != -1) {
839
+ return true;
840
+ }
841
+ }
842
+ if (genome.minorchr) {
843
+ for (const n in genome.minorchr) {
844
+ if (chrlst.indexOf(n.replace("chr", "")) != -1) {
845
+ return true;
846
+ }
847
+ }
848
+ }
849
+ return false;
850
+ }
851
+ function contigNameNoChr2(genome, chrlst) {
852
+ let nochrcount = 0, haschrcount = 0;
853
+ for (const n in genome.majorchr) {
854
+ if (chrlst.includes(n)) {
855
+ haschrcount++;
856
+ } else if (chrlst.includes(n.replace("chr", ""))) {
857
+ nochrcount++;
858
+ }
859
+ }
860
+ if (genome.minorchr) {
861
+ for (const n in genome.minorchr) {
862
+ if (chrlst.includes(n)) {
863
+ haschrcount++;
864
+ } else if (chrlst.includes(n.replace("chr", ""))) {
865
+ nochrcount++;
866
+ }
867
+ }
868
+ }
869
+ return [nochrcount, haschrcount];
870
+ }
871
+ function getMax_byiqr(lst, novaluemax) {
872
+ if (lst.length == 0) return novaluemax;
873
+ lst.sort((i, j) => i - j);
874
+ const max = lst[lst.length - 1];
875
+ if (lst.length <= 5) return max;
876
+ const q1 = lst[Math.floor(lst.length / 4)];
877
+ const q2 = lst[Math.floor(lst.length * 3 / 4)];
878
+ return Math.min(q2 + (q2 - q1) * 1.5, max);
879
+ }
880
+ function alleleInGenotypeStr(genotype, allele) {
881
+ if (!genotype) return false;
882
+ if (genotype.indexOf("/") != -1) {
883
+ return genotype.split("/").indexOf(allele) != -1;
884
+ }
885
+ return genotype.split("|").indexOf(allele) != -1;
886
+ }
887
+ const gmmode = {
888
+ genomic: "genomic",
889
+ splicingrna: "splicing RNA",
890
+ // if just 1 exon, use "RNA" as label
891
+ exononly: "exon only",
892
+ protein: "protein",
893
+ gmsum: "aggregated exons"
894
+ };
895
+ function vcfcopymclass(m, block) {
896
+ if (m.csq) {
897
+ let useone;
898
+ if (block.usegm) {
899
+ useone = m.csq.find((i) => i._isoform == block.usegm.isoform);
900
+ }
901
+ if (!useone) {
902
+ useone = m.csq.find((i) => i.CANONICAL);
903
+ if (!useone) {
904
+ useone = m.csq[0];
905
+ for (const q of m.csq) {
906
+ if (q._csqrank < useone._csqrank) {
907
+ useone = q;
908
+ }
909
+ }
910
+ }
911
+ }
912
+ if (useone) {
913
+ m.gene = useone._gene;
914
+ m.isoform = useone._isoform;
915
+ m.class = useone._class;
916
+ m.dt = useone._dt;
917
+ m.mname = useone._mname;
918
+ if (m.class == mclassnoncoding) {
919
+ delete m.class;
920
+ }
921
+ }
922
+ } else if (m.ann) {
923
+ let useone = null;
924
+ if (block.usegm) {
925
+ for (const q of m.ann) {
926
+ if (q._isoform != block.usegm.isoform) continue;
927
+ if (useone) {
928
+ if (q._csqrank < useone._csqrank) {
929
+ useone = q;
930
+ }
931
+ } else {
932
+ useone = q;
933
+ }
934
+ }
935
+ if (!useone && block.gmmode == gmmode.genomic) {
936
+ useone = m.ann[0];
937
+ }
938
+ } else {
939
+ useone = m.ann[0];
940
+ for (const q of m.ann) {
941
+ if (q._csqrank < useone._csqrank) {
942
+ useone = q;
943
+ }
944
+ }
945
+ }
946
+ if (useone) {
947
+ m.gene = useone._gene;
948
+ m.isoform = useone._isoform;
949
+ m.class = useone._class;
950
+ m.dt = useone._dt;
951
+ m.mname = useone._mname;
952
+ if (m.class == mclassnoncoding) {
953
+ delete m.class;
954
+ }
955
+ }
956
+ }
957
+ if (m.class == void 0) {
958
+ if (mclass[m.type]) {
959
+ m.class = m.type;
960
+ m.dt = mclass[m.type].dt;
961
+ m.mname = m.id && m.id != "." ? m.id : m.ref + ">" + m.alt;
962
+ if (m.mname.length > 15) {
963
+ m.mname = m.type;
964
+ }
965
+ } else {
966
+ m.class = mclassnonstandard;
967
+ m.dt = dtsnvindel;
968
+ m.mname = m.type;
969
+ }
970
+ }
971
+ delete m.type;
972
+ }
973
+ const not_annotated = "Unannotated";
974
+ function kernelDensityEstimator(kernel, X) {
975
+ return function(V) {
976
+ return X.map((x) => {
977
+ return [x, V.map((v) => kernel(x - v)).reduce((i, j) => i + j, 0) / V.length];
978
+ });
979
+ };
980
+ }
981
+ function kernelEpanechnikov(k) {
982
+ return function(v) {
983
+ return Math.abs(v /= k) <= 1 ? 0.75 * (1 - v * v) / k : 0;
984
+ };
985
+ }
986
+ const schemeCategory20 = [
987
+ "#1f77b4",
988
+ "#aec7e8",
989
+ "#ff7f0e",
990
+ "#ffbb78",
991
+ "#2ca02c",
992
+ "#98df8a",
993
+ "#d62728",
994
+ "#ff9896",
995
+ "#9467bd",
996
+ "#c5b0d5",
997
+ "#8c564b",
998
+ "#c49c94",
999
+ "#e377c2",
1000
+ "#f7b6d2",
1001
+ "#7f7f7f",
1002
+ "#c7c7c7",
1003
+ "#bcbd22",
1004
+ "#dbdb8d",
1005
+ "#17becf",
1006
+ "#9edae5"
1007
+ ];
1008
+ const schemeCategory2 = ["#e75480", "blue"];
1009
+ function getColorScheme(number) {
1010
+ if (number > 20) {
1011
+ const scheme = [];
1012
+ for (let i = 0; i < number; i++) scheme.push(d3.interpolateRainbow(i / number));
1013
+ return scheme;
1014
+ }
1015
+ if (number > 12) return schemeCategory20;
1016
+ else if (number > 8) return d3.schemePaired;
1017
+ else if (number > 2) return d3.schemeDark2;
1018
+ else return schemeCategory2;
1019
+ }
1020
+ function getColors(number) {
1021
+ const scheme = getColorScheme(number);
1022
+ return d3scale.scaleOrdinal(scheme);
1023
+ }
1024
+ const proteinDomainColors = [
1025
+ "#8dd3c7",
1026
+ "#bebada",
1027
+ "#fb8072",
1028
+ "#80b1d3",
1029
+ "#E8E89E",
1030
+ "#a6d854",
1031
+ "#fdb462",
1032
+ "#ffd92f",
1033
+ "#e5c494",
1034
+ "#b3b3b3"
1035
+ ];
1036
+ function proteinDomainColorScale() {
1037
+ return d3scale.scaleOrdinal().range(proteinDomainColors);
1038
+ }
1039
+ const truncatingMutations = ["F", "N", "L", "P"];
1040
+ const proteinChangingMutations = ["F", "N", "L", "P", "D", "I", "ProteinAltering", "M"];
1041
+ const synonymousMutations = ["S", "Intron", "Utr3", "Utr5", "noncoding", "E"];
1042
+ const mutationClasses = Object.values(mclass).filter((m) => m.dt == dtsnvindel).map((m) => m.key);
1043
+ const CNVClasses = Object.values(mclass).filter((m) => m.dt == dtcnv).map((m) => m.key);
1044
+ const dtTerms_temp = [
1045
+ {
1046
+ id: "snvindel",
1047
+ query: "snvindel",
1048
+ name: dt2label[dtsnvindel],
1049
+ parent_id: null,
1050
+ isleaf: true,
1051
+ type: "dtsnvindel",
1052
+ dt: dtsnvindel,
1053
+ values: {}
1054
+ },
1055
+ {
1056
+ id: "cnv",
1057
+ query: "cnv",
1058
+ name: dt2label[dtcnv],
1059
+ parent_id: null,
1060
+ isleaf: true,
1061
+ type: "dtcnv",
1062
+ dt: dtcnv,
1063
+ values: {}
1064
+ },
1065
+ {
1066
+ id: "fusion",
1067
+ query: "svfusion",
1068
+ name: dt2label[dtfusionrna],
1069
+ parent_id: null,
1070
+ isleaf: true,
1071
+ type: "dtfusion",
1072
+ dt: dtfusionrna,
1073
+ values: {}
1074
+ },
1075
+ {
1076
+ id: "sv",
1077
+ query: "svfusion",
1078
+ name: dt2label[dtsv],
1079
+ parent_id: null,
1080
+ isleaf: true,
1081
+ type: "dtsv",
1082
+ dt: dtsv,
1083
+ values: {}
1084
+ }
1085
+ ];
1086
+ const dtTerms_temp2 = [];
1087
+ for (const dtTerm of dtTerms_temp) {
1088
+ dtTerm.name_noOrigin = dtTerm.name;
1089
+ dtTerms_temp2.push(dtTerm);
1090
+ for (const origin of ["somatic", "germline"]) {
1091
+ const addOrigin = {
1092
+ id: `${dtTerm.id}_${origin}`,
1093
+ name: `${dtTerm.name} (${origin})`,
1094
+ origin
1095
+ };
1096
+ dtTerms_temp2.push(Object.assign({}, dtTerm, addOrigin));
1097
+ }
1098
+ }
1099
+ const dtTerms = dtTerms_temp2;
1100
+ const colorScaleMap = {
1101
+ blueWhiteRed: { domain: [0, 0.5, 1], range: ["blue", "white", "red"] },
1102
+ greenWhiteRed: { domain: [0, 0.5, 1], range: ["green", "white", "red"] },
1103
+ blueYellowRed: {
1104
+ domain: [0, 0.17, 0.33, 0.5, 0.67, 0.83, 1],
1105
+ range: ["#313695", "#649AC7", "#BCE1ED", "#FFFFBF", "#FDBE70", "#EA5839", "#A50026"]
1106
+ },
1107
+ greenBlackRed: {
1108
+ domain: [0, 0.17, 0.33, 0.5, 0.67, 0.83, 1],
1109
+ range: ["#00FF00", "#14E10C", "#1AAF10", "#000000", "#B01205", "#E20E03", "#FF0000"]
1110
+ },
1111
+ blueBlackYellow: {
1112
+ domain: [0, 0.17, 0.33, 0.5, 0.67, 0.83, 1],
1113
+ range: ["#0000FF", "#0000CC", "#000099", "#202020", "#999900", "#CCCC00", "#FFFF00"]
1114
+ },
1115
+ // when hierCluster z-score transformation is not performed, should use two-color scale
1116
+ whiteRed: { domain: [0, 1], range: ["white", "red"] }
1117
+ };
1118
+ function invalidcoord(thisgenome, chrom, start, stop) {
1119
+ if (!thisgenome) return "no genome";
1120
+ if (!chrom) return "no chr name";
1121
+ const chr = thisgenome.chrlookup[chrom.toUpperCase()];
1122
+ if (!chr) return "Invalid chromosome name: " + chr;
1123
+ if (!Number.isInteger(start)) return "Non-numerical position: " + start;
1124
+ if (start < 0 || start >= chr.len) return "Position out of range: " + start;
1125
+ if (!Number.isInteger(stop)) return "Non-numerical position: " + stop;
1126
+ if (stop < 0 || stop > chr.len) return "Position out of range: " + stop;
1127
+ if (start > stop) return "Start position is greater than stop";
1128
+ return false;
1129
+ }
1130
+ function string2pos(s, genome, donotextend) {
1131
+ s = s.replace(/,/g, "");
1132
+ const chr = genome.chrlookup[s.toUpperCase()];
1133
+ if (chr) {
1134
+ return {
1135
+ chr: chr.name,
1136
+ chrlen: chr.len,
1137
+ start: Math.max(0, Math.ceil(chr.len / 2) - 1e4),
1138
+ stop: Math.min(chr.len, Math.ceil(chr.len / 2) + 1e4)
1139
+ };
1140
+ }
1141
+ {
1142
+ const tmp2 = s.split(".");
1143
+ if (tmp2.length >= 2) {
1144
+ const chr2 = genome.chrlookup[tmp2[0].toUpperCase()];
1145
+ const pos = Number.parseInt(tmp2[1]);
1146
+ const e = invalidcoord(genome, tmp2[0], pos, pos + 1);
1147
+ if (!e) {
1148
+ const bpspan = 400;
1149
+ return {
1150
+ chr: chr2.name,
1151
+ chrlen: chr2.len,
1152
+ start: Math.max(0, pos - Math.ceil(bpspan / 2)),
1153
+ stop: Math.min(chr2.len, pos + Math.ceil(bpspan / 2)),
1154
+ actualposition: { position: pos, len: 1 }
1155
+ };
1156
+ }
1157
+ }
1158
+ }
1159
+ const tmp = s.split(/[-:\s]+/);
1160
+ if (tmp.length == 2) {
1161
+ const pos = Number.parseInt(tmp[1]);
1162
+ const e = invalidcoord(genome, tmp[0], pos, pos + 1);
1163
+ if (e) {
1164
+ return null;
1165
+ }
1166
+ const chr2 = genome.chrlookup[tmp[0].toUpperCase()];
1167
+ const bpspan = 400;
1168
+ return {
1169
+ chr: chr2.name,
1170
+ chrlen: chr2.len,
1171
+ start: Math.max(0, pos - Math.ceil(bpspan / 2)),
1172
+ stop: Math.min(chr2.len, pos + Math.ceil(bpspan / 2)),
1173
+ actualposition: { position: pos, len: 1 }
1174
+ };
1175
+ }
1176
+ if (tmp.length == 3) {
1177
+ let start = Number.parseInt(tmp[1]), stop = Number.parseInt(tmp[2]);
1178
+ const e = invalidcoord(genome, tmp[0], start, stop);
1179
+ if (e) {
1180
+ return null;
1181
+ }
1182
+ const actualposition = { position: start, len: stop - start };
1183
+ const chr2 = genome.chrlookup[tmp[0].toUpperCase()];
1184
+ if (!donotextend) {
1185
+ const minspan = 400;
1186
+ if (stop - start < minspan) {
1187
+ let center = Math.ceil((start + stop) / 2);
1188
+ if (center + minspan / 2 >= chr2.len) {
1189
+ center = chr2.len - Math.ceil(minspan / 2);
1190
+ }
1191
+ start = Math.max(0, center - Math.ceil(minspan / 2));
1192
+ stop = start + minspan;
1193
+ }
1194
+ }
1195
+ return {
1196
+ chr: chr2.name,
1197
+ chrlen: chr2.len,
1198
+ start,
1199
+ stop,
1200
+ actualposition
1201
+ };
1202
+ }
1203
+ return null;
1204
+ }
1205
+ export {
1206
+ CNVClasses,
1207
+ IN_frame,
1208
+ OUT_frame,
1209
+ SOterm2class,
1210
+ TermTypeGroups,
1211
+ alleleInGenotypeStr,
1212
+ applyOverrides,
1213
+ basecolor,
1214
+ basecompliment,
1215
+ bplen,
1216
+ class2SOterm,
1217
+ codon,
1218
+ codon_stop,
1219
+ colorScaleMap,
1220
+ contigNameNoChr,
1221
+ contigNameNoChr2,
1222
+ custommdstktype,
1223
+ default_text_color,
1224
+ defaultcolor,
1225
+ dt2color,
1226
+ dt2label,
1227
+ dt2lesion,
1228
+ dtTerms,
1229
+ dtcloss,
1230
+ dtcnv,
1231
+ dtdel,
1232
+ dtdnamethylation,
1233
+ dtfusionrna,
1234
+ dtgeneexpression,
1235
+ dtitd,
1236
+ dtloh,
1237
+ dtmetaboliteintensity,
1238
+ dtnloss,
1239
+ dtproteomeabundance,
1240
+ dtsnvindel,
1241
+ dtssgsea,
1242
+ dtsv,
1243
+ exoncolor,
1244
+ fasta2gmframecheck,
1245
+ germlinelegend,
1246
+ getColorScheme,
1247
+ getColors,
1248
+ getMax_byiqr,
1249
+ gmmode,
1250
+ invalidcoord,
1251
+ kernelDensityEstimator,
1252
+ kernelEpanechnikov,
1253
+ mclass,
1254
+ mclasscloss,
1255
+ mclasscnvAmp,
1256
+ mclasscnvHomozygousDel,
1257
+ mclasscnvgain,
1258
+ mclasscnvloh,
1259
+ mclasscnvloss,
1260
+ mclassdel,
1261
+ mclassdeletion,
1262
+ mclassfusionrna,
1263
+ mclassinsertion,
1264
+ mclassitd,
1265
+ mclassmnv,
1266
+ mclassnloss,
1267
+ mclassnoncoding,
1268
+ mclassnonstandard,
1269
+ mclasssnv,
1270
+ mclasssv,
1271
+ mclasstester,
1272
+ mclassutr3,
1273
+ mclassutr5,
1274
+ mds3tkMclass,
1275
+ mdsvcftype,
1276
+ morigin,
1277
+ morigingermline,
1278
+ morigingermlinenonpathogenic,
1279
+ morigingermlinepathogenic,
1280
+ moriginrelapse,
1281
+ moriginsomatic,
1282
+ mutationClasses,
1283
+ not_annotated,
1284
+ nt2aa,
1285
+ optionToDt,
1286
+ plotColor,
1287
+ proteinChangingMutations,
1288
+ proteinDomainColorScale,
1289
+ reversecompliment,
1290
+ schemeCategory2,
1291
+ schemeCategory20,
1292
+ spliceeventchangegmexon,
1293
+ string2pos,
1294
+ synonymousMutations,
1295
+ tkt,
1296
+ truncatingMutations,
1297
+ validate_vcfinfofilter,
1298
+ validtkt,
1299
+ vcfcopymclass,
1300
+ vepinfo
1301
+ };
1302
+ //# sourceMappingURL=common.js.map