Skip to content

Instantly share code, notes, and snippets.

@samuell
Last active Aug 29, 2015
Embed
What would you like to do?
use std::io::BufferedReader;
use std::io::File;
use std::str::StrSlice;
fn main() {
let path = Path::new("Homo_sapiens.GRCh37.67.dna_rm.chromosome.Y.fa");
let mut file = BufferedReader::new(File::open(&path));
let mut gc = 0i;
let mut at = 0i;
for line in file.lines() {
for c in line.unwrap().as_slice().chars() {
match c {
'G' => gc += 1,
'C' => gc += 1,
'A' => at += 1,
'T' => at += 1,
_ => {}
}
}
}
let gc_frac: f64 = (gc as f64) / ((at as f64) + (gc as f64));
println!("GC fraction: {}", gc_frac)
}
@samuell
Copy link
Author

samuell commented Aug 6, 2015

@huonw: I think you're right about some unfortunate differences in the code examples. I really should compile an updated benchmark soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment