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

AF3 pair_sequences函数解读

AlphaFold3 msa_pairing模块的pair_sequences函数的核心目标是基于 MSA(多序列比对)中的物种信息,在多条链之间建立 MSA 配对索引,从而帮助 AlphaFold3 捕捉共进化信息,提升蛋白复合物预测的准确性。函数pair_sequences 通过调用 _make_msa_df、  _create_species_dict  以及_match_rows_by_sequence_similarity实现其功能。

源代码:

def pair_sequences(
        examples: List[Mapping[str, np.ndarray]],
) -> Dict[int, np.ndarray]:
    """Returns indices for paired MSA sequences across chains."""

    num_examples = len(examples)

    all_chain_species_dict = []
    common_species = set()
    for chain_features in examples:
        msa_df = _make_msa_df(chain_features)
        species_dict = _create_species_dict(msa_df)
        all_chain_species_dict.append(species_dict)
        common_species.update(set(species_dict))

    common_species = sorted(common_species)
    common_species.remove(b'')  # Remove target sequence species.

    all_paired_msa_rows = [np.zeros(len(examples), int)]
    all_paired_msa_rows_dict = {k: [] for k in range(num_examples)}
    all_paired_msa_rows_dict[num_examples] = [np.zeros(len(examples), int)]

    for species in common_species:
        if not species:
            continue
        this_species_msa_dfs = []
        species_dfs_present = 0
        for species_dict in all_chain_species_dict:
            if species in species_dict:
                this_species_msa_dfs.append(species_dict[species])
                species_dfs_present += 1
            else:
                this_species_msa_dfs.append(None)

        # Skip species that are present in only one chain.
        if species_dfs_present <= 1:
            continue

        if np.any(
                np.array([len(species_df) for species_df in
                          this_species_msa_dfs if
                          isinstance(species_df, pd.DataFrame)]) > 600):
            continue

        paired_msa_rows = _match_rows_by_sequence_similarity(this_species_msa_dfs)
        all_paired_msa_rows.extend(paired_msa_rows)
        all_paired_msa_rows_dict[species_dfs_present].extend(paired_msa_rows)
    all_paired_msa_rows_dict = {
        num_examples: np.array(paired_msa_rows) for
        num_examples, paired_msa_rows in all_paired_msa_rows_dict.items()
    }
    return all_paired_msa_rows_dict

代码解读:

函数输入
def pair_sequences(examples: List[Mapping[str, np.ndarray]]) -> Dict[int, np.ndarray]

examples:包含多条链的 MSA 信息,每个元素是一个字典,代表一条蛋白链的 MSA 相关特征。

  • 例如,examples[0] 可能对应链 A 的 MSA 特征,examples[1] 可能对应链 B 的 MSA 特征。
代码执行过程
1️⃣ 提取所有链的 MSA 并构建物种索引
num_examples = len(examples)

all_chain_species_dict = []
common_species = set()
for chain_features in examples:
  

http://www.kler.cn/a/564670.html

相关文章:

  • MongoDB—(一主、一从、一仲裁)副本集搭建
  • 利用 Windows Terminal 和 SSH Config 简化 Linux 服务器管理
  • DeepSeek-R1-671B大模型满血版私有化部署高可用教程-SparkAi系统集成图文教程
  • python-leetcode-分割等和子集
  • 想转行做春晚那种扭秧歌的机器人,大概要会点什么?
  • 基于大模型的脑出血全周期预测与诊疗方案研究报告
  • AI大模型-提示工程学习笔记16—方向性刺激提示
  • Qt开发⑨Qt的事件_事件处理_按键事件和鼠标事件
  • 网络原理--IP协议简介
  • linux--多进程开发(6)IPC之内存映射
  • SSL 证书是 SSL 协议实现安全通信的必要组成部分
  • 004 rocketmq集群
  • linux 打包解压命令
  • JDK 21 与Springboot3的新特性
  • 三菱FX5U PLC工字轮排线算法(ST源代码)
  • undo log、redo log和bin log详解
  • springai系列(二)从0开始搭建和接入azure-openai实现智能问答
  • 基于springboot+vue的融合多源高校画像数据与协同过滤算法的高考择校推荐系统
  • 课程2. 用PyTorch训练神经网络与梯度下降
  • 关于回溯算法中的剪枝是否需要for循环的总结归纳