@sjcrh/proteinpaint-server 2.57.1-1 → 2.58.0-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/package.json +2 -2
- package/routes/hicdata.genome.js +93 -0
- package/src/app.js +469 -251
- package/src/mds3.gdc.filter.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjcrh/proteinpaint-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.58.0-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",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@sjcrh/augen": "2.46.0",
|
|
64
|
-
"@sjcrh/proteinpaint-rust": "2.
|
|
64
|
+
"@sjcrh/proteinpaint-rust": "2.58.0-0",
|
|
65
65
|
"better-sqlite3": "^9.4.1",
|
|
66
66
|
"body-parser": "^1.15.2",
|
|
67
67
|
"canvas": "~2.11.2",
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { fileurl } from "#src/utils.js";
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
import readline from "readline";
|
|
4
|
+
import serverconfig from "#src/serverconfig.js";
|
|
5
|
+
const api = {
|
|
6
|
+
endpoint: "hicgenome",
|
|
7
|
+
methods: {
|
|
8
|
+
get: {
|
|
9
|
+
init,
|
|
10
|
+
request: {
|
|
11
|
+
typeId: "HicdataRequest"
|
|
12
|
+
},
|
|
13
|
+
response: {
|
|
14
|
+
typeId: "HicdataResponse"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
post: {
|
|
18
|
+
alternativeFor: "get",
|
|
19
|
+
init
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function init() {
|
|
24
|
+
return async (req, res) => {
|
|
25
|
+
const data = [];
|
|
26
|
+
const erroutput = [];
|
|
27
|
+
const [e, file, isurl] = fileurl({ query: req.query });
|
|
28
|
+
if (e)
|
|
29
|
+
res.send({ error: "illegal file name" });
|
|
30
|
+
const matrixType = req.query.matrixType == "log(oe)" ? "oe" : req.query.matrixType ? req.query.matrixType : "observed";
|
|
31
|
+
const promises = req.query.chrlst.map((lead, i) => {
|
|
32
|
+
return req.query.chrlst.slice(0, i + 1).map((follow, j) => {
|
|
33
|
+
if (j <= i) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
const pos1 = req.query.nochr ? lead.replace("chr", "") : lead;
|
|
36
|
+
const pos2 = req.query.nochr ? follow.replace("chr", "") : follow;
|
|
37
|
+
const par = [
|
|
38
|
+
matrixType,
|
|
39
|
+
req.query.nmeth || "NONE",
|
|
40
|
+
file,
|
|
41
|
+
pos1,
|
|
42
|
+
pos2,
|
|
43
|
+
req.query.isfrag ? "FRAG" : "BP",
|
|
44
|
+
req.query.resolution
|
|
45
|
+
];
|
|
46
|
+
const ps = spawn(serverconfig.hicstraw, par);
|
|
47
|
+
const rl = readline.createInterface({ input: ps.stdout });
|
|
48
|
+
const items = [];
|
|
49
|
+
let linenot3fields = 0;
|
|
50
|
+
let fieldnotnumerical = 0;
|
|
51
|
+
rl.on("line", (line) => {
|
|
52
|
+
const l = line.split(" ");
|
|
53
|
+
if (l.length != 3) {
|
|
54
|
+
linenot3fields++;
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const n1 = Number.parseInt(l[0]);
|
|
58
|
+
const n2 = Number.parseInt(l[1]);
|
|
59
|
+
const v = req.query.matrixType == "log(oe)" ? Math.log(Number.parseFloat(l[2])) : Number.parseFloat(l[2]);
|
|
60
|
+
if (Number.isNaN(n1) || Number.isNaN(n2) || Number.isNaN(v)) {
|
|
61
|
+
fieldnotnumerical++;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (req.query.mincutoff != void 0 && v <= req.query.mincutoff) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
items.push([n1, n2, v]);
|
|
68
|
+
});
|
|
69
|
+
data.push({ items, lead, follow });
|
|
70
|
+
ps.stderr.on("data", (i2) => erroutput.push(`${lead} - ${follow}: `, i2));
|
|
71
|
+
ps.on("close", () => {
|
|
72
|
+
if (erroutput.length)
|
|
73
|
+
reject({ error: erroutput.join("") });
|
|
74
|
+
if (linenot3fields)
|
|
75
|
+
reject({ error: `${linenot3fields} lines have other than 3 fields` });
|
|
76
|
+
if (fieldnotnumerical)
|
|
77
|
+
reject(`${fieldnotnumerical} lines have non-numerical values in any of the 3 fields`);
|
|
78
|
+
resolve();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}).flat();
|
|
84
|
+
Promise.allSettled(promises).then(() => res.send({ data, error: erroutput.join("") })).catch((e2) => {
|
|
85
|
+
res.send({ error: e2?.message || e2 });
|
|
86
|
+
if (e2 instanceof Error && e2.stack)
|
|
87
|
+
console.log(e2);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
api
|
|
93
|
+
};
|