@lijiang

Sculpting in time

Do one thing and do it well.
Every story has a beginning and an end.

对抗 CoVid-2019

使用树莓派搭建rosetta蛋白质折叠计算集群对抗CoVid-2019疾病

6 分钟

一段简短的视频请点击这里

2020-5-16

1

RaspberryPiImage

关于分布式计算项目

第一次接触分布式计算项目是在高中毕业的那段时间,用自己的笔记本跑过Boinc分布式计算平台,其中最著名的是seti@home, Boinc平台就是为这个项目而开发的。

分布式计算的思想就是主服务器将一个任务拆分成若干个小任务,将这些小任务分派给客户端进行运算,客户端运算完成之后将小任务结果发送给主服务器,主服务器将这些计算结果汇总而得到该任务的执行结果。

由于采用超级计算机进行计算的成本相当昂贵,并且在一些预测计算领域,可能最终的计算结果是以失败告终,所以有人发明出了利用个人闲置的计算机的计算资源,将这些资源连接成一个分布式的网格系统,计算资源的获取全部在这个网格系统中进行,由此演变出了很多的分布式计算项目。

关于 Rosetta 项目

rosetta@home这个项目主要是用来预测蛋白质的三维折叠结构。根据官网所说,Rosetta在预测特定蛋白质的形状时,其实就是在寻找具有最低能量的折叠,这一点很有意思,因为可以和数学物理学中关于能量的计算拉上关系,似乎自然界本身都是在以一种最基本的能量守恒和以最低的能量代价来稳定生命和物种的繁衍。因为对这种蛋白质折叠计算突然有了好奇心,并且也关注到DeepMind研发的AlphaFold采用人工智能的方式预测蛋白质的三维结构,所以买了两本生命科学的书来进行研究,后续出稍微偏专业向的文章。

引用一句英文原文的话

proteins are truly amazing machines: before they do their work, they assemble themselves.

蛋白质是一部非常让人感到惊讶的机器,他们在有效工作之前必须先自我装配成一种特定的形状.

重新回到Rosetta的计算方式上,预测蛋白质的折叠结构的计算方式:

  1. 程序会从没有任何折叠的链开始
  2. 移动链的一部分,产生新的新的形状,计算该形状下的能量
  3. 根据能量上的变化是否接受这次移动
  4. 重复2-3的过程直到链中的每一部分都移动了足够多的次数

最后程序会得到一个结构,该结构是目前该链序列下预测出来的最低能量形状,由于预测过程中采用的是随机移动链的部分,所以计算量是相当大的。在分布式计算过程中,客户端计算完每条链的最低能量状态,然后将其结果发送给服务端,然后科研人员对所有从客户端收集到该链的最低能量状态结构进行对比,得到最低的能量状态,这样也就完成了对该蛋白质折叠的预测。

第一本书是 《结构生物学 从原子到生命》 原书名称: 《Textbook of Structural Biology结构生物学 从原子到生命

Textbook of Structural Biology

第二本书 《蛋白质物理

单白质物理

其中与Rosetta类似的蛋白质折叠项目Folding@home也是一个分布式计算项目,两者的区别就是在于 Rosetta的目的的是预测出蛋白质的最终结构,Folding@home是计算蛋白质如何折叠的过程。两者的区别我还需要阅读生物学领域的相关专业书籍之后在做出具体的分析,后续会出相关的文章。

搭建 Raspberry Pi 分布式计算集群

Raspberry Pi RPI logo

目前总共由12台ARM开发板加入到了Rosetta计算中,其中有两台是Jetson Nano,因为目前的专注领域在人工智能,所以想多理解些生物领域方面的知识,因为最初的人工神经网络ANN就是从大脑的神经元计算模式抽象出来的。

目前集群的管理和应用编排采用的是kubernetes工具,操作系统安装的是Ubuntu Server Raspberry Pi, k8s的实现方案采用的是MicroK8s, 后续会考虑采用k3s的实现方案来管理更多的节点,比如节点扩展到20台Raspberry Pi

目前已经更新到20个RPI节点,集群管理系统采用k3s,这些小机器在结束Rosetta项目之后会用于Tensorflow,MXNet的分布式学习项目中。

目前集群的架构如下图,3 * (ETCD + Master) + HAProxy + 17 * Worker

ARM-Cluster

1,jpg

2,jpg

3.jpg

Boinc以DaemonSet的模式部署在各个开发板的节点上。

boinc-ds.yaml

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: boinc
  namespace: science
  labels:
    app: boinc
