@sjcrh/proteinpaint-server 2.30.4 → 2.31.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 (54) hide show
  1. package/genome/hg19.js +3 -3
  2. package/genome/hg38.js +3 -3
  3. package/genome/hg38.test.js +3 -3
  4. package/package.json +2 -2
  5. package/routes/burden.ts +5 -2
  6. package/routes/gdc.maf.ts +39 -26
  7. package/routes/gdc.mafBuild.ts +24 -30
  8. package/routes/gdc.topVariablyExpressedGenes.ts +39 -23
  9. package/routes/hicdata.ts +113 -0
  10. package/routes/hicstat.ts +55 -0
  11. package/routes/termdb.categories.ts +30 -6
  12. package/routes/termdb.getpercentile.ts +117 -0
  13. package/routes/termdb.singlecellSamples.ts +45 -0
  14. package/routes/termdb.termbyid.ts +5 -1
  15. package/server.js +1 -1
  16. package/shared/common.js +10 -12
  17. package/src/serverconfig.js +0 -19
  18. package/cards/2dmaf.json +0 -37
  19. package/cards/README.md +0 -15
  20. package/cards/ai.json +0 -37
  21. package/cards/arc.json +0 -34
  22. package/cards/ase.json +0 -99
  23. package/cards/bam.json +0 -264
  24. package/cards/bampile.json +0 -22
  25. package/cards/bedj.json +0 -304
  26. package/cards/bigwig.json +0 -70
  27. package/cards/citations.json +0 -39
  28. package/cards/civicBtn.json +0 -15
  29. package/cards/databrowser.json +0 -276
  30. package/cards/disco.json +0 -69
  31. package/cards/dnanexusTips.txt +0 -221
  32. package/cards/exprank.json +0 -64
  33. package/cards/featuredDatasets.json +0 -84
  34. package/cards/fusioneditor.json +0 -34
  35. package/cards/gdcbam.json +0 -23
  36. package/cards/genefusion.json +0 -57
  37. package/cards/genomepaint.json +0 -122
  38. package/cards/hic.json +0 -79
  39. package/cards/index.json +0 -327
  40. package/cards/junction.json +0 -98
  41. package/cards/lollipop.json +0 -327
  42. package/cards/maf.timeline.json +0 -19
  43. package/cards/mavb.json +0 -47
  44. package/cards/nciGdcBtn.json +0 -21
  45. package/cards/pcmBtn.json +0 -16
  46. package/cards/ped2Btn.json +0 -16
  47. package/cards/pgv.json +0 -59
  48. package/cards/scatterplot.json +0 -31
  49. package/cards/singlecell.json +0 -25
  50. package/cards/study.json +0 -34
  51. package/cards/survivorBtn.json +0 -18
  52. package/cards/svview.txt +0 -101
  53. package/cards/tkFeatures.json +0 -92
  54. package/cards/tklist.json +0 -27
