1
- use crate :: processor;
2
- use reqwest:: Client ;
3
- use serde:: { Deserialize , Serialize } ;
4
- use tokio:: io:: AsyncWriteExt ;
5
1
use std:: io:: Cursor ;
6
2
use std:: path:: Path ;
3
+
4
+ use reqwest:: Client ;
7
5
use tauri:: api:: dialog:: blocking:: FileDialogBuilder ;
8
6
use tokio:: fs;
9
- use crate :: processor:: parser:: parse;
7
+ use crate :: aggregator:: aggregate;
8
+ use crate :: analyzer:: analyze;
9
+
10
+ use crate :: grouper:: { group_by_na_columns, group_by_peptides} ;
11
+ use crate :: parser:: parse;
12
+ use crate :: serializer:: { serialize, serialize_calculations} ;
10
13
11
14
#[ tauri:: command]
12
15
pub async fn install_dependencies ( app_handle : tauri:: AppHandle ) -> Result < ( ) , String > {
@@ -38,65 +41,11 @@ pub async fn install_dependencies(app_handle: tauri::AppHandle) -> Result<(), St
38
41
Ok ( ( ) )
39
42
}
40
43
41
- #[ derive( Serialize , Deserialize , Debug ) ]
42
- pub struct File {
43
- name : String ,
44
- path : String ,
45
- }
46
-
47
- #[ tauri:: command]
48
- pub async fn select_data ( data_input_type : String ) -> Result < Option < File > , String > {
49
- match data_input_type. as_str ( ) {
50
- "inputData" => {
51
- let file_path = FileDialogBuilder :: new ( )
52
- . add_filter ( "Input Data File" , & vec ! [ "csv" ] )
53
- . pick_file ( ) ;
54
-
55
- if let Some ( file_path) = file_path {
56
- let file_name = file_path
57
- . file_name ( )
58
- . unwrap ( )
59
- . to_string_lossy ( )
60
- . into_owned ( ) ;
61
-
62
- return Ok ( Some ( File {
63
- name : file_name,
64
- path : file_path. to_string_lossy ( ) . into_owned ( ) ,
65
- } ) ) ;
66
- }
67
-
68
- Ok ( None )
69
- }
70
- "heavyWaterInputData" => {
71
- let file_path = FileDialogBuilder :: new ( )
72
- . add_filter ( "Heavy Water File" , & vec ! [ "txt" ] )
73
- . pick_file ( ) ;
74
-
75
- if let Some ( file_path) = file_path {
76
- let file_name = file_path
77
- . file_name ( )
78
- . unwrap ( )
79
- . to_string_lossy ( )
80
- . into_owned ( ) ;
81
-
82
- return Ok ( Some ( File {
83
- name : file_name,
84
- path : file_path. to_string_lossy ( ) . into_owned ( ) ,
85
- } ) ) ;
86
- }
87
-
88
- Ok ( None )
89
- }
90
- _ => Err ( "Invalid data input type" . into ( ) ) ,
91
- }
92
- }
93
-
94
44
#[ tauri:: command]
95
45
pub async fn process_data (
96
46
app_handle : tauri:: AppHandle ,
97
47
should_remove_na_calculations : bool ,
98
48
input_file_path : String ,
99
- heavy_water_file_path : String ,
100
49
) -> Result < ( ) , String > {
101
50
let data_dir = app_handle
102
51
. path_resolver ( )
@@ -109,42 +58,38 @@ pub async fn process_data(
109
58
. unwrap ( )
110
59
. join ( "dependencies" ) ;
111
60
let input_file_path = Path :: new ( & input_file_path) ;
112
- let heavy_water_file_path = Path :: new ( & heavy_water_file_path) ;
113
-
114
- dbg ! ( parse( input_file_path) . await . unwrap( ) ) ;
115
-
116
- // let output_contents = processor::handle(
117
- // should_remove_na_calculations,
118
- // &data_dir,
119
- // &dependencies_dir,
120
- // &input_file_path,
121
- // heavy_water_file_path,
122
- // )
123
- // .await?;
124
- //
125
- // let input_file_name = input_file_path
126
- // .file_stem()
127
- // .unwrap()
128
- // .to_string_lossy()
129
- // .into_owned();
130
- //
131
- // let file_path = FileDialogBuilder::new()
132
- // .set_file_name(&format!("{input_file_name}.RateConst.csv"))
133
- // .add_filter("Output CSV File", &vec!["csv"])
134
- // .save_file();
135
- //
136
- // if let Some(file_path) = file_path {
137
- // // overwrite file if it already exists
138
- // fs::OpenOptions::new()
139
- // .write(true)
140
- // .create(true)
141
- // .open(&file_path)
142
- // .await
143
- // .map_err(|err| format!("Failed to write output file: {err}"))?
144
- // .write(&output_contents)
145
- // .await
146
- // .map_err(|err| format!("Failed to write output file: {err}"))?;
147
- // }
61
+
62
+ let ( days, mice, labels, peptides) = parse ( input_file_path) . await . unwrap ( ) ;
63
+
64
+ let groups = group_by_peptides ( peptides) ;
65
+ let groups = group_by_na_columns ( groups) ;
66
+
67
+ let datasets = serialize (
68
+ & data_dir,
69
+ days,
70
+ mice,
71
+ labels,
72
+ groups,
73
+ ) . await . unwrap ( ) ;
74
+
75
+ let calculations = analyze ( & dependencies_dir, & data_dir, & datasets) . await . unwrap ( ) ;
76
+ let calculations = aggregate ( & calculations) . await . unwrap ( ) ;
77
+
78
+ let input_file_name = input_file_path
79
+ . file_stem ( )
80
+ . unwrap ( )
81
+ . to_string_lossy ( )
82
+ . into_owned ( ) ;
83
+
84
+ let file_path = FileDialogBuilder :: new ( )
85
+ . set_file_name ( & format ! ( "{input_file_name}.RateConst.csv" ) )
86
+ . add_filter ( "Output CSV File" , & vec ! [ "csv" ] )
87
+ . save_file ( ) ;
88
+
89
+ if let Some ( file_path) = file_path {
90
+ serialize_calculations ( & file_path, & calculations) . unwrap ( ) ;
91
+ }
92
+
148
93
149
94
Ok ( ( ) )
150
95
}
0 commit comments