@sjcrh/proteinpaint-server 2.131.0 → 2.132.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.131.0",
3
+ "version": "2.132.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",
@@ -63,9 +63,9 @@
63
63
  "@sjcrh/augen": "2.121.0",
64
64
  "@sjcrh/proteinpaint-python": "2.118.0",
65
65
  "@sjcrh/proteinpaint-r": "2.130.0",
66
- "@sjcrh/proteinpaint-rust": "2.130.0",
67
- "@sjcrh/proteinpaint-shared": "2.129.6",
68
- "@sjcrh/proteinpaint-types": "2.131.0",
66
+ "@sjcrh/proteinpaint-rust": "2.132.1-0",
67
+ "@sjcrh/proteinpaint-shared": "2.132.0",
68
+ "@sjcrh/proteinpaint-types": "2.132.1-0",
69
69
  "@types/express": "^5.0.0",
70
70
  "@types/express-session": "^1.18.1",
71
71
  "better-sqlite3": "^9.4.1",
@@ -29,14 +29,24 @@ function init({ genomes }) {
29
29
  const ds = g.datasets?.GDC;
30
30
  if (!ds)
31
31
  throw "hg38 GDC missing";
32
- const result = {
33
- files: [],
34
- filesTotal: 0,
35
- maxTotalSizeCompressed: 0,
36
- fileCounts: { maf: 0 }
37
- };
38
- await mayListMafFiles(req.query, result, ds);
39
- await mayListCnvFiles(req.query, result, ds);
32
+ console.log("GRIN2 List Route Received:", JSON.stringify(req.query, null, 2));
33
+ const result = {};
34
+ if (req.query.mafOptions) {
35
+ result.mafFiles = {
36
+ files: [],
37
+ filesTotal: 0,
38
+ maxTotalSizeCompressed: 0,
39
+ fileCounts: { maf: 0 }
40
+ };
41
+ await listMafFiles(req.query, result, ds);
42
+ }
43
+ if (req.query.cnvOptions) {
44
+ result.cnvFiles = {
45
+ files: [],
46
+ maxTotalSizeCompressed
47
+ };
48
+ await listCnvFiles(req.query, result, ds);
49
+ }
40
50
  res.send(result);
41
51
  } catch (e) {
42
52
  if (e.stack)
@@ -45,9 +55,12 @@ function init({ genomes }) {
45
55
  }
46
56
  };
47
57
  }