@@ -0,0 +1,117 @@
1
+ // import { getpercentileRequest, getpercentileResponse } from '#shared/types/routes/termdb.getpercentile'
2
+ import * as termdbsql from '#src/termdb.sql.js'
3
+ import computePercentile from '#shared/compute.percentile.js'
4
+
5
+ export const api: any = {
6
+ endpoint: 'termdb/getpercentile',
7
+ methods: {
8
+ get: {
9
+ init,
10
+ request: {
11
+ typeId: 'getpercentileRequest'
12
+ },
13
+ response: {
14
+ typeId: 'getpercentileResponse'
15
+ },
16
+ examples: [
17
+ {
18
+ request: {
19
+ body: {
20
+ genome: 'hg38-test',
21
+ dslabel: 'TermdbTest',
22
+ embedder: 'localhost',
23
+ getpercentile: [50],
24
+ tid: 'agedx',
25
+ filter: {
26
+ type: 'tvslst',
27
+ in: true,
28
+ join: '',
29
+ lst: [
30
+ {
31
+ tag: 'cohortFilter',
32
+ type: 'tvs',
33
+ tvs: {
34
+ term: {
35
+ name: 'Cohort',
36
+ type: 'categorical',
37
+ values: { ABC: { label: 'ABC' }, XYZ: { label: 'XYZ' } },
38
+ id: 'subcohort',
39
+ isleaf: false,
40
+ groupsetting: { disabled: true }
41
+ },
42
+ values: [{ key: 'ABC', label: 'ABC' }]
43
+ }
44
+ }
45
+ ]
46
+ }
47
+ }
48
+ },
49
+ response: {
50
+ header: { status: 200 }
51
+ }
52
+ }
53
+ ]
54
+ },
55
+ post: {
56
+ alternativeFor: 'get',
57
+ init
58
+ }
59
+ }
60
+ }
61
+
62
+ function init({ genomes }) {
63
+ return async (req: any, res: any): Promise<void> => {
64
+ const q = req.query // as getpercentileRequest
65
+ try {
66
+ const g = genomes[req.query.genome]
67
+ if (!g) throw 'invalid genome name'
68
+ const ds = g.datasets[req.query.dslabel]
69
+ if (!ds) throw 'invalid dataset name'
70
+ await trigger_getpercentile(q, res, ds) // as getpercentileResponse
71
+ } catch (e) {
72
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
73
+ // @ts-ignore
74
+ res.send({ error: e?.message || e })
75
+ if (e instanceof Error && e.stack) console.log(e)
76
+ }
77
+ }
78
+ }
79
+
80
+ async function trigger_getpercentile(
81
+ q: { tid: string; getpercentile: number[]; filter: string },
82
+ res: { send: (arg0: { values: number[] }) => void },
83
+ ds: { cohort: { termdb: { q: { termjsonByOneid: (arg0: any) => any } } } }
84
+ ) {
85
+ const term = ds.cohort.termdb.q.termjsonByOneid(q.tid)
86
+ if (!term) throw 'invalid termid'
87
+ if (term.type != 'float' && term.type != 'integer') throw 'not numerical term'
88
+ const percentile_lst = q.getpercentile
89
+ const perc_values = [] as number[]
90
+ const values = [] as number[]
91
+ const rows = await termdbsql.get_rows_by_one_key({
92
+ ds,
93
+ key: q.tid,
94
+ filter: q.filter ? (typeof q.filter == 'string' ? JSON.parse(q.filter) : q.filter) : null
95
+ })
96
+ for (const { value } of rows) {
97
+ if (term.values && term.values[value] && term.values[value].uncomputable) {
98
+ // skip uncomputable values
99
+ continue
100
+ }
101
+
102
+ if (term.skip0forPercentile && value == 0) {
103
+ // quick fix: when the flag is true, will exclude 0 values from percentile computing
104
+ // to address an issue with computing knots
105
+ continue
106
+ }
107
+
108
+ values.push(Number(value))
109
+ }
110
+
111
+ // compute percentiles
112
+ for (const percentile of percentile_lst) {
113
+ const perc_value = computePercentile(values, percentile)
114
+ perc_values.push(perc_value)
115
+ }
116
+ res.send({ values: perc_values })
117
+ }
@@ -0,0 +1,45 @@
1
+ import {
2
+ TermdbSinglecellsamplesRequest,
3
+ TermdbSinglecellsamplesResponse
4
+ } from '#shared/types/routes/termdb.singlecellSamples.ts'
5
+
6
+ /* route returns list of samples with sc data
7
+ this is due to the fact that sometimes not all samples in a dataset has sc data
8
+ */
9
+
10
+ export const api: any = {
11
+ endpoint: 'termdb/singlecellSamples',
12
+ methods: {
13
+ get: {
14
+ init,
15
+ request: {
16
+ typeId: 'TermdbSinglecellsamplesRequest'
17
+ },
18
+ response: {
19
+ typeId: 'TermdbSinglecellsamplesResponse'
20
+ }
21
+ },
22
+ post: {
23
+ alternativeFor: 'get',
24
+ init
25
+ }
26
+ }
27
+ }
28
+
29
+ function init({ genomes }) {
30
+ return async (req: any, res: any): Promise<void> => {
31
+ const q = req.query as TermdbSinglecellsamplesRequest
32
+ try {
33
+ const g = genomes[q.genome]
34
+ if (!g) throw 'invalid genome name'
35
+ const ds = g.datasets[q.dslabel]
36
+ if (!ds) throw 'invalid dataset name'
37
+ if (!ds.queries?.singleCell) throw 'no singlecell data on this dataset'
38
+ const result = (await ds.queries.singleCell.samples.get(q)) as TermdbSinglecellsamplesResponse
39
+ res.send(result)
40
+ } catch (e: any) {
41
+ if (e instanceof Error && e.stack) console.log(e)
42
+ res.send({ error: e.message || e })
43
+ }
44
+ }
45
+ }
@@ -56,7 +56,11 @@ function init({ genomes }) {
56
56
  }
57
57
  }
58
58
 
59
- async function trigger_gettermbyid(q, res, tdb) {
59
+ async function trigger_gettermbyid(
60
+ q: { gettermbyid: any },
61
+ res: { send: (arg0: { term: any }) => void },
62
+ tdb: { q: { termjsonByOneid: (arg0: any) => any } }
63
+ ) {
60
64
  const t = tdb.q.termjsonByOneid(q.gettermbyid)
61
65
  res.send({
62
66
  term: t ? copy_term(t) : undefined