spec:
  selector:
    matchLabels:
      app: boinc
  template:
    metadata:
      labels:
        app: boinc
    spec:
      hostNetwork: true
      containers:
      - name: boinc
        image: localhost:32000/boinc/client:arm64v8
        env:
          - name: BOINC_CMD_LINE_OPTIONS
            value: "--allow_remote_gui_rpc"
        ports:
          - containerPort: 31416
            name: app-port
        volumeMounts:
          - name: boinc-database
            mountPath: /var/lib/boinc
      volumes:
        - name: boinc-database
          hostPath:
            path: /var/lib/boinc-k8s
            type: DirectoryOrCreate

ARM64v8 Docker Image

Dockerfile.arm64v8

Boinc Docker Github

FROM ubuntu:20.04

LABEL maintainer="BOINC" \
      description="A lightweight BOINC client on ARMv8 64-bit architecture."

# Global environment settings
ENV BOINC_GUI_RPC_PASSWORD="123" \
    BOINC_REMOTE_HOST="127.0.0.1" \
    BOINC_CMD_LINE_OPTIONS="" \
	DEBIAN_FRONTEND=noninteractive

# Copy files
COPY bin/ /usr/bin/

# Configure
WORKDIR /var/lib/boinc

# BOINC RPC port
EXPOSE 31416

# Install
RUN apt-get update && apt-get install -y --no-install-recommends \
# Install Time Zone Database
	tzdata \
# Install BOINC Client
    boinc-client && \
