Skip to content

Instantly share code, notes, and snippets.

@samuell
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save samuell/6f0ecbe4c5e88c04c387 to your computer and use it in GitHub Desktop.
Save samuell/6f0ecbe4c5e88c04c387 to your computer and use it in GitHub Desktop.
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