AlphaFold2 NIM 终端节点#

AlphaFold2 NIM 提供以下终端节点

  • protein-structure/alphafold2/predict-structure-from-sequence - 给定输入氨基酸序列,预测蛋白质结构。

  • protein-structure/alphafold2/predict-MSA-from-sequence - 执行多序列比对 (MSA),并返回用于 AlphaFold 推理的 MSA 和模板。此终端节点对于批量处理长时间运行的 MSA 推理非常有用。

  • protein-structure/alphafold2/predict-structure-from-MSA - 从输入 MSA 和模板执行结构预测。当使用预先计算的 MSA 时,这非常有用。

用法#

下面,我们概述了 API 的三个终端节点。我们给出了在 NIM 正确配置时应运行的请求的真实示例。

从输入序列预测结构#

predict-structure-from-sequence 提供完整的端到端结构预测管道。它只需要输入氨基酸序列,尽管有许多可调参数

  • sequence:有效的氨基酸序列。如果您不确定您的序列是否有效,请参阅氨基酸代码表。

  • databases:包含“uniref90”、“mgnify”和“small_bfd”中任何一个的列表。这些数据库包含用于生成多序列比对的序列,该比对用作 AlphaFold2 中结构预测神经网络的输入。一般来说,传递所有三个将提供最准确的结构预测,但代价是需要最长的运行时间。

  • algorithm:用于多序列比对的算法。目前,仅支持 jackhmmermmseqs2

  • e_value:用于过滤 MSA 中序列的序列 e 值。值越小越严格;包含的序列越少,但是,这也会降低 MSA 的灵敏度。默认值通常是一个不错的选择。此值的范围为 0 到 1。

  • bit_score:用于在 MSA 之前进行过滤的序列 bit-score。如果传递此值,则将其代替 e 值用于过滤。一个好的起点约为 200。此值大于零。

  • iterations:要执行的 MSA 迭代次数。一般来说,默认的 iterations=1 就足够了,并且花费的时间最少。

  • relax_prediction:设置为 True 以在预测后运行结构松弛。默认情况下将其设置为 True,这有助于修复预测结构中的冲突。

这是一个使用 cURL 查询序列和完整数据库集的示例

curl -X 'POST' \
    -i \
    "http://localhost:8000/protein-structure/alphafold2/predict-structure-from-sequence"  \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"sequence": "MNVIDIAIAMAI", "databases": ["uniref90", "mgnify", "small_bfd"]}'

这是相同的示例,但这次使用的是 python requests 模块。

import requests
import json

url = "http://localhost:8000/protein-structure/alphafold2/predict-structure-from-sequence"  
sequence = "MNVIDIAIAMAI"

headers = {
    "content-type": "application/json"
}

data = {
    "sequence": sequence,
    "databases": ["uniref90", "mgnify", "small_bfd"]
}

response = requests.post(url, headers=headers, data=json.dumps(data))

# Check if the request was successful
if response.ok:
    print("Request succeeded:", response.json())
else:
    print("Request failed:", response.status_code, response.text)

此终端节点的输出是 PDB 文件。PDB 格式可以使用 pymol 和其他查看程序轻松查看;有关文档和用法,请参阅 pymol 网站。

从输入序列预测 MSA#

predict-msa-from-sequence 终端节点生成用于结构预测的多序列比对和模板。如果您想在不同的节点上批量预测,这将非常有用。

以下是使用 cURL 的查询示例

curl -X 'POST' \
    -i \
    "http://localhost:8000/protein-structure/alphafold2/predict-msa-from-sequence"  \
    -H 'accept: application/json' \
    -H 'Content-Type: application/json' \
    -d '{"sequence": "MNVIDIAIAMAI", "databases": ["uniref90", "mgnify", "small_bfd"]}'

这是使用 requests 模块在 python 中的相同查询

import requests
import json

url = "http://0:8000/protein-structure/alphafold2/predict-msa-from-sequence"  # Replace with the actual URL
sequence = "STARWARSNVIDIAAAAAA"  # Replace with the actual sequence value

headers = {
    "content-type": "application/json"
}

data = {
    "sequence": sequence,
    "databases": ["uniref90", "mgnify", "small_bfd"]
}

response = requests.post(url, headers=headers, data=json.dumps(data))

# Check if the request was successful
if response.ok:
    print("Request succeeded:", response.json())
else:
    print("Request failed:", response.status_code, response.text)

