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.])表示没有任何位移发生,因此原点保持不变。

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

相关推荐
天才测试猿7 小时前
2026软件测试面试八股文(含答案+文档)
自动化测试·软件测试·python·功能测试·测试工具·面试·职场和发展
张小凡vip8 小时前
python--爬虫--成熟的爬虫框架Scrapy
爬虫·python·scrapy
Pluchon8 小时前
Java个人综合项目——萌部落社区V2.0
java·python·spring·spring cloud·postman·idea
不瘦80斤不改名9 小时前
01-vibe-coding-起源与本质
人工智能·python
夜雪一千9 小时前
如何对新闻数据进行模糊去重
python
oyguyteggytrrwwwrt11 小时前
3dgs渲染部分详细注释
python
天天爱吃肉821813 小时前
【重磅发布:拿下新超仁达代理权 】
大数据·人工智能·python·功能测试·汽车
神王宝宝 王者小学13 小时前
面向领域驱动架构的查询实现方式
前端·python·架构
ningmengjing_14 小时前
Redis 从入门到实战:Python操作全攻略
数据库·redis·python
️学习的小王14 小时前
智能文档助手:基于RAG的本地化文档问答系统实战指南
人工智能·python·机器学习