小编Exc*_*ttu的帖子

使用 Biopython 库删除 PDB 中的残留物

使用biopython库,我想删除列表中列出的残留物,如下所示。该线程(http://pelican.rsvs.ulaval.ca/mediawiki/index.php/Manipulated_PDB_files_using_BioPython)提供了一个去除残留物的示例。我有以下代码来去除残留物

 residue_ids_to_remove = [105, 5, 8, 10, 25, 48]
 structure = pdbparser.get_structure("3chy", "./3chy.pdb")
 first_model = structure[0]
 for chain in first_model:
     for residue in chain:
         id = residue.id
         if id[1] in residue_ids_to_remove:
             chain.detach_child(id[1])
 modified_first_model = first_model 
Run Code Online (Sandbox Code Playgroud)

但这段代码不起作用并引发了错误

def detach_child(self, id):
    "Remove a child."
    child=self.child_dict[id]
    KeyError: '105'
Run Code Online (Sandbox Code Playgroud)

这段代码有什么问题?

或者,我可以使用accept_residue()并将其写入PDB。我不想这样跟踪,因为我想在内存中执行此操作以进行进一步处理。

python protein-database biopython

5
推荐指数
1
解决办法
2831
查看次数

从 PDB 中去除杂原子

必须删除 pdb 文件中的杂原子。这是代码,但它不适用于我的测试 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)
Run Code Online (Sandbox Code Playgroud)

有什么建议吗?

python protein-database biopython

2
推荐指数
1
解决办法
4732
查看次数

标签 统计

biopython ×2

protein-database ×2

python ×2