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

构建每个聚类的profile和deletion_mean特征

通过summarize_clusters函数构建每个聚类的protein['cluster_profile']和protein['cluster_deletion_mean']特征。目的是把extra_msa信息反映到msa中。
 

集成函数数据处理流程: sample_msa ->make_masked_msa -> nearest_neighbor_clusters -> summarize_clusters-> ...
 

主要函数 tf.math.unsorted_segment_sum:用于沿指定轴对数据进行分段求和。
tf.math.unsorted_segment_sum(data, segment_ids, num_segments, name=None)

  • data: 输入张量,包含待求和的数据。
  • segment_ids: 用于指定每个元素属于哪个段的一维整数张量。
  • num_segments: 整数,表示分段的总数。
  • name: 可选参数,用于指定操作的名称。
import tensorflow as tf
import pickledef shape_list(x):"""Return list of dimensions of a tensor, statically where possible.Like `x.shape.as_list()` but with tensors instead of `None`s.Args:x: A tensor.Returns:A list with length equal to the rank of the tensor. The n-th element of thelist is an integer when that dimension is statically known otherwise it isthe n-th element of `tf.shape(x)`."""x = tf.convert_to_tensor(x)# If unknown rank, return dynamic shapeif x.get_shape().dims is None:return tf.shape(x)static = x.get_shape().as_list()shape = tf.shape(x)ret = []for i in range(len(static)):dim = static[i]if dim is None:dim = shape[i]ret.append(dim)return retdef data_transforms_curry1(f):"""Supply all arguments but the first."""def fc(*args, **kwargs):return lambda x: f(x, *args, **kwargs)return fc@data_transforms_curry1
def summarize_clusters(protein):"""Produce profile and deletion_matrix_mean within each cluster."""num_seq = shape_list(protein['msa'])[0]def csum(x):return tf.math.unsorted_segment_sum(x, protein['extra_cluster_assignment'], num_seq)mask = protein['extra_msa_mask']mask_counts = 1e-6 + protein['msa_mask'] + csum(mask)  # Include center# 结果张量[num_seq, num_resi],第一行表示和msa中的0号序列是最近邻序列的extr_msa之和,以此类推msa_sum = csum(mask[:, :, None] * tf.one_hot(protein['extra_msa'], 23))msa_sum += tf.one_hot(protein['msa'], 23)  # Original sequenceprotein['cluster_profile'] = msa_sum / mask_counts[:, :, None]del msa_sum# 每条msa序列的最近邻序列的extr_msa,在不同位置deletion数统计# del_sum [num_seq, num_resi],第一行表示和msa中的0号序列是最近邻序列的extr_msa,不同位置deletion数,以此类推del_sum = csum(mask * protein['extra_deletion_matrix'])del_sum += protein['deletion_matrix']  # Original sequenceprotein['cluster_deletion_mean'] = del_sum / mask_countsdel del_sumreturn proteinwith open('Human_HBB_tensor_dict_nnclusted.pkl','rb') as f:protein = pickle.load(f)print(protein.keys())protein = summarize_clusters()(protein)
print(protein.keys())
print(protein['cluster_profile'].shape)
print(protein['cluster_profile'])print(protein['cluster_deletion_mean'].shape)
print(protein['cluster_deletion_mean'])

http://www.lryc.cn/news/265946.html

相关文章:

  • Milvus数据一致性介绍及选择方法
  • 异常处理和单元测试python
  • 蓝牙物联网在汽车领域的应用
  • 用23种设计模式打造一个cocos creator的游戏框架----(二十二)原型模式
  • paddle 55 使用Paddle Inference部署嵌入nms的PPYoloe模型(端到端fps达到52.63)
  • 自动化测试工具-Selenium:WebDriver的API/方法使用全解
  • 如何通过蓝牙串口启动智能物联网?
  • Linux---基础操作命令
  • uniapp怎么动态渲染导航栏的title?
  • 【机器学习】决策树
  • [node] Node.js的全局对象Global
  • 完整的 Meteor NPM 集成
  • 智能优化算法应用:基于骑手优化算法3D无线传感器网络(WSN)覆盖优化 - 附代码
  • 解决 MATLAB 遗传算法中 exitflg=4 的问题
  • 云卷云舒:云原生业务应用成熟度模型
  • STM32的以太网外设+PHY(LAN8720)使用详解(5):MAC及DMA配置
  • GitHub、Gitee、Gitlab共用一个SSH密钥配置
  • ClickHouse(19)ClickHouse集成Hive表引擎详细解析
  • 用C求斐波那契数列-----(C每日一编程)
  • 在Jetpack Compose中使用ExoPlayer实现直播流和音频均衡器
  • 持续集成交付CICD:Jira 远程触发 Jenkins 实现更新 GitLab 分支
  • 基于SSM的面向TCP_IP的网络互联实验平台
  • 【IDEA】try-catch自动生成中修改catch的内容
  • 2024 十大AI预测
  • 【Linux基础开发工具】gcc/g++使用make/Makefile
  • Windows Nginx版本升级
  • kubernetes集群 应用实践 kafka部署
  • Featured Based知识蒸馏及代码(3): Focal and Global Knowledge (FGD)
  • CentOs 安装MySQL
  • 基于Java (spring-boot)的在线考试管理系统