如何在pdb

时间:2015-10-27 09:38:49

标签: python biopython protein-database

通过使用biopython库,我想在我的pdb文件中添加链ID。 我正在使用

p = PDBParser()
structure=p.get_structure('mypdb',mypdb.pdb)
model=structure[0]
model.child_list=["A","B"]

但我收到了这个错误:

Traceback (most recent call last):
  File "../../principal_axis_v3.py", line 319, in <module>
    main()
  File "../../principal_axis_v3.py", line 310, in main
    protA=read_PDB(struct,ch1,s1,e1)
  File "../../principal_axis_v3.py", line 104, in read_PDB
    chain=model[ch]
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/PDB/Entity.py", line 38, in __getitem__
    return self.child_dict[id]
KeyError: 'A'

我试图改变child.dict中的键,但是我又遇到了另一个错误:

Traceback (most recent call last):
  File "../../principal_axis_v3.py", line 319, in <module>
    main()
  File "../../principal_axis_v3.py", line 310, in main
    protA=read_PDB(struct,ch1,s1,e1)
  File "../../principal_axis_v3.py", line 102, in read_PDB
    model.child_dict.keys=["A","B"]
AttributeError: 'dict' object attribute 'keys' is read-only

如何添加链ID?

1 个答案:

答案 0 :(得分:1)

您的错误是child_list不是包含链ID的列表,而是Chain个对象(Bio.PDB.Chain.Chain)的列表。您必须创建Chain个对象,然后将它们添加到结构中。一个蹩脚的例子:

from Bio.PDB.Chain import Chain

my_chain = Chain("C")
model.add(my_chain)

现在您可以访问模型child_dict

>>> model.child_dict
{'A': <Chain id=A>, 'C': <Chain id=C>}
>>> model.child_dict["C"]
<Chain id=C>