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

AF3 ProteinDataset类的__getitem__方法解读

AlphaFold3 protein_dataset 模块 ProteinDataset 类  __getitem__ 方法用于从数据集中获取一个条目,并根据配置对数据进行处理。

源代码:

   def __getitem__(self, idx):
        """Return an entry from the dataset.

        If a clusters file is provided, then the idx is the index of the cluster
        and the chain is randomly selected from the cluster. Otherwise, the idx
        is the index of the data entry and the chain is randomly selected from
        the data entry.

        """
        chain_id = None
        cdr = None
        idx = self.indices[idx]
        if self.clusters is None:
            id = self.data[idx]  # data is already filtered by length
            chain_id = random.choice(list(self.files[id].keys()))
            if self.cdr is not None:
                while chain_id.split("__")[1] not in self.cdr:
                    chain_id = random.choice(list(self.files[id].keys()))
        else:
            cluster = self.data[idx]
            id = None
            chain_n = -1
            while (
                id is None or len(self.files[id][chain_id]) == 0
            ):  # some IDs can be filtered out by length
                if self.shuffle_clusters:
                    chain_n = random.randint(0, len(self.clusters[cluster]) - 1)
                else:
                    chain_n += 1
    

相关文章:

  • 论文笔记——KIMI-VL:具有增强推理能力的有效开源视觉语言模型
  • 从0到1使用C++操作MSXML
  • 在 Spring Boot 中实现服务器端推送(SSE):两种方法的比较与实践
  • MySQL事务机制
  • GPT-4、Grok 3与Gemini 2.0 Pro:三大AI模型的语气、风格与能力深度对比
  • H5:实现安卓和苹果点击下载App自动跳转到对应的应用市场
  • 【C#】CAN通信的使用
  • STM32 HAL 库开发之通用定时器中断
  • Linux中的文件传输(附加详细实验案例)
  • [MRCTF2020]ezpop wp
  • CSI-PVController
  • 面向对象编程基础:从方法论到实践的全面解析
  • 【BEPU V1物理】BEPUphysics v1 入门指南 汉化笔记#1
  • JavaScript 基础语法系统学习笔记
  • 使用MPI-IO并行读写HDF5文件
  • 操作系统简要概述
  • 深入解析 Android 图形系统:Canvas、Skia、OpenGL 与 SurfaceFlinger 的协作
  • Vue 3 自定义指令
  • Mac配置开发环境
  • 【Hadoop入门】Hadoop生态之Pig简介
  • 经济日报评外卖平台被约谈:行业竞争不能背离服务本质
  • 财政部党组召开2025年巡视工作会议暨第一轮巡视动员部署会
  • “典孝急乐批麻蚌赢”:互联网“八字真言”与当代赛博赢学
  • 王毅谈中拉论坛第四届部长级会议重要共识
  • 哲学新书联合书单|远离苏格拉底
  • 人才争夺战,二三线城市和一线城市拼什么?洛阳官方调研剖析