杂原子不应该是链的一部分。但是您可以知道残基是否是杂原子:
pdb = PDBParser().get_structure("1C4R", "1C4R.pdb")
for residue in pdb.get_residues():
tags = residue.get_full_id()
# tags contains a tuple with (Structure ID, Model ID, Chain ID, (Residue ID))
# Residue ID is a tuple with (*Hetero Field*, Residue ID, Insertion Code)
# Thus you're interested in the Hetero Field, that is empty if the residue
# is not a hetero atom or have some flag if it is (W for waters, H, etc.)
if tags[3][0] != " ":
# The residue is a heteroatom
else:
# It is not
您还可以通过以下方式获取残基的 id(没有前三个字段):
tags = residue.id
# or het_flag,_ ,_ = residue.id
if tags[0] != " ":
# The residue is a heteroatom
else:
# It is not
我正在添加相关文档的链接:http: //biopython.org/DIST/docs/cookbook/biopdb_faq.pdf
主题在第 8 页,“什么是残基 ID?”。报价:
由于笨拙的 PDB 格式,这有点复杂。残基 id 是一个包含三个元素的元组:
- 异质标志:这是“H_”加上异质残基的名称(例如,在葡萄糖分子的情况下为“H_GLC”),或在水分子的情况下为“W”。
要添加评论并恢复:
from Bio.PDB import PDBParser, PDBIO, Select
class NonHetSelect(Select):
def accept_residue(self, residue):
return 1 if residue.id[0] == " " else 0
pdb = PDBParser().get_structure("1C4R", "1C4R.pdb")
io = PDBIO()
io.set_structure(pdb)
io.save("non_het.pdb", NonHetSelect())