@sjcrh/proteinpaint-server 2.84.0 → 2.85.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 (48) hide show
  1. package/package.json +4 -5
  2. package/routes/_template_.js +14 -11
  3. package/routes/brainImaging.js +5 -14
  4. package/routes/brainImagingSamples.js +3 -3
  5. package/routes/burden.js +27 -59
  6. package/routes/dataset.js +9 -17
  7. package/routes/dsdata.js +11 -14
  8. package/routes/dzimages.js +11 -16
  9. package/routes/gdc.maf.js +8 -23
  10. package/routes/gdc.mafBuild.js +9 -9
  11. package/routes/gdc.topMutatedGenes.js +7 -7
  12. package/routes/genelookup.js +16 -34
  13. package/routes/genesetEnrichment.js +18 -14
  14. package/routes/genesetOverrepresentation.js +9 -14
  15. package/routes/healthcheck.js +26 -32
  16. package/routes/hicdata.js +7 -28
  17. package/routes/hicgenome.js +6 -27
  18. package/routes/hicstat.js +4 -22
  19. package/routes/isoformlst.js +8 -11
  20. package/routes/ntseq.js +8 -11
  21. package/routes/pdomain.js +8 -11
  22. package/routes/sampledzimages.js +12 -12
  23. package/routes/samplewsimages.js +6 -10
  24. package/routes/snp.js +8 -10
  25. package/routes/termdb.DE.js +8 -10
  26. package/routes/termdb.boxplot.js +8 -9
  27. package/routes/termdb.categories.js +4 -45
  28. package/routes/termdb.cluster.js +9 -9
  29. package/routes/termdb.cohort.summary.js +5 -8
  30. package/routes/termdb.cohorts.js +3 -7
  31. package/routes/{termdb.getdescrstats.js → termdb.descrstats.js} +8 -45
  32. package/routes/termdb.numericcategories.js +51 -0
  33. package/routes/{termdb.getpercentile.js → termdb.percentile.js} +4 -46
  34. package/routes/{termdb.getrootterm.js → termdb.rootterm.js} +4 -24
  35. package/routes/{termdb.getSampleImages.js → termdb.sampleImages.js} +9 -9
  36. package/routes/termdb.singleSampleMutation.js +3 -7
  37. package/routes/termdb.singlecellDEgenes.js +8 -8
  38. package/routes/termdb.singlecellData.js +4 -8
  39. package/routes/termdb.singlecellSamples.js +8 -8
  40. package/routes/{termdb.gettermchildren.js → termdb.termchildren.js} +8 -28
  41. package/routes/termdb.termsbyids.js +9 -16
  42. package/routes/{termdb.getTopTermsByType.js → termdb.topTermsByType.js} +9 -10
  43. package/routes/termdb.topVariablyExpressedGenes.js +8 -8
  44. package/routes/termdb.violin.js +8 -46
  45. package/routes/tileserver.js +5 -10
  46. package/routes/wsimages.js +10 -9
  47. package/src/app.js +1286 -2148
  48. package/routes/termdb.getnumericcategories.js +0 -91
@@ -1,16 +1,12 @@
1
+ import { termdbCohortSummaryPayload } from "#types";
1
2
  import { get_ds_tdb } from "#src/termdb.js";
2
3
  import { mayCopyFromCookie } from "#src/utils.js";
3
4
  const api = {
4
5
  endpoint: "termdb/cohort/summary",
5
6
  methods: {
6
7
  get: {
7
- init,
8
- request: {
9
- typeId: "any"
10
- },
11
- response: {
12
- typeId: "any"
13
- }
8
+ ...termdbCohortSummaryPayload,
9
+ init
14
10
  }
15
11
  }
16
12
  };
