Biopython无法直接访问异质残基

2024-04-17

我可以使用以下方法直接获取蛋白质 1n31 的残基:

residue = structure[0]['A'][100]

然而,当我尝试访问异质残基时,例如:

residue = structure[0]['A'][2003]

我收到错误消息:

File "<stdin>", line 1, in <module>

File "/home/azevedo/.local/lib/python3.5/site-packages/Bio/PDB/Chain.py", line 94, in __getitem__
return Entity.__getitem__(self, id)

File "/home/azevedo/.local/lib/python3.5/site-packages/Bio/PDB/Entity.py", line 41, in __getitem__
return self.child_dict[id]

关键错误:('',2003,'')

为什么会发生这种情况?如何直接获取异质残基?


简短回答

structure[0]['A'][('H_CYS', 2003, ' ')]

会给你想要的残留物

<Residue CYS het=H_CYS resseq=2003 icode= >

BioPython 的 PDB 索引

BioPython 的 PDB 残留索引使用tuple内部。它由异源标记、序列标识符和插入代码组成。对于您的残基 1000,它将是 (' ', 100, ' '),对于您的异质残基,它将是('H_CYS', 2003, ' ').

如果您仅提供一个整数作为索引,它将被转换为(' ', your_int, ' ').

代码可以在函数中找到_translate_id https://github.com/biopython/biopython/blob/master/Bio/PDB/Chain.py

通用解决方案

如果您事先不知道异质标志,您可以使用自己的函数

def get_residue_by_number(residues, number):
    for residue in residues:
        if residue.id[1] == number:
            return residue

get_residue_by_number(structure[0]['A'].get_residues(), 2003)
<Residue CYS het=H_CYS resseq=2003 icode= >
get_residue_by_number(structure[0]['A'].get_residues(), 100)
<Residue ASP het=  resseq=100 icode= >
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Biopython无法直接访问异质残基 的相关文章

随机推荐