Skip to content

Instantly share code, notes, and snippets.

@coleoguy
Created August 25, 2013 17:35
Show Gist options
  • Save coleoguy/6335185 to your computer and use it in GitHub Desktop.
Save coleoguy/6335185 to your computer and use it in GitHub Desktop.
calculate hamming distance between to aligned sequences
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