@sjcrh/proteinpaint-server 2.138.1 → 2.138.3-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/dataset/protected.test.js +13 -0
- package/dataset/termdb.test.js +0 -1
- package/package.json +2 -2
- package/routes/filterTermValues.js +25 -17
- package/routes/samplewsimages.js +17 -10
- package/src/app.js +175 -117
- package/src/serverconfig.js +46 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import termdbTestInit from "./termdb.test.ts";
|
|
2
|
+
function protected_test_default() {
|
|
3
|
+
const ds = termdbTestInit();
|
|
4
|
+
if (!ds.cohort)
|
|
5
|
+
ds.cohort = { termdb: {} };
|
|
6
|
+
ds.cohort.termdb.hasMinSampleSize = (sampleCount) => {
|
|
7
|
+
return sampleCount >= 10;
|
|
8
|
+
};
|
|
9
|
+
return ds;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
protected_test_default as default
|
|
13
|
+
};
|
package/dataset/termdb.test.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjcrh/proteinpaint-server",
|
|
3
|
-
"version": "2.138.
|
|
3
|
+
"version": "2.138.3-0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "a genomics visualization tool for exploring a cohort's genotype and phenotype data",
|
|
6
6
|
"main": "src/app.js",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@sjcrh/proteinpaint-r": "2.137.2-0",
|
|
65
65
|
"@sjcrh/proteinpaint-rust": "2.137.2-0",
|
|
66
66
|
"@sjcrh/proteinpaint-shared": "2.137.3",
|
|
67
|
-
"@sjcrh/proteinpaint-types": "2.138.
|
|
67
|
+
"@sjcrh/proteinpaint-types": "2.138.3-0",
|
|
68
68
|
"@types/express": "^5.0.0",
|
|
69
69
|
"@types/express-session": "^1.18.1",
|
|
70
70
|
"better-sqlite3": "^9.4.1",
|
|
@@ -28,7 +28,29 @@ function init({ genomes }) {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
async function getFilters(query, ds, res) {
|
|
32
|
+
if (!query.filterByUserSites)
|
|
33
|
+
authApi.mayAdjustFilter(query, ds, query.terms);
|
|
34
|
+
try {
|
|
35
|
+
const samplesPerFilter = await getSamplesPerFilter(query, ds);
|
|
36
|
+
const filtersData = await getData(
|
|
37
|
+
{
|
|
38
|
+
terms: query.terms,
|
|
39
|
+
__protected__: query.__protected__
|
|
40
|
+
},
|
|
41
|
+
ds
|
|
42
|
+
);
|
|
43
|
+
const tw2List = {};
|
|
44
|
+
for (const tw of query.terms) {
|
|
45
|
+
tw2List[tw.term.id] = getList(samplesPerFilter, filtersData, tw, query.showAll);
|
|
46
|
+
}
|
|
47
|
+
res.send({ ...tw2List });
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.log(e);
|
|
50
|
+
res.send({ error: e.message || e });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function getList(samplesPerFilter, filtersData, tw, showAll) {
|
|
32
54
|
const values = Object.values(tw.term.values);
|
|
33
55
|
values.sort((v1, v2) => v1.label.localeCompare(v2.label));
|
|
34
56
|
const twSamples = samplesPerFilter[tw.term.id];
|
|
@@ -42,28 +64,14 @@ function getList(samplesPerFilter, filtersData, tw) {
|
|
|
42
64
|
for (const value of values) {
|
|
43
65
|
const label = value.label.replace(/["']/g, "");
|
|
44
66
|
const disabled = !sampleValues.includes(value.key || value.label);
|
|
67
|
+
if (!showAll && disabled)
|
|
68
|
+
continue;
|
|
45
69
|
filteredValues.push({ value: value.key || value.label, label, disabled });
|
|
46
70
|
}
|
|
47
71
|
filteredValues.unshift({ label: "", value: "" });
|
|
48
72
|
filteredValues.sort((a, b) => a.label.localeCompare(b.label));
|
|
49
73
|
return filteredValues;
|
|
50
74
|
}
|
|
51
|
-
async function getFilters(query, ds, res) {
|
|
52
|
-
if (!query.filterByUserSites)
|
|
53
|
-
authApi.mayAdjustFilter(query, ds, query.terms);
|
|
54
|
-
try {
|
|
55
|
-
const samplesPerFilter = await getSamplesPerFilter(query, ds);
|
|
56
|
-
const filtersData = await getData({ terms: query.terms, __protected__: query.__protected__ }, ds);
|
|
57
|
-
const tw2List = {};
|
|
58
|
-
for (const tw of query.terms) {
|
|
59
|
-
tw2List[tw.term.id] = getList(samplesPerFilter, filtersData, tw);
|
|
60
|
-
}
|
|
61
|
-
res.send({ ...tw2List });
|
|
62
|
-
} catch (e) {
|
|
63
|
-
console.log(e);
|
|
64
|
-
res.send({ error: e.message || e });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
75
|
export {
|
|
68
76
|
api
|
|
69
77
|
};
|
package/routes/samplewsimages.js
CHANGED
|
@@ -49,24 +49,31 @@ function init({ genomes }) {
|
|
|
49
49
|
const featClass = ds.queries.WSImages?.classes?.find((f) => f.id == d.properties.class)?.label || d.properties.class;
|
|
50
50
|
return {
|
|
51
51
|
zoomCoordinates: d.properties.zoomCoordinates,
|
|
52
|
-
type: d.properties.type,
|
|
53
52
|
uncertainty: d.properties.uncertainty,
|
|
54
53
|
class: featClass
|
|
55
54
|
};
|
|
56
|
-
});
|
|
55
|
+
}).slice(15, 20);
|
|
57
56
|
wsimage.classes = ds.queries?.WSImages?.classes;
|
|
58
57
|
wsimage.uncertainty = ds.queries?.WSImages?.uncertainty;
|
|
59
|
-
wsimage.activePatchColor = ds.queries?.WSImages?.activePatchColor
|
|
58
|
+
wsimage.activePatchColor = ds.queries?.WSImages?.activePatchColor;
|
|
60
59
|
}
|
|
61
|
-
if (ds.queries.WSImages.
|
|
62
|
-
const
|
|
60
|
+
if (ds.queries.WSImages.getWSIPredictionPatches) {
|
|
61
|
+
const predictionsFile = await ds.queries.WSImages.getWSIPredictionPatches(sampleId, wsimage.filename);
|
|
62
|
+
const predictionsFilePath = path.join(
|
|
63
|
+
serverconfig.tpmasterdir,
|
|
64
|
+
ds.queries.WSImages.imageBySampleFolder,
|
|
63
65
|
sampleId,
|
|
64
|
-
|
|
65
|
-
query.index
|
|
66
|
+
predictionsFile[0]
|
|
66
67
|
);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
const predictionsData = JSON.parse(fs.readFileSync(predictionsFilePath, "utf8"));
|
|
69
|
+
wsimage.predictions = predictionsData.features.map((d) => {
|
|
70
|
+
const featClass = ds.queries.WSImages?.classes?.find((f) => f.id == d.properties.class)?.label || d.properties.class;
|
|
71
|
+
return {
|
|
72
|
+
zoomCoordinates: d.properties.zoomCoordinates,
|
|
73
|
+
uncertainty: d.properties.uncertainty,
|
|
74
|
+
class: featClass
|
|
75
|
+
};
|
|
76
|
+
}).slice(0, 15);
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
79
|
}
|