@sjcrh/proteinpaint-shared 2.119.0 → 2.121.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/package.json +1 -1
- package/src/mds3tk.js +35 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/src/mds3tk.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { dtcnv } from './common.js'
|
|
2
|
+
|
|
1
3
|
// this script should contain mds3 track-related stuff shared between client and backend
|
|
2
4
|
|
|
3
5
|
/*
|
|
@@ -14,3 +16,36 @@ svfusion: dt + chr + pos + strand + pairlstidx + mname
|
|
|
14
16
|
the separator must avoid conflicting with characters from gene names, and can be changed based on needs
|
|
15
17
|
*/
|
|
16
18
|
export const ssmIdFieldsSeparator = '__'
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
input: array of mixture of ssm, svfusion and cnv
|
|
22
|
+
|
|
23
|
+
output: sorted array. each element: [ class/dt, count of m ]
|
|
24
|
+
*/
|
|
25
|
+
export function summarize_mclass(mlst) {
|
|
26
|
+
const m2c = new Map() // k: mclass, v: {}
|
|
27
|
+
const cnvs = []
|
|
28
|
+
for (const m of mlst) {
|
|
29
|
+
if (m.dt == dtcnv) {
|
|
30
|
+
cnvs.push(m)
|
|
31
|
+
continue // process cnv later
|
|
32
|
+
}
|
|
33
|
+
// snvindel has m.class=str, svfusion has only dt=int
|
|
34
|
+
const key = m.class || m.dt
|
|
35
|
+
m2c.set(key, 1 + (m2c.get(key) || 0))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (cnvs.length) {
|
|
39
|
+
if (Number.isFinite(cnvs[0].value)) {
|
|
40
|
+
// first cnv uses numeric value (assumes all the same). record by dt
|
|
41
|
+
m2c.set(dtcnv, cnvs.length)
|
|
42
|
+
} else {
|
|
43
|
+
// cnv not numeric and uses class; record by each class
|
|
44
|
+
for (const c of cnvs) {
|
|
45
|
+
if (!c.class) continue // should not happen
|
|
46
|
+
m2c.set(c.class, 1 + (m2c.get(c.class) || 0))
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return [...m2c].sort((i, j) => j[1] - i[1])
|
|
51
|
+
}
|