我正在处理的数据来自一个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包可以捕获“未知氨基酸”吗?或者有其他建议吗?
发布于 2017-02-11 00:11:45
正如peterjc所说,J是一种编码亮氨酸(L)或异亮氨酸(I)的模棱两可的氨基酸。两者具有相同的分子量:
>>> from Bio.SeqUtils.ProtParam import ProteinAnalysis
>>> ProteinAnalysis('L').molecular_weight()
131.1729
>>> ProteinAnalysis('I').molecular_weight()
131.1729因此,您可以临时将所有出现的J替换为L或I,以计算分子量。
发布于 2017-02-10 23:31:59
Biopython使用来自IUPAC的蛋白质分子量,请参阅https://github.com/biopython/biopython/blob/master/Bio/Data/IUPACData.py
J是一种不明确的氨基酸,编码亮氨酸或异亮氨酸(L或I),用于无法区分它们的核磁共振中。
根据你为什么需要分子量,它可能适合你使用重量的平均值使用L和I?
https://stackoverflow.com/questions/42159712
复制相似问题