fn match_bim(
    bim: &[SourceEntry],
    name: &str,
    variants: &HashMap<String, VariantEntry>,
) -> MatchResult {
    let mut res = MatchResult {
        name: name.to_string(),
        name_match_rate: 0.0,
        name_pos_match_rate: 0.0,
        strand_match_rate: 0.0,
        plus_match_rate: 0.0,
        atcg_match_rate: 0.0,
    };

    let mut name_matches = 0;
    let mut name_pos_matches = 0;

    let mut strand_matches = 0;
    let mut plus_matches = 0;
    let mut atcg_matches = 0;

    for bimentry in bim {
        if let Some(strand) = variants.get(&bimentry.name) {
            name_matches += 1;

            if (strand.position == bimentry.position) && (strand.chromosome == bimentry.chromosome)
            {
                name_pos_matches += 1;

                match match_alleles(bimentry.alleles, strand.alleles, strand.strand) {
                    AlleleMatch::ATCG => atcg_matches += 1,
                    AlleleMatch::Original => strand_matches += 1,
                    AlleleMatch::Plus => plus_matches += 1,
                    AlleleMatch::Mismatch => {}
                }
            }
        }
    }

    res.name = name.to_string();
    res.name_match_rate = name_matches as f32 / bim.len() as f32;
    res.name_pos_match_rate = name_pos_matches as f32 / name_matches as f32;
    res.strand_match_rate = strand_matches as f32 / (name_pos_matches - atcg_matches) as f32;
    res.plus_match_rate = plus_matches as f32 / (name_pos_matches - atcg_matches) as f32;
    res.atcg_match_rate = atcg_matches as f32 / name_pos_matches as f32;

    res.name_match_rate = mzinf(res.name_match_rate);
    res.name_pos_match_rate = mzinf(res.name_pos_match_rate);
    res.strand_match_rate = mzinf(res.strand_match_rate);
    res.plus_match_rate = mzinf(res.plus_match_rate);
    res.atcg_match_rate = mzinf(res.atcg_match_rate);

    res
}
// Match a BIM file against a strand file
Match a BIM file against a strand file
Match a BIM file against a strand file
fn match_bim(
    bim: &[SourceEntry],
    name: &str,
    variants: &HashMap<String, VariantEntry>,
) -> MatchResult {
    let mut res = MatchResult {
        name: name.to_string(),
        name_match_rate: 0.0,
        name_pos_match_rate: 0.0,
        strand_match_rate: 0.0,
        plus_match_rate: 0.0,
        atcg_match_rate: 0.0,
    };
    let mut name_matches = 0;
    let mut name_pos_matches = 0;
    let mut strand_matches = 0;
    let mut plus_matches = 0;
    let mut atcg_matches = 0;
    for bimentry in bim {
        if let Some(strand) = variants.get(&bimentry.name) {
            name_matches += 1;
            if (strand.position == bimentry.position) && (strand.chromosome == bimentry.chromosome)
            {
                name_pos_matches += 1;
                match match_alleles(bimentry.alleles, strand.alleles, strand.strand) {
                    AlleleMatch::ATCG => atcg_matches += 1,
                    AlleleMatch::Original => strand_matches += 1,
                    AlleleMatch::Plus => plus_matches += 1,
                    AlleleMatch::Mismatch => {}
                }
            }
        }
    }
    res.name = name.to_string();
    res.name_match_rate = name_matches as f32 / bim.len() as f32;
    res.name_pos_match_rate = name_pos_matches as f32 / name_matches as f32;
    res.strand_match_rate = strand_matches as f32 / (name_pos_matches - atcg_matches) as f32;
    res.plus_match_rate = plus_matches as f32 / (name_pos_matches - atcg_matches) as f32;
    res.atcg_match_rate = atcg_matches as f32 / name_pos_matches as f32;
    res.name_match_rate = mzinf(res.name_match_rate);
    res.name_pos_match_rate = mzinf(res.name_pos_match_rate);
    res.strand_match_rate = mzinf(res.strand_match_rate);
    res.plus_match_rate = mzinf(res.plus_match_rate);
    res.atcg_match_rate = mzinf(res.atcg_match_rate);
    res
}
fn match_bim ( bim : & [ SourceEntry ] , name : & str , variants : & HashMap < String , VariantEntry > , ) -> MatchResult { let mut res = MatchResult { name : name . to_string ( ) , name_match_rate : 0.0 , name_pos_match_rate : 0.0 , strand_match_rate : 0.0 , plus_match_rate : 0.0 , atcg_match_rate : 0.0 , } ; let mut name_matches = 0 ; let mut name_pos_matches = 0 ; let mut strand_matches = 0 ; let mut plus_matches = 0 ; let mut atcg_matches = 0 ; for bimentry in bim { if let Some ( strand ) = variants . get ( & bimentry . name ) { name_matches += 1 ; if ( strand . position == bimentry . position ) && ( strand . chromosome == bimentry . chromosome ) { name_pos_matches += 1 ; match match_alleles ( bimentry . alleles , strand . alleles , strand . strand ) { AlleleMatch :: ATCG => atcg_matches += 1 , AlleleMatch :: Original => strand_matches += 1 , AlleleMatch :: Plus => plus_matches += 1 , AlleleMatch :: Mismatch => { } } } } } res . name = name . to_string ( ) ; res . name_match_rate = name_matches as f32 / bim . len ( ) as f32 ; res . name_pos_match_rate = name_pos_matches as f32 / name_matches as f32 ; res . strand_match_rate = strand_matches as f32 / ( name_pos_matches - atcg_matches ) as f32 ; res . plus_match_rate = plus_matches as f32 / ( name_pos_matches - atcg_matches ) as f32 ; res . atcg_match_rate = atcg_matches as f32 / name_pos_matches as f32 ; res . name_match_rate = mzinf ( res . name_match_rate ) ; res . name_pos_match_rate = mzinf ( res . name_pos_match_rate ) ; res . strand_match_rate = mzinf ( res . strand_match_rate ) ; res . plus_match_rate = mzinf ( res . plus_match_rate ) ; res . atcg_match_rate = mzinf ( res . atcg_match_rate ) ; res }
Match a BIM file against a strand file
Match a BIM file against a strand file
bim
&[SourceEntry]
name
&str
variants
&HashMap<String, VariantEntry>