蟒蛇蛋白质的分子量之和

时间:2017-08-13 14:26:26

标签: python

我试图计算蛋白质序列的分子量之和。我认为开始是正确的,但我不明白我如何能够得出这个序列的总和。

import string
seq = 'DHPFWKQTACKHV'
weights = {'A': 71.04, 'C': 103.01, 'D': 115.03, 'E': 129.04, 'F': 147.07,
       'G': 57.02, 'H': 137.06, 'I': 113.08, 'K': 128.09, 'L': 113.08,
       'M': 131.04, 'N': 114.04, 'P': 97.05, 'Q': 128.06, 'R': 156.10,
       'S': 87.03, 'T': 101.05, 'V': 99.07, 'W': 186.08, 'Y': 163.06 }
weight = sum()
print ("The molecular weight of this protein is", weight)

1 个答案:

答案 0 :(得分:5)

对于p中的每种蛋白seq,将其权重weights[p]添加到weight

weight = sum(weights[p] for p in seq) # => 1577.7599999999998