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.

In [1]:
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.

In [2]:
GFP_SEQ = """
MSKGEELFTGVVPILVELDGDVNGHKFSVSGEGEGDATYGKLTLKFICTTGKLPVPWPTL
VTTFSYGVQCFSRYPDHMKQHDFFKSAMPEGYVQERTIFFKDDGNYKTRAEVKFEGDTLV
NRIELKGIDFKEDGNILGHKLEYNYNSHNVYIMADKQKNGIKVNFKIRHNIEDGSVQLAD
HYQQNTPIGDGPVLLPDNHYLSTQSALSKDPNEKRDHMVLLEFVTAAGITHGMDELYK
""".replace('\n', '').strip().upper()
In [3]:
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.

In [4]:
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
In [5]:
# Make the POST request
response = requests.post(
    url=url,
    headers=headers,
    json=data,
)

result = response.json()
result
Out[5]:
{'results': [{'sequence_id': '0',
   'predictions': [{'label': 'GO:0044237',
     'confidence': 1.0,
     'description': 'cellular metabolic process'},
    {'label': 'GO:0008152',
     'confidence': 1.0,
     'description': 'metabolic process'},
    {'label': 'GO:0044260',
     'confidence': 0.9999998807907104,
     'description': 'cellular macromolecule metabolic process'},
    {'label': 'GO:0043170',
     'confidence': 0.9999998807907104,
     'description': 'macromolecule metabolic process'},
    {'label': 'GO:0071704',
     'confidence': 0.9999966621398926,
     'description': 'organic substance metabolic process'},
    {'label': 'GO:0044267',
     'confidence': 0.9999923706054688,
     'description': 'cellular protein metabolic process'},
    {'label': 'GO:0019538',
     'confidence': 0.9999901056289673,
     'description': 'protein metabolic process'},
    {'label': 'GO:1901564',
     'confidence': 0.9999841451644897,
     'description': 'organonitrogen compound metabolic process'},
    {'label': 'GO:0018298',
     'confidence': 0.9999812841415405,
     'description': 'protein-chromophore linkage'},
    {'label': 'GO:0006807',
     'confidence': 0.9999734163284302,
     'description': 'nitrogen compound metabolic process'},
    {'label': 'GO:0008218',
     'confidence': 0.9998859167098999,
     'description': 'bioluminescence'},
    {'label': 'GO:0008150',
     'confidence': 0.9998503923416138,
     'description': 'biological_process'},
    {'label': 'GO:0006091',
     'confidence': 0.9998190999031067,
     'description': 'generation of precursor metabolites and energy'},
    {'label': 'GO:0009987',
     'confidence': 0.9994938373565674,
     'description': 'cellular process'},
    {'label': 'GO:0043412',
     'confidence': 0.9994738698005676,
     'description': 'macromolecule modification'},
    {'label': 'GO:0044238',
     'confidence': 0.9982783794403076,
     'description': 'primary metabolic process'},
    {'label': 'GO:0006464',
     'confidence': 0.9978099465370178,
     'description': 'cellular protein modification process'},
    {'label': 'GO:0036211',
     'confidence': 0.997657060623169,
     'description': 'protein modification process'},
    {'label': 'GO:0009056',
     'confidence': 0.2060231864452362,
     'description': 'catabolic process'}]}]}

You can print these JSON results in an interactive format using iPython:

In [6]:
JSON(result)
Out[6]:
<IPython.core.display.JSON object>

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.

In [ ]: