从PDB中除去杂原子 [英] Remove heteroatoms from PDB

查看:176
本文介绍了从PDB中除去杂原子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

必须删除pdb文件中的杂原子.这是代码,但不适用于我的测试PDB 1C4R.

The heteroatoms from pdb file has to be removed. Here is the code but it did not work with my test PDB 1C4R.

for model in structure:
    for chain in model:
        for reisdue in chain:
            id = residue.id
            if id[0] != ' ':
                chain.detach_child(id)
        if len(chain) == 0:
            model.detach_child(chain.id)

有什么建议吗?

推荐答案

杂原子不应成为链的一部分.但是您可以知道残基是否为具有以下特征的杂原子:

The heteroatoms shouldn't be part of the chain. But you can know if a residue is a heteroatom with:

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(没有前三个字段):

You can also get the id of the residue (without the three first fields) with:

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

I'm adding a link to the relevant documentation: http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf

主题位于第8页,什么是残基ID?".报价:

The subject is in the page 8, "What is a residue id?". Quoting:

由于笨拙的PDB格式,这有点复杂.残基id是一个元组 包含三个元素:

This is a bit more complicated, due to the clumsy PDB format. A residue id is a tuple with three elements:

  • 杂种标记:这是"H_"加上杂种残基的名称(例如"H_GLC" 如果是葡萄糖分子,则为"W";如果是水分子,则为"W".
  • The hetero-flag: this is ’H_’ plus the name of the hetero-residue (eg. ’H_GLC’ in the case of a glucose molecule), or ’W’ in the case of a water molecule.


要添加评论并继续:


To add comments in and resume:

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())

这篇关于从PDB中除去杂原子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