@sjcrh/proteinpaint-server 2.152.0 → 2.153.1-2
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 +8 -8
- package/routes/aiProjectAdmin.js +3 -2
- package/routes/aiProjectTrainModel.js +8 -2
- package/routes/grin2.js +60 -23
- package/routes/termdb.profileFormScores.js +1 -1
- package/routes/termdb.violin.js +5 -6
- package/src/app.js +475 -730
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sjcrh/proteinpaint-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.153.1-2",
|
|
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,16 +61,16 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@sjcrh/augen": "2.143.0",
|
|
64
|
-
"@sjcrh/proteinpaint-python": "2.
|
|
65
|
-
"@sjcrh/proteinpaint-r": "2.
|
|
66
|
-
"@sjcrh/proteinpaint-rust": "2.
|
|
67
|
-
"@sjcrh/proteinpaint-shared": "2.
|
|
68
|
-
"@sjcrh/proteinpaint-types": "2.
|
|
64
|
+
"@sjcrh/proteinpaint-python": "2.153.0",
|
|
65
|
+
"@sjcrh/proteinpaint-r": "2.152.1-0",
|
|
66
|
+
"@sjcrh/proteinpaint-rust": "2.152.1-0",
|
|
67
|
+
"@sjcrh/proteinpaint-shared": "2.153.1-2",
|
|
68
|
+
"@sjcrh/proteinpaint-types": "2.153.1-2",
|
|
69
69
|
"@types/express": "^5.0.0",
|
|
70
70
|
"@types/express-session": "^1.18.1",
|
|
71
|
-
"better-sqlite3": "^
|
|
71
|
+
"better-sqlite3": "^12.4.1",
|
|
72
72
|
"body-parser": "^1.15.2",
|
|
73
|
-
"canvas": "~3.1.
|
|
73
|
+
"canvas": "~3.1.2",
|
|
74
74
|
"compression": "^1.6.2",
|
|
75
75
|
"connect-redis": "^6.1.3",
|
|
76
76
|
"cookie-parser": "^1.4.5",
|
package/routes/aiProjectAdmin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { aiProjectAdminPayload } from "#types/checkers";
|
|
2
|
-
import { getDbConnection } from "#src/aiHistoDBConnection.
|
|
2
|
+
import { getDbConnection } from "#src/aiHistoDBConnection.ts";
|
|
3
3
|
import { runMultiStmtSQL, runSQL } from "#src/runSQLHelpers.ts";
|
|
4
4
|
const api = {
|
|
5
5
|
endpoint: "aiProjectAdmin",
|
|
@@ -165,5 +165,6 @@ function addProject(connection, project) {
|
|
|
165
165
|
runMultiStmtSQL(connection, [{ sql: classSql, params: classParams }], "add");
|
|
166
166
|
}
|
|
167
167
|
export {
|
|
168
|
-
api
|
|
168
|
+
api,
|
|
169
|
+
getImages
|
|
169
170
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { aiProjectTrainModelPayload } from "#types/checkers";
|
|
2
2
|
import { TileServerSessionsHandler } from "#src/wsisessions/TileServerSessionsHandler.ts";
|
|
3
3
|
import SessionManager from "#src/wsisessions/SessionManager.ts";
|
|
4
|
+
import { getDbConnection } from "#src/aiHistoDBConnection.js";
|
|
5
|
+
import { getImages } from "#routes/aiProjectAdmin.js";
|
|
4
6
|
const api = {
|
|
5
7
|
endpoint: "aiProjectTrainModel",
|
|
6
8
|
methods: {
|
|
@@ -18,13 +20,17 @@ function init({ genomes }) {
|
|
|
18
20
|
return async function(req, res) {
|
|
19
21
|
try {
|
|
20
22
|
const query = req.query;
|
|
21
|
-
console.log(query);
|
|
22
23
|
const g = genomes[query.genome];
|
|
23
24
|
if (!g) throw "invalid genome name";
|
|
24
25
|
const ds = g.datasets[query.dslabel];
|
|
25
26
|
if (!ds) throw "invalid dataset name";
|
|
26
27
|
if (typeof ds.queries.WSImages.retrainModel == "function") {
|
|
27
|
-
|
|
28
|
+
const connection = getDbConnection(ds);
|
|
29
|
+
const project = {
|
|
30
|
+
id: query.projectId
|
|
31
|
+
};
|
|
32
|
+
const wsimages = getImages(connection, project);
|
|
33
|
+
await ds.queries.WSImages.retrainModel(query.projectId, wsimages);
|
|
28
34
|
try {
|
|
29
35
|
const handler = new TileServerSessionsHandler();
|
|
30
36
|
const sessionMgr = SessionManager.getInstance();
|
package/routes/grin2.js
CHANGED
|
@@ -153,6 +153,10 @@ function allTypesCapped(tracker) {
|
|
|
153
153
|
}
|
|
154
154
|
async function processSampleData(samples, ds, request, tracker) {
|
|
155
155
|
const lesions = [];
|
|
156
|
+
const samplesPerType = /* @__PURE__ */ new Map();
|
|
157
|
+
for (const [type] of tracker.entries()) {
|
|
158
|
+
samplesPerType.set(type, /* @__PURE__ */ new Set());
|
|
159
|
+
}
|
|
156
160
|
const processingSummary = {
|
|
157
161
|
totalSamples: samples.length,
|
|
158
162
|
processedSamples: 0,
|
|
@@ -174,8 +178,11 @@ async function processSampleData(samples, ds, request, tracker) {
|
|
|
174
178
|
try {
|
|
175
179
|
await file_is_readable(filepath);
|
|
176
180
|
const mlst = JSON.parse(await read_file(filepath));
|
|
177
|
-
const { sampleLesions } = await processSampleMlst(sample.name, mlst, request, tracker);
|
|
181
|
+
const { sampleLesions, contributedTypes } = await processSampleMlst(sample.name, mlst, request, tracker);
|
|
178
182
|
lesions.push(...sampleLesions);
|
|
183
|
+
for (const type of contributedTypes) {
|
|
184
|
+
samplesPerType.get(type)?.add(sample.name);
|
|
185
|
+
}
|
|
179
186
|
processingSummary.processedSamples += 1;
|
|
180
187
|
processingSummary.totalLesions += sampleLesions.length;
|
|
181
188
|
if (allTypesCapped(tracker)) {
|
|
@@ -195,35 +202,61 @@ async function processSampleData(samples, ds, request, tracker) {
|
|
|
195
202
|
}
|
|
196
203
|
}
|
|
197
204
|
processingSummary.processedLesions = lesions.length;
|
|
205
|
+
const lesionCounts = {
|
|
206
|
+
total: lesions.length,
|
|
207
|
+
byType: {}
|
|
208
|
+
};
|
|
209
|
+
const lesionTypeCounts = {};
|
|
210
|
+
for (const lesion of lesions) {
|
|
211
|
+
const lesionType = lesion[4];
|
|
212
|
+
lesionTypeCounts[lesionType] = (lesionTypeCounts[lesionType] || 0) + 1;
|
|
213
|
+
}
|
|
198
214
|
for (const [type, info] of tracker.entries()) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
const isCapped = info.count >= MAX_LESIONS_PER_TYPE;
|
|
216
|
+
switch (type) {
|
|
217
|
+
case dtsnvindel:
|
|
218
|
+
lesionCounts.byType["mutation"] = {
|
|
219
|
+
count: lesionTypeCounts["mutation"] || 0,
|
|
220
|
+
capped: isCapped,
|
|
221
|
+
samples: samplesPerType.get(type)?.size || 0
|
|
222
|
+
};
|
|
223
|
+
break;
|
|
224
|
+
case dtcnv: {
|
|
225
|
+
const sampleCount = samplesPerType.get(type)?.size || 0;
|
|
226
|
+
lesionCounts.byType["gain"] = {
|
|
227
|
+
count: lesionTypeCounts["gain"] || 0,
|
|
228
|
+
capped: isCapped,
|
|
229
|
+
samples: sampleCount
|
|
230
|
+
};
|
|
231
|
+
lesionCounts.byType["loss"] = {
|
|
232
|
+
count: lesionTypeCounts["loss"] || 0,
|
|
233
|
+
capped: isCapped,
|
|
234
|
+
samples: sampleCount
|
|
235
|
+
};
|
|
236
|
+
break;
|
|
217
237
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
238
|
+
case dtfusionrna:
|
|
239
|
+
lesionCounts.byType["fusion"] = {
|
|
240
|
+
count: lesionTypeCounts["fusion"] || 0,
|
|
241
|
+
capped: isCapped,
|
|
242
|
+
samples: samplesPerType.get(type)?.size || 0
|
|
243
|
+
};
|
|
244
|
+
break;
|
|
245
|
+
case dtsv:
|
|
246
|
+
lesionCounts.byType["sv"] = {
|
|
247
|
+
count: lesionTypeCounts["sv"] || 0,
|
|
248
|
+
capped: isCapped,
|
|
249
|
+
samples: samplesPerType.get(type)?.size || 0
|
|
250
|
+
};
|
|
251
|
+
break;
|
|
221
252
|
}
|
|
222
253
|
}
|
|
254
|
+
processingSummary.lesionCounts = lesionCounts;
|
|
223
255
|
return { lesions, processingSummary };
|
|
224
256
|
}
|
|
225
257
|
async function processSampleMlst(sampleName, mlst, request, tracker) {
|
|
226
258
|
const sampleLesions = [];
|
|
259
|
+
const contributedTypes = /* @__PURE__ */ new Set();
|
|
227
260
|
for (const m of mlst) {
|
|
228
261
|
switch (m.dt) {
|
|
229
262
|
case dtsnvindel: {
|
|
@@ -236,6 +269,7 @@ async function processSampleMlst(sampleName, mlst, request, tracker) {
|
|
|
236
269
|
if (les && entry) {
|
|
237
270
|
entry.count++;
|
|
238
271
|
sampleLesions.push(les);
|
|
272
|
+
contributedTypes.add(dtsnvindel);
|
|
239
273
|
}
|
|
240
274
|
break;
|
|
241
275
|
}
|
|
@@ -249,6 +283,7 @@ async function processSampleMlst(sampleName, mlst, request, tracker) {
|
|
|
249
283
|
if (les && cnv) {
|
|
250
284
|
cnv.count++;
|
|
251
285
|
sampleLesions.push(les);
|
|
286
|
+
contributedTypes.add(dtcnv);
|
|
252
287
|
}
|
|
253
288
|
break;
|
|
254
289
|
}
|
|
@@ -273,6 +308,7 @@ async function processSampleMlst(sampleName, mlst, request, tracker) {
|
|
|
273
308
|
sampleLesions.push(les);
|
|
274
309
|
fusion.count++;
|
|
275
310
|
}
|
|
311
|
+
contributedTypes.add(dtfusionrna);
|
|
276
312
|
}
|
|
277
313
|
break;
|
|
278
314
|
}
|
|
@@ -297,6 +333,7 @@ async function processSampleMlst(sampleName, mlst, request, tracker) {
|
|
|
297
333
|
sampleLesions.push(les);
|
|
298
334
|
sv.count++;
|
|
299
335
|
}
|
|
336
|
+
contributedTypes.add(dtsv);
|
|
300
337
|
}
|
|
301
338
|
break;
|
|
302
339
|
}
|
|
@@ -304,7 +341,7 @@ async function processSampleMlst(sampleName, mlst, request, tracker) {
|
|
|
304
341
|
break;
|
|
305
342
|
}
|
|
306
343
|
}
|
|
307
|
-
return { sampleLesions };
|
|
344
|
+
return { sampleLesions, contributedTypes };
|
|
308
345
|
}
|
|
309
346
|
function filterAndConvertSnvIndel(sampleName, entry, options) {
|
|
310
347
|
if (!options?.consequences) {
|
package/routes/termdb.violin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { violinPayload } from "#types/checkers";
|
|
2
|
-
import { scaleLinear, scaleLog
|
|
2
|
+
import { scaleLinear, scaleLog } from "d3";
|
|
3
3
|
import { run_rust } from "@sjcrh/proteinpaint-rust";
|
|
4
4
|
import { getData } from "../src/termdb.matrix.js";
|
|
5
5
|
import { createCanvas } from "canvas";
|
|
@@ -181,7 +181,7 @@ async function createCanvasImg(q, result, ds) {
|
|
|
181
181
|
const chart = result.charts[k];
|
|
182
182
|
const plot2Values = {};
|
|
183
183
|
for (const plot of chart.plots) plot2Values[plot.label] = plot.values;
|
|
184
|
-
const densities = await getDensities(plot2Values
|
|
184
|
+
const densities = await getDensities(plot2Values);
|
|
185
185
|
let axisScale;
|
|
186
186
|
const useLog = q.unit == "log";
|
|
187
187
|
if (useLog) {
|
|
@@ -229,12 +229,11 @@ async function createCanvasImg(q, result, ds) {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
async function getDensity(values) {
|
|
232
|
-
const
|
|
233
|
-
const result = await getDensities({ plot: values }, min, max);
|
|
232
|
+
const result = await getDensities({ plot: values });
|
|
234
233
|
return result.plot;
|
|
235
234
|
}
|
|
236
|
-
async function getDensities(plot2Values
|
|
237
|
-
const plot2Density = JSON.parse(await run_R("density.R", JSON.stringify({ plot2Values
|
|
235
|
+
async function getDensities(plot2Values) {
|
|
236
|
+
const plot2Density = JSON.parse(await run_R("density.R", JSON.stringify({ plot2Values })));
|
|
238
237
|
const densities = {};
|
|
239
238
|
for (const plot in plot2Density) {
|
|
240
239
|
const result = plot2Density[plot];
|