predict-msa-from-sequence 终端节点采用以下参数

  • sequence:有效的氨基酸序列。如果您不确定您的序列是否有效,请参阅氨基酸代码表。

  • databases:包含“uniref90”、“mgnify”和“small_bfd”中任何一个的列表。这些数据库包含用于生成多序列比对的序列,该比对用作 AlphaFold2 中结构预测神经网络的输入。一般来说,传递所有三个将提供最准确的结构预测,但代价是需要最长的运行时间。如果您必须只选择一个,则 uniref90 被认为是最佳选择,但仍然建议使用所有三个数据库运行。

  • algorithm:用于多序列比对的算法。目前,仅支持 jackhmmer 和 mmseqs2。

  • e_value:用于过滤 MSA 中序列的序列 e 值。值越小越严格;包含的序列越少,但是,这也会降低 MSA 的灵敏度。默认值通常是一个不错的选择。此值的范围为 0 到 1。

  • bit_score:用于在 MSA 之前进行过滤的序列 bit-score。如果传递此值,则将其代替 e 值用于过滤。一个好的起点约为 200。此值大于零。

  • iterations:要执行的 MSA 迭代次数。一般来说,默认的 iterations=1 就足够了,并且花费的时间最少。

从输入 MSA 预测结构#

predict-structure-from-msa 终端节点采用 predict-msa-from-sequence 终端节点的结果并运行结构预测。

注意:我们不建议使用 CURL 运行 msa 到结构的预测。这是因为输入中包含需要在 bash 中仔细转义的字符。为了获得最佳用户体验,我们建议通过 python request 模块与此终端节点交互。

predict-structure-from-msa 终端节点采用以下参数

  • sequence:有效的氨基酸序列。如果您不确定您的序列是否有效,请参阅氨基酸代码表。

  • alignments:来自 predict-msa-from-sequence 的 MSA 结果。这是一种元组字典,格式为 {<db name> : {<db name>, <MSA output>, <MSA output format>}}

  • templates:来自结构数据库搜索的模板。这些模板采用 AlphaFold2 内部结构特定的格式;更多字段详细信息可以在此处找到

  • relax_prediction:设置为 True 以在预测后运行结构松弛。默认情况下将其设置为 True,这有助于修复预测结构中的冲突。

这是一个使用 python request 模块向 predict-structure-from-msa 终端节点发出请求的示例。

import requests
import json

url = "http://0:8000/protein-structure/alphafold2/predict-structure-from-msa"  # Replace with the actual URL
sequence = "STARWARSNVIDIAAAAAA"  # Replace with the actual sequence value


alignments = {'uniref90':
    ['uniref90', '# STOCKHOLM 1.0\n\n-151285509650596177 STARWARSNVIDIAAAAAA\n#=GC RF             xxxxxxxxxxxxxxxxxxx\n//\n', 'sto'],
    'small_bfd': ['small_bfd', '# STOCKHOLM 1.0\n\n-151285509650596177 STARWARSNVIDIAAAAAA\n#=GC RF             xxxxxxxxxxxxxxxxxxx\n//\n', 'sto']}
