@sjcrh/proteinpaint-server 2.108.0 → 2.108.3-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.108.0",
3
+ "version": "2.108.3-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",
@@ -59,7 +59,7 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@sjcrh/augen": "2.87.0",
62
- "@sjcrh/proteinpaint-rust": "2.99.0",
62
+ "@sjcrh/proteinpaint-rust": "2.108.3-0",
63
63
  "@sjcrh/proteinpaint-shared": "2.108.0",
64
64
  "@sjcrh/proteinpaint-types": "2.108.0",
65
65
  "@types/express": "^5.0.0",
package/routes/gdc.maf.js CHANGED
@@ -101,8 +101,10 @@ async function listMafFiles(q, ds) {
101
101
  if (normalTypeName)
102
102
  file.sample_types.push(normalTypeName);
103
103
  }
104
+ file.sample_types = [...new Set(file.sample_types)];
104
105
  files.push(file);
105
106
  }
107
+ files.sort((a, b) => b.file_size - a.file_size);
106
108
  const result = {
107
109
  files,
108
110
  filesTotal: re.data.pagination.total,
@@ -1,6 +1,6 @@
1
1
  import ky from "ky";
2
2
  import { joinUrl } from "#shared/joinUrl.js";
3
- import { run_rust_stream } from "@sjcrh/proteinpaint-rust";
3
+ import { stream_rust } from "@sjcrh/proteinpaint-rust";
4
4
  import { gdcMafPayload } from "#types/checkers";
5
5
  import { maxTotalSizeCompressed } from "./gdc.maf.ts";
6
6
  import { mayLog } from "#src/helpers.ts";
@@ -46,19 +46,26 @@ async function buildMaf(q, res, ds) {
46
46
  host: joinUrl(host.rest, "data")
47
47
  // must use the /data/ endpoint from current host
48
48
  };
49
- const rustStream = run_rust_stream("gdcmaf", JSON.stringify(arg));
50
- res.setHeader("Content-Type", "application/octet-stream");
51
- res.setHeader("Content-Disposition", "attachment; filename=cohort.maf.gz");
52
- rustStream.pipe(res);
53
- rustStream.on("end", () => {
49
+ const boundary = "GDC_MAF_MULTIPART_BOUNDARY";
50
+ res.setHeader("content-type", `multipart/mixed; boundary=${boundary}`);
51
+ res.write(`--${boundary}`);
52
+ res.write("\ncontent-disposition: attachment; filename=cohort.maf.gz");
53
+ res.write("\ncontent-type: application/octet-stream\n\n");
54
+ res.flush();
55
+ const rustStream = stream_rust("gdcmaf", JSON.stringify(arg), emitJson);
56
+ rustStream.pipe(res, { end: false });
57
+ function emitJson(data, end = true) {
58
+ res.write(`
59
+ --${boundary}`);
60
+ res.write("\ncontent-type: application/json");
61
+ const json = typeof data === "string" ? data : JSON.stringify(data || { ok: true, status: "ok" });
62
+ res.write("\n\n" + json);
63
+ res.write(`
64
+ --${boundary}--`);
54
65
  mayLog("rust gdcmaf", Date.now() - t0);
55
- res.end();
56
- });
57
- rustStream.on("error", (err) => {
58
- console.error(err);
59
- res.statusCode = 500;
60
- res.end("Internal Server Error");
61
- });
66
+ if (end)
67
+ res.end();
68
+ }
62
69
  }
63
70
  async function getFileLstUnderSizeLimit(lst, host) {
64
71
  if (lst.length == 0)
@@ -74,6 +74,12 @@ async function getResult(q, ds, genome) {
74
74
  ;
75
75
  ({ term2sample2value, byTermId, bySampleId } = await ds.queries[q.dataType].get(_q));
76
76
  }
77
+ for (const [term, obj] of term2sample2value) {
78
+ if (Object.keys(obj).length === 0) {
79
+ term2sample2value.delete(term);
80
+ delete byTermId[term];
81
+ }
82
+ }
77
83
  if (term2sample2value.size == 0)
78
84
  throw "no data";
79
85
  if (term2sample2value.size == 1) {