Created
August 25, 2013 17:35
-
-
Save coleoguy/6335185 to your computer and use it in GitHub Desktop.
calculate hamming distance between to aligned sequences
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dna <- read.table("rosalind_hamm.txt") | |
dna1 <- unlist(strsplit(as.character(dna[1,1]),"")) | |
dna2 <- unlist(strsplit(as.character(dna[2,1]),"")) | |
ham.dist <- 0 | |
for(i in 1:length(dna1)){ | |
if(dna1[i] != dna2[i]){ | |
ham.dist <- ham.dist +1 | |
} | |
} | |
cat(ham.dist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment