biopython提取.cif文件的变换矩阵

蛋白质符合体结构中包含旋转矩阵和平移向量信息。要从 .mmCIF 文件中提取变换矩阵,可以解析文件中存储的 struct_oper 列表。.mmCIF 文件通常包含变换矩阵用于描述不同生物学组装、对称操作等。变换矩阵的信息通常存储在 _pdbx_struct_oper_list 标签下,例如 _pdbx_struct_oper_list.matrix[1][1] 对应矩阵的某个元素。

下面是一个解析 .mmCIF 文件中变换矩阵的代码示例:

复制代码
from Bio.PDB import MMCIF2Dict
import numpy as np

# 解析变换矩阵
def parse_transformation_matrices(file_path):
    # 使用 MMCIF2Dict 解析 mmCIF 文件
    cif_dict = MMCIF2Dict.MMCIF2Dict(file_path)
    
    # 提取变换矩阵信息
    matrices = []
    
    # 如果 mmCIF 文件包含变换矩阵,则从 _pdbx_struct_oper_list 中提取
    if '_pdbx_struct_oper_list.matrix[1][1]' in cif_dict:
        n_matrices = len(cif_dict['_pdbx_struct_oper_list.matrix[1][1]'])  # 矩阵数量
        
        for i in range(n_matrices):
            # 提取矩阵元素,按行存储
            matrix = np.array([
                [
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[1][1]'][i]),
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[1][2]'][i]),
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[1][3]'][i])
                ],
                [
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[2][1]'][i]),
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[2][2]'][i]),
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[2][3]'][i])
                ],
                [
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[3][1]'][i]),
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[3][2]'][i]),
                    float(cif_dict[f'_pdbx_struct_oper_list.matrix[3][3]'][i])
                ]
            ])
            
            # 提取平移向量
            translation = np.array([
                float(cif_dict[f'_pdbx_struct_oper_list.vector[1]'][i]),
                float(cif_dict[f'_pdbx_struct_oper_list.vector[2]'][i]),
                float(cif_dict[f'_pdbx_struct_oper_list.vector[3]'][i])
            ])
            
            matrices.append({'matrix': matrix, 'translation': translation})
    
    return matrices

# 示例调用
file_path = '/path/to/8p0j.cif'

# 解析变换矩阵信息
transformation_matrices = parse_transformation_matrices(file_path)

# 打印解析的变换矩阵和平移向量
for i, transform in enumerate(transformation_matrices):
    print(f"Transformation Matrix {i+1}:\n{transform['matrix']}")
    print(f"Translation Vector {i+1}:\n{transform['translation']}")

解析步骤说明:

  1. 使用 MMCIF2Dict

    • MMCIF2Dict 是 Biopython 的一个功能,它会将 .mmCIF 文件解析成一个字典。字典中的键是 .mmCIF 标签,值是对应的内容。
    • .mmCIF 文件中,变换矩阵通常以 _pdbx_struct_oper_list.matrix[n][m]_pdbx_struct_oper_list.vector[n] 的形式出现,分别表示矩阵的元素和平移向量。
  2. 提取变换矩阵和平移向量

    • 每个矩阵是一个 3x3 的矩阵,元素通过不同的标签(如 _pdbx_struct_oper_list.matrix[1][1])来获取。
    • 平移向量通过 _pdbx_struct_oper_list.vector[n] 获取。

输出结果及解释:

复制代码
Transformation Matrix 1:
[[1. 0. 0.]
 [0. 1. 0.]
 [0. 0. 1.]]
Translation Vector 1:
[0. 0. 0.]

提取出的变换矩阵为单位矩阵(Transformation Matrix 1: [[1. 0. 0.], [0. 1. 0.], [0. 0. 1.]])且平移向量(Translation Vector 1: [0. 0. 0.])为零,表示此情况下并没有对坐标进行任何变换。因此,单体的坐标就是复合体中的坐标。

解释:

  • 单位矩阵[[1. 0. 0.], [0. 1. 0.], [0. 0. 1.]])是一个不对坐标进行旋转或缩放的矩阵,意味着坐标保持不变。
  • 平移向量[0. 0. 0.])表示没有任何位移发生,因此原点保持不变。

因此,单体的坐标不会因为这组变换矩阵而改变,复合体中的单体坐标和单体自身的坐标一致。这种情况下,复合体可能只是一个由多个单体构成的集合,且这些单体的相对位置没有通过任何变换(旋转、平移)发生变化。

相关推荐
weixin_贾1 小时前
最新AI-Python机器学习与深度学习技术在植被参数反演中的核心技术应用
python·机器学习·植被参数·遥感反演
张槊哲1 小时前
函数的定义与使用(python)
开发语言·python
船长@Quant1 小时前
文档构建:Sphinx全面使用指南 — 实战篇
python·markdown·sphinx·文档构建
偶尔微微一笑2 小时前
AI网络渗透kali应用(gptshell)
linux·人工智能·python·自然语言处理·编辑器
船长@Quant3 小时前
文档构建:Sphinx全面使用指南 — 基础篇
python·markdown·sphinx·文档构建
喵手4 小时前
从 Java 到 Kotlin:在现有项目中迁移的最佳实践!
java·python·kotlin
liuweidong08024 小时前
【Pandas】pandas DataFrame rsub
开发语言·python·pandas
CH3_CH2_CHO4 小时前
不吃【Numpy】版
开发语言·python·numpy
-曾牛5 小时前
企业级AI开发利器:Spring AI框架深度解析与实战
java·人工智能·python·spring·ai·rag·大模型应用
Light605 小时前
智启未来:深度解析Python Transformers库及其应用场景
开发语言·python·深度学习·自然语言处理·预训练模型·transformers库 |·|应用场景