python - 如何相对于引用系移动蛋白质坐标

标签 python biopython protein-database

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

我想相对于原点处的引用系(即 x=0、y=0、z=0)移动坐标并生成一个新的坐标文件。

我通读了biopython教程(http://biopython.org/wiki/The_Biopython_Structural_Bioinformatics_FAQ),使用了Atom对象的transform方法(http://biopython.org/DIST/docs/api/Bio.PDB.Atom.Atom-class.html#transform),并想出了这个脚本,但没有成功。

我该如何解决这个问题?非常感谢!

from Bio import PDB
import numpy as np

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:
                def rotmat():
                    rotation = rotmat(np.pi, Vector(0.0, 0.0, 0.0))
                    translation = np.array((0.0, 0.0, 0.0), 'f')
                    atom.transform(rotation, translation)

io.set_structure(struct)
io.save('1abz_coord.pdb')

最佳答案

  • 在最后一个循环中,每次循环原子时都会定义函数 rotmat,但从未调用该函数。
  • 尝试删除行 def rotmat():
  • 目前,您的旋转平移都不会改变原子坐标。

如果您想将 C1 定义为引用点,您可以使用以下代码。

rotation_matrix 只是一个不会旋转蛋白质的矩阵。 np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) 也会做同样的事情。

from Bio import PDB
import numpy as np

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

rotation_matrix = PDB.rotmat(PDB.Vector([0, 0, 0]), PDB.Vector([0, 0, 0]))

for atom in struct.get_atoms():
    atom_C1 = atom.coord.copy()
    break

for model in struct:
    for chain in model:
        for residue in chain:
            for atom in residue:
                atom.transform(rotation_matrix, -atom_C1)

io.set_structure(struct)
io.save('1abz_coord.pdb')

关于python - 如何相对于引用系移动蛋白质坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47806879/

相关文章:

python - Instagram 检测 python 请求

python - 了解已知错误 : cx_Freeze & Python 3. 7 的修复

python - 将元组转换为元素列表

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

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

python - 从蛋白质数据库 (PDB) 文本文件中提取列

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

python - 将行名称转换为 Pandas 中的列

python - 安装biopython包时遇到问题

python - DNA 搜索序列正则表达式中存在多个不匹配