【问题标题】:BioPython: Amino acid Sequence contains 'J' and can't calculate the molecular weightBioPython:氨基酸序列包含“J”,无法计算分子量
【发布时间】:2017-02-13 11:45:14
【问题描述】:

我正在使用的数据来自一个 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 包,它在那里捕获“未知氨基酸”或有其他建议吗?

【问题讨论】:

  • 这个问题似乎是非常特定于包的,这不是任何 python 标准模块。我建议查看特定论坛或项目的 github 页面。

标签: python bioinformatics xlrd biopython


【解决方案1】:

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

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

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

【讨论】:

  • 非常感谢!我将编写一个函数来验证序列并在 J 出现时将其更改为 L。
【解决方案2】:

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

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

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

【讨论】:

  • 非常感谢!我将编写一个函数来验证序列并在 J 出现时将其更改为 L。
  • 我应该检查一下,很好发现。 Biopython 在没有用户干预的情况下为J 执行此操作似乎是合理的。你喜欢提出拉取请求或提交问题吗?
猜你喜欢
  • 2014-03-28
  • 2019-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-10
  • 2014-04-08
  • 1970-01-01
  • 2014-05-13
相关资源
最近更新 更多