Skip to content

Commit

Permalink
Add Complement DNA in Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay9596 committed Oct 11, 2018
1 parent 3e4416d commit e8b373b
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
fn complement_dna(dna: &str) -> String {
dna.chars()
.rev()
.map(|c| match c {
'A' => 'T',
'T' => 'A',
'C' => 'G',
'G' => 'C',
_ => ' ',
}).collect()
}

#[test]
fn sample_test() {
assert_eq!(complement_dna("AAAACCCGGT"), "ACCGGGTTTT");
}

0 comments on commit e8b373b

Please sign in to comment.