@@ -24,9 +24,9 @@ pub struct ReadQC {
2424/// Function to serialize a vector of structs into split-oriented JSON with precision and indexing
2525pub fn write_structs_to_split_json_file < T : Serialize > (
2626 file_path : & str ,
27- data : & Vec < T > ,
28- columns : & Vec < & str > ,
29- struct_values : & Vec < & str > ,
27+ data : & [ T ] ,
28+ columns : & [ & str ] ,
29+ struct_values : & [ & str ] ,
3030) -> Result < ( ) , Box < dyn Error > > {
3131 // Create the "split-oriented" JSON structure
3232 let split_json = json ! ( {
@@ -58,9 +58,9 @@ pub fn write_structs_to_split_json_file<T: Serialize>(
5858/// Write to CSV
5959pub fn write_structs_to_csv_file < T : Serialize > (
6060 file_path : & str ,
61- data : & Vec < T > ,
62- columns : & Vec < & str > ,
63- struct_values : & Vec < & str > ,
61+ data : & [ T ] ,
62+ columns : & [ & str ] ,
63+ struct_values : & [ & str ] ,
6464) -> Result < ( ) , Box < dyn Error > > {
6565 let mut csv_writer = Writer :: from_path ( file_path) ?;
6666
@@ -94,8 +94,8 @@ pub fn write_structs_to_csv_file<T: Serialize>(
9494pub fn write_ref_data_json (
9595 file_path : & str ,
9696 ref_lens : & HashMap < String , usize > ,
97- segments : & Vec < String > ,
98- segset : & Vec < String > ,
97+ segments : & [ String ] ,
98+ segset : & [ String ] ,
9999 segcolor : & HashMap < String , & str > ,
100100) -> Result < ( ) , Box < dyn Error > > {
101101 let json_data = json ! ( {
@@ -117,22 +117,22 @@ pub fn write_ref_data_json(
117117
118118/// Write the reads data to parquet file.
119119pub fn write_reads_to_parquet (
120- reads_data : & Vec < ReadsData > ,
120+ reads_data : & [ ReadsData ] ,
121121 output_file : & str ,
122122) -> Result < ( ) , Box < dyn Error > > {
123123 // Convert values in struct to vector of values
124124 let sample_ids_vec: Vec < Option < String > > =
125- extract_field ( reads_data. clone ( ) , |item| item. sample_id . clone ( ) ) ;
126- let record_vec = extract_field ( reads_data. clone ( ) , |item| item. record . clone ( ) ) ;
127- let reads_vec = extract_field ( reads_data. clone ( ) , |item| item. reads ) ;
128- let patterns_vec = extract_string_fields_as_float ( reads_data. clone ( ) , |item| & item. patterns ) ;
125+ extract_field ( reads_data. to_owned ( ) , |item| item. sample_id . clone ( ) ) ;
126+ let record_vec = extract_field ( reads_data. to_owned ( ) , |item| item. record . clone ( ) ) ;
127+ let reads_vec = extract_field ( reads_data. to_owned ( ) , |item| item. reads ) ;
128+ let patterns_vec = extract_string_fields_as_float ( reads_data. to_owned ( ) , |item| & item. patterns ) ;
129129 let pairs_and_windows_vec =
130- extract_string_fields_as_float ( reads_data. clone ( ) , |item| & item. pairs_and_windows ) ;
131- let stages_vec = extract_string_fields_as_int ( reads_data. clone ( ) , |item| {
130+ extract_string_fields_as_float ( reads_data. to_owned ( ) , |item| & item. pairs_and_windows ) ;
131+ let stages_vec = extract_string_fields_as_int ( reads_data. to_owned ( ) , |item| {
132132 item. stage . as_deref ( ) . unwrap_or ( "" )
133133 } ) ;
134- let runid_vec = extract_field ( reads_data. clone ( ) , |item| item. run_id . clone ( ) ) ;
135- let instrument_vec = extract_field ( reads_data. clone ( ) , |item| item. instrument . clone ( ) ) ;
134+ let runid_vec = extract_field ( reads_data. to_owned ( ) , |item| item. run_id . clone ( ) ) ;
135+ let instrument_vec = extract_field ( reads_data. to_owned ( ) , |item| item. instrument . clone ( ) ) ;
136136
137137 // Convert the vectors into Arrow columns
138138 let sample_array: ArrayRef = Arc :: new ( StringArray :: from ( sample_ids_vec) ) ;
@@ -183,8 +183,8 @@ pub fn write_reads_to_parquet(
183183
184184pub fn negative_qc_statement (
185185 output_file : & str ,
186- reads_data : & Vec < ReadsData > ,
187- neg_control_list : & Vec < String > ,
186+ reads_data : & [ ReadsData ] ,
187+ neg_control_list : & [ String ] ,
188188) -> Result < ( ) , Box < dyn Error > > {
189189 let filtered_reads_data = filter_struct_by_ids ( reads_data, neg_control_list. to_vec ( ) ) ;
190190
@@ -207,7 +207,7 @@ pub fn negative_qc_statement(
207207
208208 if total_reads_stage_3 > 0 {
209209 let percent_mapping =
210- ( total_reads_stage_3 as f64 / reads_stage_1 as f64 * 100.0 ) . round ( ) ;
210+ ( f64 :: from ( total_reads_stage_3) / f64:: from ( reads_stage_1 ) * 100.0 ) . round ( ) ;
211211
212212 results. push ( ReadQC {
213213 sample_id : sample_id. clone ( ) ,
0 commit comments