AF3 ProteinDataset类的_patch方法解读

打印 上一主题 下一主题

主题 1630|帖子 1630|积分 4890

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

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

  1.     def _patch(self, data):
  2.         """Cut the data around the anchor residues."""
  3.         # adapted from diffab
  4.         pos_alpha = data["X"][:, 2]
  5.         if self.mask_whole_chains:
  6.             mask_ = (data["mask"] * data["masked_res"]).bool()
  7.             anchor_points = pos_alpha[mask_].mean(0).unsqueeze(0)
  8.             anchor_ind = []
  9.         else:
  10.             anchor_ind = self.get_anchor_ind(data["masked_res"], data["mask"])
  11.             anchor_points = torch.stack([pos_alpha[ind] for ind in anchor_ind], dim=0)
  12.         dist_anchor = torch.cdist(pos_alpha, anchor_points, p=2).min(dim=1)[0]  # (L, )
  13.         dist_anchor[~data["mask"].bool()] = float("+inf")
  14.         initial_patch_idx = torch.topk(
  15.             dist_anchor,
  16.             k=min(self.initial_patch_size, dist_anchor.size(0)),
  17.             largest=False,
  18.             sorted=True,
  19.         )[
  20.             1
  21.         ]  # (initial_patch_size, )
  22.         patch_mask = data["masked_res"].bool().clone()
  23.         patch_mask[[int(x) for x in anchor_ind]] = True
  24.         patch_mask[initial_patch_idx] = True
  25.         if self.sabdab:
  26.             antibody_mask = self._get_antibody_mask(data)
  27.             antigen_mask = ~antibody_mask
  28.             dist_anchor_antigen = dist_anchor.masked_fill(
  29.                
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

民工心事

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表