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

AF3​​​​​​​ get_atom_coords函数解读

AlphaFold3 中的get_atom_coords函数的主要作用是从 MmcifObject 中提取某条链的所有原子坐标,并返回坐标矩阵和掩码矩阵,以便后续用于蛋白质建模或 AlphaFold3 的预测。

源代码:

def get_atom_coords(
    mmcif_object: MmcifObject, 
    chain_id: str, 
    _zero_center_positions: bool = False
) -> Tuple[np.ndarray, np.ndarray]:
    # Locate the right chain
    chains = list(mmcif_object.structure.get_chains())
    relevant_chains = [c for c in chains if c.id == chain_id]
    if len(relevant_chains) != 1:
        raise MultipleChainsError(
            f"Expected exactly one chain in structure with id {chain_id}."
        )
    chain = relevant_chains[0]

    # Extract the coordinates
    num_res = len(mmcif_object.chain_to_seqres[chain_id])
    all_atom_positions = np.zeros(
        [num_res, residue_constants.atom_type_num, 3], dtype=np.float32
    )
    all_atom_mask = np.zeros(
        [num_res, residue_constants.atom_type_num], dtype=np.float32
    )
    for res_index in range(num_res):
        pos = np.zeros([residue_constants.atom_type_num, 3], dtype=np.float32)
        mask = np.zeros([residue_constants.atom_type_num], dtype=np.float32)
        res_at_position = mmcif_object.seqres_to_structure[chain_id][res_index]
        if not res_at_position.is_missing:
            res = chain[
                (
                    res_at_position.hetflag,
                    res_at_position.position.residue_number,
                    res_at_position.position.insertion_code,
                )
            ]
            for atom in res.get_atoms():
                atom_name = atom.get_name()
                x, y, z = atom.get_coord()
                if atom_name in residue_constants.atom_order.keys():
                    pos[residue_constants.atom_order[atom_name]] = [x, y, z]
                    mask[residue_constants.atom_order[atom_name]] = 1.0
                elif atom_name.upper() == "SE" and res.get_resname() == "MSE":
                    # Put the coords of the selenium atom in the sulphur column
                    pos[residue_constants.atom_order["SD"]] = [x, y, z]
                    mask[residue_constants.atom_order["SD"]] = 1.0

            # Fix naming errors in arginine residu

相关文章:

  • 火语言RPA--字符串内插入字符串
  • 适配器模式详解(Java)
  • . Unable to find a @SpringBootConfiguration(默认软件包中的 Spring Boot 应用程序)
  • 三、Unity基础(主要框架)
  • 撕碎QT面具(1):Tab Widget转到某个Tab页
  • 数据结构——顺序表与链表
  • 华为昇腾920b服务器部署DeepSeek翻车现场
  • ESP32鼠标驱动(ble hid device_demo)【ESP32指向鼠标】
  • 外贸订货系统的核心功能模块解析
  • 基于fastadmin快速搭建导航站和API接口站点系统源码
  • 深入剖析GC问题:如何有效判断与排查
  • DeepSeek专题:DeepSeek-V1核心知识点速览
  • 国内情智机器人:从“通情达理”到温暖陪伴的跨越
  • UDP通信开发
  • 前端面试技巧与实践
  • 基于AWS云平台的法律AI应用系统开发方案
  • 嵌入式软件、系统、RTOS(高软23)
  • 深入理解Python多进程编程 multiprocessing
  • 「软件设计模式」外观模式(Facade)
  • 洛谷 B4025:最大公约数 ← 辗转相除法+更相减损法
  • 齐白石精品在波士顿展出,“白石画屋”呈现水墨挥洒
  • 文化润疆|为新疆青少年提供科普大餐,“小小博物家(喀什版)”启动
  • 风雨天涯梦——《袁保龄公牍》发微
  • 上海团队在医学顶刊连发两文,率先提出“证据污染”循证概念
  • “11+2”复式票,宝山购彩者领走大乐透1170万头奖
  • 为惩戒“工贼”,美国编剧工会“痛下杀手”