@sjcrh/proteinpaint-server 2.70.2 → 2.70.3-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/package.json +4 -1
- package/routes/sampletiaimages.js +51 -0
- package/routes/termdb.config.js +5 -0
- package/routes/tiaimages.js +83 -0
- package/routes/tileserver.js +40 -0
- package/src/app.js +690 -269
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjcrh/proteinpaint-server",
|
|
3
|
-
"version": "2.70.
|
|
3
|
+
"version": "2.70.3-1",
|
|
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",
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"@babel/preset-typescript": "^7.21.4",
|
|
45
45
|
"@babel/register": "^7.14.5",
|
|
46
46
|
"@types/node": "^20.11.24",
|
|
47
|
+
"@types/qs": "^6.9.15",
|
|
47
48
|
"@typescript-eslint/eslint-plugin": "^5.60.0",
|
|
48
49
|
"babel-loader": "^8.2.2",
|
|
49
50
|
"esbuild": "^0.19.12",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"dependencies": {
|
|
63
64
|
"@sjcrh/augen": "2.46.0",
|
|
64
65
|
"@sjcrh/proteinpaint-rust": "2.61.1",
|
|
66
|
+
"axios": "^1.7.2",
|
|
65
67
|
"better-sqlite3": "^9.4.1",
|
|
66
68
|
"body-parser": "^1.15.2",
|
|
67
69
|
"canvas": "~2.11.2",
|
|
@@ -81,6 +83,7 @@
|
|
|
81
83
|
"minimatch": "^3.1.2",
|
|
82
84
|
"node-fetch": "^2.6.1",
|
|
83
85
|
"partjson": "^0.58.2",
|
|
86
|
+
"qs": "^6.12.3",
|
|
84
87
|
"tiny-async-pool": "^1.2.0",
|
|
85
88
|
"typedoc-plugin-missing-exports": "^2.0.1"
|
|
86
89
|
},
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import serverconfig from "#src/serverconfig.js";
|
|
4
|
+
const api = {
|
|
5
|
+
endpoint: "sampletiaimages",
|
|
6
|
+
methods: {
|
|
7
|
+
get: {
|
|
8
|
+
init,
|
|
9
|
+
request: {
|
|
10
|
+
typeId: "GetSampleTiaImagesRequest"
|
|
11
|
+
},
|
|
12
|
+
response: {
|
|
13
|
+
typeId: "GetSampleTiaImagesResponse"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
post: {
|
|
17
|
+
alternativeFor: "get",
|
|
18
|
+
init
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function init({ genomes }) {
|
|
23
|
+
return async (req, res) => {
|
|
24
|
+
try {
|
|
25
|
+
const g = genomes[req.query.genome];
|
|
26
|
+
if (!g)
|
|
27
|
+
throw "invalid genome name";
|
|
28
|
+
const ds = g.datasets[req.query.dslabel];
|
|
29
|
+
if (!ds)
|
|
30
|
+
throw "invalid dataset name";
|
|
31
|
+
const sampleId = req.query.sample_id;
|
|
32
|
+
const sampleTiaImagesPath = path.join(
|
|
33
|
+
`${serverconfig.tpmasterdir}/${ds.queries.TiaImages.imageBySampleFolder}`,
|
|
34
|
+
sampleId
|
|
35
|
+
);
|
|
36
|
+
console.log("sampleId", sampleId);
|
|
37
|
+
const sampleTiaImages = getTiaImages(sampleTiaImagesPath);
|
|
38
|
+
res.send({ sampleTiaImages });
|
|
39
|
+
} catch (e) {
|
|
40
|
+
console.log(e);
|
|
41
|
+
res.status(404).send("Sample images not found");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function getTiaImages(sampleImagesPath) {
|
|
46
|
+
const files = fs.readdirSync(sampleImagesPath);
|
|
47
|
+
return files.filter((file) => [".svs", ".mrxs"].includes(path.extname(file)));
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
api
|
|
51
|
+
};
|
package/routes/termdb.config.js
CHANGED
|
@@ -182,6 +182,11 @@ function addNonDictionaryQueries(c, ds, genome) {
|
|
|
182
182
|
type: q.DZImages.type
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
+
if (q.TiaImages) {
|
|
186
|
+
q2.TiaImages = {
|
|
187
|
+
type: q.TiaImages.type
|
|
188
|
+
};
|
|
189
|
+
}
|
|
185
190
|
if (q.singleSampleGbtk) {
|
|
186
191
|
q2.singleSampleGbtk = {};
|
|
187
192
|
for (const k in q.singleSampleGbtk) {
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import qs from "qs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import serverconfig from "#src/serverconfig.js";
|
|
5
|
+
import fs from "fs";
|
|
6
|
+
const routePath = "tiaimages";
|
|
7
|
+
const api = {
|
|
8
|
+
endpoint: `${routePath}`,
|
|
9
|
+
methods: {
|
|
10
|
+
get: {
|
|
11
|
+
init,
|
|
12
|
+
request: {
|
|
13
|
+
typeId: "any"
|
|
14
|
+
},
|
|
15
|
+
response: {
|
|
16
|
+
typeId: "any"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
post: {
|
|
20
|
+
alternativeFor: "get",
|
|
21
|
+
init
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function init({ genomes }) {
|
|
26
|
+
return async (req, res) => {
|
|
27
|
+
try {
|
|
28
|
+
const g = genomes[req.query.genome];
|
|
29
|
+
if (!g)
|
|
30
|
+
throw "invalid genome name";
|
|
31
|
+
const ds = g.datasets[req.query.dslabel];
|
|
32
|
+
if (!ds)
|
|
33
|
+
throw "invalid dataset name";
|
|
34
|
+
const sampleId = req.query.sampleId;
|
|
35
|
+
if (!sampleId)
|
|
36
|
+
throw "invalid sampleId";
|
|
37
|
+
const sessionResponse = await axios.get("http://127.0.0.1:5000/tileserver/session_id", { withCredentials: true });
|
|
38
|
+
const setCookieHeader = sessionResponse.headers["set-cookie"];
|
|
39
|
+
const sessionId = setCookieHeader && setCookieHeader[0].split(";")[0].split("=")[1];
|
|
40
|
+
console.log("sessionId", sessionId);
|
|
41
|
+
const sampleTiaImagesPath = path.join(
|
|
42
|
+
`${serverconfig.tpmasterdir}/${ds.queries.TiaImages.imageBySampleFolder}`,
|
|
43
|
+
sampleId
|
|
44
|
+
);
|
|
45
|
+
const images = getTiaImages(sampleTiaImagesPath);
|
|
46
|
+
const sampleTiaTileServer = path.join(
|
|
47
|
+
`${serverconfig.tileServerMount}/${ds.queries.TiaImages.imageBySampleFolder}`,
|
|
48
|
+
sampleId
|
|
49
|
+
);
|
|
50
|
+
const fname = `${sampleTiaTileServer}/${images[0]}`;
|
|
51
|
+
const data = qs.stringify({ slide_path: fname });
|
|
52
|
+
const putResponse = await axios.put("http://127.0.0.1:5000/tileserver/slide", data, {
|
|
53
|
+
withCredentials: true,
|
|
54
|
+
headers: {
|
|
55
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
56
|
+
Cookie: `session_id=${sessionId}`
|
|
57
|
+
// Include the session_id in the headers
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const getResponse = await axios.get("http://127.0.0.1:5000/tileserver/slide", {
|
|
61
|
+
withCredentials: true,
|
|
62
|
+
headers: {
|
|
63
|
+
Cookie: `session_id=${sessionId}`
|
|
64
|
+
// Include the session_id in the headers
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
res.status(200).json({ sessionId, slide_dimensions: getResponse.data.slide_dimensions });
|
|
68
|
+
} catch (e) {
|
|
69
|
+
console.log(e);
|
|
70
|
+
res.send({
|
|
71
|
+
status: "error",
|
|
72
|
+
error: e.error || e
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function getTiaImages(sampleImagesPath) {
|
|
78
|
+
const files = fs.readdirSync(sampleImagesPath);
|
|
79
|
+
return files.filter((file) => [".svs", ".mrxs"].includes(path.extname(file)));
|
|
80
|
+
}
|
|
81
|
+
export {
|
|
82
|
+
api
|
|
83
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import serverconfig from "#src/serverconfig.js";
|
|
3
|
+
const routePath = "tileserver";
|
|
4
|
+
const api = {
|
|
5
|
+
endpoint: `${routePath}/layer/slide/:sampleId/zoomify/:TileGroup/:z-:x-:y@1x.jpg`,
|
|
6
|
+
methods: {
|
|
7
|
+
get: {
|
|
8
|
+
init,
|
|
9
|
+
request: {
|
|
10
|
+
typeId: "any"
|
|
11
|
+
},
|
|
12
|
+
response: {
|
|
13
|
+
typeId: "any"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
post: {
|
|
17
|
+
alternativeFor: "get",
|
|
18
|
+
init
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
function init() {
|
|
23
|
+
return async (req, res) => {
|
|
24
|
+
try {
|
|
25
|
+
const { sampleId, TileGroup, z, x, y } = req.params;
|
|
26
|
+
const url = `${serverconfig.tileServerURL}/tileserver/layer/slide/${sampleId}/zoomify/${TileGroup}/${z}-${x}-${y}@1x.jpg`;
|
|
27
|
+
const response = await axios.get(url, { responseType: "arraybuffer" });
|
|
28
|
+
res.status(response.status).send(response.data);
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error.response) {
|
|
31
|
+
res.status(error.response.status).send(error.response.data);
|
|
32
|
+
} else {
|
|
33
|
+
res.status(500).send("Internal Server Error");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
api
|
|
40
|
+
};
|