Skip to content

Commit

Permalink
Merge pull request OpenGenus#3785 from Jay9596/rust_complement_dna
Browse files Browse the repository at this point in the history
Add Complement DNA in Rust
  • Loading branch information
arnavb authored Mar 1, 2019
2 parents 1a51d90 + 8e374a9 commit 2bde260
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
fn complement_dna(dna: &str) -> String {
dna.chars()
.rev()
.map(|c| match c {
'A' => 'T',
'T' => 'A',
'C' => 'G',
'G' => 'C',
_ => ' ',
})
.collect()
}

#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sample_test() {
assert_eq!(complement_dna("AAAACCCGGT"), "ACCGGGTTTT");
}
}

0 comments on commit 2bde260

Please sign in to comment.