掘金 人工智能 20小时前
蛋白质设计新高度,RFdiffusion 实现从零设计高亲和力蛋白质
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

RFdiffusion是由David Baker实验室开发的革命性蛋白质设计框架,它融合了RoseTTAFold和扩散生成模型,实现了从头构建功能明确、构型复杂的蛋白质。该工具能够根据已有功能核心补全蛋白质结构,精确控制空间构型,并在多种设计任务中展现出强大通用性。RFdiffusion支持根据指定基序构建骨架、从零生成全新蛋白质、设计对称结构、生成功能变体及精确设计结合界面,为基础研究、酶设计、分子对接和药物开发提供了高效的生成式解决方案。

🔬 **蛋白质结构与功能的全方位生成**:RFdiffusion能够从头开始构建功能明确、构型复杂的蛋白质,并能根据已有的功能核心自动补全蛋白质结构,实现高度可控的空间构型设计。

💡 **多样化的设计能力**:该框架支持六大关键设计方向,包括根据指定基序构建骨架、从零生成全新蛋白质、设计具有对称性的结构、生成多样化的功能变体、精确设计结合界面,以及在对称约束下完成复杂结构的补全。

🚀 **技术融合与创新**:RFdiffusion以RoseTTAFold为骨架,引入了先进的扩散生成模型,成功地将结构预测与生成设计相结合,为蛋白质设计领域带来了突破性的进展。

⚙️ **广泛的应用前景**:RFdiffusion在基础研究、酶设计、分子对接和药物开发等多个领域展现出强大的通用性和创造性,为解决生物技术和医疗健康领域的挑战提供了有力的生成式解决方案。

你可以将 RFdiffusion 理解为「蛋白质宇宙的建构者」。它由蛋白质设计领域的核心团队——David Baker 实验室于 2022 年提出,该框架以 RoseTTAFold 为骨架,引入扩散 生成模型 ,将结构预测与生成设计融合,首次实现了从头构建功能明确、构型复杂的蛋白质。 RFdiffusion 能够根据已有的功能核心自动补全蛋白质结构,生成高度可控的空间构型,并在多个蛋白质设计任务中展现出强大的通用性与创造性。

其功能覆盖六个关键方向:可根据指定基序构建骨架、从零生成全新蛋白质、设计具有对称性要求的结构、生成多样化的功能变体、精确设计结合界面,甚至可在具备对称约束的前提下完成复杂结构的补全。无论是基础研究、酶设计,还是分子对接与药物开发,RFdiffusion 都提供了一个强有力的生成式解决方案。

教程链接:go.openbayes.com/gljKD

使用云平台: OpenBayes

openbayes.com/console/sig…

首先点击「公共教程」,在公共教程中找到「RFdiffusion:扩散式蛋白设计模型」,单击打开。

页面跳转后,点击右上角「克隆」,将该教程克隆至自己的容器中。

在当前页面中看到的算力资源均可以在平台一键选择使用。平台会默认选配好原教程所使用的算力资源、镜像版本,不需要再进行手动选择。点击「继续执行」,等待分配资源。

数据和代码都已经同步完成了。容器状态显示为「运行中」后,点击「打开工作空间」。

1.设置 RFdiffusion 扩散

