首页 > 代码库 > 06 Counting Point Mutations
06 Counting Point Mutations
Problem
Figure 2. The Hamming distance between these two strings is 7. Mismatched symbols are colored red.
Given two strings ss and tt of equal length, the Hamming distance between ss and tt, denoted dH(s,t)dH(s,t), is the number of corresponding symbols that differ in ss and tt. See Figure 2.
Given: Two DNA strings ss and tt of equal length (not exceeding 1 kbp).
Return: The Hamming distance dH(s,t)dH(s,t).
Sample Dataset
GAGCCTACTAACGGGATCATCGTAATGACGGCCT
Sample Output
7
方法一:
s = ‘GAGCCTACTAACGGGAT‘t = ‘CATCGTAATGACGGCCT‘count = 0for i in xrange(len(s)): if s[i] != t[i]: count +=1print count
方法二:
### Counting Point Mutations ###fh = open(‘/Users/DONG/Downloads/rosalind_hamm.txt‘, ‘rt‘)seq = fh.readlines() a,b = seq[0].strip(),seq[1].strip() hammingDistance = 0 for i in range(len(a)): if a[i] != b[i]: hammingDistance += 1 print (hammingDistance)
06 Counting Point Mutations
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。