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

AF3 from_pdb_string和from_mmcif_string函数解读

AlphaFold3的from_pdb_string和from_mmcif_string函数分别用来解析蛋白质PDB和mmCIF 格式结构数据并转换为 Protein 数据类。它通过 Biopython 提供的 PDBParser 和 MMCIFParser 解析 PDB/mmCIF 文件,再通过调用_from_bio_structure函数从 Biopython 解析出的 Structure 提取 原子坐标、残基类型、B 因子等信息,最终返回一个 Protein 对象。

源代码:

def _from_bio_structure(
        structure: Structure, chain_id: Optional[str] = None
) -> Protein:
    """Takes a Biopython structure and creates a `Protein` instance.

  WARNING: All non-standard residue types will be converted into UNK. All
    non-standard atoms will be ignored.

  Args:
    structure: Structure from the Biopython library.
    chain_id: If chain_id is specified (e.g. A), then only that chain is parsed.
      Otherwise all chains are parsed.

  Returns:
    A new `Protein` created from the structure contents.

  Raises:
    ValueError: If the number of models included in the structure is not 1.
    ValueError: If insertion code is detected at a residue.
  """
    models = list(structure.get_models())
    if len(models) != 1:
        raise ValueError(
            'Only single model PDBs/mmCIFs are supported. Found'
            f' {len(models)} models.'
        )
    model = models[0]

    atom_positions = []
    aatype = []
    atom_mask = []
    residue_index = []
    chain_ids = []
    b_factors = []

    for chain in model:
        if chain_id is not None and chain.id != chain_id:
            continue
        for res in chain:
            if res.id[2] != ' ':
                raise ValueError(
                    f'PDB/mmCIF contains an insertion code at chain {chain.id} and'
                    f' residue index {res.id[1]}. These are not supported.'
                )
            res_shortname = residue_constants.restype_3to1.get(res.resname, 'X')
            restype_idx = residue_constants.restype_order.get(
                res_shortname, residue_constants.restype_num)
            pos = np.zeros((residue_constants.atom_type_num, 3))
            mask = np.zeros((residue_constants.atom_type_num,))
            res_b_factors = np.zeros((residue_constants.atom_type_num,))
            for atom in res:
                if atom.name not in residue_constants.atom_types:
                  

相关文章:

  • 麻将对对碰游戏:规则与模拟实现
  • 【Unity3D】Jenkins Pipeline流水线自动构建Apk
  • 深入剖析 Vue 的响应式原理:构建高效 Web 应用的基石
  • HTML4
  • 记使用AScript自动化操作ios苹果手机
  • C语言中的常量与只读变量,#define与const的区别
  • CUDA-计算内存事务的次数
  • Xmind 2024安装教程超详细(小白零基础入门)图文教程【附安装包】
  • ffmpeg学习:ubuntu下编译Android版ffmpeg-kit
  • Windows搭建CUDA大模型Docker环境
  • AMESim中批处理功能的应用
  • Java类与类的关系
  • 【Hadoop】大数据权限管理工具Ranger2.1.0编译
  • 【人工智能】释放数据潜能:使用Featuretools进行自动化特征工程
  • Android Studio - Android Studio 查看项目的 Android SDK 版本(4 种方式)
  • 八、OSG学习笔记-
  • spring cloud 微服务部署(2025年)第四章:Nacos、LoadBalancer、GateWay、Ribbon集成之跨服务调用ribbon
  • 【CSS进阶】CSS元素的水平、垂直居中方法
  • C++ 实践扩展(Qt Creator 联动 Visual Studio 2022)
  • 【线段树模板】
  • 中方发布会:中美经贸高层会谈氛围是坦诚的、深入的、具有建设性的
  • 竞彩湃|热刺、曼联一周双赛不易,勒沃库森能否欢送阿隆索
  • 马鞍山市原常务副市长黄化锋一审获刑11年,涉案金额三千余万元
  • 刘元春在《光明日报》撰文:以法治护航民营经济高质量发展
  • 铁肩担道义,历史鉴未来——中共中央政治局委员、外交部长王毅谈习近平主席对俄罗斯进行国事访问并出席纪念苏联伟大卫国战争胜利80周年庆典
  • 习近平结束对俄罗斯国事访问并出席纪念苏联伟大卫国战争胜利80周年庆典回到北京