@@ -662,8 +662,11 @@ pub fn count_minority_indels(data: &Vec<IndelsData>) -> Vec<VariantCountData> {
662662 let mut counts: HashMap < ( Option < String > , String ) , i32 > = HashMap :: new ( ) ;
663663
664664 for entry in data {
665- let key = ( entry. sample_id . clone ( ) , entry. reference_name . clone ( ) ) ;
666- * counts. entry ( key) . or_insert ( 0 ) += 1 ;
665+ //Alleles were already filtered, but have to filter indels for >= 0.2 freq here.
666+ if entry. frequency >= 0.2 {
667+ let key = ( entry. sample_id . clone ( ) , entry. reference_name . clone ( ) ) ;
668+ * counts. entry ( key) . or_insert ( 0 ) += 1 ;
669+ }
667670 }
668671
669672 let mut result = Vec :: new ( ) ;
@@ -675,6 +678,8 @@ pub fn count_minority_indels(data: &Vec<IndelsData>) -> Vec<VariantCountData> {
675678 } ) ;
676679 }
677680
681+ println ! ( "{result:?}" ) ;
682+
678683 result
679684}
680685
@@ -690,11 +695,10 @@ pub fn create_irma_summary(
690695 let allele_count_data = count_minority_alleles ( alleles_df) ;
691696 let indel_count_data = count_minority_indels ( indels_df) ;
692697
693- // First loop: Populate ` irma_summary` with initial data from ` reads_count_df`
698+ // Populate irma_summary with initial data from reads_count_df
694699 for sample in sample_list {
695700 let mut found_match = false ;
696701 for entry in reads_count_df {
697- println ! ( "{} --- {}" , & sample, entry. sample_id) ;
698702 if * sample == entry. sample_id {
699703 found_match = true ;
700704 irma_summary. push ( IRMASummary {
@@ -705,8 +709,8 @@ pub fn create_irma_summary(
705709 reads_mapped : Some ( entry. reads_mapped . clone ( ) ) ,
706710 precent_reference_coverage : None ,
707711 median_coverage : None ,
708- count_minor_snv : None ,
709- count_minor_indel : None ,
712+ count_minor_snv : Some ( 0 ) ,
713+ count_minor_indel : Some ( 0 ) ,
710714 spike_percent_coverage : None ,
711715 spike_median_coverage : None ,
712716 pass_fail_reason : None ,
@@ -740,7 +744,7 @@ pub fn create_irma_summary(
740744 }
741745 }
742746
743- // Second loop: Update ` irma_summary` with data from other dataframes
747+ //Update irma_summary with data from other dataframes
744748 for sample in & mut irma_summary {
745749 for entry in calc_cov_df {
746750 if sample. sample_id == Some ( entry. sample . clone ( ) )
@@ -754,22 +758,17 @@ pub fn create_irma_summary(
754758 for entry in & allele_count_data {
755759 if sample. sample_id == entry. sample_id . clone ( )
756760 && sample. reference == Some ( entry. reference . clone ( ) )
757- && entry. minor_variant_count > 0
758761 {
759762 sample. count_minor_snv = Some ( entry. minor_variant_count ) ;
760- } else {
761- sample. count_minor_snv = Some ( 0 ) ;
762763 }
763764 }
764765
765766 for entry in & indel_count_data {
766767 if sample. sample_id == entry. sample_id . clone ( )
767768 && sample. reference == Some ( entry. reference . clone ( ) )
768- && entry. minor_variant_count > 0
769769 {
770+ println ! ( "check {}" , entry. minor_variant_count) ;
770771 sample. count_minor_indel = Some ( entry. minor_variant_count ) ;
771- } else {
772- sample. count_minor_indel = Some ( 0 ) ;
773772 }
774773 }
775774 }
0 commit comments