民工心事 发表于 2025-4-18 01:43:08

AF3 ProteinDataset类的_patch方法解读

AlphaFold3 protein_dataset模块 ProteinDataset 类_patch 方法的主要目标是围绕锚点残基(anchor residues)裁剪蛋白质数据,提取一个局部补丁(patch)作为模型输入。
源代码:

    def _patch(self, data):
      """Cut the data around the anchor residues."""
      # adapted from diffab
      pos_alpha = data["X"][:, 2]
      if self.mask_whole_chains:
            mask_ = (data["mask"] * data["masked_res"]).bool()
            anchor_points = pos_alpha.mean(0).unsqueeze(0)
            anchor_ind = []
      else:
            anchor_ind = self.get_anchor_ind(data["masked_res"], data["mask"])
            anchor_points = torch.stack( for ind in anchor_ind], dim=0)
      dist_anchor = torch.cdist(pos_alpha, anchor_points, p=2).min(dim=1)# (L, )
      dist_anchor[~data["mask"].bool()] = float("+inf")
      initial_patch_idx = torch.topk(
            dist_anchor,
            k=min(self.initial_patch_size, dist_anchor.size(0)),
            largest=False,
            sorted=True,
      )[
            1
      ]# (initial_patch_size, )
      patch_mask = data["masked_res"].bool().clone()
      patch_mask[] = True
      patch_mask = True

      if self.sabdab:
            antibody_mask = self._get_antibody_mask(data)
            antigen_mask = ~antibody_mask
            dist_anchor_antigen = dist_anchor.masked_fill(
               
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: AF3 ProteinDataset类的_patch方法解读