@sjcrh/proteinpaint-shared 2.78.0-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.
@@ -0,0 +1,126 @@
1
+ ////////////////////////////////////
2
+ //
3
+ // shared between client and server
4
+ //
5
+ ////////////////////////////////////
6
+
7
+ import * as common from './common.js'
8
+ import * as bulk from './bulk.js'
9
+
10
+ export function parseheader(line, flag) {
11
+ const header = line.toLowerCase().split('\t')
12
+ if (header.length <= 1) return 'invalid header line for truncation'
13
+ const htry = (...lst) => {
14
+ for (const e of lst) {
15
+ const j = header.indexOf(e)
16
+ if (j != -1) return j
17
+ }
18
+ return -1
19
+ }
20
+ let i = htry('gene')
21
+ if (i == -1) return 'gene missing from header'
22
+ header[i] = 'gene'
23
+ i = htry(
24
+ 'annovar_isoform',
25
+ 'mrna_accession',
26
+ 'mrna accession',
27
+ 'refseq_mrna_id',
28
+ 'annovar_sj_filter_isoform',
29
+ 'refseq',
30
+ 'isoform'
31
+ )
32
+ if (i == -1) return 'isoform missing from header'
33
+ header[i] = 'isoform'
34
+ let hasrnapos = false
35
+ i = htry('rnaposition')
36
+ if (i != -1) {
37
+ header[i] = 'rnaposition'
38
+ hasrnapos = true
39
+ }
40
+ i = htry('losstype')
41
+ if (i == -1) return 'lossType missing from header'
42
+ header[i] = 'losstype'
43
+ let hasgenomic = false
44
+ i = htry('chromosome', 'chr')
45
+ if (i != -1) {
46
+ header[i] = 'chr'
47
+ i = htry('start', 'start_position', 'wu_hg19_pos', 'chr_position', 'position')
48
+ if (i == -1) {
49
+ return 'genomic position missing from header'
50
+ }
51
+ header[i] = 'pos'
52
+ hasgenomic = true
53
+ }
54
+ if (!hasrnapos && !hasgenomic) {
55
+ return 'neither rnaposition nor genomic position is given'
56
+ }
57
+
58
+ i = htry('sample', 'sample_name', 'tumor_sample_barcode')
59
+ if (i != -1) header[i] = 'sample'
60
+ i = htry('patient', 'donor', 'target_case_id')
61
+ if (i != -1) header[i] = 'patient'
62
+ i = htry('disease')
63
+ if (i != -1) header[i] = 'disease'
64
+ i = htry('origin')
65
+ if (i != -1) header[i] = 'origin'
66
+ i = htry('sampletype', 'sample type', 'sample_type')
67
+ if (i != -1) header[i] = 'sampletype'
68
+ flag.truncation.header = header
69
+ flag.truncation.loaded = true
70
+ return false
71
+ }
72
+
73
+ export function parseline(i, line, flag) {
74
+ if (line == '' || line[0] == '#') return
75
+ const lst = line.split('\t')
76
+ const m = {}
77
+ for (let j = 0; j < flag.truncation.header.length; j++) {
78
+ m[flag.truncation.header[j]] = lst[j]
79
+ }
80
+ if (!m.gene) {
81
+ flag.truncation.badlines.push([i, 'missing gene', lst])
82
+ return
83
+ }
84
+ if (m.rnaposition) {
85
+ const v = Number.parseInt(m.rnaposition)
86
+ if (Number.isNaN(v) || v < 0) {
87
+ flag.truncation.badlines.push([i, 'invalid rnaPosition value', lst])
88
+ return
89
+ }
90
+ m.rnaposition = v
91
+ }
92
+ if (m.pos) {
93
+ const v = Number.parseInt(m.pos)
94
+ if (Number.isNaN(v) || v < 0) {
95
+ flag.truncation.badlines.push([i, 'invalid genomic position', lst])
96
+ return
97
+ }
98
+ m.pos = v
99
+ }
100
+ if (!m.losstype) {
101
+ flag.truncation.badlines.push([i, 'missing lossType value', lst])
102
+ return
103
+ }
104
+ if (m.losstype != 'n' && m.losstype != 'c') {
105
+ flag.truncation.badlines.push([i, 'lossType value not "n" or "c"', lst])
106
+ return
107
+ }
108
+ if (bulk.parsesample(m, flag, i, lst, flag.truncation.badlines)) {
109
+ return
110
+ }
111
+ if (m.losstype == 'n') {
112
+ m.dt = common.dtnloss
113
+ m.class = common.mclassnloss
114
+ m.mname = 'N-loss'
115
+ } else {
116
+ m.dt = common.dtcloss
117
+ m.class = common.mclasscloss
118
+ m.mname = 'C-loss'
119
+ }
120
+ flag.good++
121
+ const n = flag.geneToUpper ? m.gene.toUpperCase() : m.gene
122
+ if (!(n in flag.data)) {
123
+ flag.data[n] = []
124
+ }
125
+ flag.data[n].push(m)
126
+ }
@@ -0,0 +1,66 @@
1
+ export const clusterMethodLst = [
2
+ {
3
+ label: 'Average',
4
+ value: 'average',
5
+ title: `Cluster by average value`
6
+ },
7
+ {
8
+ label: `Complete`,
9
+ value: 'complete',
10
+ title: `Use the complete clustering method`
11
+ },
12
+ {
13
+ label: `Single`,
14
+ value: 'single',
15
+ title: `Use the single clustering method`
16
+ },
17
+ {
18
+ label: `Ward.D`,
19
+ value: 'ward.D',
20
+ title: `Use the ward.D clustering method`
21
+ },
22
+ {
23
+ label: `Ward.D2`,
24
+ value: 'ward.D2',
25
+ title: `Use the ward.D2 clustering method`
26
+ },
27
+ {
28
+ label: `Mcquitty`,
29
+ value: 'mcquitty',
30
+ title: `Use the Mcquity clustering method`
31
+ }
32
+ /* These methods are currently disabled because the dendrogram lines tend to cross one another.
33
+ {
34
+ label: `Centroid`,
35
+ value: 'centroid',
36
+ title: `Use the centroid clustering method`
37
+ },
38
+ {
39
+ label: `Median`,
40
+ value: 'median',
41
+ title: `Use the median clustering method`
42
+ }
43
+ */
44
+ ]
45
+ export const distanceMethodLst = [
46
+ {
47
+ label: 'Euclidean',
48
+ value: 'euclidean',
49
+ title: `Calculate distance using euclidean method`
50
+ },
51
+ {
52
+ label: 'Maximum',
53
+ value: 'maximum',
54
+ title: `Maximum distance between two components of x and y`
55
+ },
56
+ {
57
+ label: 'Manhattan',
58
+ value: 'manhattan',
59
+ title: `Calculate distance using the absolute distance between the two vectors`
60
+ },
61
+ {
62
+ label: 'Canberra',
63
+ value: 'canberra',
64
+ title: `Calculate distance using Canberra method`
65
+ }
66
+ ]