首页 > 其他 > 详细

06 Counting Point Mutations

时间:2017-08-01 20:06:16      阅读:255      评论:0      收藏:0      [点我收藏+]

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

GAGCCTACTAACGGGAT
CATCGTAATGACGGCCT

Sample Output

7

方法一:
s = ‘GAGCCTACTAACGGGAT‘
t = ‘CATCGTAATGACGGCCT‘
count = 0
for i in xrange(len(s)):
    if s[i] != t[i]:
        count +=1
print 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

原文:http://www.cnblogs.com/think-and-do/p/7270049.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!