Example Requests#
OpenFold2 NIM provides the following endpoint:
biology/openfold/openfold2/predict-structure-from-msa-and-template: Perform structure prediction from an input MSA and templates.
Usage#
Below, we give real examples of requests that should run when the NIM is correctly configured.
Note: We do not recommend submitting requests to this endpoint using the tool, curl, as its inputs have characters that require careful escaping in bash. We recommend interacting with this endpoint using the Python request module.
Predict Structure#
The endpoint accepts requests where the data is formatted as in the OpenApI Specification
Here is an example request using the Python requests module.
The field
sequenceis required.The field
alignmentsis optional, but omission can result in inaccurate structures. If included, the MSA content must be ina3mformat.The field
selected_modelsis optional, but included here to reduce runtime, since the default specifies 5 models.If you want to include templates, they must be in
hhrformat.
The following workflow is recommended when predicting structures for a given protein sequence.
Use other tools to produce multiple-sequence-alignments, and to put them in the
a3mformat.Use other tools, and potentially the MSA results from step 1 to generate template search results in an
hhrfileLoad the
a3mfiles andhhrfiles, in a Python script, and format the request as specified in the Open API specifications, included at the end of this documentation.
import os
import requests
import json
# --------------------------------
# parameters
# --------------------------------
url = "http://localhost:8000/biology/openfold/openfold2/predict-structure-from-msa-and-template"
headers = {"Content-Type": "application/json"}
sequence = (
"GGSKENEISHHAKEIERLQKEIERHKQSIKKLKQSEQSNPPPNP"
"EGTRQARRNRRRRWRERQRQKENEISHHAKEIERLQKEIERHKQSIKKLKQSEC"
)
uniref90_alignment_in_a3m_trunc10=\
""">BQXYMDHSRWGGVPIWVK
GGSKENEISHHAKEIERLQKEIERHKQSIKKLKQSEQSNPPPNPEGTRQARRNRRRRWRERQRQKENEISHHAKEIERLQKEIERHKQSIKKLKQSEC
>UniRef90_A0A221IUG4
--------------------------QTVKLVKRLYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
>UniRef90_A7KWE0
---------------------------TVRLIKQLYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
>UniRef90_A0A2I6UE91
---------------------------TVKLIKEIYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
>UniRef90_D6NY33
---------------------------AVRLIKQIYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
>UniRef90_A0A221IUJ5
--------------------------QTVKLIKRLYQSNPPPNPEGTRQARRNRRRRWREKQRQ----------------------------------
>UniRef90_D6NYR3
---------------------------TVRLVKQLYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
>UniRef90_I6Y2C4
---------------------------TVRLIKRIYQSNPPPNPEGTRQARRNRRRRWRERQRQIQN-------------------------------
>UniRef90_A0A161CVP3
--------------------------QTIRLIKLLYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
>UniRef90_Q6EFX9
--------------------------QTVRLIKLLYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
>UniRef90_A0A2I6UAR5
--------------------------ETVKIIKYLYQSNPPPNPEGTRQARRNRRRRWRERQRQ----------------------------------
"""
small_bfd_alignment_in_a3m = \
""">BQXYMDHSRWGGVPIWVK
GGSKENEISHHAKEIERLQKEIERHKQSIKKLKQSEQSNPPPNPEGTRQARRNRRRRWRERQRQKENEISHHAKEIERLQKEIERHKQSIKKLKQSEC
>A0A076V4A1_9HIV1
------------------------------------QSNPPPNHEGTRQARRNRRRRWRERQRQ----------------------------------
"""
# --------------------------------
# assemble request content
# --------------------------------
data = {
"sequence": sequence,
"selected_models": [1, 2],
"alignments": {
"uniref90": {
"a3m": {
"alignment": uniref90_alignment_in_a3m_trunc10,
"format": "a3m",
}
},
"small_bfd": {
"a3m": {
"alignment": small_bfd_alignment_in_a3m,
"format": "a3m",
}
}
},
}
# --------------------------------
# post-to-server
# --------------------------------
response = requests.post(
url=url,
data=json.dumps(data),
headers=headers,
timeout=300,
)
# Check if the request was successful
if response.ok:
print("Request succeeded:", response.json())
else:
print("Request failed:", response.status_code, response.text)
The runtime for structure prediction is impacted by both sequence length and the number of sequences in the multiple-sequence-alignment. On an `NVIDIA H100 80GB HBM3’ device, this example should complete in under 30 seconds.