@sjcrh/proteinpaint-server 2.40.6 → 2.40.8

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.40.6",
3
+ "version": "2.40.8",
4
4
  "description": "a genomics visualization tool for exploring a cohort's genotype and phenotype data",
5
5
  "main": "server.js",
6
6
  "bin": "start.js",
@@ -157,7 +157,7 @@ export async function validate_query_geneExpression(ds: any, genome: any) {
157
157
  return
158
158
  }
159
159
  if (q.src == 'native') {
160
- validateNative(q, ds, genome)
160
+ await validateNative(q, ds, genome)
161
161
  return
162
162
  }
163
163
  throw 'unknown queries.geneExpression.src'
@@ -165,6 +165,7 @@ export async function validate_query_geneExpression(ds: any, genome: any) {
165
165
 
166
166
  async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any) {
167
167
  q.file = path.join(serverconfig.tpmasterdir, q.file)
168
+ if (!q.samples) q.samples = []
168
169
  await utils.validate_tabixfile(q.file)
169
170
  q.nochr = await utils.tabix_is_nochr(q.file, null, genome)
170
171
  q.samples = [] as number[]
@@ -177,7 +178,7 @@ async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any
177
178
  if (l.slice(0, 4).join('\t') != '#chr\tstart\tstop\tgene') throw 'header line has wrong content for columns 1-4'
178
179
  for (let i = 4; i < l.length; i++) {
179
180
  const id = ds.cohort.termdb.q.sampleName2id(l[i])
180
- if (id == undefined) throw 'unknown sample from header'
181
+ if (id == undefined) throw 'queries.geneExpression: unknown sample from header: ' + l[i]
181
182
  q.samples.push(id)
182
183
  }
183
184
  console.log(q.samples.length, 'samples from geneExpression of', ds.label)
@@ -203,13 +204,14 @@ async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any
203
204
  // has at least 1 sample passing filter and with exp data
204
205
  // TODO what if there's just 1 sample not enough for clustering?
205
206
  const bySampleId = {}
207
+ const samples = q.samples || []
206
208
  if (limitSamples) {
207
209
  for (const sid of limitSamples) {
208
210
  bySampleId[sid] = { label: ds.cohort.termdb.q.id2sampleName(sid) }
209
211
  }
210
212
  } else {
211
213
  // use all samples with exp data
212
- for (const sid of q.samples) {
214
+ for (const sid of samples) {
213
215
  bySampleId[sid] = { label: ds.cohort.termdb.q.id2sampleName(sid) }
214
216
  }
215
217
  }
@@ -238,7 +240,7 @@ async function validateNative(q: GeneExpressionQueryNative, ds: any, genome: any
238
240
  // case-insensitive match! FIXME if g.gene is alias won't work
239
241
  if (l[3].toLowerCase() != g.gene.toLowerCase()) return
240
242
  for (let i = 4; i < l.length; i++) {
241
- const sampleId = q.samples[i - 4]
243
+ const sampleId = samples[i - 4]
242
244
  if (limitSamples && !limitSamples.has(sampleId)) continue // doing filtering and sample of current column is not used
243
245
  // if l[i] is blank string?
244
246
  const v = Number(l[i])
@@ -1,11 +1,11 @@
1
1
  import { getdescrstatsRequest, getdescrstatsResponse } from '#shared/types/routes/termdb.getdescrstats.ts'
2
- import * as termdbsql from '../src/termdb.sql.js'
2
+ import { get_rows_by_one_key } from '../src/termdb.sql.js'
3
3
  import Summarystats from '../shared/descriptive.stats.js'
4
4
 
5
5
  export const api: any = {
6
6
  endpoint: 'termdb/descrstats',
7
7
  methods: {
8
- get: {
8
+ all: {
9
9
  init,
10
10
  request: {
11
11
  typeId: 'getdescrstatsRequest'
@@ -20,7 +20,6 @@ export const api: any = {
20
20
  genome: 'hg38-test',
21
21
  dslabel: 'TermdbTest',
22
22
  embedder: 'localhost',
23
- getdescrstats: 1,
24
23
  tid: 'hrtavg',
25
24
  filter: {
26
25
  type: 'tvslst',
@@ -51,10 +50,6 @@ export const api: any = {
51
50
  }
52
51
  }
53
52
  ]
54
- },
55
- post: {
56
- alternativeFor: 'get',
57
- init
58
53
  }
59
54
  }
60
55
  }
@@ -84,14 +79,14 @@ async function trigger_getdescrstats(q: any, res: any, ds: any) {
84
79
  const term = ds.cohort.termdb.q.termjsonByOneid(q.tid)
85
80
  if (!term) throw 'invalid termid'
86
81
  if (term.type != 'float' && term.type != 'integer') throw 'not numerical term'
87
- const rows = await termdbsql.get_rows_by_one_key({
82
+ const rows = await get_rows_by_one_key({
88
83
  ds,
89
84
  key: q.tid,
90
- filter: q.filter ? (typeof q.filter == 'string' ? JSON.parse(q.filter) : q.filter) : null
85
+ filter: q.filter
91
86
  })
92
87
  const values: number[] = []
93
88
  for (const { value } of rows) {
94
- if (term.values && term.values[value] && term.values[value].uncomputable) {
89
+ if (term.values?.[value]?.uncomputable) {
95
90
  // skip uncomputable values
96
91
  continue
97
92
  }