# Cleaning up
    apt-get autoremove -y && \
    rm -rf /var/lib/apt/lists/*

CMD ["start-boinc.sh"]

监控系统

监控系统采用 prometheus + grafana + node-exporter 监控各个节点的系统数据

Rosetta 项目任务的监控采用 prometheus pushgateway, 将数据加上标签推送到pushgateway中,由prometheus负责抓取。

rosettaMonitor.py

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu May  7 16:04:55 2020
pip install prometheus_client
@author: alexchen
"""

#!/bin/env python3
from prometheus_client import CollectorRegistry, Gauge, pushadd_to_gateway
from subprocess import check_output
import time


class rosettaTask():
    def __init__(self,servers=None):
        self.projinfo = {}
        self.finishedinfo = {}
        self.projrunninginfo = {}
        self.servers = servers
        self.pushgateway = "http://192.168.1.188:9091"

    def get_task_info(self,server):
    	# 通过shell命令抓取到相关任务的信息
        projcmd = "boinccmd  --host %s --passwd 123 --get_tasks | grep  WU | awk -F ':' '{print $2}'" % server
        statcmd = "boinccmd  --host %s --passwd 123 --get_tasks | grep scheduler  | awk -F ':' '{print $2}'" % server
        fractionstatcmd = "boinccmd  --host %s --passwd 123 --get_tasks | grep  fraction | awk -F ':' '{print $2}'" % server
	
        projs = check_output(projcmd,shell=True)
        status  = check_output(statcmd, shell=True)
        fractionstat = check_output(fractionstatcmd, shell=True)
        projs = projs.decode('utf-8').replace(' ','').split('\n')
        status = status.decode('utf-8').replace(' ','').split('\n')
        fractionstat = fractionstat.decode('utf-8').replace(' ','').split('\n')
        temp = []
        for i in range(len(projs)):
            if status[i] != '':
                self.projinfo[projs[i]] = status[i]
            if status[i] != "uninitialized" and status[i] != '':
	       #去除掉未运行的任务
               temp.append(projs[i])
        for i in range(len(temp)):
            self.projrunninginfo[temp[i]] = fractionstat[i]


    def runningTaskMonitor(self):
        registry = CollectorRegistry()
	# 添加两类metric (rosetta_tasks 和 rosetta_jobnum) 任务信息和任务数量
        g = Gauge("rosetta_tasks",'rosetta tasks monitor',['task','server'],registry=registry)
        h = Gauge("rosetta_jobnum", 'rosetta job numbers',['server'], registry=registry)
        for i in self.servers:
	    # 初始化任务信息列表
            self.projinfo = {}
            self.finishedinfo = {}
            self.projrunninginfo = {}

	    # 通过get_task_info得到任务信息赋值到信息列表中
            self.get_task_info(i)
            print(i)
            print(self.projrunninginfo)
            for key in self.projrunninginfo:
                task = key
                fractionstat = self.projrunninginfo[key]
                server = i
                print(task)
                print(fractionstat)
		# metric添加task server标签 统计正在运行的任务
                g.labels(task, server).set(fractionstat)
            print("job nums")
            print(len(self.projrunninginfo))
	    # 添加 server标签 统计正在运行的任务数量
            h.labels(i).set(len(self.projrunninginfo))
        pushadd_to_gateway(self.pushgateway,job='rosettainfo',registry=registry,timeout=20)



if __name__ == "__main__":
            servers = [
                        "192.168.1.108",
                        "192.168.1.112",
                        "192.168.1.113",
                        "192.168.1.114",
                        "192.168.1.115",
                        "192.168.1.116",
                        "192.168.1.117",
                        "192.168.1.120",
                        "192.168.1.121",
                        "192.168.1.122",
                        "192.168.1.123",
                        "192.168.1.124",
                        "192.168.1.125",
                        "192.168.1.126",
                        "192.168.1.127",
                        "192.168.1.129",
                        "192.168.1.130",
                        "192.168.1.131",
                        "192.168.1.132",
                        "192.168.1.107",
                        "192.168.1.118"]
            while True:
                task = rosettaTask(servers=servers)
                task.runningTaskMonitor()
                print("loop...")
                time.sleep(300)

监控图表展示

监控每台节点正在运行的任务数量和运行进度情况

rosettatasks1

监控每台节点的IO,SWAP等使用情况,系统负载,以及Raspberry Pi温度监控,当CPU 温度超过60摄氏度监控平台发送报警。

rosettaservers1

rosettaservers2

节点UPS Backup 电源

为了防止断电导致 Rosetta 任务数据丢失我购买了一台APC施耐德UPS不间断电源BK650-CH型号,为什么选择这台UPS主要是因为价格适中,并且配备数据传输接口,可以将数据接口连接到树莓派上通过apcupsd后台程序管理该UPS,并且apcupsd还可以集群化,配置一台master,其他所有slave节点连接该master获取电池状态,以便做出停电之后的响应操作。

3.jpg

master apcupsd.conf 配置 (master和UPS通过数据线连接):

UPSNAME rosetta
UPSCABLE usb
UPSTYPE usb
DEVICE
POLLTIME 10
LOCKFILE /var/lock
SCRIPTDIR /etc/apcupsd
PWRFAILDIR /etc/apcupsd
NOLOGINDIR /etc
ONBATTERYDELAY 6
BATTERYLEVEL 15
MINUTES 3
TIMEOUT 0
ANNOY 300
ANNOYDELAY 160
NOLOGON disable
KILLDELAY 60
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

slave apcupsd.conf 配置:

UPSNAME rosetta
UPSCABLE ether
UPSTYPE net
DEVICE 192.168.1.106 ## master 的节点地址 ##
POLLTIME 10
LOCKFILE /var/lock
SCRIPTDIR /etc/apcupsd
PWRFAILDIR /etc/apcupsd
NOLOGINDIR /etc
ONBATTERYDELAY 6
BATTERYLEVEL 25
MINUTES 4
TIMEOUT 0
ANNOY 300
ANNOYDELAY 30
NOLOGON disable
KILLDELAY 10
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0

为了防止rosetta的任务数据丢失在电池还有25%电力或者在支撑电力剩余4分钟时,Slave节点会启动 shutdown 调度任务将节点的boinc任务停止,然后节点进入关机状态。配置apcupsd的事件响应任务都在/etc/apcupsd/apccontrol文件中。

UPS监控图表

UPS_Stat_board

关于蛋白质的设计

Rosetta@home 是由华盛顿大学发起的计算项目,从他们的官网上可以了解有关于Rosetta对抗Covid-2019的最新消息,以下内容和理解来自他们的官方网站,有兴趣的朋友可以直接到达官方网站阅读更详细的信息。

Rosetta’s role in fighting coronavirus

Rosetta 在抗击Covid-2019中扮演的角色

We are happy to report that the Rosetta molecular modeling suite was recently used to accurately predict the atomic-scale structure of an important coronavirus protein weeks before it could be measured in the lab. Knowledge gained from studying this viral protein is now being used to guide the design of novel vaccines and antiviral drugs.

在实验室中被精准测定之前,Rosetta能够在分子层面建模精准预测出冠状病毒蛋白质的原子尺度的排列结构,通过对病毒携带的蛋白质的分析,可以更好的帮助我们研发疫苗和抗病毒药物。

Importantly, structural biologists are quickly gaining insights into what the proteins that make up this virus look like and how they function.

结构生物学者正在快速的发现冠状病毒中蛋白质的结构以及这些蛋白质的功能。

One viral protein in particular — the spike protein — allows SARS-CoV-2 to fuse its membrane with those on human cells, leading to infection. Researchers at UT Austin this week used cryo-electron microscopy to create the first 3D atomic-scale map of the SARS-CoV-2 spike protein in its prefusion state

病毒中的一种特定蛋白质 - 刺突蛋白 - 允许该病毒侵入人体的细胞使其感染,研究人员已经通过低温电子显微镜创建了该病毒在预融合状态下刺突蛋白的三维结构。 图中是Rosetta预测得到最优的刺突蛋白的三维结构图与实验室中在低温显微镜下观察得到的三维结构图相当吻合。 2020-02-24-at-9.15.03-AM-768x652.png

图片来源www.ipd.uw.edu

Coronavirus spike proteins — like the proteins found in your body — ‘fold up’ in order to function.

就像你身体内部的蛋白质一样,冠状病毒的蛋白质为了起到特定的作用必须先折叠起来。

Robetta是一个在线面向学术研究的基于Rosetta精准预测蛋白质结构的服务平台,早在2020.2月份,研究团队已经预测出刺突蛋白的三维结构,预测结果与后来实验室得到结果非常接近。

刺突蛋白的三维结构

spike-protein-structure

参考文献:

  1. Breakthrough in Coronavirus Research Results in New Map to Support Vaccine Design
  2. Cryo-EM structure of the 2019-nCoV spike in the prefusion conformation
  3. Massively parallel de novo protein design for targeted therapeutics

With this knowledge in hand, researchers at the Institute for Protein Design are now working to create new proteins to neutralize coronavirus. If successful, these antiviral proteins would stick to the SARS-CoV-2 spike protein and thereby prevent viral particles from infecting healthy cells

蛋白质设计机构的研究人员正在创建一种能够中和冠状病毒的新蛋白质,如果该项研究成功了,反病毒蛋白质将附着到SARS-CoV-2的刺突蛋白质上从而阻止病毒进入正常的细胞。

These new drug candidates — a type of molecule we call ‘mini-protein binders’ — seek to combine the specificity of antibodies with the high stability and manufacturability of small molecule drugs. Mini-protein binders are custom-designed on the computer to adhere only to specific targets, such as specific grooves on the SARS-CoV-2 spike protein.

这种类型的药物我们称之为 mini-protein binders,将特定的抗体与具有高度稳定性可制造性的小型分子药物结合得到mini-protein binders。mini-protein binders在计算机上进行计算和模拟使得能够附着在特定蛋白的表面,比如附着在SARS-CoV-2刺突蛋白的表面。下图显示设计中的miniprotein binder(粉色)与刺突蛋白结合。 具体内容可以参考Building 20,000 new drug candidates

Screen-Shot-2020-02-24-at-9.18.53-AM-768x628 图片来源www.ipd.uw.edu

Our researchers are now designing on the computer tens of thousands of anti-coronavirus mini-protein binders. In the coming weeks we hope to produce these mini-proteins in the lab and measure their ability to bind to spike protein. Following this, much more laboratory testing would still be needed to evaluate the safety and efficacy of these experimental coronavirus drugs.

研究人员现在设计出了成千上万种反病毒的miniprotein binder,在接下来的数周实验中,我们希望能够在实验室中制造出这些结合刺突蛋白的蛋白质。需要更多的测试来确定这些实验药物的安全性和有效性。

Designing coronavirus vaccines

设计冠状病毒的疫苗

Screen-Shot-2020-02-24-at-9.22.24-AM-400x398.png

图片来源www.ipd.uw.edu

This experimental SARS-CoV-2 vaccine was made by fusing multiple copies of the coronavirus spike protein (red) to the outside of a designed protein nanoparticle (orange and gray).

实验性的SARS-CoV-2疫苗是将多份冠状病毒的刺突蛋白结合到设计好的蛋白纳米颗粒的外部。

Volunteers rally to Rosetta@Home to stop COVID-19

志愿者联合起来对抗COVID-19

原文地址

Frost Science将计算机资源贡献出来用于对抗2019冠状病毒。

Frost-Planetarium-servers图片来源Frost Science

RosettaCommons 机构

RosettaCommons主要是开发Rosetta蛋白质建模程序的组织,该程序用于科研和商业项目。 以下内容详见: With an emergency meeting, RosettaCommons aims to accelerate COVID-19 research

计算机生成疫苗

Rosetta是快速开发疫苗的强有力工具,它已经被证明能够自动化精准的设计自定义免疫原。

论文1 论文2

设计抗病毒药物

The Fleichman lab at the Weizmann Institute of Science in Israel is working to automate the design of certain antivirals. Graduate student Jonathan Weinstein shared an update on their efforts to automatically design anti-coronavirus nanobodies. These natural proteins resemble antibodies, but are much smaller, potentially making them easier and cheaper to produce.

已经有研究机构自动设计出抗击冠状病毒纳米药物,这些自然的蛋白质类似抗体,但是非常小,这使得他们很容易制造并且成本低廉。

使用机器学习

DeepMind 开发的AlphaFold, 基于机器学习来预测蛋白质结构,相关文章阅读

后期文章中我会集中探讨在机器学习中预测蛋白质结构的有关知识的文章。

结束语

如果你对rosetta@home感兴趣并且想做出一份小小贡献,那么可以下载Boinc, 并且在添加项目里面选择rosetta@home,创建自己的账户,然后Boinc就会根据你的配置加载Rosetta主程序,下载资源包,开始它的计算之旅。

附上加入Rosetta@home项目的相关图片

1

2

3

最新文章

分类

关于

Keep thinking, Stay curious
Always be sensitive to new things