@sjcrh/proteinpaint-server 2.63.4 → 2.63.5
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 +1 -1
- package/routes/termdb.config.js +8 -10
- package/routes/termdb.singlecellSamples.js +50 -5
- package/src/app.js +165 -90
- package/utils/burden.R +3 -1
package/package.json
CHANGED
package/routes/termdb.config.js
CHANGED
|
@@ -84,8 +84,7 @@ function make(q, res, ds, genome) {
|
|
|
84
84
|
addRestrictAncestries(c, tdb);
|
|
85
85
|
addScatterplots(c, ds);
|
|
86
86
|
addMatrixplots(c, ds);
|
|
87
|
-
|
|
88
|
-
addImageQueries(c, ds);
|
|
87
|
+
addNonDictionaryQueries(c, ds, genome);
|
|
89
88
|
res.send({ termdbConfig: c });
|
|
90
89
|
}
|
|
91
90
|
function addRestrictAncestries(c, tdb) {
|
|
@@ -95,13 +94,6 @@ function addRestrictAncestries(c, tdb) {
|
|
|
95
94
|
return { name: i.name, tvs: i.tvs, PCcount: i.PCcount };
|
|
96
95
|
});
|
|
97
96
|
}
|
|
98
|
-
function addImageQueries(c, ds) {
|
|
99
|
-
const q = ds.queries;
|
|
100
|
-
const q2 = c.queries;
|
|
101
|
-
if (q.images) {
|
|
102
|
-
q2.images = {};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
97
|
function addScatterplots(c, ds) {
|
|
106
98
|
if (!ds.cohort.scatterplots)
|
|
107
99
|
return;
|
|
@@ -126,7 +118,7 @@ function addMatrixplots(c, ds) {
|
|
|
126
118
|
return { name: p.name };
|
|
127
119
|
});
|
|
128
120
|
}
|
|
129
|
-
function
|
|
121
|
+
function addNonDictionaryQueries(c, ds, genome) {
|
|
130
122
|
const q = ds.queries;
|
|
131
123
|
if (!q)
|
|
132
124
|
return;
|
|
@@ -210,6 +202,12 @@ function addGenomicQueries(c, ds, genome) {
|
|
|
210
202
|
refName: q.singleCell.data.refName
|
|
211
203
|
}
|
|
212
204
|
};
|
|
205
|
+
if (q.singleCell.geneExpression) {
|
|
206
|
+
q2.singleCell.geneExpression = {};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (q.images) {
|
|
210
|
+
q2.images = {};
|
|
213
211
|
}
|
|
214
212
|
}
|
|
215
213
|
function getAllowedTermTypes(ds) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
3
|
+
import { spawn } from "child_process";
|
|
4
|
+
import { read_file, get_header_txt } from "#src/utils.js";
|
|
4
5
|
import serverconfig from "#src/serverconfig.js";
|
|
5
6
|
import { gdc_validate_query_singleCell_samples, gdc_validate_query_singleCell_data } from "#src/mds3.gdc.js";
|
|
6
7
|
const api = {
|
|
@@ -53,19 +54,27 @@ async function validate_query_singleCell(ds, genome) {
|
|
|
53
54
|
if (q.samples.src == "gdcapi") {
|
|
54
55
|
gdc_validate_query_singleCell_samples(ds, genome);
|
|
55
56
|
} else if (q.samples.src == "native") {
|
|
56
|
-
|
|
57
|
+
validateSamplesNative(q.samples, ds);
|
|
57
58
|
} else {
|
|
58
59
|
throw "unknown singleCell.samples.src";
|
|
59
60
|
}
|
|
60
61
|
if (q.data.src == "gdcapi") {
|
|
61
62
|
gdc_validate_query_singleCell_data(ds, genome);
|
|
62
63
|
} else if (q.data.src == "native") {
|
|
63
|
-
|
|
64
|
+
validateDataNative(q.data);
|
|
64
65
|
} else {
|
|
65
66
|
throw "unknown singleCell.data.src";
|
|
66
67
|
}
|
|
68
|
+
if (q.geneExpression) {
|
|
69
|
+
if (q.geneExpression.src == "native") {
|
|
70
|
+
validateGeneExpressionNative(q.geneExpression);
|
|
71
|
+
} else if (q.geneExpression.src == "gdcapi") {
|
|
72
|
+
} else {
|
|
73
|
+
throw "unknown singleCell.geneExpression.src";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
67
76
|
}
|
|
68
|
-
async function
|
|
77
|
+
async function validateSamplesNative(S, ds) {
|
|
69
78
|
const samples = {};
|
|
70
79
|
if (S.sampleColumns) {
|
|
71
80
|
for (const term of S.sampleColumns) {
|
|
@@ -81,7 +90,7 @@ async function getSamplesNative(S, ds) {
|
|
|
81
90
|
return { samples: Object.values(samples) };
|
|
82
91
|
};
|
|
83
92
|
}
|
|
84
|
-
function
|
|
93
|
+
function validateDataNative(D) {
|
|
85
94
|
const nameSet = /* @__PURE__ */ new Set();
|
|
86
95
|
for (const plot of D.plots) {
|
|
87
96
|
if (nameSet.has(plot.name))
|
|
@@ -128,6 +137,42 @@ function getDataNative(D, ds) {
|
|
|
128
137
|
}
|
|
129
138
|
};
|
|
130
139
|
}
|
|
140
|
+
function validateGeneExpressionNative(G) {
|
|
141
|
+
G.get = async (q) => {
|
|
142
|
+
const tsvfile = path.join(serverconfig.tpmasterdir, G.folder, q.sample);
|
|
143
|
+
try {
|
|
144
|
+
await fs.promises.stat(tsvfile);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
throw "geneExp matrix file not found or readable for this sample";
|
|
147
|
+
}
|
|
148
|
+
const header = await get_header_txt(tsvfile);
|
|
149
|
+
return await grepMatrix4geneExpression(tsvfile, q.gene, header);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function grepMatrix4geneExpression(tsvfile, gene, header) {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const cp = spawn("grep", ["-m", "1", gene + " ", tsvfile]);
|
|
155
|
+
const out = [], err = [];
|
|
156
|
+
cp.stdout.on("data", (d) => out.push(d));
|
|
157
|
+
cp.stderr.on("data", (d) => err.push(d));
|
|
158
|
+
cp.on("close", () => {
|
|
159
|
+
const e = err.join("");
|
|
160
|
+
if (e)
|
|
161
|
+
reject(e);
|
|
162
|
+
const l = out.join("").split(" ");
|
|
163
|
+
if (l.length != header.length)
|
|
164
|
+
reject(`number of fields differ between data line and header: ${l.length} ${header.length}`);
|
|
165
|
+
const cell2value = {};
|
|
166
|
+
for (let i = 1; i < l.length; i++) {
|
|
167
|
+
const v = Number(l[i]);
|
|
168
|
+
if (Number.isNaN(v))
|
|
169
|
+
continue;
|
|
170
|
+
cell2value[header[i]] = v;
|
|
171
|
+
}
|
|
172
|
+
resolve(cell2value);
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
131
176
|
export {
|
|
132
177
|
api,
|
|
133
178
|
validate_query_singleCell
|