python - 如何从 pdb 文件中分别获取 X、Y 或 Z 坐标

标签 python biopython protein-database

我有一个 PDB 文件“1abz”(https://files.rcsb.org/view/1ABZ.pdb),其中包含蛋白质结构的坐标。请忽略标题注释行,有趣的信息从第 276 行开始,上面写着“MODEL 1”。

我想从 pdb 文件中单独获取 X、Y 或 Z 坐标。

此链接解释了 pdb 文件的列号:http://cupnet.net/pdb-format/

这是我的代码,但我收到一条错误消息。

from Bio import PDB

parser = PDB.PDBParser()
io = PDB.PDBIO()
struct = parser.get_structure('1abz','1abz.pdb')

for model in struct:
    for chain in model:
        for residue in chain:
            for atom in residue:
                XYZ = atom.get_coord()
                for line in XYZ:
                    x_coord = float(line[30:38].strip())
                    y_coord = float(line[38:46].strip())
                    z_coord = float(line[46:54].strip())
                    print x_coord
                    print y_coord
                    print z_coord

最佳答案

>>> Bio.__version__
'1.69'

from Bio import PDB

parser = PDB.PDBParser()
io = PDB.PDBIO()
struct = parser.get_structure('1ABZ','1ABZ.pdb')

for model in struct:
    for chain in model:
        for residue in chain:
            for atom in residue:
                x,y,z = atom.get_coord()
                print(x,y,z)

结果:

15.254 -0.607 3.211
16.429 -0.874 3.019
14.337 -1.034 2.53
14.908 0.287 4.404
13.772 1.237 4.018
12.591 1.037 4.971
11.729 0.213 4.737
15.778 0.862 4.685
14.596 -0.326 5.237
13.458 1.028 3.007
14.118 2.259 4.084
...

关于python - 如何从 pdb 文件中分别获取 X、Y 或 Z 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47825542/

相关文章:

python - 使用 Azurite 在本地调试 Azure Function 时如何修复 'launch.json' 错误?

python - 在 Python 3 中获取所有父类(super class)

python - 如何使用 GenericRelation 的逆函数

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

linux - 在 pdb 文件的每 2-3-4 行使用 awk 和 sed 替换文本

python - 两个类似的实现退出运行时间差异巨大

python - 返回外部函数

macos - MacOSX El Capitan上安装Biopython,gcc报错-Qunused-arguments

python - Biopython 类实例 - Entrez.read : I don't know how to manipulate the output 的输出

linux - 如何删除与另一个文件中的元素匹配的行