替换PDB中的残余数字为给定的残余数字列表

2024-10-03 02:42:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我重新编号了残基编号,新的残基=[18,19,20,21,22,34,35,36,37。。。。130131132]我想用这个列表更改我的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")

Tags: inidchain列表newformodelstructure
1条回答
网友
1楼 · 发布于 2024-10-03 02:42:21

在你的例子中,你覆盖了所有关于残基的信息,还有关于特定位置的氨基酸的信息。在

让我们将文件中的所有id递增200,循环使用models和structures,然后使用get_residues()和{}来获得所有的残数和索引。在

在残留物.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")

相关问题 更多 >