RFDiffusion Sampler类的sample_init方法介绍

发布于:2024-12-18 ⋅ 阅读:(128) ⋅ 点赞:(0)

sample_init 方法

sample_init 是一个核心方法,用于初始化扩散采样的起始状态,包括坐标、序列、配体潜在能量等。以下是对其分步骤的详细解读:

方法目的
  • 初始化扩散过程的输入特征(初始坐标和序列)。
  • 配置采样所需的辅助模块,如 PotentialManager 和去噪器。
  • 解析输入数据并进行必要的处理(例如生成片段映射)。
方法返回
  • xt: 初始坐标,部分随机化。
  • seq_t: 初始序列,其中部分残基被设置为未知标志(掩码)。

源代码:

    def sample_init(self, return_forward_trajectory=False):
        """
        Initial features to start the sampling process.
        
        Modify signature and function body for different initialization
        based on the config.
        
        Returns:
            xt: Starting positions with a portion of them randomly sampled.
            seq_t: Starting sequence with a portion of them set to unknown.
        """
        
        #######################
        ### Parse input pdb ###
        #######################

        self.target_feats = iu.process_target(self.inf_conf.input_pdb, parse_hetatom=True, center=False)

        ################################
        ### Generate specific contig ###
        ################################

        # Generate a specific contig from the range of possibilities specified at input

        self.contig_map = self.construct_contig(self.target_feats)
        self.mappings = self.contig_map.get_mappings()
        self.mask_seq = torch.from_numpy(self.contig_map.inpaint_seq)[None,:]
        self.mask_str = torch.from_numpy(self.contig_map.inpaint_str)[None,:]
        self.binderlen =  len(self.contig_map.inpaint)

        ####################
        ### Get Hotspots ###
        ####################

        self.hotspot_0idx=iu.get_idx0_hotspots(self.mappings, self.ppi_conf, self.binderlen)


        #####################################
        ### Initialise Potentials Manager ###
        #####################################

        self.potential_manager = PotentialManager(self.potential_conf,
                                                  self.ppi_conf,
                                                  self.diffuser_conf,
                                                  self.inf_conf,
                                                  self.hotspot_0idx,
                                                  self.binderlen)

        ###################################
        ### Initialize other attributes ###
        ###################################

        xyz_27 = self.target_feats['xyz_27']
        mask_27 = self.target_feats['mask_27']
        seq_orig = self.target_fe

网站公告

今日签到

点亮在社区的每一天
去签到