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

RFDiffusion中的ContigMap类介绍

功能概述

在RFDiffusion中,ContigMap类的主要作用是帮助管理和处理蛋白质设计中模板和目标序列的残基映射关系。它为用户提供了一种方式来描述蛋白质片段的拓扑结构,并将输入数据(如残基编号、链编号等)映射到模型中使用的内部索引系统。

源代码:

class ContigMap:
    """
    Class for doing mapping.
    Inherited from Inpainting. To update at some point.
    Supports multichain or multiple crops from a single receptor chain.
    Also supports indexing jump (+200) or not, based on contig input.
    Default chain outputs are inpainted chains as A (and B, C etc if multiple chains), and all fragments of receptor chain on the next one (generally B)
    Output chains can be specified. Sequence must be the same number of elements as in contig string
    """

    def __init__(
        self,
        parsed_pdb,
        contigs=None,
        inpaint_seq=None,
        inpaint_str=None,
        length=None,
        ref_idx=None,
        hal_idx=None,
        idx_rf=None,
        inpaint_seq_tensor=None,
        inpaint_str_tensor=None,
        topo=False,
        provide_seq=None,
        inpaint_str_strand=None,
        inpaint_str_helix=None,
        inpaint_str_loop=None
    ):
        # sanity checks
        if contigs is None and ref_idx is None:
            sys.exit("Must either specify a contig string or precise mapping")
        if idx_rf is not None or hal_idx is not None or ref_idx is not None:
            if idx_rf is None or hal_idx is None or ref_idx is None:
                sys.exit(
                    "If you're specifying specific contig mappings, the reference and output positions must be specified, AND the indexing for RoseTTAFold (idx_rf)"
                )

        self.chain_order = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        if length is not None:
            if "-" not in length:
                self.length = [int(length), int(length) + 1]
            else:
                self.length = [int(length.split("-")[0]), int(length.split("-")[1]) + 1]
        else:
            self.length = None
        self.ref_idx = ref_idx
        self.hal_idx = hal_idx
        self.idx_rf = idx_rf

        parse_inpaint = lambda x: "/".join(x).split("/") if x is not None else None
        self.inpaint_seq = parse_inpaint(inpaint_seq)
        self.inpaint_str = parse_inpaint(inpaint_str)

        self.inpaint_str_helix=parse_inpaint(inpaint_str_helix)
        self.inpaint_str_strand=parse_inpaint(inpaint_str_strand)
        self.inpaint_str_loop=parse_inpaint(inpaint_str_loop)

        self.inpaint_seq_tensor = inpaint_seq_tensor
        self.inpaint_str_tensor = inpaint_str_tensor
        self.parsed_pdb = parsed_pdb
        self.topo = topo
        if ref_idx is None:
            # using default contig generation, which outputs in rosetta-like format
            self.contigs = contigs
            (
                self.sampled_mask,
                self.contig_length,
                self.n_inpaint_chains,
            ) = self.get_sampled_mask()
            self.receptor_chain = self.chain_order[self.n_inpaint_chains]
            (
                self.receptor,
                self.receptor_hal,
                self.receptor_rf,
                self.inpaint,
                self.inpaint_hal,
                self.inpaint_rf,
            ) = self.expand_sampled_mask()
            self.ref = self.inpaint + self.receptor
            self.hal = self.inpaint_hal + self.receptor_hal
            self.rf = self.inpaint_rf + self.receptor_rf
        else:
            # specifying precise mappings
            self.ref = ref_idx
            self.hal = hal_idx
            self.rf = idx_rf
        self.mask_1d = [False if i == ("_", "_") else True for i in self.ref]
        # take care of sequence and structure masking
        if self.inpaint_seq_tensor is None:
            if self.inpaint_seq is not None:
                self.inpaint_seq = self.get_inpaint_seq_str(self.inpaint_seq)
            else:
                self.inpaint_seq = np.array(
                    [True if i != ("_", "_") else False for i in self.ref]
                )
        else:
            self.inpaint_seq = self.inpaint_seq_tensor

        if self.inpaint_str_tensor is None:
            if self.inpaint_str is not None:
                self.inpaint_str = self.get_inpaint_seq_str(se

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

相关文章:

  • GraphRAG如何使用ollama提供的llm model 和Embedding model服务构建本地知识库
  • leetcode hot100(2)
  • 数仓建模:如何设计可扩展性较好的同环比计算模型?
  • 《自动驾驶与机器人中的SLAM技术》ch4:预积分学
  • C# .NetCore 使用 Flurl.Http 与 HttpClient 请求处理流式响应
  • 2.slf4j入口
  • linux 命令获取apk 的安装应用的包名
  • 使用ssh免密登录实现自动化部署rsync+nfs+lsync(脚本)
  • 20 设计模式之职责链模式(问题处理案例)
  • Android 事件分发机制详解/ 及Activity启动流程浅谈
  • Flutter如何调用java接口如何导入java包
  • 【数据结构】堆的概念、结构、模拟实现以及应用
  • SQL注入:sqli-labs靶场通关(第九关 时间盲注)
  • 【单元测试】单元测试介绍
  • Java 装饰器模式详解:动态增强对象功能
  • 宝塔面板-java项目 spring 无法正常启动 java spring 宝塔 没有显示日志 问题解决方案-spring项目宝塔面板无日志
  • 如何实现 3D GPR的仿真模拟
  • Scala 隐式转换
  • 【前端】JavaScript 的装箱(Boxing)机制详解
  • k8s-持久化存储之StorageClass(2)
  • 【算法练习】852. 山脉数组的峰顶索引
  • Python + OpenCV 系列:图像阈值处理
  • 【CC++】fatal error: curses.h: No such file or directory(Ubuntu 22.04)
  • 使用 ASP.NET Core HttpLoggingMiddleware 记录 http 请求/响应
  • 六、Prompt工程——进阶迭代
  • 现代C++16 pair