python - python中蛋白质的分子量总和

标签 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)

最佳答案

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

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

关于python - python中蛋白质的分子量总和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45661391/

相关文章:

python - 并行 Python - 在并行执行中将对象创建到另一个类中

Python cgi.FieldStorage() 在表单提交时为空

python - 帮助更改 Tk 窗口的图标

Python enum.Flag 具有一个被其他人使用的标志

python - Python 中有 "wildcard method"吗?

python - 如何通过获取 shell 文件在 Python 中使用变量

python - python 中的 OpenGL 因 glCheckError 调用而变慢

python - 聚合 groupby dataFrame 并输出到新 DataFrame 的有效方法

python - 如何在 PyCharm 中为 flake8 启用自动代码格式化

javascript - 通过程序获取 Coursera 视频下载链接