当前位置: 首页 > news >正文

AF3 Rigid类make_transform_from_reference方法解读

AF3 rigid_utils模块Rigid类make_transform_from_reference 方法其实是实现从全局坐标到局部坐标的变换,输入的为氨基酸残基的 N(氮原子)、CA(α-碳原子)、C(羧基碳原子)三点坐标,返回一个全局坐标到局部坐标的变rigid实例。make_transform_from_reference 和 from_3_points方法都是返回一个到参考坐标系的变换rigid实例,但实现逻辑和返回值不一样。

源代码:

    @staticmethod
    def make_transform_from_reference(n_xyz, ca_xyz, c_xyz, eps=1e-20):
        """
            Returns a transformation object from reference coordinates.
  
            Note that this method does not take care of symmetries. If you 
            provide the atom positions in the non-standard way, the N atom will 
            end up not at [-0.527250, 1.359329, 0.0] but instead at 
            [-0.527250, -1.359329, 0.0]. You need to take care of such cases in 
            your code.
  
            Args:
                n_xyz: A [*, 3] tensor of nitrogen xyz coordinates.
                ca_xyz: A [*, 3] tensor of carbon alpha xyz coordinates.
                c_xyz: A [*, 3] tensor of carbon xyz coordinates.
            Returns:
                A transformation object. After applying the translation and 
                rotation to the reference backbone, the coordinates will 
                approximately equal to the input coordinates.
        """    
        translation = -1 * ca_xyz
        n_xyz = n_xyz + translation
        c_xyz = c_xyz + translation

        c_x, c_y, c_z = [c_xyz[..., i] for i in range(3)]
        norm = torch.sqrt(eps + c_x ** 2 + c_y ** 2)
        sin_c1 = -c_y / norm
        cos_c1 = c_x / norm
        zeros = sin_c1.new_zeros(sin_c1.shape)
        ones = sin_c1.new_ones(sin_c1.shape)

        c1_rots = sin_c1.new_zeros((*sin_c1.shape, 3, 3))
        c1_rots[..., 0, 0] = cos_c1
        c1_rots[..., 0, 1] = -1 * sin_c1
        c1_rots[..., 1, 0] = sin_c1
        c1_rots[..., 1, 1] = cos_c1
        c1_rots[..., 2, 2] = 1

        norm = torch.sqrt(eps + c_x ** 2 + c_y ** 2 + c_z ** 2)
        sin_c2 = c_z / norm
        cos_c2 = torch.sqrt(c_x ** 2 + c_y ** 2) / norm

        c2_rots = sin_c2.new_zeros((*sin_c2.shape, 3, 3))
        c2_rots[..., 0, 0] = cos_c2
        c2_rots[..., 0, 2] = sin_c2
        c2_rots[..., 1, 1] = 1
        c2_rots[..., 2, 0] = -1 * sin_c2
        c2_rots[..., 2, 2] = cos_c2

        c_rots = rot_matmul(c2_rots, c1_rots)
        n_xyz = rot_vec_mul(c_rots, n_xyz)

        _, n_y, n_z = [n_xyz[..., i] for i in range(3)]
        norm = torch.sqrt(eps + n_y ** 2 + n_z ** 2)
        sin_n = -n_z / norm
        cos_n = n_y / norm

        n_rots = sin_c2.new_zeros((*sin_c2.shape, 3, 3))
        n_rots[..., 0, 0] = 1
        n_rots[..., 1, 1] = cos_n
     

相关文章:

  • C++题目
  • NO.56|基础算法-模拟|多项式输出|蛇形方阵|字符串的展开|方向向量(C++)
  • 《汽车理论》第一章作业1.3
  • 如何学好linux驱动
  • 【机器学习】什么是线性回归?
  • 3.24-1接口测试理论
  • C++输入输出流第二弹:文件输入输出流and字符串输入输出流
  • Simula语言的正则表达式
  • 提升生产效率的关键: ethercat转TCPIP网关智能通信
  • 详细Linux中级知识(不断完善)
  • FreeSWITCH入门到精通系列(四):FreeSWITCH模块介绍与使用
  • C . Serval and The Formula【Codeforces Round 1011 (Div. 2)】
  • 社群经济4.0时代:开源链动模式与AI技术驱动的电商生态重构
  • DockerFile制作镜像(Dockerfile Creates an Image)
  • 在Spring Boot中,可以通过实现一些特定的接口来拓展Starter
  • 心法利器[132] | 大模型系统性能优化trick
  • 5.2 位运算专题:LeetCode 268. 丢失的数字
  • Ubuntu 系统部署 Ollama + DeepSeek + Docker + Ragflow
  • 企业微信实现“关联外部选项“、“审批控件中的外部选项“
  • Four.meme是什么,一篇文章读懂
  • 金砖国家外长会晤发表主席声明,强调南方国家合作
  • 交行一季度净利253.72亿元增1.54%,不良率微降
  • 癌症来临前,可能伪装成这几种常见病,千万别大意
  • 西班牙葡萄牙突发全国大停电,欧洲近年来最严重停电事故何以酿成
  • 上海“生育友好岗”已让4000余人受益,今年将推产假社保补贴政策
  • 上海虹桥至福建三明直飞航线开通,飞行时间1小时40分