@@ -10,9 +10,7 @@ use std::{
1010use crate :: processes:: prepare_mira_reports:: SamplesheetI ;
1111use crate :: processes:: prepare_mira_reports:: SamplesheetO ;
1212
13- use super :: data_ingest:: {
14- AllelesData , CoverageData , DaisSeqData , IndelsData , ProcessedRecord , ReadsData ,
15- } ;
13+ use super :: data_ingest:: { AllelesData , CoverageData , DaisSeqData , IndelsData , ReadsData } ;
1614
1715/// Dais Variants Struct
1816#[ derive( Serialize , Deserialize , Debug ) ]
@@ -160,20 +158,14 @@ where
160158
161159//Function to filter struct by sample id
162160//If using this with a Vec of structs then you need to add impl to HasSampleID trait above if not done already
163- pub fn filter_struct_by_ids < T > ( samples : & Vec < T > , ids : Vec < String > ) -> Vec < T >
161+ pub fn filter_struct_by_ids < T > ( samples : & [ T ] , ids : Vec < String > ) -> Vec < T >
164162where
165163 T : Serialize + Clone ,
166164 T : HasSampleId ,
167165{
168166 samples
169167 . iter ( )
170- . filter ( |sample| {
171- if let sample_id = sample. sample_id ( ) {
172- ids. contains ( sample_id)
173- } else {
174- false
175- }
176- } )
168+ . filter ( |sample| ids. contains ( sample. sample_id ( ) ) )
177169 . cloned ( )
178170 . collect ( )
179171}
@@ -204,7 +196,7 @@ pub fn append_with_comma(base: &mut String, new_entry: &str) {
204196 }
205197}
206198
207- pub fn collect_sample_id < T > ( samples : & Vec < T > ) -> Vec < String >
199+ pub fn collect_sample_id < T > ( samples : & [ T ] ) -> Vec < String >
208200where
209201 T : Serialize + Clone ,
210202 T : HasSampleId , // Custom trait to ensure T has a sample_id field
@@ -219,7 +211,7 @@ where
219211 sample_list
220212}
221213
222- pub fn collect_negatives < T > ( samples : & Vec < T > ) -> Vec < String >
214+ pub fn collect_negatives < T > ( samples : & [ T ] ) -> Vec < String >
223215where
224216 T : Serialize + Clone ,
225217 T : HasSampleType + HasSampleId , // Custom trait to ensure T has a `sample_type` and sample_id field
@@ -284,8 +276,8 @@ pub fn return_seg_data(
284276//////////////// Functions used to process the variants found in dais outputs ///////////////
285277// Function to calculate the aa variants - this is specifically for flu right now
286278pub fn compute_dais_variants (
287- ref_seqs_data : & Vec < DaisSeqData > ,
288- sample_seqs_data : & Vec < DaisSeqData > ,
279+ ref_seqs_data : & [ DaisSeqData ] ,
280+ sample_seqs_data : & [ DaisSeqData ] ,
289281) -> Result < Vec < DaisVarsData > , Box < dyn Error > > {
290282 let mut dais_vars_data: Vec < DaisVarsData > = Vec :: new ( ) ;
291283
@@ -348,8 +340,8 @@ pub fn compute_dais_variants(
348340
349341/// Compute CVV DAIS Variants
350342pub fn compute_cvv_dais_variants (
351- ref_seqs_data : & Vec < DaisSeqData > ,
352- sample_seqs_data : & Vec < DaisSeqData > ,
343+ ref_seqs_data : & [ DaisSeqData ] ,
344+ sample_seqs_data : & [ DaisSeqData ] ,
353345) -> Result < Vec < DaisVarsData > , Box < dyn Error > > {
354346 let mut merged_data = merge_sequences ( ref_seqs_data, sample_seqs_data) ?;
355347
@@ -397,8 +389,8 @@ pub fn compute_cvv_dais_variants(
397389
398390/// Merge sequences based on Coordspace and Protein - used by compute_cvv_dais_variants fn
399391fn merge_sequences (
400- ref_seqs_data : & Vec < DaisSeqData > ,
401- sample_seqs_data : & Vec < DaisSeqData > ,
392+ ref_seqs_data : & [ DaisSeqData ] ,
393+ sample_seqs_data : & [ DaisSeqData ] ,
402394) -> Result < Vec < DaisSeqData > , Box < dyn Error > > {
403395 let mut merged_data = Vec :: new ( ) ;
404396
@@ -453,7 +445,7 @@ fn compute_aa_variants(aligned_aa_sequence: &str, ref_aa_sequence: &str) -> Stri
453445}
454446
455447/// Get subtypes for flu
456- pub fn extract_subtype_flu ( dais_vars : & Vec < DaisVarsData > ) -> Result < Vec < Subtype > , Box < dyn Error > > {
448+ pub fn extract_subtype_flu ( dais_vars : & [ DaisVarsData ] ) -> Result < Vec < Subtype > , Box < dyn Error > > {
457449 let mut subtype_data: Vec < Subtype > = Vec :: new ( ) ;
458450 let mut sample_ha_map: HashMap < String , String > = HashMap :: new ( ) ;
459451 let mut sample_na_map: HashMap < String , String > = HashMap :: new ( ) ;
@@ -536,7 +528,7 @@ pub fn extract_subtype_flu(dais_vars: &Vec<DaisVarsData>) -> Result<Vec<Subtype>
536528 Ok ( subtype_data)
537529}
538530
539- pub fn extract_subtype_sc2 ( dais_vars : & Vec < DaisVarsData > ) -> Result < Vec < Subtype > , Box < dyn Error > > {
531+ pub fn extract_subtype_sc2 ( dais_vars : & [ DaisVarsData ] ) -> Result < Vec < Subtype > , Box < dyn Error > > {
540532 let mut subtype_data: Vec < Subtype > = Vec :: new ( ) ;
541533
542534 for entry in dais_vars {
@@ -551,7 +543,7 @@ pub fn extract_subtype_sc2(dais_vars: &Vec<DaisVarsData>) -> Result<Vec<Subtype>
551543
552544//////////////// Functions used to create irma_summary ///////////////
553545/// Flip orientation of the reads structs
554- pub fn melt_reads_data ( records : & Vec < ReadsData > ) -> Vec < MeltedRecord > {
546+ pub fn melt_reads_data ( records : & [ ReadsData ] ) -> Vec < MeltedRecord > {
555547 let mut result = Vec :: new ( ) ;
556548 let mut sample_data: HashMap < String , ( i32 , i32 ) > = HashMap :: new ( ) ;
557549
@@ -606,7 +598,7 @@ fn calculate_median(values: &[i32]) -> f64 {
606598
607599/// Coverage dataframe calculations
608600pub fn process_wgs_coverage_data (
609- coverage_df : & Vec < CoverageData > ,
601+ coverage_df : & [ CoverageData ] ,
610602 ref_lens : & HashMap < String , usize > ,
611603) -> Vec < ProcessedCoverage > {
612604 // Filter out invalid consensus values
@@ -677,7 +669,7 @@ pub fn process_wgs_coverage_data(
677669}
678670
679671pub fn process_position_coverage_data (
680- coverage_df : & Vec < CoverageData > ,
672+ coverage_df : & [ CoverageData ] ,
681673 ref_lens : & HashMap < String , usize > ,
682674 position_1 : i32 ,
683675 position_2 : i32 ,
@@ -755,7 +747,7 @@ pub fn process_position_coverage_data(
755747}
756748
757749/// Count minority alleles for each unique sample_id and reference - used in IRMA summary below
758- pub fn count_minority_alleles ( data : & Vec < AllelesData > ) -> Vec < VariantCountData > {
750+ pub fn count_minority_alleles ( data : & [ AllelesData ] ) -> Vec < VariantCountData > {
759751 let mut counts: HashMap < ( Option < String > , String ) , i32 > = HashMap :: new ( ) ;
760752
761753 for entry in data {
@@ -776,7 +768,7 @@ pub fn count_minority_alleles(data: &Vec<AllelesData>) -> Vec<VariantCountData>
776768}
777769
778770/// Count minority alleles for each unique sample_id and reference - used in IRMA summary below
779- pub fn count_minority_indels ( data : & Vec < IndelsData > ) -> Vec < VariantCountData > {
771+ pub fn count_minority_indels ( data : & [ IndelsData ] ) -> Vec < VariantCountData > {
780772 let mut counts: HashMap < ( Option < String > , String ) , i32 > = HashMap :: new ( ) ;
781773
782774 for entry in data {
@@ -840,12 +832,12 @@ pub fn collect_analysis_metadata(
840832
841833/// Combine all df to create IRMA summary
842834pub fn create_prelim_irma_summary_df (
843- sample_list : & Vec < String > ,
844- reads_count_df : & Vec < MeltedRecord > ,
845- calc_cov_df : & Vec < ProcessedCoverage > ,
846- alleles_df : & Vec < AllelesData > ,
847- indels_df : & Vec < IndelsData > ,
848- subtype_df : & Vec < Subtype > ,
835+ sample_list : & [ String ] ,
836+ reads_count_df : & [ MeltedRecord ] ,
837+ calc_cov_df : & [ ProcessedCoverage ] ,
838+ alleles_df : & [ AllelesData ] ,
839+ indels_df : & [ IndelsData ] ,
840+ subtype_df : & [ Subtype ] ,
849841 metadata : Metadata ,
850842) -> Result < Vec < IRMASummary > , Box < dyn Error > > {
851843 let mut irma_summary: Vec < IRMASummary > = Vec :: new ( ) ;
0 commit comments