Skip to content

Instantly share code, notes, and snippets.

@stepjue
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save stepjue/ccaef56d5aa5df51c1e1 to your computer and use it in GitHub Desktop.

Select an option

Save stepjue/ccaef56d5aa5df51c1e1 to your computer and use it in GitHub Desktop.
Solution for Rosalind's "hamm" problem (http://rosalind.info/problems/hamm/). Finds the Hamming distance of two DNA strings.
def hamming_distance(s,t):
dist = 0
for i in range(s):
if(s[i] != t[i]):
dist++
return dist
if __name__ == "__main__":
lines = []
for line in open("rosalind_hamm.txt"):
lines.append(line)
s = lines[0]
t = lines[1]
dist = hamming_distance(s,t)
print(dist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment