@sjcrh/proteinpaint-rust 2.120.1 → 2.121.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/README.md +6 -6
- package/downloadBinariesOrCompileSource.js +12 -8
- package/index.js +11 -9
- package/package.json +3 -2
- package/src/DEanalysis.rs +8 -1
package/README.md
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
This directory holds the source code for rust-compiled utilities.
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
## Code layout
|
|
7
6
|
|
|
8
7
|
All source code files should be directly under the `src/` directory. For a source
|
|
9
8
|
code file to be compiled, create a `[[bin]]` entry for it in the Cargo.toml file:
|
|
10
9
|
|
|
11
|
-
|
|
12
10
|
```toml
|
|
13
11
|
[[bin]]
|
|
14
12
|
name="tool0"
|
|
@@ -27,10 +25,10 @@ which goes against rust cargo's assumptions of having source code under `src/bin
|
|
|
27
25
|
## Using from nodejs
|
|
28
26
|
|
|
29
27
|
```js
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
// Assuming a js or ts file from server/src
|
|
29
|
+
|
|
30
|
+
import { run_rust } from '@sjcrh/proteinpaint-rust'
|
|
31
|
+
|
|
34
32
|
|
|
35
33
|
// 'indel' may be replaced by any binary name as specified in Cargo.toml
|
|
36
34
|
const out = await run_rust('indel', input_data)
|
|
@@ -39,8 +37,10 @@ const out = await run_rust('indel', input_data)
|
|
|
39
37
|
## Test
|
|
40
38
|
|
|
41
39
|
From the `proteinpaint/server` directory,
|
|
40
|
+
|
|
42
41
|
```bash
|
|
43
42
|
npx test
|
|
43
|
+
npx tsc
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
## Build
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Import necessary modules
|
|
2
|
+
import https from 'https'
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
import os from 'os'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
import { exec } from 'child_process'
|
|
7
|
+
import * as tar from 'tar'
|
|
7
8
|
|
|
8
|
-
//
|
|
9
|
-
const
|
|
9
|
+
// Setting up directory name
|
|
10
|
+
const __dirname = import.meta.dirname
|
|
11
|
+
|
|
12
|
+
// Read package.json
|
|
13
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'))
|
|
10
14
|
const { version, pp_release_tag } = packageJson
|
|
11
15
|
|
|
12
16
|
const targetDirectory = './target/release'
|
package/index.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Import necessary modules
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import { spawn, exec } from 'child_process'
|
|
5
|
+
import { Readable, Transform } from 'stream'
|
|
6
|
+
import { promisify } from 'util'
|
|
7
|
+
|
|
8
|
+
const __dirname = import.meta.dirname
|
|
7
9
|
|
|
8
10
|
const execPromise = promisify(exec)
|
|
9
11
|
|
|
10
|
-
//
|
|
12
|
+
// Check if rust binary directory exists and is not empty
|
|
11
13
|
const binaryDir = path.join(__dirname, '/target/release/')
|
|
12
14
|
if (!fs.existsSync(binaryDir)) throw `missing rust binary directory='${binaryDir}'`
|
|
13
15
|
if (!fs.readdirSync(binaryDir).length) throw `empty rust binary directory='${binaryDir}'`
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
export function run_rust(binfile, input_data) {
|
|
16
18
|
return new Promise((resolve, reject) => {
|
|
17
19
|
const binpath = path.join(__dirname, '/target/release/', binfile)
|
|
18
20
|
const ps = spawn(binpath)
|
|
@@ -52,7 +54,7 @@ exports.run_rust = function (binfile, input_data) {
|
|
|
52
54
|
})
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
export function stream_rust(binfile, input_data, emitJson) {
|
|
56
58
|
const binpath = path.join(__dirname, '/target/release/', binfile)
|
|
57
59
|
|
|
58
60
|
const ps = spawn(binpath)
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.121.0",
|
|
3
3
|
"name": "@sjcrh/proteinpaint-rust",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "Rust-based utilities for proteinpaint",
|
|
5
6
|
"main": "index.js",
|
|
6
7
|
"bin": {
|
|
@@ -38,5 +39,5 @@
|
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"tape": "^5.2.2"
|
|
40
41
|
},
|
|
41
|
-
"pp_release_tag": "v2.
|
|
42
|
+
"pp_release_tag": "v2.121.0"
|
|
42
43
|
}
|
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];
|