@sjcrh/proteinpaint-rust 2.116.0 → 2.117.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/Cargo.toml +2 -1
- package/package.json +2 -2
- package/src/readHDF5.rs +809 -240
- package/src/topGeneByExpressionVariance.rs +126 -126
|
@@ -64,15 +64,15 @@ fn input_data_hdf5(
|
|
|
64
64
|
let file = match File::open(filename) {
|
|
65
65
|
Ok(f) => f,
|
|
66
66
|
Err(err) => {
|
|
67
|
-
eprintln!("Failed to open HDF5 file: {}", err);
|
|
68
|
-
println!(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
);
|
|
67
|
+
// eprintln!("Failed to open HDF5 file: {}", err);
|
|
68
|
+
// println!(
|
|
69
|
+
// "{}",
|
|
70
|
+
// serde_json::json!({
|
|
71
|
+
// "status": "error",
|
|
72
|
+
// "message": format!("Failed to open HDF5 file: {}", err),
|
|
73
|
+
// "file_path": filename
|
|
74
|
+
// })
|
|
75
|
+
// );
|
|
76
76
|
return Err(hdf5::Error::Internal(format!(
|
|
77
77
|
"Failed to open HDF5 file: {}",
|
|
78
78
|
err
|
|
@@ -84,15 +84,15 @@ fn input_data_hdf5(
|
|
|
84
84
|
let genes_dataset = match file.dataset("gene_symbols") {
|
|
85
85
|
Ok(ds) => ds,
|
|
86
86
|
Err(err) => {
|
|
87
|
-
eprintln!("Failed to open gene_symbols dataset: {}", err);
|
|
88
|
-
println!(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
);
|
|
87
|
+
// eprintln!("Failed to open gene_symbols dataset: {}", err);
|
|
88
|
+
// println!(
|
|
89
|
+
// "{}",
|
|
90
|
+
// serde_json::json!({
|
|
91
|
+
// "status": "error",
|
|
92
|
+
// "message": format!("Failed to open gene_symbols dataset: {}", err),
|
|
93
|
+
// "file_path": filename
|
|
94
|
+
// })
|
|
95
|
+
// );
|
|
96
96
|
return Err(hdf5::Error::Internal(format!(
|
|
97
97
|
"Failed to open gene_symbols dataset: {}",
|
|
98
98
|
err
|
|
@@ -104,15 +104,15 @@ fn input_data_hdf5(
|
|
|
104
104
|
let genes_varlen = match genes_dataset.read_1d::<VarLenAscii>() {
|
|
105
105
|
Ok(g) => g,
|
|
106
106
|
Err(err) => {
|
|
107
|
-
eprintln!("Failed to read gene symbols: {}", err);
|
|
108
|
-
println!(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
);
|
|
107
|
+
// eprintln!("Failed to read gene symbols: {}", err);
|
|
108
|
+
// println!(
|
|
109
|
+
// "{}",
|
|
110
|
+
// serde_json::json!({
|
|
111
|
+
// "status": "error",
|
|
112
|
+
// "message": format!("Failed to read gene symbols: {}", err),
|
|
113
|
+
// "file_path": filename
|
|
114
|
+
// })
|
|
115
|
+
// );
|
|
116
116
|
return Err(hdf5::Error::Internal(format!(
|
|
117
117
|
"Failed to read gene symbols: {}",
|
|
118
118
|
err
|
|
@@ -129,7 +129,7 @@ fn input_data_hdf5(
|
|
|
129
129
|
let samples_dataset = match file.dataset("samples") {
|
|
130
130
|
Ok(ds) => ds,
|
|
131
131
|
Err(err) => {
|
|
132
|
-
eprintln!("Failed to open samples dataset: {}", err);
|
|
132
|
+
// eprintln!("Failed to open samples dataset: {}", err);
|
|
133
133
|
println!(
|
|
134
134
|
"{}",
|
|
135
135
|
serde_json::json!({
|
|
@@ -149,7 +149,7 @@ fn input_data_hdf5(
|
|
|
149
149
|
let samples_varlen = match samples_dataset.read_1d::<VarLenAscii>() {
|
|
150
150
|
Ok(s) => s,
|
|
151
151
|
Err(err) => {
|
|
152
|
-
eprintln!("Failed to read sample names: {}", err);
|
|
152
|
+
// eprintln!("Failed to read sample names: {}", err);
|
|
153
153
|
println!(
|
|
154
154
|
"{}",
|
|
155
155
|
serde_json::json!({
|
|
@@ -175,16 +175,16 @@ fn input_data_hdf5(
|
|
|
175
175
|
if let Some(index) = all_samples.iter().position(|s| s == sample) {
|
|
176
176
|
column_indices.push(index);
|
|
177
177
|
} else {
|
|
178
|
-
eprintln!("Sample {} not found in the dataset", sample);
|
|
179
|
-
println!(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
);
|
|
178
|
+
// eprintln!("Sample {} not found in the dataset", sample);
|
|
179
|
+
// println!(
|
|
180
|
+
// "{}",
|
|
181
|
+
// serde_json::json!({
|
|
182
|
+
// "status": "error",
|
|
183
|
+
// "message": format!("Sample '{}' not found in the dataset", sample),
|
|
184
|
+
// "file_path": filename,
|
|
185
|
+
// "available_samples": all_samples
|
|
186
|
+
// })
|
|
187
|
+
// );
|
|
188
188
|
return Err(hdf5::Error::Internal(format!(
|
|
189
189
|
"Sample '{}' not found in the dataset",
|
|
190
190
|
sample
|
|
@@ -196,15 +196,15 @@ fn input_data_hdf5(
|
|
|
196
196
|
let counts_dataset = match file.dataset("counts") {
|
|
197
197
|
Ok(ds) => ds,
|
|
198
198
|
Err(err) => {
|
|
199
|
-
eprintln!("Failed to open counts dataset: {}", err);
|
|
200
|
-
println!(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
);
|
|
199
|
+
// eprintln!("Failed to open counts dataset: {}", err);
|
|
200
|
+
// println!(
|
|
201
|
+
// "{}",
|
|
202
|
+
// serde_json::json!({
|
|
203
|
+
// "status": "error",
|
|
204
|
+
// "message": format!("Failed to open counts dataset: {}", err),
|
|
205
|
+
// "file_path": filename
|
|
206
|
+
// })
|
|
207
|
+
// );
|
|
208
208
|
return Err(hdf5::Error::Internal(format!(
|
|
209
209
|
"Failed to open counts dataset: {}",
|
|
210
210
|
err
|
|
@@ -215,16 +215,16 @@ fn input_data_hdf5(
|
|
|
215
215
|
// Get dataset dimensions for validation
|
|
216
216
|
let dataset_shape = counts_dataset.shape();
|
|
217
217
|
if dataset_shape.len() != 2 {
|
|
218
|
-
eprintln!("Counts dataset does not have the expected 2D shape");
|
|
219
|
-
println!(
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
);
|
|
218
|
+
// eprintln!("Counts dataset does not have the expected 2D shape");
|
|
219
|
+
// println!(
|
|
220
|
+
// "{}",
|
|
221
|
+
// serde_json::json!({
|
|
222
|
+
// "status": "error",
|
|
223
|
+
// "message": "Expected a 2D dataset for counts",
|
|
224
|
+
// "file_path": filename,
|
|
225
|
+
// "actual_shape": dataset_shape
|
|
226
|
+
// })
|
|
227
|
+
// );
|
|
228
228
|
return Err(hdf5::Error::Internal(
|
|
229
229
|
"Expected a 2D dataset for counts".to_string(),
|
|
230
230
|
));
|
|
@@ -232,19 +232,19 @@ fn input_data_hdf5(
|
|
|
232
232
|
|
|
233
233
|
// Check dimensions match expected values
|
|
234
234
|
if dataset_shape[0] != num_genes {
|
|
235
|
-
eprintln!(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
);
|
|
239
|
-
println!(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
);
|
|
235
|
+
// eprintln!(
|
|
236
|
+
// "Counts dataset first dimension ({}) doesn't match number of genes ({})",
|
|
237
|
+
// dataset_shape[0], num_genes
|
|
238
|
+
// );
|
|
239
|
+
// println!(
|
|
240
|
+
// "{}",
|
|
241
|
+
// serde_json::json!({
|
|
242
|
+
// "status": "error",
|
|
243
|
+
// "message": format!("Counts dataset first dimension ({}) doesn't match number of genes ({})",
|
|
244
|
+
// dataset_shape[0], num_genes),
|
|
245
|
+
// "file_path": filename
|
|
246
|
+
// })
|
|
247
|
+
// );
|
|
248
248
|
return Err(hdf5::Error::Internal(format!(
|
|
249
249
|
"Counts dataset first dimension ({}) doesn't match number of genes ({})",
|
|
250
250
|
dataset_shape[0], num_genes
|
|
@@ -252,20 +252,20 @@ fn input_data_hdf5(
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
if dataset_shape[1] != all_samples.len() {
|
|
255
|
-
eprintln!(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
);
|
|
260
|
-
println!(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
);
|
|
255
|
+
// eprintln!(
|
|
256
|
+
// "Counts dataset second dimension ({}) doesn't match number of samples ({})",
|
|
257
|
+
// dataset_shape[1],
|
|
258
|
+
// all_samples.len()
|
|
259
|
+
// );
|
|
260
|
+
// println!(
|
|
261
|
+
// "{}",
|
|
262
|
+
// serde_json::json!({
|
|
263
|
+
// "status": "error",
|
|
264
|
+
// "message": format!("Counts dataset second dimension ({}) doesn't match number of samples ({})",
|
|
265
|
+
// dataset_shape[1], all_samples.len()),
|
|
266
|
+
// "file_path": filename
|
|
267
|
+
// })
|
|
268
|
+
// );
|
|
269
269
|
return Err(hdf5::Error::Internal(format!(
|
|
270
270
|
"Counts dataset second dimension ({}) doesn't match number of samples ({})",
|
|
271
271
|
dataset_shape[1],
|
|
@@ -277,15 +277,15 @@ fn input_data_hdf5(
|
|
|
277
277
|
let all_counts = match counts_dataset.read::<f64, Dim<[usize; 2]>>() {
|
|
278
278
|
Ok(data) => data,
|
|
279
279
|
Err(err) => {
|
|
280
|
-
eprintln!("Failed to read expression data: {}", err);
|
|
281
|
-
println!(
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
);
|
|
280
|
+
// eprintln!("Failed to read expression data: {}", err);
|
|
281
|
+
// println!(
|
|
282
|
+
// "{}",
|
|
283
|
+
// serde_json::json!({
|
|
284
|
+
// "status": "error",
|
|
285
|
+
// "message": format!("Failed to read expression data: {}", err),
|
|
286
|
+
// "file_path": filename
|
|
287
|
+
// })
|
|
288
|
+
// );
|
|
289
289
|
return Err(hdf5::Error::Internal(format!(
|
|
290
290
|
"Failed to read expression data: {}",
|
|
291
291
|
err
|
|
@@ -536,28 +536,28 @@ fn cpm(
|
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
fn main() {
|
|
539
|
-
//
|
|
539
|
+
// println!("Starting gene variance calculation...");
|
|
540
540
|
let mut input = String::new();
|
|
541
541
|
match io::stdin().read_line(&mut input) {
|
|
542
542
|
// Accepting the piped input from nodejs (or command line from testing)
|
|
543
543
|
Ok(_bytes_read) => {
|
|
544
|
-
// eprintln!("Read {} bytes from stdin",
|
|
545
|
-
//println!("{} bytes read", bytes_read);
|
|
546
|
-
//println!("{}", input);
|
|
544
|
+
// eprintln!("Read {} bytes from stdin", bytes_read);
|
|
545
|
+
// println!("{} bytes read", bytes_read);
|
|
546
|
+
// println!("{}", input);
|
|
547
547
|
let input_json = json::parse(&input);
|
|
548
548
|
match input_json {
|
|
549
549
|
Ok(json_string) => {
|
|
550
|
-
//
|
|
550
|
+
// println!("Successfully parsed JSON input");
|
|
551
551
|
// let now = Instant::now();
|
|
552
552
|
let samples_string_result = &json_string["samples"].to_owned();
|
|
553
553
|
let samples_string;
|
|
554
554
|
match samples_string_result.as_str() {
|
|
555
555
|
Some(x) => {
|
|
556
556
|
samples_string = x.to_string();
|
|
557
|
-
//
|
|
557
|
+
// println!("Samples: {}", samples_string);
|
|
558
558
|
}
|
|
559
559
|
None => {
|
|
560
|
-
eprintln!("ERROR: Samples not provided in JSON");
|
|
560
|
+
// eprintln!("ERROR: Samples not provided in JSON");
|
|
561
561
|
println!(
|
|
562
562
|
"{}",
|
|
563
563
|
serde_json::json!({
|
|
@@ -583,14 +583,14 @@ fn main() {
|
|
|
583
583
|
// );
|
|
584
584
|
}
|
|
585
585
|
None => {
|
|
586
|
-
eprintln!("ERROR: File name missing in JSON");
|
|
587
|
-
println!(
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
);
|
|
586
|
+
// eprintln!("ERROR: File name missing in JSON");
|
|
587
|
+
// println!(
|
|
588
|
+
// "{}",
|
|
589
|
+
// serde_json::json!({
|
|
590
|
+
// "status": "error",
|
|
591
|
+
// "message": "File name is missing"
|
|
592
|
+
// })
|
|
593
|
+
// );
|
|
594
594
|
return;
|
|
595
595
|
}
|
|
596
596
|
}
|
|
@@ -613,14 +613,14 @@ fn main() {
|
|
|
613
613
|
// eprintln!("Rank type: {}", rank_type);
|
|
614
614
|
if rank_type != "var" && rank_type != "iqr" {
|
|
615
615
|
// Check if any unknown method has been provided
|
|
616
|
-
eprintln!("ERROR: Unknown rank method: {}", rank_type);
|
|
617
|
-
println!(
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
);
|
|
616
|
+
// eprintln!("ERROR: Unknown rank method: {}", rank_type);
|
|
617
|
+
// println!(
|
|
618
|
+
// "{}",
|
|
619
|
+
// serde_json::json!({
|
|
620
|
+
// "status": "error",
|
|
621
|
+
// "message": format!("Unknown rank method: {}. Must be 'var' or 'iqr'", rank_type)
|
|
622
|
+
// })
|
|
623
|
+
// );
|
|
624
624
|
return;
|
|
625
625
|
}
|
|
626
626
|
let filter_extreme_values_result = &json_string["filter_extreme_values"];
|
|
@@ -629,7 +629,7 @@ fn main() {
|
|
|
629
629
|
match filter_extreme_values_result.as_bool() {
|
|
630
630
|
Some(x) => {
|
|
631
631
|
filter_extreme_values = x;
|
|
632
|
-
eprintln!("Filter extreme values: {}", filter_extreme_values);
|
|
632
|
+
// eprintln!("Filter extreme values: {}", filter_extreme_values);
|
|
633
633
|
}
|
|
634
634
|
None => {
|
|
635
635
|
filter_extreme_values = true; // If filter_extreme_values field is missing, set it to true by default
|
|
@@ -648,7 +648,7 @@ fn main() {
|
|
|
648
648
|
// eprintln!("Number of genes requested: {}", num_genes);
|
|
649
649
|
}
|
|
650
650
|
None => {
|
|
651
|
-
eprintln!("ERROR: Number of genes to be given is missing");
|
|
651
|
+
// eprintln!("ERROR: Number of genes to be given is missing");
|
|
652
652
|
println!(
|
|
653
653
|
"{}",
|
|
654
654
|
serde_json::json!({
|
|
@@ -668,7 +668,7 @@ fn main() {
|
|
|
668
668
|
// eprintln!("Min count: {}", x);
|
|
669
669
|
}
|
|
670
670
|
None => {
|
|
671
|
-
eprintln!("Min count not specified, will use default");
|
|
671
|
+
// eprintln!("Min count not specified, will use default");
|
|
672
672
|
}
|
|
673
673
|
}
|
|
674
674
|
|
|
@@ -680,7 +680,7 @@ fn main() {
|
|
|
680
680
|
// eprintln!("Min total count: {}", x);
|
|
681
681
|
}
|
|
682
682
|
None => {
|
|
683
|
-
eprintln!("Min total count not specified, will use default");
|
|
683
|
+
// eprintln!("Min total count not specified, will use default");
|
|
684
684
|
}
|
|
685
685
|
}
|
|
686
686
|
|
|
@@ -780,11 +780,11 @@ fn main() {
|
|
|
780
780
|
|
|
781
781
|
// Check if we have enough genes for the requested output
|
|
782
782
|
if gene_infos.len() < num_genes {
|
|
783
|
-
eprintln!(
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
);
|
|
783
|
+
// eprintln!(
|
|
784
|
+
// "WARNING: Only {} genes found, but {} were requested",
|
|
785
|
+
// gene_infos.len(),
|
|
786
|
+
// num_genes
|
|
787
|
+
// );
|
|
788
788
|
}
|
|
789
789
|
|
|
790
790
|
let actual_num_genes = std::cmp::min(num_genes, gene_infos.len());
|