用给定的残留数列表替换pdb中的残留数

时间:2017-06-16 16:22:49

标签: python biopython pdb pdb-files

我将重新编号的残留数列表作为new_residues = [18,19,20,21,22,34,35,36,37 ...... 130,131,132],我想用此列表更改我的pdb残留数。你有什么想法重新编号吗?

...

w=PDBIO()
            structure=p.get_structure(" ", pdbfile)
            for model in structure:
                    for chain in model:
                            chain_ID=model[chainID]
                            for residue in chain_ID:
                            #for i in range(len(residue.id)):
                                            #resID=new_resnums[i]
                                    residue.id=(" ",new_resnums[residue.id[1]], " ")
            w.set_structure(structure)
            w.save(pdbfile + "-new.pdb")

1 个答案:

答案 0 :(得分:0)

在您的示例中,您将覆盖有关残留物的所有信息,以及有关特定位置氨基酸的信息。

让我们将文件中的所有ID增加200,循环遍历modelstructures,然后将get_residues()enumerate结合使用以获取所有残差和索引。

residual.id存储在list中,只更改了id。然后将此list转换回tuple并代替原始ID。

from Bio import PDB

pdb_io = PDB.PDBIO()
pdb_parser = PDB.PDBParser()
pdbfile = '1ubq.pdb'
structure = pdb_parser.get_structure(" ", pdbfile)

new_resnums = [i + 200 for i in range(135)]

for model in structure:
    for chain in model:
        for i, residue in enumerate(chain.get_residues()):
            res_id = list(residue.id)
            res_id[1] = new_resnums[i]
            residue.id = tuple(res_id)

pdb_io.set_structure(structure)
pdb_io.save(pdbfile + "-new.pdb")