AF3 pair_sequences函数解读

news/2025/3/1 4:15:34/

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:continuethis_species_msa_dfs = []species_dfs_present = 0for species_dict in all_chain_species_dict:if species in species_dict:this_species_msa_dfs.append(species_dict[species])species_dfs_present += 1else:this_species_msa_dfs.append(None)# Skip species that are present in only one chain.if species_dfs_present <= 1:continueif np.any(np.array([len(species_df) for species_df inthis_species_msa_dfs ifisinstance(species_df, pd.DataFrame)]) > 600):continuepaired_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) fornum_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: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))
  • 遍历 examples
    • 使用 _make_msa_df 将每条链的 MSA 信息转换为 DataFrame(包含 msa_similaritymsa_rowmsa_species_identifiers)。
    • 使用 _create_species_dict 按物种对 MSA 进行分组,得到 species_dict
    • 将 species_dict 存入 all_chain_species_dict,并收集所有物种信息,存入 common_species
2️⃣ 筛选出所有链共有的物种
common_species = sorted(common_species)
common_species.remove(b'')  # 移除目标序列所在的物种
  • 由于 MSA 可能包含多个物种的序列,该步骤确保只保留所有链都出现过的物种
  • 移除 b'',它代表目标序列自身的物种,不需要配对。
3️⃣ 初始化存储配对 MSA 结果的字典
all_paired_msa_rows = [np

http://www.ppmy.cn/news/1575682.html

相关文章

JAVA面试_进阶部分_Linux面试题

Linux概述 1. 什么是Linux Linux是一套免费使用和自由传播的类Unix操作系统&#xff0c;是一个基于POSIX和Unix 的多用户、多任务、支持多线程和多CPU的操作系统。它能运行主要的Unix工 具软件、应用程序和网络协议。它支持32位和64位硬件。Linux继承了Unix以网 络为核心的设…

Excel工作圈小工具一个集合了大量Excel功能的绿色工具软件

​Excel工作圈小工具 一个集合了大量Excel功能的绿色工具软件&#xff0c;可以大大加强生产效率~ 软件虽然看起来比较简陋&#xff0c;但功能却是十分丰富。无需联网即可运行&#xff0c;而且兼容WPS和MS office各版本。 以下是软件的功能详细截图。 总的来说功能挺丰富&#…

QT MD5校验文件和数据的完整性

MD5介绍&#xff1a; ‌MD5&#xff0c;全称为‌‌Message-Digest Algorithm 5&#xff08;消息摘要算法5&#xff09;‌&#xff0c;是一种广泛使用的密码散列函数。它可以将任意长度的“字节串”变换成一个128位&#xff08;16字节&#xff09;的散列值&#xff08;hash valu…

Oracle Fusion Middleware更改weblogic密码

前言 当用户忘记weblogic密码时&#xff0c;且无法登录到web界面中&#xff0c;需要使用服务器命令更改密码 更改方式 1、备份 首先进入 weblogic 安装目录&#xff0c;备份三个文件&#xff1a;boot.properties&#xff0c;DefaultAuthenticatorInit.ldift&#xff0c;Def…

【含文档+PPT+源码】基于SpringBoot+Vue医药知识学习与分享平台的设计与实现

项目介绍 本课程演示的是一款 基于SpringBootVue医药知识学习与分享平台的设计与实现&#xff0c;主要针对计算机相关专业的正在做毕设的学生与需要项目实战练习的 Java 学习者。 1.包含&#xff1a;项目源码、项目文档、数据库脚本、软件工具等所有资料 2.带你从零开始部署…

1分钟用DeepSeek编写一个PDF转Word软件

一、引言 如今&#xff0c;在线工具的普及让PDF转Word成为了一个常见需求&#xff0c;常见的pdf转word工具有收费的wps&#xff0c;免费的有pdfgear&#xff0c;见下文&#xff1a; PDFgear:一款免费的PDF编辑、格式转化软件-CSDN博客 还有网上在线的免费pdf转word工具smallp…

从混淆到精通:C/C++常量指针与指针常量的本质差异与实战应用

一、定义与声明 常量指针&#xff08;Pointer to Constant&#xff09; 定义&#xff1a;指针指向的内容为常量&#xff0c;不可通过该指针修改&#xff0c;但指针本身可改变指向。声明方式&#xff1a;const int* p 或 int const* pconst int a 10; const int* p &a; /…

RawShaderMaterial 与 ShaderMaterial

目录 自动添加的 Uniforms 和 Attributes ShaderMaterial RawShaderMaterial GLSL 预处理 ShaderMaterial RawShaderMaterial 使用场景 ShaderMaterial RawShaderMaterial 代码示例对比 使用 ShaderMaterial 使用 RawShaderMaterial 常见问题与注意事项 总结 在 Th…