@sjcrh/proteinpaint-server 2.145.1-0 → 2.145.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.
@@ -303,7 +303,6 @@ function termdb_test_default() {
303
303
  geneExpression: {
304
304
  src: "native",
305
305
  file: "files/hg38/TermdbTest/rnaseq/TermdbTest.fpkm.matrix.new.h5",
306
- newformat: true,
307
306
  unit: "FPKM"
308
307
  },
309
308
  ssGSEA: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.145.1-0",
3
+ "version": "2.145.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",
@@ -63,9 +63,9 @@
63
63
  "@sjcrh/augen": "2.143.0",
64
64
  "@sjcrh/proteinpaint-python": "2.144.0",
65
65
  "@sjcrh/proteinpaint-r": "2.145.1-0",
66
- "@sjcrh/proteinpaint-rust": "2.145.1-0",
66
+ "@sjcrh/proteinpaint-rust": "2.145.1",
67
67
  "@sjcrh/proteinpaint-shared": "2.145.1-0",
68
- "@sjcrh/proteinpaint-types": "2.145.1-0",
68
+ "@sjcrh/proteinpaint-types": "2.145.1-1",
69
69
  "@types/express": "^5.0.0",
70
70
  "@types/express-session": "^1.18.1",
71
71
  "better-sqlite3": "^9.4.1",
@@ -213,22 +213,6 @@ async function validate_query_geneExpression(ds, genome) {
213
213
  }
214
214
  throw "unknown queries.geneExpression.src";
215
215
  }
