Counting Point Mutations

本文介绍如何计算两个等长DNA字符串之间的汉明距离,并提供了一个简单的Python实现示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Problem

Figure 2. The Hamming distance between these two strings is 7. Mismatched symbols are colored red.

Given two strings   and   of equal length, the Hamming distance between   and  , denoted  , is the number of corresponding symbols that differ in   and  . See Figure 2.

Given: Two DNA strings   and   of equal length (not exceeding 1 kbp).

Return: The Hamming distance  .

Sample Dataset

GAGCCTACTAACGGGAT
CATCGTAATGACGGCCT

Sample Output

7
字符比较,对于文件读取还是不是很熟
file=open('rosalind_hamm.txt','r')
line=list()
for lines in file.readlines():
	line.append(lines.rstrip('\n'))
leng=len(line[0])
mutation=0;
for i in range(0,leng):
	if(line[0][i]!=line[1][i]):
		mutation+=1;
print(mutation)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值