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

ProteinMPNN中蛋白质特征提取

函数 featurize 的主要作用是将一批蛋白质序列和结构信息转化为深度学习模型可以接受的特征矩阵。它在处理蛋白质多链结构(即多个链的蛋白质复合体)时,考虑了可见链和被掩码链的区分。

代码:

import torch
import numpy as np
import csv
import time
import os
import random


def featurize(batch, device):
    alphabet = 'ACDEFGHIKLMNPQRSTVWYX'
    B = len(batch)
    lengths = np.array([len(b['seq']) for b in batch], dtype=np.int32) #sum of chain seq lengths
    L_max = max([len(b['seq']) for b in batch])
    X = np.zeros([B, L_max, 4, 3])
    residue_idx = -100*np.ones([B, L_max], dtype=np.int32) #residue idx with jumps across chains
    chain_M = np.zeros([B, L_max], dtype=np.int32) #1.0 for the bits that need to be predicted, 0.0 for the bits that are given
    mask_self = np.ones([B, L_max, L_max], dtype=np.int32) #for interface loss calculation - 0.0 for self interaction, 1.0 for other
    chain_encoding_all = np.zeros([B, L_max], dtype=np.int32) #integer encoding for chains 0, 0, 0,...0, 1, 1,..., 1, 2, 2, 2...
    S = np.zeros([B, L_max], dtype=np.int32) #sequence AAs integers
    init_alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G','H', 'I', 'J','K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T','U', 'V','W','X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g','h', 'i', 'j','k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't','u', 'v','w','x', 'y', 'z']
    extra_alphabet = [str(item) for item in list(np.arange(300))]
    chain_letters = init_alphabet + extra_alphabet
    for i, b in enumerate(batch):
        masked_chains = b['masked_list']
        visible_chains = b['visible_list']
        all_chains = masked_chains + visible_chains
        visible_temp_dict = {}
        masked_temp_dict = {}
        for step, letter in enumerate(all_chains):
            chain_seq = b[f'seq_chain_{letter}']
            if letter in visible_chains:
                visible_temp_dict[letter] = chain_seq
            elif letter in masked_chains:
                masked_temp_dict[letter] = chain_seq
        for km, vm in masked_temp_dict.items():
            for kv, vv in visible_temp_dict.items():
                if v

http://www.kler.cn/news/353814.html

相关文章:

  • python的多线程和多进程
  • 【vue+printJs】前端打印, 自定义字体大小, 自定义样式, 封装共享样式
  • 【Flutter】Dart:函数
  • esp32 开发需要那些开发语言
  • paypal php 实现详细攻略
  • 4 登录接口实现(Vue3+Spring boot+mysql)
  • LeetCode322:零钱兑换
  • 图论刷题
  • 好用的python相关的AI工具Bito介绍
  • Linux多任务编程(网络编程-数据库篇)
  • 【wpf】05 几种容器动态创建控件的对比
  • 【c++篇】:初识c++--编程新手的快速入门之道(二)
  • MyBatisPlus笔记之逻辑删除、枚举处理器、JSON处理器
  • WindowsAPI|每天了解几个winAPI接口之网络配置相关文档Iphlpapi.h详细分析五
  • 微服务经典应用架构图
  • QUIC 协议的优势
  • Node.js基础与应用
  • 力扣面试150 交错字符串 二维DP
  • 数学建模算法与应用 第7章 数理统计与方法
  • Python | Leetcode Python题解之第482题秘钥格式化