fn read_bim(filename: &str) -> Result<Vec<SourceEntry>> {
    let file = File::open(filename)?;
    let mut names: Vec<SourceEntry> = Vec::new();
    let mut entry = SourceEntry {
        name: String::from(""),
        chromosome: 0,
        position: 0,
        alleles: ('X', 'X'),
    };

    // Data syntax:
    // <some value> <variant-name*> <some other value> <position*> <some other value> ...
    //              ^^^^^^^^^^^^^^^ String             ^^^^^^^^^^^^ u64
    for line in BufReader::new(file).lines() {
        let line = line?;
        let mut l = line.split_whitespace();
        entry.chromosome = chromosome_to_number(l.next().unwrap());
        entry.name = l.next().unwrap().to_string();
        entry.position = u64::from_str_radix(l.nth(1).unwrap(), 10).unwrap();
        entry.alleles.0 = l.next().unwrap().chars().next().unwrap();
        entry.alleles.1 = l.next().unwrap().chars().next().unwrap();

        names.push(entry.clone());
    }
    Ok(names)
}
// Reads a list of variants from the BIM file
Reads a list of variants from the BIM file
Reads a list of variants from the BIM file
fn read_bim(filename: &str) -> Result<Vec<SourceEntry>> {
    let file = File::open(filename)?;
    let mut names: Vec<SourceEntry> = Vec::new();
    let mut entry = SourceEntry {
        name: String::from(""),
        chromosome: 0,
        position: 0,
        alleles: ('X', 'X'),
    };
    // Data syntax:
    // <some value> <variant-name*> <some other value> <position*> <some other value> ...
    //              ^^^^^^^^^^^^^^^ String             ^^^^^^^^^^^^ u64
    for line in BufReader::new(file).lines() {
        let line = line?;
        let mut l = line.split_whitespace();
        entry.chromosome = chromosome_to_number(l.next().unwrap());
        entry.name = l.next().unwrap().to_string();
        entry.position = u64::from_str_radix(l.nth(1).unwrap(), 10).unwrap();
        entry.alleles.0 = l.next().unwrap().chars().next().unwrap();
        entry.alleles.1 = l.next().unwrap().chars().next().unwrap();
        names.push(entry.clone());
    }
    Ok(names)
}
fn read_bim ( filename : & str ) -> Result < Vec < SourceEntry > > { let file = File :: open ( filename ) ? ; let mut names : Vec < SourceEntry > = Vec :: new ( ) ; let mut entry = SourceEntry { name : String :: from ( " " ) , chromosome : 0 , position : 0 , alleles : ( 'X' , 'X' ) , } ; // Data syntax: // <some value> <variant-name*> <some other value> <position*> <some other value> ... //              ^^^^^^^^^^^^^^^ String             ^^^^^^^^^^^^ u64 for line in BufReader :: new ( file ) . lines ( ) { let line = line ? ; let mut l = line . split_whitespace ( ) ; entry . chromosome = chromosome_to_number ( l . next ( ) . unwrap ( ) ) ; entry . name = l . next ( ) . unwrap ( ) . to_string ( ) ; entry . position = u64 :: from_str_radix ( l . nth ( 1 ) . unwrap ( ) , 10 ) . unwrap ( ) ; entry . alleles . 0 = l . next ( ) . unwrap ( ) . chars ( ) . next ( ) . unwrap ( ) ; entry . alleles . 1 = l . next ( ) . unwrap ( ) . chars ( ) . next ( ) . unwrap ( ) ; names . push ( entry . clone ( ) ) ; } Ok ( names ) }
Reads a list of variants from the BIM file
Reads a list of variants from the BIM file
filename
&str