@sjcrh/proteinpaint-server 2.153.1-2 → 2.155.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.153.1-2",
3
+ "version": "2.155.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",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@sjcrh/augen": "2.143.0",
64
- "@sjcrh/proteinpaint-python": "2.153.0",
64
+ "@sjcrh/proteinpaint-python": "2.153.1-3",
65
65
  "@sjcrh/proteinpaint-r": "2.152.1-0",
66
66
  "@sjcrh/proteinpaint-rust": "2.152.1-0",
67
67
  "@sjcrh/proteinpaint-shared": "2.153.1-2",
@@ -1,6 +1,8 @@
1
1
  import { FilterTermValuesPayload } from "#types/checkers";
2
- import { getData, getSamplesPerFilter } from "../src/termdb.matrix.js";
3
- import { authApi } from "../src/auth.js";
2
+ import { getData } from "../src/termdb.matrix.js";
3
+ import { authApi } from "#src/auth.js";
4
+ import { filterJoin } from "#shared/filter.js";
5
+ import { get_samples } from "../src/termdb.sql.js";
4
6
  const api = {
5
7
  endpoint: "termdb/filterTermValues",
6
8
  methods: {
@@ -28,7 +30,6 @@ function init({ genomes }) {
28
30
  };
29
31
  }
30
32
  async function getFilters(query, ds) {
31
- if (!query.filterByUserSites) authApi.mayAdjustFilter(query, ds, query.terms);
32
33
  const samplesPerFilter = await getSamplesPerFilter(query, ds);
33
34
  const filtersData = await getData(
34
35
  {
@@ -43,6 +44,23 @@ async function getFilters(query, ds) {
43
44
  }
44
45
  return { ...tw2List };
45
46
  }
47
+ async function getSamplesPerFilter(q, ds) {
48
+ q.ds = ds;
49
+ const samples = {};
50
+ const userFilter = q.filter ? structuredClone(q.filter) : null;
51
+ if (!q.filterByUserSites) {
52
+ q.__protected__.ignoredTermIds.push(q.facilityTW.term.id);
53
+ authApi.mayAdjustFilter(q, ds, q.terms);
54
+ }
55
+ for (const id in q.filters) {
56
+ const termfilter = id == q.facilityTW.term.id ? userFilter : q.filter;
57
+ let filter = q.filters[id];
58
+ if (q.filter) filter = filterJoin([termfilter, q.filters[id]]);
59
+ const result = (await get_samples({ filter, __protected__: q.__protected__ }, q.ds)).map((i) => i.id);
60
+ samples[id] = Array.from(new Set(result));
61
+ }
62
+ return samples;
63
+ }
46
64
  function getList(samplesPerFilter, filtersData, tw, showAll) {
47
65
  const values = Object.values(tw.term.values);
48
66
  values.sort((v1, v2) => v1.label.localeCompare(v2.label));