AF3 pair_sequences函数解读

server/2025/3/1 12:57:58/

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/server/171550.html

相关文章

正大杯攻略|量表类问卷数据分析基本步骤

在量表类问卷研究领域&#xff0c;分析变量之间的影响关系是基础且常用的手段。一般先提出关于自变量 X 对因变量 Y 影响关系的假设&#xff0c;随后运用合适的统计方法进行验证&#xff0c;挖掘二者间规律&#xff0c;进而得出结论&#xff0c;为研究发展提供建议。具体分析步…

页面加载速度,如何优化提升?

页面加载速度&#xff0c;如何优化提升&#xff1f; 咱来好好唠唠页面加载速度这事儿&#xff0c;再说说怎么把它提上去。 页面加载速度是咋回事儿 页面加载速度啊&#xff0c;就好比你去餐厅吃饭&#xff0c;从你坐下点餐到饭菜端上桌的时间。在网页里&#xff0c;就是你在…

DeepSeek掘金——调用DeepSeek API接口 实现智能数据挖掘与分析

调用DeepSeek API接口:实现智能数据挖掘与分析 在当今数据驱动的时代,企业和开发者越来越依赖高效的数据挖掘与分析工具来获取有价值的洞察。DeepSeek作为一款先进的智能数据挖掘平台,提供了强大的API接口,帮助用户轻松集成其功能到自己的应用中。本文将详细介绍如何调用D…

layui 获取select值和文本

在表单中&#xff0c;使用layui渲染select <select name"pan" lay-filter"down_link_name" id"down_link_name"><option value"">网盘名称</option><option value"01">诚通</option><opt…

SERPENTINE Tools

Tools Here we present the tools created within the SERPENTINE project. They are available from the general SERPENTINE repository at GitHub, and can also be run on the SERPENTINE Hub server without the need to install Python locally. 此处展示SERPENTINE项目组…

postman上一个接口返回值作为下一个接口的入参

1.在第一个接口中提取响应数据 假设接口返回以下数据&#xff1a; {"total": 2,"rows": [{"createBy": null,"createTime": "2024-07-21 12:54:24","updateBy": null,"updateTime": "2024-09-09…

苍穹外卖-阿里云OSS文件上传

苍穹外卖-阿里云OSS文件上传 一、阿里云OSS简介**获取AccessKey**获取enpoint 二、代码实现1 引入依赖2 定义OSS相关配置2.1 application-dev.yml2.2 application.yml 3 读取OSS配置3.1 AliOssProperties 4 生成OSS工具类对象4.1 AliOssUtil4.2 OssConfiguration2.5 CommonCont…

Flutter的permission_handler插件检查iOS的通知权限不准确

今天&#xff0c;做好了一个功能&#xff0c;就是在app内检查用户有没有给当前APP打开通知权限&#xff0c; 如果没打开&#xff0c;就展示一个 banner &#xff0c;让用户去点击banner去打开权限 。 android上测试得非常顺利&#xff0c; 结果&#xff0c; 在iOS 上就是不…