import numpy as npimport os, time, signalimport sys, random, string, reimport zipfilefrom IPython.display import display, HTMLif 'RFdiffusion' not in sys.path:  os.environ["DGLBACKEND"] = "pytorch"  sys.path.append('RFdiffusion')os.environ["CUDA_VISIBLE_DEVICES"] = "0"  os.environ["MKL_THREADING_LAYER"] = "GNU"import jsonimport matplotlib.pyplot as pltfrom IPython.display import display, HTMLimport ipywidgets as widgetsimport py3Dmolfrom inference.utils import parse_pdbfrom colabdesign.rf.utils import get_cafrom colabdesign.rf.utils import fix_contigs, fix_partial_contigs, fix_pdb, sym_itfrom colabdesign.shared.protein import pdb_to_stringfrom colabdesign.shared.plot import plot_pseudo_3Dfrom ipywidgets import FileUploadfrom IPython.display import displayimport subprocessdef get_pdb(pdb_code=None):    print("pdb_code",pdb_code)    if pdb_code is None or pdb_code == "":        uploader = FileUpload(description="Upload PDB", multiple=False)        display(uploader)        while not uploader.value:            time.sleep(0.1)                 uploaded_filename = next(iter(uploader.value))        pdb_bytes = uploader.value[uploaded_filename]["content"]                with open("tmp.pdb", "wb") as out:            out.write(pdb_bytes)        return "tmp.pdb"        elif os.path.isfile(pdb_code):        return pdb_code        elif len(pdb_code) == 4:        if not os.path.isfile(f"{pdb_code}.pdb1"):            os.system(f"wget -qnc https://files.rcsb.org/download/{pdb_code}.pdb1.gz")            os.system(f"gunzip {pdb_code}.pdb1.gz")        return f"{pdb_code}.pdb1"        else:        os.system(f"wget -qnc https://alphafold.ebi.ac.uk/files/AF-{pdb_code}-F1-model_v3.pdb")        return f"AF-{pdb_code}-F1-model_v3.pdb"def run_ananas(pdb_str, path, sym=None):    pdb_filename = f"outputs/{path}/ananas_input.pdb"    out_filename = f"outputs/{path}/ananas.json"    with open(pdb_filename, "w") as handle:        handle.write(pdb_str)    cmd = f"./ananas {pdb_filename} -u -j {out_filename}"    if sym is None:        os.system(cmd)    else:        os.system(f"{cmd} {sym}")    try:        out = json.loads(open(out_filename, "r").read())        results, AU = out[0], out[-1]["AU"]        group = AU["group"]        chains = AU["chain names"]        rmsd = results["Average_RMSD"]        print(f"AnAnaS detected {group} symmetry at RMSD:{rmsd:.3}")        C = np.array(results['transforms'][0]['CENTER'])        A = [np.array(t["AXIS"]) for t in results['transforms']]        new_lines = []        for line in pdb_str.split("\n"):            if line.startswith("ATOM"):                chain = line[21:22]                if chain in chains:                    x = np.array([float(line[i:(i+8)]) for i in [30, 38, 46]])                    if group[0] == "c":                        x = sym_it(x, C, A[0])                    if group[0] == "d":                        x = sym_it(x, C, A[1], A[0])                    coord_str = "".join(["{:8.3f}".format(a) for a in x])                    new_lines.append(line[:30] + coord_str + line[54:])            else:                new_lines.append(line)        return results, "\n".join(new_lines)    except:        return None, pdb_strdef run(command, steps, num_designs=1, visual="none"):    def run_command_and_get_pid(command):        pid_file = '/dev/shm/pid'        os.system(f'nohup {command} > /dev/null & echo $! > {pid_file}')        with open(pid_file, 'r') as f:            pid = int(f.read().strip())        os.remove(pid_file)        return pid    def is_process_running(pid):        try:            os.kill(pid, 0)        except OSError:            return False        else:            return True    run_output = widgets.Output()    progress = widgets.FloatProgress(min=0, max=1, description='running', bar_style='info')    display(widgets.VBox([progress, run_output]))    for n in range(steps):        if os.path.isfile(f"/dev/shm/{n}.pdb"):            os.remove(f"/dev/shm/{n}.pdb")    pid = run_command_and_get_pid(command)    try:        fail = False        for _ in range(num_designs):            for n in range(steps):                wait = True                while wait and not fail:                    time.sleep(0.1)                    if os.path.isfile(f"/dev/shm/{n}.pdb"):                        pdb_str = open(f"/dev/shm/{n}.pdb").read()                        if pdb_str[-3:] == "TER":                            wait = False                        elif not is_process_running(pid):                            fail = True                    elif not is_process_running(pid):                        fail = True                if fail:                    progress.bar_style = 'danger'                    progress.description = "failed"                    break                else:                    progress.value = (n+1) / steps                    if visual != "none":                        with run_output:                            run_output.clear_output(wait=True)                            if visual == "image":                                xyz, bfact = get_ca(f"/dev/shm/{n}.pdb", get_bfact=True)                                fig = plt.figure()                                fig.set_dpi(100);fig.set_figwidth(6);fig.set_figheight(6)                                ax1 = fig.add_subplot(111);ax1.set_xticks([]);ax1.set_yticks([])                                plot_pseudo_3D(xyz, c=bfact, cmin=0.5, cmax=0.9, ax=ax1)                                plt.show()                            if visual == "interactive":                                view = py3Dmol.view(js='https://3dmol.org/build/3Dmol.js')                                view.addModel(pdb_str, 'pdb')                                view.setStyle({'cartoon': {'colorscheme': {'prop': 'b', 'gradient': 'roygb', 'min': 0.5, 'max': 0.9}}})                                view.zoomTo()                                view.show()                if os.path.exists(f"/dev/shm/{n}.pdb"):                    os.remove(f"/dev/shm/{n}.pdb")            if fail:                progress.bar_style = 'danger'                progress.description = "failed"                break        while is_process_running(pid):            time.sleep(0.1)    except KeyboardInterrupt:        os.kill(pid, signal.SIGTERM)        progress.bar_style = 'danger'        progress.description = "stopped"def run_diffusion(contigs, path, pdb=None, iterations=50,                  symmetry="none", order=1, hotspot=None,                  chains=None, add_potential=False,                  num_designs=1, visual="none"):    full_path = f"outputs/{path}"    os.makedirs(full_path, exist_ok=True)    opts = [f"inference.output_prefix={full_path}",            f"inference.num_designs={num_designs}"]    if chains == "":         chains = None    if symmetry in ["auto", "cyclic", "dihedral"]:        if symmetry == "auto":            sym, copies = None, 1        else:            sym, copies = {"cyclic": (f"c{order}", order),                           "dihedral": (f"d{order}", order * 2)}[symmetry]    else:        symmetry = None        sym, copies = None, 1    contigs = contigs.replace(",", " ").replace(":", " ").split()    is_fixed, is_free = False, False    fixed_chains = []    for contig in contigs:        for x in contig.split("/"):            a = x.split("-")[0]            if a[0].isalpha():                is_fixed = True                if a[0] not in fixed_chains:                    fixed_chains.append(a[0])            if a.isnumeric():                is_free = True    if len(contigs) == 0 or not is_free:        mode = "partial"    elif is_fixed:        mode = "fixed"    else:        mode = "free"    if mode in ["partial", "fixed"]:        pdb_str = pdb_to_string(get_pdb(pdb), chains=chains)        if symmetry == "auto":            a, pdb_str = run_ananas(pdb_str, path)            if a is None:                print(f'ERROR: no symmetry detected')                symmetry = None                sym, copies = None, 1            else:                if a["group"][0] == "c":                    symmetry = "cyclic"                    sym, copies = a["group"], int(a["group"][1:])                elif a["group"][0] == "d":                    symmetry = "dihedral"                    sym, copies = a["group"], 2 * int(a["group"][1:])                else:                    print(f'ERROR: the detected symmetry ({a["group"]}) not currently supported')                    symmetry = None                    sym, copies = None, 1        elif mode == "fixed":            pdb_str = pdb_to_string(pdb_str, chains=fixed_chains)        pdb_filename = f"{full_path}/input.pdb"        with open(pdb_filename, "w") as handle:            handle.write(pdb_str)        parsed_pdb = parse_pdb(pdb_filename)        opts.append(f"inference.input_pdb={pdb_filename}")        if mode in ["partial"]:            iterations = int(80 * (iterations / 200))            opts.append(f"diffuser.partial_T={iterations}")            contigs = fix_partial_contigs(contigs, parsed_pdb)        else:            opts.append(f"diffuser.T={iterations}")            contigs = fix_contigs(contigs, parsed_pdb)    else:        opts.append(f"diffuser.T={iterations}")        parsed_pdb = None        contigs = fix_contigs(contigs, parsed_pdb)    if hotspot is not None and hotspot != "":        opts.append(f"ppi.hotspot_res=[{hotspot}]")    if sym is not None:        sym_opts = ["--config-name symmetry", f"inference.symmetry={sym}"]        if add_potential:            sym_opts += ["'potentials.guiding_potentials=["type:olig_contacts,weight_intra:1,weight_inter:0.1"]'",                         "potentials.olig_intra_all=True", "potentials.olig_inter_all=True",                         "potentials.guide_scale=2", "potentials.guide_decay=quadratic"]        opts = sym_opts + opts        contigs = sum([contigs] * copies, [])    opts.append(f"'contigmap.contigs=[{' '.join(contigs)}]'")    opts += ["inference.dump_pdb=True", "inference.dump_pdb_path='/dev/shm'"]    print("mode:", mode)    print("output:", full_path)    print("contigs:", contigs)    opts_str = " ".join(opts)    print(opts_str)    cmd =f"bash -c 'source activate /openbayes/input/input0/py3102 && python /openbayes/home/RFdiffusion/run_inference.py {opts_str}'"    print(cmd)    run(cmd, iterations, num_designs, visual=visual)    print("-"*20)    for n in range(num_designs):        pdbs = [f"/openbayes/home/outputs/traj/{path}_{n}_pX0_traj.pdb",                f"/openbayes/home/outputs/traj/{path}_{n}_Xt-1_traj.pdb",                f"{full_path}_{n}.pdb"]        for pdb in pdbs:            with open(pdb, "r") as handle:                pdb_str = handle.read()            with open(pdb, "w") as handle:                handle.write(fix_pdb(pdb_str, contigs))    return contigs, copies
/openbayes/input/input0/py3102/lib/python3.10/site-packages/requests/__init__.py:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer).  warnings.warn(/output/RFdiffusion/Track_module.py:241: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.  @torch.cuda.amp.autocast(enabled=False)

2.运行 RFdiffusion 以生成 backbone

#@title run **RFdiffusion** to generate a backbonename = "test" #@param {type:"string"}contigs = "100" #@param {type:"string"}pdb = "" #@param {type:"string"}iterations = 25 #@param [25, 50, 100, 150, 200] {type:"raw"}hotspot = "" #@param {type:"string"}num_designs = 1 #@param [1, 2, 4, 8, 16, 32] {type:"raw"}visual = "interactive" #@param ["none", "image", "interactive"]#@markdown ---#@markdown **symmetry** settings#@markdown ---symmetry = "auto" #@param ["none", "auto", "cyclic", "dihedral"]order = 1 #@param [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] {type:"raw"}chains = "" #@param {type:"string"}add_potential = True #@param {type:"boolean"}#@markdown - `symmetry='auto'` enables automatic symmetry dectection with [AnAnaS](https://team.inria.fr/nano-d/software/ananas/).#@markdown - `chains="A,B"` filter PDB input to these chains (may help auto-symm detector)#@markdown - `add_potential` to discourage clashes between chainspath = namewhile os.path.exists(f"/openbayes/home/outputs/{path}_0.pdb"):    path = name + "_" + ''.join(random.choices(string.ascii_lowercase + string.digits, k=5))flags = {"contigs":contigs,         "pdb":pdb,         "order":order,         "iterations":iterations,         "symmetry":symmetry,         "hotspot":hotspot,         "path":path,         "chains":chains,         "add_potential":add_potential,         "num_designs":num_designs,         "visual":visual}for k,v in flags.items():    if isinstance(v,str):        flags[k] = v.replace("'","").replace('"','')contigs, copies = run_diffusion(**flags)
mode: freeoutput: outputs/test_s67hhcontigs: ['100-100']inference.output_prefix=outputs/test_s67hh inference.num_designs=1 diffuser.T=25 'contigmap.contigs=[100-100]' inference.dump_pdb=True inference.dump_pdb_path='/dev/shm'bash -c 'source activate /openbayes/input/input0/py3102 && python /openbayes/home/RFdiffusion/run_inference.py inference.output_prefix=outputs/test_s67hh inference.num_designs=1 diffuser.T=25 'contigmap.contigs=[100-100]' inference.dump_pdb=True inference.dump_pdb_path='/dev/shm''
VBox(children=(FloatProgress(value=0.0, bar_style='info', description='running', max=1.0), Output()))
/openbayes/input/input0/py3102/lib/python3.10/site-packages/requests/__init__.py:86: RequestsDependencyWarning: Unable to find acceptable character detection dependency (chardet or charset_normalizer).  warnings.warn(/output/RFdiffusion/Track_module.py:241: FutureWarning: `torch.cuda.amp.autocast(args...)` is deprecated. Please use `torch.amp.autocast('cuda', args...)` instead.  @torch.cuda.amp.autocast(enabled=False)/output/RFdiffusion/inference/model_runners.py:175: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.  self.ckpt  = torch.load(/output/RFdiffusion/util_module.py:259: UserWarning: Using torch.cross without specifying the dim arg is deprecated.Please either pass the dim explicitly or simply use torch.linalg.cross.The default value of dim will change to agree with that of linalg.cross in a future release. (Triggered internally at ../aten/src/ATen/native/Cross.cpp:62.)  CBrotaxis1 = (CBr-CAr).cross(NCr-CAr)

参数说明:

基本语法

示例说明

3.显示 3D 结构

#@title Display 3D structure {run: "auto"}animate = "none" #@param ["none", "movie", "interactive"]color = "chain" #@param ["rainbow", "chain", "plddt"]denoise = Truedpi = 100 #@param [100, 200, 400] {type:"raw"}from colabdesign.shared.plot import pymol_color_listfrom colabdesign.rf.utils import get_ca, get_Ls, make_animationfrom string import ascii_uppercase, ascii_lowercasealphabet_list = list(ascii_uppercase + ascii_lowercase)def plot_pdb(num=0):    if denoise:        pdb_traj = f"/openbayes/home/outputs/traj/{path}_{num}_pX0_traj.pdb"    else:        pdb_traj = f"/openbayes/home/outputs/traj/{path}_{num}_Xt-1_traj.pdb"    if animate in ["none", "interactive"]:        hbondCutoff = 4.0        view = py3Dmol.view(js='https://3dmol.org/build/3Dmol.js')        # view = py3Dmol.view(js='/openbayes/home/RFdiffusion/3Dmol.js')        if animate == "interactive":            pdb_str = open(pdb_traj, 'r').read()            view.addModelsAsFrames(pdb_str, 'pdb', {'hbondCutoff': hbondCutoff})        else:            pdb = f"outputs/{path}_{num}.pdb"            pdb_str = open(pdb, 'r').read()            view.addModel(pdb_str, 'pdb', {'hbondCutoff': hbondCutoff})        if color == "rainbow":            view.setStyle({'cartoon': {'color': 'spectrum'}})        elif color == "chain":            for n, chain, c in zip(range(len(contigs)),                                  alphabet_list,                                  pymol_color_list):                view.setStyle({'chain': chain}, {'cartoon': {'color': c}})        else:            view.setStyle({'cartoon': {'colorscheme': {'prop': 'b', 'gradient': 'roygb', 'min': 0.5, 'max': 0.9}}})        view.zoomTo()        if animate == "interactive":            view.animate({'loop': 'backAndForth'})        view.show()    else:        Ls = get_Ls(contigs)        xyz, bfact = get_ca(pdb_traj, get_bfact=True)        xyz = xyz.reshape((-1, sum(Ls), 3))[::-1]        bfact = bfact.reshape((-1, sum(Ls)))[::-1]        if color == "chain":            display(HTML(make_animation(xyz, Ls=Ls, dpi=dpi, ref=-1)))        elif color == "rainbow":            display(HTML(make_animation(xyz, dpi=dpi, ref=-1)))        else:            display(HTML(make_animation(xyz, plddt=bfact*100, dpi=dpi, ref=-1)))if num_designs > 1:    output = widgets.Output()    def on_change(change):        if change['name'] == 'value':            with output:                output.clear_output(wait=True)                plot_pdb(change['new'])    dropdown = widgets.Dropdown(        options=[(f'{k}', k) for k in range(num_designs)],        value=0, description='design:',    )    dropdown.observe(on_change)    display(widgets.VBox([dropdown, output]))    with output:        plot_pdb(dropdown.value)else:    plot_pdb()

参数说明:

4.运行 ProteinMPNN 以生成序列,然后使用 AlphaFold 进行验证。

#@title run **ProteinMPNN** to generate a sequence and **AlphaFold** to validatenum_seqs = 8 #@param [1, 2, 4, 8, 16, 32, 64] {type:"raw"}initial_guess = False #@param {type:"boolean"}num_recycles = 1 #@param [0, 1, 2, 3, 6, 12] {type:"raw"}use_multimer = False #@param {type:"boolean"}rm_aa = "C" #@param {type:"string"}mpnn_sampling_temp = 0.1 #@param [0.0001, 0.1, 0.15, 0.2, 0.25, 0.3, 0.5, 1.0] {type:"raw"}#@markdown - for **binder** design, we recommend `initial_guess=True num_recycles=3`import subprocessif not os.path.isfile("/openbayes/input/input0/params/done.txt"):  print("downloading AlphaFold params...")  while not os.path.isfile("/openbayes/input/input0/params/done.txt"):    time.sleep(5)contigs_str = ":".join(contigs)opts = [f"--pdb=/openbayes/home/outputs/{path}_0.pdb",        f"--loc=/openbayes/home/outputs/{path}",        f"--contig={contigs_str}",        f"--copies={copies}",        f"--num_seqs={num_seqs}",        f"--num_recycles={num_recycles}",        f"--rm_aa={rm_aa}",        f"--mpnn_sampling_temp={mpnn_sampling_temp}",        f"--num_designs={num_designs}"]if initial_guess: opts.append("--initial_guess")if use_multimer: opts.append("--use_multimer")opts = ' '.join(opts)conda_prefix = "/openbayes/input/input0/py3102"env = os.environ.copy()env["LD_LIBRARY_PATH"] = f"{conda_prefix}/lib:" + env.get("LD_LIBRARY_PATH", "")cmd_list = [    f"{conda_prefix}/bin/python",    "/openbayes/home/colabdesign/rf/designability_test.py",] + opts.split()  print("Running:", " ".join(cmd_list))subprocess.run(cmd_list, env=env, check=True)
Running: /openbayes/input/input0/py3102/bin/python /openbayes/home/colabdesign/rf/designability_test.py --pdb=/openbayes/home/outputs/test_s67hh_0.pdb --loc=/openbayes/home/outputs/test_s67hh --contig=100-100 --copies=1 --num_seqs=8 --num_recycles=1 --rm_aa=C --mpnn_sampling_temp=0.1 --num_designs=1{'pdb':'/openbayes/home/outputs/test_s67hh_0.pdb','loc':'/openbayes/home/outputs/test_s67hh','contigs':'100-100','copies':1,'num_seqs':8,'initial_guess':False,'use_multimer':False,'num_recycles':1,'rm_aa':'C','num_designs':1,'mpnn_sampling_temp':0.1}protocol=fixbbrunning proteinMPNN...running AlphaFold...design:0 n:0 mpnn:1.038 plddt:0.909 ptm:0.754 pae:4.021 rmsd:0.605 KEKELKERIEKKIKAFGKELGKTSEKFFEFFKALLELVRKKGYEEVKKLLEEGPEALAKALKEELGVDISVSFIKSISKEELEKILEKAKEIVEEEKELEdesign:0 n:1 mpnn:1.117 plddt:0.891 ptm:0.756 pae:4.604 rmsd:0.886 KEEELEKEIEERIKEFAKELGLTSEEFLELFRAILELVRKLGYEEVRRLLEEGPEALARALEEVLGKRVSVAFIRSLSRETLEKILEEAERIVEEEEKKKdesign:0 n:2 mpnn:1.078 plddt:0.915 ptm:0.770 pae:3.792 rmsd:0.497 KEEEIEKKIEEKIKKFAEELGKTSEKFIELLKNILELVKKEGYEKVEELLKKGNEALAKALEEVLGAKISVKFLESISKEEKEKMLEHAKEIVEEEEELKdesign:0 n:3 mpnn:1.052 plddt:0.894 ptm:0.726 pae:4.354 rmsd:0.859 KKEEIEKRIEEKIKKKAEELGKTSEEFIEIFKAIYELVKKKGYEEVRKLLEEGPEALAKALEEELGVKVKVSTLKSISKEEWEKILEFAKEIVEEEKELKdesign:0 n:4 mpnn:1.034 plddt:0.903 ptm:0.757 pae:4.178 rmsd:0.574 KKEELEKRIEEKIKKFAKELGRTSPEFLELLKAIYELVKKKGYEEVEKLLKEGAEALAKALKEELGLDVPVSFIESISPEELEKMLKKAKEIVEEEKKLEdesign:0 n:5 mpnn:1.136 plddt:0.908 ptm:0.784 pae:3.463 rmsd:0.647 AAAAVAEARDAAIRAFGAELGRTSPEFLTLARALLALVERLGYAEVRRLLEAGRAALAAALARELGLKVPVSFLESISPEELAALLEHAEALVAELRALAdesign:0 n:6 mpnn:1.137 plddt:0.913 ptm:0.780 pae:3.729 rmsd:0.593 EEAALEEEVEERIRAFAEELGLTSPRFLELFRAILELVRRLGREEVRALLAAGAEALAAALKEVLGLDVPVSFLESLSPETWEAILEKAEEIAEELEEREdesign:0 n:7 mpnn:1.070 plddt:0.946 ptm:0.841 pae:2.574 rmsd:0.721 SAAALEAAVEADIRAFGASLGLTSPAALAFFRALLALVRREGAAAVRALLAAGPEALAAALRERLGADVPVAFLRSLSPATLEAALAHAEALVAREAAAA
CompletedProcess(args=['/openbayes/input/input0/py3102/bin/python', '/openbayes/home/colabdesign/rf/designability_test.py', '--pdb=/openbayes/home/outputs/test_s67hh_0.pdb', '--loc=/openbayes/home/outputs/test_s67hh', '--contig=100-100', '--copies=1', '--num_seqs=8', '--num_recycles=1', '--rm_aa=C', '--mpnn_sampling_temp=0.1', '--num_designs=1'], returncode=0)

参数说明:

5.显示最佳结果

def plot_pdb(num="best"):    if num == "best":        with open(f"/openbayes/home/outputs/{path}/best.pdb", "r") as f:            info = f.readline().strip('\n').split()        num = info[3]    hbondCutoff = 4.0    view = py3Dmol.view(js='https://3dmol.org/build/3Dmol.js')    pdb_str = open(f"/openbayes/home/outputs/{path}_{num}.pdb", 'r').read()    view.addModel(pdb_str, 'pdb', {'hbondCutoff': hbondCutoff})    pdb_str = open(f"/openbayes/home/outputs/{path}/best_design{num}.pdb", 'r').read()    view.addModel(pdb_str, 'pdb', {'hbondCutoff': hbondCutoff})    view.setStyle({"model": 0}, {'cartoon': {}})    view.setStyle({"model": 1}, {'cartoon': {'colorscheme': {'prop': 'b', 'gradient': 'roygb', 'min': 0, 'max': 100}}})    view.zoomTo()    view.show()if num_designs > 1:    def on_change(change):        if change['name'] == 'value':            with output:                output.clear_output(wait=True)                plot_pdb(change['new'])    dropdown = widgets.Dropdown(        options=["best"] + [str(k) for k in range(num_designs)],        value="best",        description='design:',    )    dropdown.observe(on_change)    output = widgets.Output()    display(widgets.VBox([dropdown, output]))    with output:        plot_pdb(dropdown.value)else:    plot_pdb()

2.6 打包和下载

def create_zip():    zip_path = f"{path}.result.zip"with zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED) as zipf:        for root, _, files in os.walk("outputs"):            for file in files:                if file.startswith(path):                    file_path = os.path.join(root, file)                    arcname = os.path.relpath(file_path, "outputs")                    zipf.write(file_path, arcname)                for root, _, files in os.walk("outputs/traj"):            for file in files:                if file.startswith(path):                    file_path = os.path.join(root, file)                    arcname = os.path.relpath(file_path, "outputs/traj")                    zipf.write(file_path, arcname)        return zip_pathtry:    zip_path = create_zip()    file_size = os.path.getsize(zip_path)/1024/1024        display(HTML(f'<b style="color:green">Compression completed!</b> File size: {file_size:.2f} MB'))    display(HTML(f'<b>Download link:</b> <a href="{zip_path}" download>{zip_path}</a>'))    except Exception as e:    display(HTML(f'<b style="color:red">An error occurred:</b> {str(e)}'))    display(HTML('Please check if the path exists: <code>!ls outputs/{path}*</code>'))

Compression completed! File size: 0.50 MB

Download link: test_s67hh.result.zip

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

RFdiffusion 蛋白质设计 AI 扩散模型 生物技术
相关文章