@@ -23,7 +19,8 @@ function init({ genomes }) {
23
19
  if (!genome)
24
20
  throw "invalid genome";
25
21
  const [ds] = get_ds_tdb(genome, q);
26
- res.send({ count: ds.cohort.termdb.q.getCohortSampleCount(q.cohort) });
22
+ const count = ds.cohort.termdb.q.getCohortSampleCount(q.cohort);
23
+ res.send({ count });
27
24
  } catch (e) {
28
25
  res.send({ error: e.message || e });
29
26
  if (e.stack)
@@ -1,16 +1,12 @@
1
+ import { termdbCohortsPayload } from "#types";
1
2
  import { get_ds_tdb } from "#src/termdb.js";
2
3
  import { mayCopyFromCookie } from "#src/utils.js";
3
4
  const api = {
4
5
  endpoint: "termdb/cohorts",
5
6
  methods: {
6
7
  get: {
7
- init,
8
- request: {
9
- typeId: "any"
10
- },
11
- response: {
12
- typeId: "any"
13
- }
8
+ ...termdbCohortsPayload,
9
+ init
14
10
  }
15
11
  }
16
12
  };
@@ -1,53 +1,16 @@
1
+ import { descrStatsPayload } from "#types";
1
2
  import Summarystats from "#shared/descriptive.stats.js";
2
3
  import { getData } from "#src/termdb.matrix.js";
3
4
  const api = {
4
5
  endpoint: "termdb/descrstats",
5
6
  methods: {
6
- all: {
7
- init,
8
- request: {
9
- typeId: "getdescrstatsRequest"
10
- },
11
- response: {
12
- typeId: "getdescrstatsResponse"
13
- },
14
- examples: [
15
- {
16
- request: {
17
- body: {
18
- genome: "hg38-test",
19
- dslabel: "TermdbTest",
20
- embedder: "localhost",
21
- tw: { term: { id: "hrtavg" }, q: { mode: "continuous" } },
22
- filter: {
23
- type: "tvslst",
24
- in: true,
25
- join: "",
26
- lst: [
27
- {
28
- tag: "cohortFilter",
29
- type: "tvs",
30
- tvs: {
31
- term: {
32
- name: "Cohort",
33
- type: "categorical",
34
- values: { ABC: { label: "ABC" }, XYZ: { label: "XYZ" } },
35
- id: "subcohort",
36
- isleaf: false,
37
- groupsetting: { disabled: true }
38
- },
39
- values: [{ key: "ABC", label: "ABC" }]
40
- }
41
- }
42
- ]
43
- }
44
- }
45
- },
46
- response: {
47
- header: { status: 200 }
48
- }
49
- }
50
- ]
7
+ get: {
8
+ ...descrStatsPayload,
9
+ init
10
+ },
11
+ post: {
12
+ ...descrStatsPayload,
13
+ init
51
14
  }
52
15
  }
53
16
  };
@@ -0,0 +1,51 @@
1
+ import { numericCategoriesPayload } from "#types";
2
+ import * as termdbsql from "#src/termdb.sql.js";
3
+ const api = {
4
+ endpoint: "termdb/numericcategories",
5
+ methods: {
6
+ get: {
7
+ ...numericCategoriesPayload,
8
+ init
9
+ },
10
+ post: {
11
+ ...numericCategoriesPayload,
12
+ init
13
+ }
14
+ }
15
+ };
16
+ function init({ genomes }) {
17
+ return async (req, res) => {
18
+ const q = req.query;
19
+ try {
20
+ const g = genomes[req.query.genome];
21
+ if (!g)
22
+ throw "invalid genome name";
23
+ const ds = g.datasets[req.query.dslabel];
24
+ if (!ds)
25
+ throw "invalid dataset name";
26
+ const tdb = ds.cohort.termdb;
27
+ if (!tdb)
28
+ throw "invalid termdb object";
29
+ const result = await trigger_getnumericcategories(q, tdb, ds);
30
+ res.send(result);
31
+ } catch (e) {
32
+ res.send({ error: e instanceof Error ? e.message : e });
33
+ if (e instanceof Error && e.stack)
34
+ console.log(e);
35
+ }
36
+ };
37
+ }
38
+ async function trigger_getnumericcategories(q, tdb, ds) {
39
+ if (!q.tid)
40
+ throw ".tid missing";
41
+ const arg = {
42
+ ds,
43
+ term_id: q.tid,
44
+ filter: q.filter
45
+ };
46
+ const lst = await termdbsql.get_summary_numericcategories(arg);
47
+ return { lst };
48
+ }
49
+ export {
50
+ api
51
+ };
@@ -1,57 +1,15 @@
1
+ import { percentilePayload } from "#types";
1
2
  import * as termdbsql from "#src/termdb.sql.js";
2
3
  import computePercentile from "#shared/compute.percentile.js";
3
4
  const api = {
4
5
  endpoint: "termdb/getpercentile",
5
6
  methods: {
6
7
  get: {
7
- init,
8
- request: {
9
- typeId: "getpercentileRequest"
10
- },
11
- response: {
12
- typeId: "getpercentileResponse"
13
- },
14
- examples: [
15
- {
16
- request: {
17
- body: {
18
- genome: "hg38-test",
19
- dslabel: "TermdbTest",
20
- embedder: "localhost",
21
- getpercentile: [50],
22
- tid: "agedx",
23
- filter: {
24
- type: "tvslst",
25
- in: true,
26
- join: "",
27
- lst: [
28
- {
29
- tag: "cohortFilter",
30
- type: "tvs",
31
- tvs: {
32
- term: {
33
- name: "Cohort",
34
- type: "categorical",
35
- values: { ABC: { label: "ABC" }, XYZ: { label: "XYZ" } },
36
- id: "subcohort",
37
- isleaf: false,
38
- groupsetting: { disabled: true }
39
- },
40
- values: [{ key: "ABC", label: "ABC" }]
41
- }
42
- }
43
- ]
44
- }
45
- }
46
- },
47
- response: {
48
- header: { status: 200 }
49
- }
50
- }
51
- ]
8
+ ...percentilePayload,
9
+ init
52
10
  },
53
11
  post: {
54
- alternativeFor: "get",
12
+ ...percentilePayload,
55
13
  init
56
14
  }
57
15
  }
@@ -1,34 +1,14 @@
1
+ import { rootTermPayload } from "#types";
1
2
  import { get_ds_tdb } from "#src/termdb.js";
2
3
  const api = {
3
4
  endpoint: "termdb/rootterm",
4
5
  methods: {
5
6
  get: {
6
- init,
7
- request: {
8
- typeId: "getroottermRequest"
9
- },
10
- response: {
11
- typeId: "getroottermResponse"
12
- },
13
- examples: [
14
- {
15
- request: {
16
- body: {
17
- genome: "hg38-test",
18
- dslabel: "TermdbTest",
19
- embedder: "localhost",
20
- default_rootterm: 1,
21
- cohortValues: "ABC"
22
- }
23
- },
24
- response: {
25
- header: { status: 200 }
26
- }
27
- }
28
- ]
7
+ ...rootTermPayload,
8
+ init
29
9
  },
30
10
  post: {
31
- alternativeFor: "get",
11
+ ...rootTermPayload,
32
12
  init
33
13
  }
34
14
  }
@@ -1,17 +1,17 @@
1
+ import { termdbSampleImagesPayload } from "#types";
1
2
  import path from "path";
2
3
  import fs from "fs";
3
4
  import serverconfig from "#src/serverconfig.js";
4
5
  const api = {
5
6
  endpoint: "termdb/getSampleImages",
6
7
  methods: {
7
- all: {
8
- init,
9
- request: {
10
- typeId: "TermdbGetSampleImagesRequest"
11
- },
12
- response: {
13
- typeId: "TermdbGetSampleImagesResponse"
14
- }
8
+ get: {
9
+ ...termdbSampleImagesPayload,
10
+ init
11
+ },
12
+ post: {
13
+ ...termdbSampleImagesPayload,
14
+ init
15
15
  }
16
16
  }
17
17
  };
@@ -33,7 +33,7 @@ function init({ genomes }) {
33
33
  }
34
34
  };
35
35
  }
36
- function validate_query_getSampleImages(ds, genome) {
36
+ function validate_query_getSampleImages(ds) {
37
37
  const q = ds.queries.images;
38
38
  if (!q)
39
39
  return;
@@ -2,18 +2,14 @@ import fs from "fs";
2
2
  import path from "path";
3
3
  import { read_file } from "#src/utils.js";
4
4
  import serverconfig from "#src/serverconfig.js";
5
+ import { termdbSingleSampleMutationPayload } from "#types";
5
6
  import { gdcValidate_query_singleSampleMutation } from "#src/mds3.gdc.js";
6
7
  const api = {
7
8
  endpoint: "termdb/singleSampleMutation",
8
9
  methods: {
9
10
  get: {
10
- init,
11
- request: {
12
- typeId: "TermdbSingleSampleMutationRequest"
13
- },
14
- response: {
15
- typeId: "TermdbSingleSampleMutationResponse"
16
- }
11
+ ...termdbSingleSampleMutationPayload,
12
+ init
17
13
  }
18
14
  }
19
15
  };
@@ -1,15 +1,15 @@
1
+ import { termdbSingleCellDEgenesPayload } from "#types";
1
2
  import { gdc_validate_query_singleCell_DEgenes } from "#src/mds3.gdc.js";
2
3
  const api = {
3
4
  endpoint: "termdb/singlecellDEgenes",
4
5
  methods: {
5
- all: {
6
- init,
7
- request: {
8
- typeId: "TermdbSinglecellDEgenesRequest"
9
- },
10
- response: {
11
- typeId: "TermdbSinglecellDEgenesResponse"
12
- }
6
+ get: {
7
+ ...termdbSingleCellDEgenesPayload,
8
+ init
9
+ },
10
+ post: {
11
+ ...termdbSingleCellDEgenesPayload,
12
+ init
13
13
  }
14
14
  }
15
15
  };
@@ -1,17 +1,13 @@
1
+ import { termdbSingleCellDataPayload } from "#types";
1
2
  const api = {
2
3
  endpoint: "termdb/singlecellData",
3
4
  methods: {
4
5
  get: {
5
- init,
6
- request: {
7
- typeId: "TermdbSinglecellDataRequest"
8
- },
9
- response: {
10
- typeId: "TermdbSinglecellDataResponse"
11
- }
6
+ ...termdbSingleCellDataPayload,
7
+ init
12
8
  },
13
9
  post: {
14
- alternativeFor: "get",
10
+ ...termdbSingleCellDataPayload,
15
11
  init
16
12
  }
17
13
  }
@@ -4,20 +4,20 @@ import { read_file } from "#src/utils.js";
4
4
  import run_R from "#src/run_R.js";
5
5
  import { run_rust } from "@sjcrh/proteinpaint-rust";
6
6
  import serverconfig from "#src/serverconfig.js";
7
+ import { termdbSingleCellSamplesPayload } from "#types";
7
8
  import { validate_query_singleCell_DEgenes } from "./termdb.singlecellDEgenes.ts";
8
9
  import { gdc_validate_query_singleCell_samples, gdc_validate_query_singleCell_data } from "#src/mds3.gdc.js";
9
10
  import ky from "ky";
10
11
  const api = {
11
12
  endpoint: "termdb/singlecellSamples",
12
13
  methods: {
13
- all: {
14
- init,
15
- request: {
16
- typeId: "TermdbSinglecellsamplesRequest"
17
- },
18
- response: {
19
- typeId: "TermdbSinglecellsamplesResponse"
20
- }
14
+ get: {
15
+ ...termdbSingleCellSamplesPayload,
16
+ init
17
+ },
18
+ post: {
19
+ ...termdbSingleCellSamplesPayload,
20
+ init
21
21
  }
22
22
  }
23
23
  };
@@ -1,35 +1,14 @@
1
+ import { termChildrenPayload } from "#types";
1
2
  import { copy_term, get_ds_tdb } from "#src/termdb.js";
2
3
  const api = {
3
4
  endpoint: "termdb/termchildren",
4
5
  methods: {
5
6
  get: {
6
- init,
7
- request: {
8
- typeId: "gettermchildrenRequest"
9
- },
10
- response: {
11
- typeId: "gettermchildrenResponse"
12
- },
13
- examples: [
14
- {
15
- request: {
16
- body: {
17
- genome: "hg38-test",
18
- dslabel: "TermdbTest",
19
- embedder: "localhost",
20
- get_children: 1,
21
- cohortValues: "ABC",
22
- tid: "GO:0000001"
23
- }
24
- },
25
- response: {
26
- header: { status: 200 }
27
- }
28
- }
29
- ]
7
+ ...termChildrenPayload,
8
+ init
30
9
  },
31
10
  post: {
32
- alternativeFor: "get",
11
+ ...termChildrenPayload,
33
12
  init
34
13
  }
35
14
  }
@@ -46,7 +25,8 @@ function init({ genomes }) {
46
25
  throw "invalid dataset name";
47
26
  if (!tdb)
48
27
  throw "invalid termdb object";
49
- await trigger_children(q, res, tdb);
28
+ const result = await trigger_children(q, tdb);
29
+ res.send(result);
50
30
  } catch (e) {
51
31
  res.send({ error: e instanceof Error ? e.message : e });
52
32
  if (e instanceof Error && e.stack)
@@ -54,13 +34,13 @@ function init({ genomes }) {
54
34
  }
55
35
  };
56
36
  }
57
- async function trigger_children(q, res, tdb) {
37
+ async function trigger_children(q, tdb) {
58
38
  if (!q.tid)
59
39
  throw "no parent term id";
60
40
  const cohortValues = q.cohortValues ? q.cohortValues : "";
61
41
  const treeFilter = q.treeFilter ? q.treeFilter : "";
62
42
  const terms = await tdb.q.getTermChildren(q.tid, cohortValues, treeFilter);
63
- res.send({ lst: terms.map(copy_term) });
43
+ return { lst: terms.map(copy_term) };
64
44
  }
65
45
  export {
66
46
  api
@@ -1,18 +1,14 @@
1
+ import { termsByIdsPayload } from "#types";
1
2
  import { copy_term } from "#src/termdb.js";
2
3
  const api = {
3
4
  endpoint: "termdb/termsbyids",
4
5
  methods: {
5
6
  get: {
6
- init,
7
- request: {
8
- typeId: "gettermsbyidsRequest"
9
- },
10
- response: {
11
- typeId: "gettermsbyidsResponse"
12
- }
7
+ ...termsByIdsPayload,
8
+ init
13
9
  },
14
10
  post: {
15
- alternativeFor: "get",
11
+ ...termsByIdsPayload,
16
12
  init
17
13
  }
18
14
  }
@@ -30,7 +26,8 @@ function init({ genomes }) {
30
26
  const tdb = ds.cohort.termdb;
31
27
  if (!tdb)
32
28
  throw "invalid termdb object";
33
- await trigger_gettermsbyid(q, res, tdb);
29
+ const results = await trigger_gettermsbyid(q, tdb);
30
+ res.send(results);
34
31
  } catch (e) {
35
32
  res.send({ error: e instanceof Error ? e.message : e });
36
33
  if (e instanceof Error && e.stack)
@@ -38,10 +35,8 @@ function init({ genomes }) {
38
35
  }
39
36
  };
40
37
  }
41
- async function trigger_gettermsbyid(q, res, tdb) {
42
- const terms = {
43
- terms: {}
44
- };
38
+ async function trigger_gettermsbyid(q, tdb) {
39
+ const terms = {};
45
40
  for (const id of q.ids) {
46
41
  const term = tdb.q.termjsonByOneid(id);
47
42
  if (term) {
@@ -52,9 +47,7 @@ async function trigger_gettermsbyid(q, res, tdb) {
52
47
  }
53
48
  terms[id] = term ? copy_term(term) : void 0;
54
49
  }
55
- res.send({
56
- terms
57
- });
50
+ return { terms };
58
51
  }
59
52
  export {
60
53
  api
@@ -1,17 +1,17 @@
1
+ import { termdbTopTermsByTypePayload } from "#types";
1
2
  import { run_rust } from "@sjcrh/proteinpaint-rust";
2
3
  import { get_samples } from "#src/termdb.sql.js";
3
4
  import { TermTypes } from "#shared/terms.js";
4
5
  const api = {
5
6
  endpoint: "termdb/getTopTermsByType",
6
7
  methods: {
7
- all: {
8
- init,
9
- request: {
10
- typeId: "TermdbTopTermsByTypeRequest"
11
- },
12
- response: {
13
- typeId: "TermdbTopTermsByTypeResponse"
14
- }
8
+ get: {
9
+ ...termdbTopTermsByTypePayload,
10
+ init
11
+ },
12
+ post: {
13
+ ...termdbTopTermsByTypePayload,
14
+ init
15
15
  }
16
16
  }
17
17
  };
@@ -28,7 +28,6 @@ function init({ genomes }) {
28
28
  throw "invalid dslabel";
29
29
  if (!ds.queries[type])
30
30
  throw "not supported on dataset";
31
- const t = Date.now();
32
31
  const terms = await ds.queries[type].getTopTerms(q);
33
32
  res.send({ terms });
34
33
  } catch (e) {
@@ -96,7 +95,7 @@ async function computeTopTerms(file, samples, type) {
96
95
  return varMetabolite;
97
96
  }
98
97
  function gdcValidateQuery(ds, genome, type) {
99
- ds.queries[type].getTopTerms = async (q) => {
98
+ ds.queries[type].getTopTerms = async () => {
100
99
  return [];
101
100
  };
102
101
  }
@@ -1,3 +1,4 @@
1
+ import { termdbTopVariablyExpressedGenesPayload } from "#types";
1
2
  import { run_rust } from "@sjcrh/proteinpaint-rust";
2
3
  import serverconfig from "#src/serverconfig.js";
3
4
  import { get_samples } from "#src/termdb.sql.js";
@@ -7,14 +8,13 @@ import { joinUrl } from "#src/helpers.ts";
7
8
  const api = {
8
9
  endpoint: "termdb/topVariablyExpressedGenes",
9
10
  methods: {
10
- all: {
11
- init,
12
- request: {
13
- typeId: "TermdbTopVariablyExpressedGenesRequest"
14
- },
15
- response: {
16
- typeId: "TermdbTopVariablyExpressedGenesResponse"
17
- }
11
+ get: {
12
+ ...termdbTopVariablyExpressedGenesPayload,
13
+ init
14
+ },
15
+ post: {
16
+ ...termdbTopVariablyExpressedGenesPayload,
17
+ init
18
18
  }
19
19
  }
20
20
  };
@@ -1,53 +1,15 @@
1
+ import { violinPayload } from "#types";
1
2
  import { trigger_getViolinPlotData } from "#src/termdb.violin.js";
2
3
  const api = {
3
4
  endpoint: "termdb/violin",
4
5
  methods: {
5
- all: {
6
- init,
7
- request: {
8
- typeId: "getViolinRequest"
9
- },
10
- response: {
11
- typeId: "getViolinResponse"
12
- },
13
- examples: [
14
- {
15
- request: {
16
- body: {
17
- genome: "hg38-test",
18
- dslabel: "TermdbTest",
19
- embedder: "localhost",
20
- devicePixelRatio: 2.200000047683716,
21
- maxThickness: 150,
22
- screenThickness: 1218,
23
- filter: {
24
- type: "tvslst",
25
- in: true,
26
- join: "",
27
- lst: [
28
- {
29
- tag: "cohortFilter",
30
- type: "tvs",
31
- tvs: { term: { id: "subcohort", type: "categorical" }, values: [{ key: "ABC", label: "ABC" }] }
32
- }
33
- ]
34
- },
35
- svgw: 227.27272234672367,
36
- orientation: "horizontal",
37
- datasymbol: "bean",
38
- radius: 5,
39
- strokeWidth: 0.2,
40
- axisHeight: 60,
41
- rightMargin: 50,
42
- unit: "abs",
43
- termid: "agedx"
44
- }
45
- },
46
- response: {
47
- header: { status: 200 }
48
- }
49
- }
50
- ]
6
+ get: {
7
+ ...violinPayload,
8
+ init
9
+ },
10
+ post: {
11
+ ...violinPayload,
12
+ init
51
13
  }
52
14
  }
53
15
  };
@@ -1,20 +1,15 @@
1
+ import { tilePayload } from "#types";
1
2
  import ky from "ky";
2
3
  import serverconfig from "#src/serverconfig.js";
3
- const routePath = "tileserver";
4
4
  const api = {
5
- endpoint: `${routePath}/layer/slide/:sampleId/zoomify/:TileGroup/:z-:x-:y@1x.jpg`,
5
+ endpoint: `tileserver/layer/slide/:sampleId/zoomify/:TileGroup/:z-:x-:y@1x.jpg`,
6
6
  methods: {
7
7
  get: {
8
- init,
9
- request: {
10
- typeId: "any"
11
- },
12
- response: {
13
- typeId: "any"
14
- }
8
+ ...tilePayload,
9
+ init
15
10
  },
16
11
  post: {
17
- alternativeFor: "get",
12
+ ...tilePayload,
18
13
  init
19
14
  }
20
15
  }