templates = [{'index': 1, 'name': '5X6U_E Ragulator complex protein LAMTOR3, Ragulator; Ragulator complex, scaffold, roadblock, lysosome; 2.4A {Homo sapiens}', 'aligned_cols': 10, 'sum_probs': 0.0, 'query': 'RSNVIDIAAA', 'hit_sequence': 'ASNIIDVSAA', 'indices_query': [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'index': 2, 'name': '5X6V_E Ragulator complex protein LAMTOR3, Ragulator; Ragulator Rag GTPase complex, scaffold; 2.02A {Homo sapiens}', 'aligned_cols': 10, 'sum_probs': 7.9, 'query': 'RSNVIDIAAA', 'hit_sequence': 'ASNIIDVSAA', 'indices_query': [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [23, 24, 25, 26, 27, 28, 29, 30, 31, 32]}, {'index': 3, 'name': '6EHP_E Ragulator complex protein LAMTOR3, Ragulator; Scaffolding complex, Rag-GTPase, mTOR, Ragulator; 2.3A {Homo sapiens}', 'aligned_cols': 10, 'sum_probs': 0.0, 'query': 'RSNVIDIAAA', 'hit_sequence': 'ASNIIDVSAA', 'indices_query': [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [45, 46, 47, 48, 49, 50, 51, 52, 53, 54]}, {'index': 4, 'name': '6EHR_E Ragulator complex protein LAMTOR3, Ragulator; Scaffolding complex, Rag-GTPases, mTOR, Ragulator; 2.898A {Homo sapiens}', 'aligned_cols': 10, 'sum_probs': 7.8, 'query': 'RSNVIDIAAA', 'hit_sequence': 'ASNIIDVSAA', 'indices_query': [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [45, 46, 47, 48, 49, 50, 51, 52, 53, 54]}, {'index': 5, 'name': '6CTD_B Large-conductance mechanosensitive channel; Channel Mechanosensitive Mycobacterium tuberculosis, MEMBRANE; 5.8A {Mycobacterium tuberculosis (strain ATCC 25177 / H37Ra)}', 'aligned_cols': 11, 'sum_probs': 8.7, 'query': 'ARSNVIDIAAA', 'hit_sequence': 'ARGNIVDLAVA', 'indices_query': [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]}, {'index': 6, 'name': '3HZQ_A Large-conductance mechanosensitive channel; intermediate state Mechanosensitive channel osmoregulation; 3.82A {Staphylococcus aureus subsp. aureus MW2}', 'aligned_cols': 11, 'sum_probs': 8.6, 'query': 'ARSNVIDIAAA', 'hit_sequence': 'LKGNVLDLAIA', 'indices_query': [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]}, {'index': 7, 'name': '6B9X_A Ragulator complex protein LAMTOR1, Ragulator; Ragulator, Lamtor, SIGNALING PROTEIN; 1.42A {Homo sapiens}', 'aligned_cols': 12, 'sum_probs': 0.0, 'query': 'WARSNVIDIAAA', 'hit_sequence': 'KTASNIIDVSAA', 'indices_query': [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]}, {'index': 8, 'name': '4V7H_BM Ribosome; eukaryotic ribosome, 80S, RACK1 protein; HET: OMC, PSU, 5MU, 1MA, OMG, 5MC, YYG, 7MG, 2MG, H2U, M2G; 8.9A {Thermomyces lanuginosus}', 'aligned_cols': 15, 'sum_probs': 9.1, 'query': 'RWARSNVIDIAAAAA', 'hit_sequence': 'GWKAAAAAAAAAAAA', 'indices_query': [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], 'indices_hit': [139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153]}, {'index': 9, 'name': '6QKP_A Nucleoid-associated protein Lsr2; Tuberculosis, DNA organisation, Transcriptional regulator; NMR {Mycobacterium tuberculosis (strain ATCC 25618 / H37Rv)}', 'aligned_cols': 12, 'sum_probs': 9.2, 'query': 'RWARSNVIDIAA', 'hit_sequence': 'EWARRNGHNVST', 'indices_query': [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 'indices_hit': [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]}, {'index': 10, 'name': "1QGN_F CYSTATHIONINE GAMMA-SYNTHASE; METHIONINE BIOSYNTHESIS, PYRIDOXAL 5'-PHOSPHATE, GAMMA-FAMILY; HET: PLP; 2.9A {Nicotiana tabacum} SCOP: c.67.1.3", 'aligned_cols': 10, 'sum_probs': 0.0, 'query': 'NVIDIAAAAA', 'hit_sequence': 'KAVDAAAAAA', 'indices_query': [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], 'indices_hit': [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]}, {'index': 11, 'name': '2OAR_E Large-conductance mechanosensitive channel; stretch activated ion channel mechanosensitive; 3.5A {Mycobacterium tuberculosis H37Ra} SCOP: f.16.1.1', 'aligned_cols': 11, 'sum_probs': 8.9, 'query': 'ARSNVIDIAAA', 'hit_sequence': 'ARGNIVDLAVA', 'indices_query': [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], 'indices_hit': [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42]}, {'index': 12, 'name': '5XKX_A Flavin-containing monooxygenase; Dimethylsulfoniopropionate (DMSP) lyase, LYASE; 1.5A {Acinetobacter bereziniae NIPH 3}', 'aligned_cols': 10, 'sum_probs': 8.0, 'query': 'ARWARSNVID', 'hit_sequence': 'TVWARTTAQD', 'indices_query': [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], 'indices_hit': [356, 357, 358, 359, 360, 361, 362, 363, 364, 365]}]

headers = {
    "content-type": "application/json"
}

data = {
    "sequence": sequence,
    "alignments": alignments,
    "templates": templates
}

response = requests.post(url, headers=headers, data=json.dumps(data))

# Check if the request was successful
if response.ok:
    print("Request succeeded:", response.json())
else:
    print("Request failed:", response.status_code, response.text)

结构预测模块的规模与序列长度呈二次方关系。长序列可能需要几个小时才能预测。