BioPython:氨基酸序列包含'J',无法计算分子量

BioPython: Amino acid Sequence contains 'J' and can't calculate the molecular weight

我正在使用的数据来自一个 Excel 文件,该文件的氨基酸序列位于索引 1 上。我正在尝试使用 BioPython 根据序列计算不同的属性。我现在拥有的代码:

import xlrd
import sys
from Bio.SeqUtils.ProtParam import ProteinAnalysis

print '~~~~~~~~~~~~~~~ EXCEL PARSER FOR PVA/NON-PVA DATA ~~~~~~~~~~~~~~~'

print 'Path to Excel file:', str(sys.argv[1])
fname = sys.argv[1]
workbook = xlrd.open_workbook(fname, 'rU')

print ''
print 'The sheet names that have been found in the Excel file: '
sheet_names = workbook.sheet_names()
number_of_sheet = 1
for sheet_name in sheet_names:
    print '*', number_of_sheet, ':     ', sheet_name
    number_of_sheet += 1

with open("thefile.txt","w") as f:
    lines = []
    f.write('LENGTH.SEQUENCE,SEQUENCE,MOLECULAR.WEIGHT\n')
    for sheet_name in sheet_names:
        worksheet = workbook.sheet_by_name(sheet_name)
        print 'opened: ', sheet_name
        for i in range(1, worksheet.nrows):
            row = worksheet.row_values(i)
            analysed_seq = ProteinAnalysis(row[1].encode('utf-8'))
            weight = analysed_seq.molecular_weight()
            lines.append('{},{},{}\n'.format(row[2], row[1].encode('utf-8'), weight))
    f.writelines(lines)

它一直在工作,直到我添加了分子量的计算。这表明出现以下错误:

Traceback (most recent call last):
  File "Excel_PVAdata_Parser.py", line 28, in <module>
    weight = analysed_seq.molecular_weight()
  File "/usr/lib/python2.7/dist-packages/Bio/SeqUtils/ProtParam.py", line 114, in molecular_weight
    total_weight += aa_weights[aa]
KeyError: 'J'

我查看了 Excel 数据文件,这表明氨基酸序列确实包含一个 J。有人知道捕获那里的 BioPython 包吗 'unknown aminoacids' 或者有其他建议?

Biopython 使用来自 IUPAC 的蛋白质分子量,参见 https://github.com/biopython/biopython/blob/master/Bio/Data/IUPACData.py

J 是亮氨酸或异亮氨酸(L 或 I)的模糊氨基酸编码,用于无法区分它们的 NMR。

根据您需要分子量的原因,使用 L 和 I 的重量平均值可能适合您?

正如peterjc所说,J是亮氨酸(L)或异亮氨酸(I)的模糊氨基酸编码。两者具有相同的分子量:

>>> from Bio.SeqUtils.ProtParam import ProteinAnalysis
>>> ProteinAnalysis('L').molecular_weight()
131.1729
>>> ProteinAnalysis('I').molecular_weight()
131.1729

因此您可以暂时将所有出现的 J 替换为 LI 以计算分子量。