Learn how to get predictions from a BioLM endpoint, using ProteInfer as an example.
Introduction¶
Introduction to the BioLM.ai API and programmatic access to the platform.
Postman API Docs |
Python SDK Docs |
Set Your API Token¶
In order to use the BioLM API, you need to have a token. You can get one from the User API Tokens page.
Paste the API token you generated in the cell below, as the value
of the variable BIOLMAI_TOKEN
.
BIOLMAI_TOKEN = " " # !!! YOUR API TOKEN HERE !!!
When running notebooks on jupyter.biolm.ai, the files and execution environment are local. This uses an in-browser JupyterLite kernel, and any changes remain on your machine only.
Example API Call¶
We'll quickly demonstrate an API call to the ProteInfer-GO prediction endpoint.
We construct a payload matching the documentation
and then POST to the API with Python requests
.
GFP_SEQ = """
MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTL
VTTFSYGVQCFSRYPDHMKQHDFFKSAMPEGYVQERTIFFKDDGNYKTRAEVKFEGDTLV
NRIELKGIDFKEDGNILGHKLEYNYNSHNVYIMADKQKNGIKVNFKIRHNIEDGSVQLAD
HYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK
""".replace('\n', '').strip().upper()
data = {
"items": [
{
"sequence": GFP_SEQ
}
]
}
url = "https://biolm.ai/api/v2/proteinfer-go/predict/"
headers = {
"Content-Type": "application/json",
"Authorization": f"Token {BIOLMAI_TOKEN.strip()}",
}
Let's install requests
if running on jupyter.biolm.ai. If running this notebook locally or elsewhere, please make sure requests
is already installed in your Python environment.
from IPython.display import JSON # Helpful UI for JSON display
try:
# Install packages to make API requests in JLite
import micropip
await micropip.install('requests')
await micropip.install('pyodide-http')
# Patch requests for in-browser support
import pyodide_http
pyodide_http.patch_all()
except ModuleNotFoundError:
pass # Won't be using micropip outside of JLite
import requests # Will use to make calls to BioLM.ai
# Make the POST request
response = requests.post(
url=url,
headers=headers,
json=data,
)
result = response.json()
result
You can print these JSON results in an interactive format using iPython:
JSON(result)
Next Steps¶
Check out additional tutorials at jupyter.biolm.ai, or head over to our BioLM Documentation to explore additional models and functionality.
See more use-cases and APIs on your BioLM Console Catalog.¶
BioLM hosts deep learning models and runs inference at scale. You do the science.¶
Enzyme Engineering | Antibody Engineering | Biosecurity |
Single-Cell Genomics | DNA Sequence Modelling | Finetuning |
Contact us to learn more.¶