48
- async function mayListMafFiles(q, result, ds) {
58
+ async function listMafFiles(q, result, ds) {
49
59
  if (!q.mafOptions)
50
60
  return;
61
+ if (!result.mafFiles) {
62
+ throw new Error("result.mafFiles must be initialized before calling listMafFiles");
63
+ }
51
64
  const filters = {
52
65
  op: "and",
53
66
  content: [
@@ -158,12 +171,12 @@ If you want to include it, please increase the maxFileSizeAllowed in the code.`
158
171
  );
159
172
  }
160
173
  deduplicatedFiles.sort((a, b) => b.file_size - a.file_size);
161
- result.files.push(...deduplicatedFiles);
162
- result.filesTotal = re.data.pagination.total;
163
- if (result.fileCounts) {
164
- result.fileCounts.maf = files.length;
174
+ result.mafFiles.files.push(...deduplicatedFiles);
175
+ result.mafFiles.filesTotal = re.data.pagination.total;
176
+ if (result.mafFiles.fileCounts) {
177
+ result.mafFiles.fileCounts.maf = files.length;
165
178
  }
166
- result.deduplicationStats = {
179
+ result.mafFiles.deduplicationStats = {
167
180
  originalFileCount: files.length,
168
181
  deduplicatedFileCount: deduplicatedFiles.length,
169
182
  duplicatesRemoved,
@@ -171,8 +184,7 @@ If you want to include it, please increase the maxFileSizeAllowed in the code.`
171
184
  filteredFiles
172
185
  };
173
186
  }
174
- async function mayListCnvFiles(q, result, ds) {
175
- result.cnvFiles = { files: [] };
187
+ async function listCnvFiles(q, result, ds) {
176
188
  if (!q.cnvOptions) {
177
189
  console.log("No cnvOptions provided, returning empty cnvFiles");
178
190
  return;
@@ -240,11 +252,11 @@ async function mayListCnvFiles(q, result, ds) {
240
252
  cnvFiles.push(file);
241
253
  }
242
254
  }
243
- result.cnvFiles = { files: cnvFiles };
255
+ result.cnvFiles = { files: cnvFiles, maxTotalSizeCompressed };
244
256
  console.log(`Successfully processed ${cnvFiles.length} CNV files`);
245
257
  } catch (error) {
246
258
  console.error("Error fetching CNV files:", error);
247
- result.cnvFiles = { files: [] };
259
+ result.cnvFiles = { files: [], maxTotalSizeCompressed };
248
260
  }
249
261
  }
250
262
  export {
@@ -21,13 +21,18 @@ function parseJsonlOutput(rustOutput) {
21
21
  const lines = rustOutput.trim().split("\n");
22
22
  const allSuccessfulData = [];
23
23
  let finalSummary = null;
24
+ let processedFiles = 0;
24
25
  for (const line of lines) {
25
26
  const trimmedLine = line.trim();
26
27
  if (trimmedLine) {
27
28
  try {
28
29
  const data = JSON.parse(trimmedLine);
29
30
  if (data.type === "data") {
31
+ processedFiles++;
30
32
  allSuccessfulData.push(data.data);
33
+ console.log(
34
+ `[GRIN2] Processed file ${processedFiles}: ${data.case_id} (${data.data_type}) - ${data.data.length} records`
35
+ );
31
36
  } else if (data.type === "summary") {
32
37
  finalSummary = data;
33
38
  console.log(`[GRIN2] Download complete: ${data.successful_files}/${data.total_files} files successful`);
@@ -55,7 +60,9 @@ function parseJsonlOutput(rustOutput) {
55
60
  filtered_records: finalSummary.filtered_records || 0,
56
61
  filtered_maf_records: finalSummary.filtered_maf_records || 0,
57
62
  filtered_cnv_records: finalSummary.filtered_cnv_records || 0,
58
- filtered_records_by_case: finalSummary.filtered_records_by_case || {}
63
+ filtered_records_by_case: finalSummary.filtered_records_by_case || {},
64
+ included_maf_records: finalSummary.included_maf_records || 0,
65
+ included_cnv_records: finalSummary.included_cnv_records || 0
59
66
  }
60
67
  };
61
68
  }
@@ -74,8 +81,10 @@ function init({ genomes }) {
74
81
  console.log(`[GRIN2] Parsed request: ${JSON.stringify(parsedRequest)}`);
75
82
  const rustInput = JSON.stringify({
76
83
  caseFiles: parsedRequest.caseFiles,
77
- mafOptions: parsedRequest.mafOptions
84
+ mafOptions: parsedRequest.mafOptions,
85
+ cnvOptions: parsedRequest.cnvOptions
78
86
  });
87
+ console.log(`[GRIN2] Rust input: ${rustInput}`);
79
88
  console.log("[GRIN2] Executing Rust function with streaming...");
80
89
  let rustOutput = "";
81
90
  let buffer = "";
@@ -144,10 +153,11 @@ function init({ genomes }) {
144
153
  // The mutation string from Rust
145
154
  });
146
155
  console.log("[GRIN2] Executing R script...");
147
- const rAnalysisTime = Date.now();
156
+ const grin2AnalysisStart = Date.now();
148
157
  const rResult = await run_R("gdcGRIN2.R", rInput, []);
149
158
  console.log("[GRIN2] R execution completed");
150
- console.log(`[GRIN2] R analysis took ${formatElapsedTime(Date.now() - rAnalysisTime)}`);
159
+ const grin2AnalysisTime = formatElapsedTime(Date.now() - grin2AnalysisStart);
160
+ console.log(`[GRIN2] Rust processing took ${grin2AnalysisTime}`);
151
161
  let resultData;
152
162
  try {
153
163
  resultData = JSON.parse(rResult);
@@ -155,12 +165,18 @@ function init({ genomes }) {
155
165
  const pngImg = resultData.png[0];
156
166
  const topGeneTable = resultData.topGeneTable || null;
157
167
  const analysisStats = parsedRustResult.summary || {};
158
- console.log("[GRIN2] Total GRIN2 processing time:", formatElapsedTime(Date.now() - downloadStartTime));
168
+ const totalProcessTime = formatElapsedTime(Date.now() - downloadStartTime);
169
+ console.log("[GRIN2] Total GRIN2 processing time:", totalProcessTime);
159
170
  return res.json({
160
171
  pngImg,
161
172
  topGeneTable,
162
173
  rustResult: parsedRustResult,
163
174
  analysisStats,
175
+ timing: {
176
+ rustProcessingTime: downloadTime,
177
+ grin2ProcessingTime: grin2AnalysisTime,
178
+ totalTime: totalProcessTime
179
+ },
164
180
  status: "success"
165
181
  });
166
182
  } catch (parseError) {
@@ -41,6 +41,7 @@ async function trigger_getcategories(q, res, tdb, ds, genome) {
41
41
  const $id = q.tw.$id;
42
42
  const arg = {
43
43
  filter: q.filter,
44
+ filter0: q.filter0,
44
45
  terms: [q.tw],
45
46
  currentGeneNames: q.currentGeneNames,
46
47
  // optional, from mds3 mayAddGetCategoryArgs()