@sjcrh/proteinpaint-server 2.44.0 → 2.46.1
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/dataset/clinvar.hg19.js +53 -52
- package/dataset/clinvar.hg38.js +74 -73
- package/dataset/clinvar.js +164 -47
- package/dataset/termdb.test.js +257 -0
- package/genome/CriGri.js +1859 -27
- package/genome/cgc.js +743 -7
- package/genome/danRer10.js +1108 -46
- package/genome/dm3.js +71 -44
- package/genome/dm6.js +1926 -45
- package/genome/galGal5.js +23522 -46
- package/genome/galGal6.js +512 -46
- package/genome/hg19.js +293 -198
- package/genome/hg38.js +472 -105
- package/genome/hg38.test.js +406 -40
- package/genome/hgvirus.js +45 -20
- package/genome/mm10.js +135 -67
- package/genome/mm9.js +116 -79
- package/genome/rn6.js +1002 -47
- package/package.json +31 -35
- package/routes/_template_.js +30 -0
- package/routes/burden.js +149 -0
- package/routes/dataset.js +266 -0
- package/routes/dsdata.js +127 -0
- package/routes/gdc.maf.js +120 -0
- package/routes/gdc.mafBuild.js +106 -0
- package/routes/gdc.topMutatedGenes.js +465 -0
- package/routes/gene2canonicalisoform.js +41 -0
- package/routes/genelookup.js +52 -0
- package/routes/genomes.js +144 -0
- package/routes/healthcheck.js +30 -0
- package/routes/hicdata.js +98 -0
- package/routes/hicstat.js +55 -0
- package/routes/isoformlst.js +57 -0
- package/routes/ntseq.js +43 -0
- package/routes/pdomain.js +61 -0
- package/routes/snp.js +107 -0
- package/routes/termdb.categories.js +209 -0
- package/routes/termdb.cluster.js +228 -0
- package/routes/termdb.cohort.summary.js +38 -0
- package/routes/termdb.cohorts.js +49 -0
- package/routes/termdb.config.js +202 -0
- package/routes/termdb.getdescrstats.js +102 -0
- package/routes/termdb.getnumericcategories.js +92 -0
- package/routes/termdb.getpercentile.js +108 -0
- package/routes/termdb.getrootterm.js +65 -0
- package/routes/termdb.gettermchildren.js +67 -0
- package/routes/termdb.singleSampleMutation.js +80 -0
- package/routes/termdb.singlecellData.js +46 -0
- package/routes/termdb.singlecellSamples.js +160 -0
- package/routes/termdb.termsbyids.js +59 -0
- package/routes/termdb.topVariablyExpressedGenes.js +171 -0
- package/routes/termdb.violin.js +77 -0
- package/src/app.js +41500 -0
- package/src/serverconfig.js +14 -8
- package/start.js +3 -3
- package/routes/README.md +0 -84
- package/routes/burden.ts +0 -143
- package/routes/gdc.maf.ts +0 -195
- package/routes/gdc.mafBuild.ts +0 -114
- package/routes/gdc.topMutatedGenes.ts +0 -586
- package/routes/genelookup.ts +0 -50
- package/routes/healthcheck.ts +0 -29
- package/routes/hicdata.ts +0 -111
- package/routes/hicstat.ts +0 -55
- package/routes/termdb.categories.ts +0 -245
- package/routes/termdb.cluster.ts +0 -248
- package/routes/termdb.getdescrstats.ts +0 -102
- package/routes/termdb.getnumericcategories.ts +0 -99
- package/routes/termdb.getpercentile.ts +0 -118
- package/routes/termdb.getrootterm.ts +0 -73
- package/routes/termdb.gettermchildren.ts +0 -82
- package/routes/termdb.singleSampleMutation.ts +0 -87
- package/routes/termdb.singlecellData.ts +0 -49
- package/routes/termdb.singlecellSamples.ts +0 -175
- package/routes/termdb.termsbyids.ts +0 -63
- package/routes/termdb.topVariablyExpressedGenes.ts +0 -214
- package/routes/termdb.violin.ts +0 -77
- package/server.js +0 -2
- package/server.js.map +0 -1
- package/shared/common.js +0 -1080
- package/shared/termdb.initbinconfig.js +0 -96
- package/shared/vcf.js +0 -629
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import serverconfig from "#src/serverconfig.js";
|
|
2
|
+
import { authApi } from "#src/auth.js";
|
|
3
|
+
import { get_ds_tdb } from "#src/termdb.js";
|
|
4
|
+
import { mayCopyFromCookie } from "#src/utils.js";
|
|
5
|
+
import { mayComputeTermtypeByCohort } from "#src/termdb.server.init.js";
|
|
6
|
+
const api = {
|
|
7
|
+
endpoint: "termdb/config",
|
|
8
|
+
methods: {
|
|
9
|
+
get: {
|
|
10
|
+
init,
|
|
11
|
+
request: {
|
|
12
|
+
typeId: "any"
|
|
13
|
+
},
|
|
14
|
+
response: {
|
|
15
|
+
typeId: "any"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
function init({ genomes }) {
|
|
21
|
+
return async (req, res) => {
|
|
22
|
+
const q = req.query;
|
|
23
|
+
mayCopyFromCookie(q, req.cookies);
|
|
24
|
+
try {
|
|
25
|
+
const genome = genomes[q.genome];
|
|
26
|
+
if (!genome)
|
|
27
|
+
throw "invalid genome";
|
|
28
|
+
const [ds, tdb] = get_ds_tdb(genome, q);
|
|
29
|
+
return make(q, res, ds, genome);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
res.send({ error: e.message || e });
|
|
32
|
+
if (e.stack)
|
|
33
|
+
console.log(e.stack);
|
|
34
|
+
else
|
|
35
|
+
console.log(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function make(q, res, ds, genome) {
|
|
40
|
+
const tdb = ds.cohort.termdb;
|
|
41
|
+
const c = {
|
|
42
|
+
selectCohort: tdb.selectCohort,
|
|
43
|
+
// optional
|
|
44
|
+
supportedChartTypes: tdb.q.getSupportedChartTypes(q.embedder),
|
|
45
|
+
hiddenChartTypes: ds.cohort.hiddenChartTypes,
|
|
46
|
+
renamedChartTypes: ds.cohort.renamedChartTypes,
|
|
47
|
+
allowedTermTypes: getAllowedTermTypes(ds),
|
|
48
|
+
termMatch2geneSet: tdb.termMatch2geneSet,
|
|
49
|
+
massSessionDuration: serverconfig.features.massSessionDuration || 30,
|
|
50
|
+
dataDownloadCatch: tdb.dataDownloadCatch,
|
|
51
|
+
matrix: tdb.matrix,
|
|
52
|
+
hierCluster: tdb.hierCluster,
|
|
53
|
+
mclass: tdb.mclass,
|
|
54
|
+
alwaysRefillCategoricalTermValues: tdb.alwaysRefillCategoricalTermValues,
|
|
55
|
+
isGeneSetTermdb: tdb.isGeneSetTermdb,
|
|
56
|
+
lollipop: tdb.lollipop,
|
|
57
|
+
urlTemplates: tdb.urlTemplates
|
|
58
|
+
};
|
|
59
|
+
if (tdb.chartConfigByType)
|
|
60
|
+
c.chartConfigByType = tdb.chartConfigByType;
|
|
61
|
+
if (tdb.multipleTestingCorrection)
|
|
62
|
+
c.multipleTestingCorrection = tdb.multipleTestingCorrection;
|
|
63
|
+
if (tdb.helpPages)
|
|
64
|
+
c.helpPages = tdb.helpPages;
|
|
65
|
+
if (tdb.minTimeSinceDx)
|
|
66
|
+
c.minTimeSinceDx = tdb.minTimeSinceDx;
|
|
67
|
+
if (tdb.timeUnit)
|
|
68
|
+
c.timeUnit = tdb.timeUnit;
|
|
69
|
+
if (tdb.cohortStartTimeMsg)
|
|
70
|
+
c.cohortStartTimeMsg = tdb.cohortStartTimeMsg;
|
|
71
|
+
if (tdb.displaySampleIds)
|
|
72
|
+
c.displaySampleIds = tdb.displaySampleIds;
|
|
73
|
+
if (tdb.logscaleBase2)
|
|
74
|
+
c.logscaleBase2 = tdb.logscaleBase2;
|
|
75
|
+
if (ds.assayAvailability)
|
|
76
|
+
c.assayAvailability = ds.assayAvailability;
|
|
77
|
+
if (ds.customTwQByType)
|
|
78
|
+
c.customTwQByType = ds.customTwQByType;
|
|
79
|
+
c.requiredAuth = authApi.getRequiredCredForDsEmbedder(q.dslabel, q.embedder);
|
|
80
|
+
addRestrictAncestries(c, tdb);
|
|
81
|
+
addScatterplots(c, ds);
|
|
82
|
+
addMatrixplots(c, ds);
|
|
83
|
+
addGenomicQueries(c, ds, genome);
|
|
84
|
+
res.send({ termdbConfig: c });
|
|
85
|
+
}
|
|
86
|
+
function addRestrictAncestries(c, tdb) {
|
|
87
|
+
if (!tdb.restrictAncestries)
|
|
88
|
+
return;
|
|
89
|
+
c.restrictAncestries = tdb.restrictAncestries.map((i) => {
|
|
90
|
+
return { name: i.name, tvs: i.tvs, PCcount: i.PCcount };
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function addScatterplots(c, ds) {
|
|
94
|
+
if (!ds.cohort.scatterplots)
|
|
95
|
+
return;
|
|
96
|
+
c.scatterplots = ds.cohort.scatterplots.plots.map((p) => {
|
|
97
|
+
return {
|
|
98
|
+
name: p.name,
|
|
99
|
+
dimensions: p.dimensions,
|
|
100
|
+
colorTW: p.colorTW,
|
|
101
|
+
shapeTW: p.shapeTW,
|
|
102
|
+
colorColumn: p.colorColumn,
|
|
103
|
+
settings: p.settings
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function addMatrixplots(c, ds) {
|
|
108
|
+
if (!ds.cohort.matrixplots)
|
|
109
|
+
return;
|
|
110
|
+
c.matrixplots = ds.cohort.matrixplots.plots.map((p) => {
|
|
111
|
+
return { name: p.name };
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function addGenomicQueries(c, ds, genome) {
|
|
115
|
+
const q = ds.queries;
|
|
116
|
+
if (!q)
|
|
117
|
+
return;
|
|
118
|
+
c.queries = {
|
|
119
|
+
defaultCoord: q.defaultCoord || genome.defaultcoord
|
|
120
|
+
};
|
|
121
|
+
const q2 = c.queries;
|
|
122
|
+
if (q.defaultBlock2GeneMode)
|
|
123
|
+
q2.defaultBlock2GeneMode = q.defaultBlock2GeneMode;
|
|
124
|
+
if (q.snvindel) {
|
|
125
|
+
q2.snvindel = {
|
|
126
|
+
allowSNPs: q.snvindel.allowSNPs
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (q.cnv) {
|
|
130
|
+
q2.cnv = {};
|
|
131
|
+
for (const k of [
|
|
132
|
+
"cnvMaxLength",
|
|
133
|
+
"cnvGainCutoff",
|
|
134
|
+
"cnvLossCutoff",
|
|
135
|
+
"absoluteValueRenderMax",
|
|
136
|
+
"gainColor",
|
|
137
|
+
"lossColor"
|
|
138
|
+
]) {
|
|
139
|
+
if (k in q.cnv)
|
|
140
|
+
q2.cnv[k] = q.cnv[k];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (q.topMutatedGenes)
|
|
144
|
+
q2.topMutatedGenes = q.topMutatedGenes;
|
|
145
|
+
if (q.topVariablyExpressedGenes)
|
|
146
|
+
q2.topVariablyExpressedGenes = q.topVariablyExpressedGenes;
|
|
147
|
+
if (q.singleSampleMutation) {
|
|
148
|
+
q2.singleSampleMutation = {
|
|
149
|
+
sample_id_key: q.singleSampleMutation.sample_id_key,
|
|
150
|
+
discoSkipChrM: q.singleSampleMutation.discoSkipChrM
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (q.singleSampleGenomeQuantification) {
|
|
154
|
+
q2.singleSampleGenomeQuantification = {};
|
|
155
|
+
for (const k in q.singleSampleGenomeQuantification) {
|
|
156
|
+
q2.singleSampleGenomeQuantification[k] = JSON.parse(JSON.stringify(q.singleSampleGenomeQuantification[k]));
|
|
157
|
+
delete q2.singleSampleGenomeQuantification[k].folder;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
if (q.singleSampleGbtk) {
|
|
161
|
+
q2.singleSampleGbtk = {};
|
|
162
|
+
for (const k in q.singleSampleGbtk) {
|
|
163
|
+
q2.singleSampleGbtk[k] = JSON.parse(JSON.stringify(q.singleSampleGbtk[k]));
|
|
164
|
+
delete q2.singleSampleGbtk[k].folder;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (q.rnaseqGeneCount) {
|
|
168
|
+
q2.rnaseqGeneCount = true;
|
|
169
|
+
}
|
|
170
|
+
if (q.singleCell) {
|
|
171
|
+
q2.singleCell = {
|
|
172
|
+
samples: {
|
|
173
|
+
firstColumnName: q.singleCell.samples.firstColumnName,
|
|
174
|
+
sampleColumns: q.singleCell.samples.sampleColumns,
|
|
175
|
+
experimentColumns: q.singleCell.samples.experimentColumns
|
|
176
|
+
},
|
|
177
|
+
data: {
|
|
178
|
+
sameLegend: q.singleCell.data.sameLegend,
|
|
179
|
+
refName: q.singleCell.data.refName
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function getAllowedTermTypes(ds) {
|
|
185
|
+
mayComputeTermtypeByCohort(ds);
|
|
186
|
+
const typeSet = /* @__PURE__ */ new Set();
|
|
187
|
+
for (const r of ds.cohort.termdb.termtypeByCohort) {
|
|
188
|
+
if (r.type)
|
|
189
|
+
typeSet.add(r.type);
|
|
190
|
+
}
|
|
191
|
+
if (ds.cohort.termdb.allowedTermTypes) {
|
|
192
|
+
for (const t of ds.cohort.termdb.allowedTermTypes)
|
|
193
|
+
typeSet.add(t);
|
|
194
|
+
}
|
|
195
|
+
if (ds?.queries?.defaultBlock2GeneMode) {
|
|
196
|
+
typeSet.add("geneVariant");
|
|
197
|
+
}
|
|
198
|
+
return [...typeSet];
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
api
|
|
202
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { get_rows_by_one_key } from "../src/termdb.sql.js";
|
|
2
|
+
import Summarystats from "../shared/descriptive.stats.js";
|
|
3
|
+
const api = {
|
|
4
|
+
endpoint: "termdb/descrstats",
|
|
5
|
+
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
|
+
tid: "hrtavg",
|
|
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
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
function init({ genomes }) {
|
|
55
|
+
return async (req, res) => {
|
|
56
|
+
const q = req.query;
|
|
57
|
+
try {
|
|
58
|
+
const g = genomes[req.query.genome];
|
|
59
|
+
if (!g)
|
|
60
|
+
throw "invalid genome name";
|
|
61
|
+
const ds = g.datasets[req.query.dslabel];
|
|
62
|
+
if (!ds)
|
|
63
|
+
throw "invalid dataset name";
|
|
64
|
+
const tdb = ds.cohort.termdb;
|
|
65
|
+
if (!tdb)
|
|
66
|
+
throw "invalid termdb object";
|
|
67
|
+
await trigger_getdescrstats(q, res, ds);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
res.send({ error: e?.message || e });
|
|
70
|
+
if (e instanceof Error && e.stack)
|
|
71
|
+
console.log(e);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async function trigger_getdescrstats(q, res, ds) {
|
|
76
|
+
const term = ds.cohort.termdb.q.termjsonByOneid(q.tid);
|
|
77
|
+
if (!term)
|
|
78
|
+
throw "invalid termid";
|
|
79
|
+
if (term.type != "float" && term.type != "integer")
|
|
80
|
+
throw "not numerical term";
|
|
81
|
+
const rows = await get_rows_by_one_key({
|
|
82
|
+
ds,
|
|
83
|
+
key: q.tid,
|
|
84
|
+
filter: q.filter
|
|
85
|
+
});
|
|
86
|
+
const values = [];
|
|
87
|
+
for (const { value } of rows) {
|
|
88
|
+
if (term.values?.[value]?.uncomputable) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (q.settings?.violin?.unit === "log") {
|
|
92
|
+
if (value === 0) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
values.push(value);
|
|
97
|
+
}
|
|
98
|
+
res.send(Summarystats(values));
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
api
|
|
102
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as termdbsql from "#src/termdb.sql.js";
|
|
2
|
+
const api = {
|
|
3
|
+
endpoint: "termdb/numericcategories",
|
|
4
|
+
methods: {
|
|
5
|
+
get: {
|
|
6
|
+
init,
|
|
7
|
+
request: {
|
|
8
|
+
typeId: "getnumericcategoriesRequest"
|
|
9
|
+
},
|
|
10
|
+
response: {
|
|
11
|
+
typeId: "getnumericcategoriesResponse"
|
|
12
|
+
},
|
|
13
|
+
examples: [
|
|
14
|
+
{
|
|
15
|
+
request: {
|
|
16
|
+
body: {
|
|
17
|
+
genome: "hg38-test",
|
|
18
|
+
dslabel: "TermdbTest",
|
|
19
|
+
embedder: "localhost",
|
|
20
|
+
tid: "aaclassic_5",
|
|
21
|
+
filter: {
|
|
22
|
+
type: "tvslst",
|
|
23
|
+
in: true,
|
|
24
|
+
join: "",
|
|
25
|
+
lst: [
|
|
26
|
+
{
|
|
27
|
+
tag: "cohortFilter",
|
|
28
|
+
type: "tvs",
|
|
29
|
+
tvs: {
|
|
30
|
+
term: {
|
|
31
|
+
name: "Cohort",
|
|
32
|
+
type: "categorical",
|
|
33
|
+
values: { ABC: { label: "ABC" }, XYZ: { label: "XYZ" } },
|
|
34
|
+
id: "subcohort",
|
|
35
|
+
isleaf: false,
|
|
36
|
+
groupsetting: { disabled: true }
|
|
37
|
+
},
|
|
38
|
+
values: [{ key: "ABC", label: "ABC" }]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
response: {
|
|
46
|
+
header: { status: 200 }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
post: {
|
|
52
|
+
alternativeFor: "get",
|
|
53
|
+
init
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
function init({ genomes }) {
|
|
58
|
+
return async (req, res) => {
|
|
59
|
+
const q = req.query;
|
|
60
|
+
try {
|
|
61
|
+
const g = genomes[req.query.genome];
|
|
62
|
+
if (!g)
|
|
63
|
+
throw "invalid genome name";
|
|
64
|
+
const ds = g.datasets[req.query.dslabel];
|
|
65
|
+
if (!ds)
|
|
66
|
+
throw "invalid dataset name";
|
|
67
|
+
const tdb = ds.cohort.termdb;
|
|
68
|
+
if (!tdb)
|
|
69
|
+
throw "invalid termdb object";
|
|
70
|
+
await trigger_getnumericcategories(q, res, tdb, ds);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
res.send({ error: e?.message || e });
|
|
73
|
+
if (e instanceof Error && e.stack)
|
|
74
|
+
console.log(e);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async function trigger_getnumericcategories(q, res, tdb, ds) {
|
|
79
|
+
if (!q.tid)
|
|
80
|
+
throw ".tid missing";
|
|
81
|
+
const term = tdb.q.termjsonByOneid(q.tid);
|
|
82
|
+
const arg = {
|
|
83
|
+
ds,
|
|
84
|
+
term_id: q.tid,
|
|
85
|
+
filter: q.filter
|
|
86
|
+
};
|
|
87
|
+
const lst = await termdbsql.get_summary_numericcategories(arg);
|
|
88
|
+
res.send({ lst });
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
api
|
|
92
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as termdbsql from "../src/termdb.sql.js";
|
|
2
|
+
import computePercentile from "../shared/compute.percentile.js";
|
|
3
|
+
const api = {
|
|
4
|
+
endpoint: "termdb/getpercentile",
|
|
5
|
+
methods: {
|
|
6
|
+
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
|
+
]
|
|
52
|
+
},
|
|
53
|
+
post: {
|
|
54
|
+
alternativeFor: "get",
|
|
55
|
+
init
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
function init({ genomes }) {
|
|
60
|
+
return async (req, res) => {
|
|
61
|
+
const q = req.query;
|
|
62
|
+
try {
|
|
63
|
+
const g = genomes[req.query.genome];
|
|
64
|
+
if (!g)
|
|
65
|
+
throw "invalid genome name";
|
|
66
|
+
const ds = g.datasets[req.query.dslabel];
|
|
67
|
+
if (!ds)
|
|
68
|
+
throw "invalid dataset name";
|
|
69
|
+
await trigger_getpercentile(q, res, ds);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
res.send({ error: e?.message || e });
|
|
72
|
+
if (e instanceof Error && e.stack)
|
|
73
|
+
console.log(e);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function trigger_getpercentile(q, res, ds) {
|
|
78
|
+
const term = ds.cohort.termdb.q.termjsonByOneid(q.tid);
|
|
79
|
+
if (!term)
|
|
80
|
+
throw "invalid termid";
|
|
81
|
+
if (term.type != "float" && term.type != "integer")
|
|
82
|
+
throw "not numerical term";
|
|
83
|
+
const percentile_lst = q.getpercentile;
|
|
84
|
+
const perc_values = [];
|
|
85
|
+
const values = [];
|
|
86
|
+
const rows = await termdbsql.get_rows_by_one_key({
|
|
87
|
+
ds,
|
|
88
|
+
key: q.tid,
|
|
89
|
+
filter: q.filter ? typeof q.filter == "string" ? JSON.parse(q.filter) : q.filter : null
|
|
90
|
+
});
|
|
91
|
+
for (const { value } of rows) {
|
|
92
|
+
if (term.values && term.values[value] && term.values[value].uncomputable) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (term.skip0forPercentile && value == 0) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
values.push(Number(value));
|
|
99
|
+
}
|
|
100
|
+
for (const percentile of percentile_lst) {
|
|
101
|
+
const perc_value = computePercentile(values, percentile);
|
|
102
|
+
perc_values.push(perc_value);
|
|
103
|
+
}
|
|
104
|
+
res.send({ values: perc_values });
|
|
105
|
+
}
|
|
106
|
+
export {
|
|
107
|
+
api
|
|
108
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { get_ds_tdb } from "#src/termdb.js";
|
|
2
|
+
const api = {
|
|
3
|
+
endpoint: "termdb/rootterm",
|
|
4
|
+
methods: {
|
|
5
|
+
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
|
+
]
|
|
29
|
+
},
|
|
30
|
+
post: {
|
|
31
|
+
alternativeFor: "get",
|
|
32
|
+
init
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
function init({ genomes }) {
|
|
37
|
+
return async (req, res) => {
|
|
38
|
+
const q = req.query;
|
|
39
|
+
const cohortValues = q.cohortValues ? q.cohortValues : "";
|
|
40
|
+
const treeFilter = q.treeFilter ? q.treeFilter : "";
|
|
41
|
+
try {
|
|
42
|
+
const g = genomes[req.query.genome];
|
|
43
|
+
if (!g)
|
|
44
|
+
throw "invalid genome name";
|
|
45
|
+
const [ds, tdb] = get_ds_tdb(g, q);
|
|
46
|
+
if (!ds)
|
|
47
|
+
throw "invalid dataset name";
|
|
48
|
+
if (!tdb)
|
|
49
|
+
throw "invalid termdb object";
|
|
50
|
+
await trigger_rootterm(q, res, tdb);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
res.send({ error: e?.message || e });
|
|
53
|
+
if (e instanceof Error && e.stack)
|
|
54
|
+
console.log(e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
async function trigger_rootterm(q, res, tdb) {
|
|
59
|
+
const cohortValues = q.cohortValues ? q.cohortValues : "";
|
|
60
|
+
const treeFilter = q.treeFilter ? q.treeFilter : "";
|
|
61
|
+
res.send({ lst: await tdb.q.getRootTerms(cohortValues, treeFilter) });
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
api
|
|
65
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { copy_term, get_ds_tdb } from "#src/termdb.js";
|
|
2
|
+
const api = {
|
|
3
|
+
endpoint: "termdb/termchildren",
|
|
4
|
+
methods: {
|
|
5
|
+
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
|
+
]
|
|
30
|
+
},
|
|
31
|
+
post: {
|
|
32
|
+
alternativeFor: "get",
|
|
33
|
+
init
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function init({ genomes }) {
|
|
38
|
+
return async (req, res) => {
|
|
39
|
+
const q = req.query;
|
|
40
|
+
try {
|
|
41
|
+
const g = genomes[req.query.genome];
|
|
42
|
+
if (!g)
|
|
43
|
+
throw "invalid genome name";
|
|
44
|
+
const [ds, tdb] = await get_ds_tdb(g, q);
|
|
45
|
+
if (!ds)
|
|
46
|
+
throw "invalid dataset name";
|
|
47
|
+
if (!tdb)
|
|
48
|
+
throw "invalid termdb object";
|
|
49
|
+
await trigger_children(q, res, tdb);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
res.send({ error: e?.message || e });
|
|
52
|
+
if (e instanceof Error && e.stack)
|
|
53
|
+
console.log(e);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function trigger_children(q, res, tdb) {
|
|
58
|
+
if (!q.tid)
|
|
59
|
+
throw "no parent term id";
|
|
60
|
+
const cohortValues = q.cohortValues ? q.cohortValues : "";
|
|
61
|
+
const treeFilter = q.treeFilter ? q.treeFilter : "";
|
|
62
|
+
const terms = await tdb.q.getTermChildren(q.tid, cohortValues, treeFilter);
|
|
63
|
+
res.send({ lst: terms.map(copy_term) });
|
|
64
|
+
}
|
|
65
|
+
export {
|
|
66
|
+
api
|
|
67
|
+
};
|