@sjcrh/proteinpaint-server 2.69.0 → 2.69.1-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.69.0",
3
+ "version": "2.69.1-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",
@@ -1,4 +1,5 @@
1
1
  import fs from "fs";
2
+ import path from "path";
2
3
  import { spawn } from "child_process";
3
4
  import { Readable } from "stream";
4
5
  import serverconfig from "../src/serverconfig.js";
@@ -22,7 +23,20 @@ function init({ genomes }) {
22
23
  return async (req, res) => {
23
24
  try {
24
25
  const results = await run_genesetEnrichment_analysis(req.query, genomes);
25
- res.send(results);
26
+ if (!req.query.geneset_name) {
27
+ res.send(results);
28
+ } else {
29
+ res.sendFile(results, (err) => {
30
+ fs.unlink(results, (del_err) => {
31
+ if (del_err) {
32
+ console.error("Error deleting file " + results + ":", del_err);
33
+ }
34
+ });
35
+ if (err) {
36
+ res.status(404).send("Image not found");
37
+ }
38
+ });
39
+ }
26
40
  } catch (e) {
27
41
  res.send({ status: "error", error: e.message || e });
28
42
  }
@@ -36,7 +50,10 @@ async function run_genesetEnrichment_analysis(q, genomes) {
36
50
  fold_change: q.fold_change,
37
51
  db: genomes[q.genome].termdbs.msigdb.cohort.db.connection.name,
38
52
  // For now msigdb has been added, but later databases other than msigdb may be used
39
- gene_set_group: q.geneSetGroup
53
+ geneset_group: q.geneSetGroup,
54
+ cachedir: serverconfig.cachedir,
55
+ geneset_name: q.geneset_name,
56
+ pickle_file: q.pickle_file
40
57
  };
41
58
  const gsea_output = await run_gsea(
42
59
  `${serverconfig.binpath}/utils/gsea.py`,
@@ -44,14 +61,25 @@ async function run_genesetEnrichment_analysis(q, genomes) {
44
61
  // "/" is needed for python to accept the bracket "{" as a bracket
45
62
  );
46
63
  let result;
64
+ let data_found = false;
65
+ let image_found = false;
47
66
  for (const line of gsea_output.split("\n")) {
48
67
  if (line.startsWith("result: ")) {
49
68
  result = JSON.parse(line.replace("result: ", ""));
69
+ data_found = true;
70
+ } else if (line.startsWith("image: ")) {
71
+ result = JSON.parse(line.replace("image: ", ""));
72
+ image_found = true;
50
73
  } else {
51
74
  console.log(line);
52
75
  }
53
76
  }
54
- return result;
77
+ if (data_found) {
78
+ return result;
79
+ } else if (image_found) {
80
+ const imagePath = path.join(serverconfig.cachedir, result.image_file);
81
+ return imagePath;
82
+ }
55
83
  }
56
84
  async function run_gsea(path2, data) {
57
85
  try {