@sjcrh/proteinpaint-shared 2.163.1 → 2.167.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-shared",
3
- "version": "2.163.1",
3
+ "version": "2.167.0",
4
4
  "description": "ProteinPaint code that is shared between server and client-side workspaces",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/common.js CHANGED
@@ -30,7 +30,8 @@ export const TermTypeGroups = {
30
30
  SNP: 'SNP Genotype',
31
31
  SNP_LIST: 'SNP List',
32
32
  SNP_LOCUS: 'SNP Locus',
33
- SSGSEA: 'Geneset Expression'
33
+ SSGSEA: 'Geneset Expression',
34
+ TERM_COLLECTION: 'Term Collection'
34
35
  }
35
36
 
36
37
  export const defaultcolor = rgb('#8AB1D4').darker()
package/src/mds3tk.js CHANGED
@@ -1,4 +1,4 @@
1
- import { dtcnv } from './common.js'
1
+ import { dtcnv, dtsnvindel, dtsv, dtfusionrna } from './common.js'
2
2
 
3
3
  // this script should contain mds3 track-related stuff shared between client and backend
4
4
 
@@ -49,3 +49,50 @@ export function summarize_mclass(mlst) {
49
49
  }
50
50
  return [...m2c].sort((i, j) => j[1] - i[1])
51
51
  }
52
+
53
+ /*
54
+ ssmid is not specific for ssm, it covers all alterations
55
+ gdc ssm are identified by a specific uuid, thus the design
56
+ */
57
+ export function guessSsmid(ssmid) {
58
+ const l = ssmid.split(ssmIdFieldsSeparator)
59
+ if (l.length == 4) {
60
+ const [chr, tmp, ref, alt] = l
61
+ const pos = Number(tmp)
62
+ if (Number.isNaN(pos)) throw 'ssmid snvindel pos not integer'
63
+ return { dt: dtsnvindel, l: [chr, pos, ref, alt] }
64
+ }
65
+ if (l.length == 5) {
66
+ // cnv. if type=cat, _value is blank string
67
+ const [chr, _start, _stop, _class, _value] = l
68
+ const start = Number(_start),
69
+ stop = Number(_stop),
70
+ value = _value == '' ? null : Number(_value)
71
+ if (Number.isNaN(start) || Number.isNaN(stop)) throw 'ssmid cnv start/stop not integer'
72
+ return { dt: dtcnv, l: [chr, start, stop, _class, value] }
73
+ }
74
+ if (l.length == 6) {
75
+ if (l[3] == '+' || l[3] == '-') {
76
+ // sv/fusion
77
+ const [_dt, chr, _pos, strand, _pi, _mname] = l
78
+
79
+ // mname is encoded in case it contains comma (and is same as ssmIdFieldsSeparator)
80
+ const mname = decodeURIComponent(_mname)
81
+ const dt = Number(_dt)
82
+ if (dt != dtsv && dt != dtfusionrna) throw 'ssmid dt not sv/fusion'
83
+ const pos = Number(_pos)
84
+ if (Number.isNaN(pos)) throw 'ssmid svfusion position not integer'
85
+ const pairlstIdx = Number(_pi)
86
+ if (Number.isNaN(pairlstIdx)) throw 'ssmid pairlstIdx not integer'
87
+ return { dt, l: [dt, chr, pos, strand, pairlstIdx, mname] }
88
+ }
89
+ // cnv with sample
90
+ const [chr, _start, _stop, _class, _value, sample] = l
91
+ const start = Number(_start),
92
+ stop = Number(_stop),
93
+ value = _value == '' ? null : Number(_value) // if cnv not using value, must avoid `Number('')=0`
94
+ if (Number.isNaN(start) || Number.isNaN(stop)) throw 'ssmid cnv start/stop not integer'
95
+ return { dt: dtcnv, l: [chr, start, stop, _class, value, sample] }
96
+ }
97
+ throw 'unknown ssmid'
98
+ }
package/src/terms.js CHANGED
@@ -39,7 +39,8 @@ export const TermTypes = {
39
39
  SINGLECELL_GENE_EXPRESSION: 'singleCellGeneExpression',
40
40
  SINGLECELL_CELLTYPE: 'singleCellCellType',
41
41
  MULTIVALUE: 'multivalue',
42
- DATE: 'date'
42
+ DATE: 'date',
43
+ TERM_COLLECTION: 'termCollection'
43
44
  }
44
45
  export const dtTermTypes = new Set(dtTerms.map(t => t.type))
45
46
  for (const dtTermType of dtTermTypes) {
@@ -68,7 +69,8 @@ export const typeGroup = {
68
69
  [TermTypes.SNP_LOCUS]: TermTypeGroups.SNP_LOCUS,
69
70
  [TermTypes.GENE_EXPRESSION]: TermTypeGroups.GENE_EXPRESSION,
70
71
  [TermTypes.SSGSEA]: TermTypeGroups.SSGSEA,
71
- [TermTypes.METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY
72
+ [TermTypes.METABOLITE_INTENSITY]: TermTypeGroups.METABOLITE_INTENSITY,
73
+ [TermTypes.TERM_COLLECTION]: TermTypeGroups.TERM_COLLECTION
72
74
  }
73
75
 
74
76
  const nonDictTypes = new Set([
@@ -218,7 +220,8 @@ const typeMap = {
218
220
  snplocus: 'SNP Locus',
219
221
  snp: 'SNP',
220
222
  snplst: 'SNP List',
221
- numericDictTerm: 'Numeric Dictionary Term'
223
+ numericDictTerm: 'Numeric Dictionary Term',
224
+ termCollection: 'Term Collection'
222
225
  }
223
226
 
224
227
  export function termType2label(type) {