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

AF3​​​​​​​ parse函数解读

AlphaFold3 中mmcif_parsing模块的parse函数的主要作用是 解析 mmCIF 文件内容,提取蛋白质结构信息,转换为 MmcifObject,并返回解析结果

源代码:

@functools.lru_cache(16, typed=False)
def parse(
    *, file_id: str, mmcif_string: str, catch_all_errors: bool = True
) -> ParsingResult:
    """Entry point, parses an mmcif_string.

    Args:
      file_id: A string identifier for this file. Should be unique within the
        collection of files being processed.
      mmcif_string: Contents of an mmCIF file.
      catch_all_errors: If True, all exceptions are caught and error messages are
        returned as part of the ParsingResult. If False exceptions will be allowed
        to propagate.

    Returns:
      A ParsingResult.
    """
    errors = {}
    try:
        parser = PDB.MMCIFParser(QUIET=True)
        handle = io.StringIO(mmcif_string)
        full_structure = parser.get_structure("", handle)
        first_model_structure = _get_first_model(full_structure)
        # Extract the _mmcif_dict from the parser, which contains useful fields not
        # reflected in the Biopython structure.
        parsed_info = parser._mmcif_dict  # pylint:disable=protected-access

        # Ensure all values are lists, even if singletons.
        for key, value in parsed_info.items():
            if not isinstance(value, list):
                parsed_info[key] = [value]

        header = _get_header(parsed_info)

        # Determine the protein chains, and their start numbers according to the
        # internal mmCIF numbering scheme (likely but not guaranteed to be 1).
        valid_chains = _get_protein_chains(parsed_info=parsed_info)
        if not valid_chains:
            return ParsingResult(
                None, {(file_id, ""): "No protein chains found in this file."}
            )
        seq_start_num = {
            chain_id: min([monomer.num for monomer in seq])
            for chain_id, seq in valid_chains.items()
        }

        # Loop over the atoms for which we have coordinates. Populate two mappings:
        # -mmcif_to_author_chain_id (maps internal mmCIF chain ids to chain ids used
        # the authors / Biopython).
        # -seq_to_structure_mappings (maps idx into sequence to ResidueAtPosition).
        mmcif_to_author_chain_id = {}
        seq_to_structure_mappings = {}
        for atom in _get_atom_site_list(parsed_info):
            if atom.model_num != "1":
                # We only process the first model at the moment.
                continue

            mmcif_to_author_chain_id[atom.mmcif_chain_id] = atom.author_chain_id

            if atom.mmcif_chain_id in valid_chains:
                hetflag = " "
                if atom.hetatm_atom == "HETATM":
                    # Water atoms are assigned a special hetflag

相关文章:

  • 以下是C++从入门到精通的学习路径及实践方法,结合系统学习框架与实战经验,帮助普通人和程序员高效掌握并开发第一个产品
  • LlamaFactory可视化模型微调-Deepseek模型微调+CUDA Toolkit+cuDNN安装
  • Spark Streaming是如何实现实时大数据处理的
  • 前端如何播放二进制音频数据
  • 使用AWS Amplify AI Kit和Neon Postgres构建基于RAG的应用程序
  • string类详解(上)
  • 【AscendC】复现AI原生创新算子挑战赛S1(二)
  • 以 Serverless 低成本的⽅式 快速在亚马逊云科技上部署 DeepSeek
  • linux中(base) [root@ZS ~]# 是什么情况,怎么退出
  • DeepSeek 对成语理解能力的研究与分析
  • npm install --legacy-peer-deps和npm install --force的区别
  • Cookie介绍及使用场景
  • 图片属性——位深度
  • 学习threejs,使用PointLight点光源
  • EasyExcel的简单使用
  • es-head 正则查询和标准正则查询的差异
  • 基于Dify、Ollama与DeepSeek的私有化AI知识库构建:工具作用、场景与优势分析
  • SpringCloud面试题----什么是Zuul微服务网关
  • KT142C语音芯片支持的语音文件格式什么?Mp3还是wav呢?
  • 排序算法复习——包括插入排序、希尔排序、冒泡排序、快排(包括霍尔法、挖坑法、快慢指针法)、堆排、选择排序、归并排序等 (代码采用c/c++混编)
  • 黄仁勋访华期间表示希望继续与中国合作,贸促会回应
  • 四川在浙江公开招募200名退休教师,赴川支教帮扶
  • 坚守刑事检察一线13年,“在我心中每次庭审都是一次大考”
  • 商务部:将积极会同相关部门加快推进离境退税政策落实落地
  • 大家聊中国式现代化|周冯琦:转角见美,让“绿意”触手可及
  • 航行警告!黄海南部进行实弹射击,禁止驶入