@sjcrh/proteinpaint-server 2.137.2-2 → 2.137.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.
@@ -1,7 +1,3 @@
1
- import serverconfig from "@sjcrh/proteinpaint-server/src/serverconfig.js";
2
- import * as path from "path";
3
- import { existsSync, unlinkSync, symlinkSync, access, constants } from "fs";
4
- copyDataFilesFromRepo2Tp();
5
1
  function termdb_test_default() {
6
2
  return {
7
3
  isMds3: true,
@@ -141,7 +137,7 @@ function termdb_test_default() {
141
137
  {
142
138
  chartType: "barchart",
143
139
  term: { id: "diaggrp" },
144
- settings: { barchart: { colorBars: true, showPercent: true, colorUsing: "generated" } }
140
+ settings: { barchart: { colorBars: true, showPercent: true, colorUsing: "present" } }
145
141
  }
146
142
  ]
147
143
  },
@@ -345,27 +341,6 @@ function termdb_test_default() {
345
341
  }
346
342
  };
347
343
  }
348
- function copyDataFilesFromRepo2Tp() {
349
- if (existsSync("/home/root/pp"))
350
- return;
351
- const targetDir = path.join(serverconfig.binpath, "test/tp/files/hg38/TermdbTest");
352
- const datadir = path.join(serverconfig.tpmasterdir, "files/hg38/TermdbTest");
353
- if (datadir == `${serverconfig.binpath}/test/tp`) {
354
- access(datadir, constants.R_OK | constants.W_OK, (err) => {
355
- if (!err) {
356
- try {
357
- if (!existsSync(datadir))
358
- unlinkSync(datadir);
359
- symlinkSync(targetDir, datadir);
360
- } catch (error) {
361
- console.warn("Error while coping data files from Repo to Tp: " + error);
362
- }
363
- } else {
364
- console.warn(`user doesn't have sufficient permissions for `);
365
- }
366
- });
367
- }
368
- }
369
344
  export {
370
345
  termdb_test_default as default
371
346
  };
@@ -0,0 +1,57 @@
1
+ import serverconfig from '@sjcrh/proteinpaint-server/src/serverconfig.js'
2
+ import * as path from 'path'
3
+ import fs from 'fs'
4
+ import { spawnSync } from 'child_process'
5
+
6
+ /*
7
+ copyDataFilesFromRepo2Tp()
8
+ - does not work when tp is not writable, such as when the tp dir is mounted as read-only onto a container
9
+ - must be called before genome and dataset init steps in initGenomeDs(),
10
+ such as by calling in the genome js file like in genome/hg38.test.ts
11
+ */
12
+ export async function copyDataFilesFromRepo2Tp(testPath) {
13
+ // when running tests where the tp directory is not writable (such as from inside a container),
14
+ // the workflow script should copy the server/test/tp dir as serverconfig.tpmasterdir
15
+ // and not trigger the symlinks below
16
+ if (fs.existsSync('/home/root/pp')) {
17
+ console.warn('skipped TermdbTest copying, assumed the mounted host tp dir is not writable from within a container')
18
+ return
19
+ }
20
+
21
+ const targetDir = path.join(serverconfig.binpath, 'test/tp', testPath)
22
+ const datadir = path.join(serverconfig.tpmasterdir, testPath)
23
+
24
+ // no need to copy files or set the symlink when the target TermdbTest dir
25
+ // already equals the datadir under serverconfig.tpmasterdir
26
+ if (targetDir === datadir) return
27
+
28
+ try {
29
+ await fs.promises.access(serverconfig.tpmasterdir)
30
+ } catch {
31
+ // the tp dir is not readable and/or writable,
32
+ // may still be okay if the tp/files/hg38/TermdbTest already exists and is up-to-date
33
+ console.log(`!!! insufficient permissions to create or update TermdbTest directory or symlink !!!`)
34
+ return
35
+ }
36
+
37
+ try {
38
+ if (!fs.existsSync(datadir)) {
39
+ fs.symlinkSync(targetDir, datadir)
40
+ } else if (fs.statSync(datadir).isDirectory()) {
41
+ // support an option to have an actual TermdbTest dir locally instead of a symlink,
42
+ // to make it easier to switch between native or container dev/test process,
43
+ // since a local symlink will not work as a container mount
44
+ console.log(`copying TermdbTest files to tp dir ...`)
45
+ // do not delete, copy files from repo to tp
46
+ const ps = spawnSync(`rsync`, ['-av', `${targetDir}/`, datadir], { encoding: 'utf-8' })
47
+ if (ps.stderr) throw ps.stderr
48
+ //console.log(421, [ps.stdout, ps.stderr])
49
+ } else {
50
+ console.log('replacing the TermdbTest symlink ...')
51
+ fs.unlinkSync(datadir)
52
+ fs.symlinkSync(targetDir, datadir)
53
+ }
54
+ } catch (error) {
55
+ console.warn('Error while copying data files from Repo to Tp: ', error)
56
+ }
57
+ }
@@ -1,3 +1,5 @@
1
+ import { copyDataFilesFromRepo2Tp } from "./copyDataFilesFromRepo2Tp.js";
2
+ await copyDataFilesFromRepo2Tp("files/hg38/TermdbTest");
1
3
  const genome = {
2
4
  species: "human",
3
5
  genomefile: "NA",
@@ -8,8 +10,9 @@ const genome = {
8
10
  msigdb: {
9
11
  label: "MSigDB",
10
12
  cohort: {
11
- db: { file: "files/hg38/TermdbTest/msigdb/db" },
13
+ // NOTE: in the dev environment, sjpp/start.js is
12
14
  // nest file under TermdbTest since the folder is auto symlinked
15
+ db: { file: "files/hg38/TermdbTest/msigdb/db" },
13
16
  termdb: {
14
17
  isGeneSetTermdb: true
15
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-server",
3
- "version": "2.137.2-2",
3
+ "version": "2.137.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",
@@ -64,7 +64,7 @@
64
64
  "@sjcrh/proteinpaint-r": "2.137.2-0",
65
65
  "@sjcrh/proteinpaint-rust": "2.137.2-0",
66
66
  "@sjcrh/proteinpaint-shared": "2.137.2-2",
67
- "@sjcrh/proteinpaint-types": "2.137.2-2",
67
+ "@sjcrh/proteinpaint-types": "2.137.2",
68
68
  "@types/express": "^5.0.0",
69
69
  "@types/express-session": "^1.18.1",
70
70
  "better-sqlite3": "^9.4.1",