216
- async function queryGeneExpression(hdf5_file, geneNames) {
217
- const jsonInput = JSON.stringify({
218
- hdf5_file,
219
- gene: geneNames
220
- });
221
- try {
222
- const result = await run_rust("readHDF5", jsonInput);
223
- if (!result || result.length === 0) {
224
- throw new Error("Failed to retrieve expression data: Empty or missing response");
225
- }
226
- return result;
227
- } catch (error) {
228
- console.error(`Error querying gene expression for ${geneNames}`);
229
- throw error;
230
- }
231
- }
232
216
  async function queryHDF5(hdf5_file, query) {
233
217
  const jsonInput = JSON.stringify({
234
218
  hdf5_file,
@@ -250,34 +234,16 @@ async function validateNative(q, ds) {
250
234
  q.samples = [];
251
235
  try {
252
236
  await utils.file_is_readable(q.file);
253
- let tmp;
254
- if (q.newformat) {
255
- tmp = await run_rust("readH5", JSON.stringify({ hdf5_file: q.file, validate: true }));
256
- } else {
257
- tmp = await run_rust("validateHDF5", JSON.stringify({ hdf5_file: q.file }));
258
- }
237
+ const tmp = await run_rust("readH5", JSON.stringify({ hdf5_file: q.file, validate: true }));
259
238
  const vr = JSON.parse(tmp);
260
239
  if (vr.status !== "success") throw vr.message;
261
- if (q.newformat) {
262
- if (!vr.samples?.length) throw "HDF5 file has no samples, please check file.";
263
- for (const sn of vr.samples) {
264
- const si = ds.cohort.termdb.q.sampleName2id(sn);
265
- if (si == void 0) throw `unknown sample ${sn} from HDF5 ${q.file}`;
266
- q.samples.push(si);
267
- }
268
- console.log(`${ds.label}: geneExpression HDF5 file validated. Format: ${vr.format}, Samples:`, vr.samples.length);
269
- } else {
270
- if (!vr.sampleNames?.length) throw "HDF5 file has no samples, please check file.";
271
- for (const sn of vr.sampleNames) {
272
- const si = ds.cohort.termdb.q.sampleName2id(sn);
273
- if (si == void 0) throw `unknown sample ${sn} from HDF5 ${q.file}`;
274
- q.samples.push(si);
275
- }
276
- console.log(
277
- `${ds.label}: geneExpression HDF5 file validated. Format: ${vr.format}, Samples:`,
278
- vr.sampleNames.length
279
- );
240
+ if (!vr.samples?.length) throw "HDF5 file has no samples, please check file.";
241
+ for (const sn of vr.samples) {
242
+ const si = ds.cohort.termdb.q.sampleName2id(sn);
243
+ if (si == void 0) throw `unknown sample ${sn} from HDF5 ${q.file}`;
244
+ q.samples.push(si);
280
245
  }
246
+ console.log(`${ds.label}: geneExpression HDF5 file validated. Format: ${vr.format}, Samples:`, vr.samples.length);
281
247
  } catch (error) {
282
248
  throw `${ds.label}: Failed to validate geneExpression HDF5 file: ${error}`;
283
249
  }
@@ -310,63 +276,32 @@ async function validateNative(q, ds) {
310
276
  return { term2sample2value, byTermId };
311
277
  }
312
278
  const time1 = Date.now();
313
- let geneData;
314
- if (q.newformat) {
315
- geneData = JSON.parse(await queryHDF5(q.file, geneNames));
316
- } else {
317
- geneData = JSON.parse(await queryGeneExpression(q.file, geneNames));
318
- }
279
+ const geneData = JSON.parse(await queryHDF5(q.file, geneNames));
319
280
  mayLog("Time taken to run gene query:", formatElapsedTime(Date.now() - time1));
320
- if (q.newformat) {
321
- const genesData = geneData.query_output || {};
322
- if (!genesData) throw "No expression data returned from HDF5 query";
323
- for (const tw of param.terms) {
324
- if (!tw.term.gene) continue;
325
- const geneResult = genesData[tw.term.gene];
326
- if (!geneResult) {
327
- console.warn(`No data found for gene ${tw.term.gene} in the response`);
328
- continue;
329
- }
330
- const samplesData = geneResult.samples || {};
331
- const s2v = {};
332
- for (const sampleName in samplesData) {
333
- const sampleId = ds.cohort.termdb.q.sampleName2id(sampleName);
334
- if (!sampleId) continue;
335
- if (limitSamples && !limitSamples.has(sampleId)) continue;
336
- s2v[sampleId] = samplesData[sampleName];
337
- }
338
- if (Object.keys(s2v).length) {
339
- term2sample2value.set(tw.$id, s2v);
340
- }
281
+ const genesData = geneData.query_output || {};
282
+ if (!genesData) throw "No expression data returned from HDF5 query";
283
+ for (const tw of param.terms) {
284
+ if (!tw.term.gene) continue;
285
+ const geneResult = genesData[tw.term.gene];
286
+ if (!geneResult) {
287
+ console.warn(`No data found for gene ${tw.term.gene} in the response`);
288
+ continue;
341
289
  }
342
- if (term2sample2value.size == 0) {
343
- throw "No data available for the input " + param.terms?.map((tw) => tw.term.gene).join(", ");
290
+ const samplesData = geneResult.samples || {};
291
+ const s2v = {};
292
+ for (const sampleName in samplesData) {
293
+ const sampleId = ds.cohort.termdb.q.sampleName2id(sampleName);
294
+ if (!sampleId) continue;
295
+ if (limitSamples && !limitSamples.has(sampleId)) continue;
296
+ s2v[sampleId] = samplesData[sampleName];
344
297
  }
345
- } else {
346
- const genesData = geneData.genes || { [geneNames[0]]: geneData };
347
- for (const tw of param.terms) {
348
- if (!tw.term.gene) continue;
349
- const geneResult = genesData[tw.term.gene];
350
- if (!geneResult) {
351
- console.warn(`No data found for gene ${tw.term.gene} in the response`);
352
- continue;
353
- }
354
- const samplesData = geneResult.samples || {};
355
- const s2v = {};
356
- for (const [sampleName, value] of Object.entries(samplesData)) {
357
- const sampleId = ds.cohort.termdb.q.sampleName2id(sampleName);
358
- if (!sampleId) continue;
359
- if (limitSamples && !limitSamples.has(sampleId)) continue;
360
- s2v[sampleId] = value;
361
- }
362
- if (Object.keys(s2v).length) {
363
- term2sample2value.set(tw.$id, s2v);
364
- }
365
- }
366
- if (term2sample2value.size == 0) {
367
- throw "No data available for the input " + param.terms?.map((tw) => tw.term.gene).join(", ");
298
+ if (Object.keys(s2v).length) {
299
+ term2sample2value.set(tw.$id, s2v);
368
300
  }
369
301
  }
302
+ if (term2sample2value.size == 0) {
303
+ throw "No data available for the input " + param.terms?.map((tw) => tw.term.gene).join(", ");
304
+ }
370
305
  return { term2sample2value, byTermId, bySampleId };
371
306
  };
372
307
  }