@sjcrh/proteinpaint-rust 2.120.0 → 2.120.2-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/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const fs = require('fs')
1
2
  const path = require('path'),
2
3
  { spawn, exec } = require('child_process'),
3
4
  Readable = require('stream').Readable,
@@ -6,6 +7,11 @@ const path = require('path'),
6
7
 
7
8
  const execPromise = promisify(exec)
8
9
 
10
+ // check if rust binary directory exists and is not empty
11
+ const binaryDir = path.join(__dirname, '/target/release/')
12
+ if (!fs.existsSync(binaryDir)) throw `missing rust binary directory='${binaryDir}'`
13
+ if (!fs.readdirSync(binaryDir).length) throw `empty rust binary directory='${binaryDir}'`
14
+
9
15
  exports.run_rust = function (binfile, input_data) {
10
16
  return new Promise((resolve, reject) => {
11
17
  const binpath = path.join(__dirname, '/target/release/', binfile)
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.120.0",
2
+ "version": "2.120.2-0",
3
3
  "name": "@sjcrh/proteinpaint-rust",
4
4
  "description": "Rust-based utilities for proteinpaint",
5
5
  "main": "index.js",
@@ -38,5 +38,5 @@
38
38
  "devDependencies": {
39
39
  "tape": "^5.2.2"
40
40
  },
41
- "pp_release_tag": "v2.120.0"
41
+ "pp_release_tag": "v2.120.2-0"
42
42
  }
package/src/DEanalysis.rs CHANGED
@@ -664,6 +664,14 @@ fn main() {
664
664
  //println!("filtering time:{:?}", filtering_time.elapsed());
665
665
  //println!("filtered_matrix_rows:{:?}", filtered_matrix.nrows());
666
666
  //println!("filtered_matrix_cols:{:?}", filtered_matrix.ncols());
667
+ if filtered_matrix.nrows() == 0 {
668
+ // Its possible after filtering there might not be any genes left in the matrix, in such a case the rust code must exit gracefully with an error.
669
+ panic!("Number of genes after filtering = 0, cannot proceed any further")
670
+ }
671
+ if filtered_matrix.ncols() == 0 {
672
+ // Its possible after filtering there might not be any samples left in the matrix, in such a case the rust code must exit gracefully with an error.
673
+ panic!("Number of samples after filtering = 0, cannot proceed any further")
674
+ }
667
675
  //let cpm_normalization_time = Instant::now();
668
676
  let mut normalized_matrix = cpm(&filtered_matrix);
669
677
  //println!(
@@ -1214,7 +1222,6 @@ fn calc_factor_quantile(
1214
1222
  for i in 0..input_matrix.nrows() {
1215
1223
  row_vec.push(input_matrix[(i, j)] as f64);
1216
1224
  }
1217
- //println!("row_vec:{:?}", row_vec);
1218
1225
  let quan = calc_quantile(row_vec, P);
1219
1226
  //println!("quan:{}", quan);
1220
1227
  let num = quan / lib_sizes[j];