BioLMTox API#

Chance Challacombe

Dec 26, 2023

6 min read

This page explains applications of BioLMTox and documents it’s usage for classification and embedding extraction on BioLM.

Endpoints#

The BioLM endpoint for BioLMTox is https://biolm.ai/api/v1/models/biolmtox_v1/<model_action>/.

Embedding API Usage#

The endpoint for BioLMTox embedding extraction is https://biolm.ai/api/v1/models/biolmtox_v1/transform/.

Making Requests#

curl --location 'https://biolm.ai/api/v1/models/biolmtox_v1/transform/' \
--header "Authorization: Token $BIOLMAI_TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"instances": [{
   "data": {"text": "MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARELGWQDIKVADNADNDALLRALQ"}
}]
}'
import requests
import json

url = "https://biolm.ai/api/v1/models/biolmtox_v1/transform/"

payload = json.dumps({
"instances": [
   {
      "data": {
      "text": "MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARELGWQDIKVADNADNDALLRALQ"
      }
   }
]
})
headers = {
'Authorization': 'Token {}'.format(os.environ['BIOLMAI_TOKEN']),
'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
import biolmai
seqs = [""MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARELGWQDIKVADNADNDALLRALQ"]

cls = biolmai.BioLMToxv1()
resp = cls.transform(seqs)
library(RCurl)
headers = c(
'Authorization' = paste('Token', Sys.getenv('BIOLMAI_TOKEN')),
"Content-Type" = "application/json"
)
params = "{
\"instances\": [
   {
      \"data\": {
      \"text\": \"MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARLGWQDIKVADNADNDALLRALQ"
      }
   }
]
}"
res <- postForm("https://biolm.ai/api/v1/models/biolmtox_v1/transform/", .opts=list(postfields = params, httpheader = headers, followlocation = TRUE), style = "httppost")
cat(res)

JSON Response#

Expand Example Response
{"predictions": [
[
    0.05734514817595482,
    -0.38758233189582825,
    0.14011333882808685,
    0.1311631053686142,
    0.6449017524719238,
    0.042671725153923035,
    0.04185352101922035,

Note

The above response is only a small snippet of the full JSON response. However, all the relevant response keys are included.

Request Definitions#

data:

Inside each instance, there’s a key named “data” that holds another dictionary. This dictionary contains the actual input data for the endpoint action.

text:

Inside the “data” dictionary, there’s a key named “text”. The value associated with “text” should be a string containing the amino acid sequence that the user wants to submit for toxin classification or embedding extraction.

Response Definitions#

predictions:

This is the main key in the JSON object that contains an array of embedding extraction results with one embedding array per sequence in the request

Prediction API Usage#

The endpoint for BioLMTox toxin classification is https://biolm.ai/api/v1/models/biolmtox_v1/predict/.

Making Requests#

curl --location 'https://biolm.ai/api/v1/models/biolmtox_v1/predict/' \
--header "Authorization: Token $BIOLMAI_TOKEN" \
--header 'Content-Type: application/json' \
--data '{
"instances": [{
   "data": {"text": "MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARELGWQDIKVADNADNDALLRALQ"}
}]
}'
import requests
import json

url = "https://biolm.ai/api/v1/models/biolmtox_v1/predict/"

payload = json.dumps({
"instances": [
   {
      "data": {
      "text": "MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARELGWQDIKVADNADNDALLRALQ"
      }
   }
]
})
headers = {
'Authorization': 'Token {}'.format(os.environ["BIOLMAI_TOKEN"]),
'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)
import biolmai
seqs = [""MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARELGWQDIKVADNADNDALLRALQ"]

cls = biolmai.BioLMToxv1()
resp = cls.predict(seqs)
library(RCurl)
headers = c(
'Authorization' = paste('Token', Sys.getenv('BIOLMAI_TOKEN')),
"Content-Type" = "application/json"
)
params = "{
\"instances\": [
   {
      \"data\": {
      \"text\": \"MSILVTRPSPAGEELVSRLRTLGQVAWHFPLIEFSPGQQLPQLADQLAALGESDLLFALSQHAVAFAQSQLHQQDRKWPRLPDYFAIGRTTALALHTVSGQKILYPQDREISEVLLQLPELQNIAGKRALILRGNGGRELIGDTLTARGAEVTFCECYQRCAIHYDGAEEAMRWQAREVTMVVVTSGEMLQQLWSLIPQWYREHWLLHCRLLVVSERLAKLARELGWQDIKVADNADNDALLRALQ\"
      }
   }
]
}"
res <- postForm("https://biolm.ai/api/v1/models/biolmtox_v1/predict/", .opts=list(postfields = params, httpheader = headers, followlocation = TRUE), style = "httppost")
cat(res)

JSON Response#

Expand Example Response
{"predictions": [
    {
    "label":"not toxin",
    "score":0.9998562335968018
    }
]
}

Request Definitions#

data:

Inside each instance, there’s a key named “data” that holds another dictionary. This dictionary contains the actual input data for the endpoint action.

text:

Inside the “data” dictionary, there’s a key named “text”. The value associated with “text” should be a string containing the amino acid sequence that the user wants to submit for toxin classification or embedding extraction.

Response Definitions#

predictions:

This is the main key in the JSON object that contains an array of prediction results. Each element in the array represents a set of predictions for one input instance.

label:

This key holds the predicted classification label for the input instance, it will be either toxin or not toxin

score:

The model score for predicted class label, the closer the score is to 1 the more confident the model is in the prediction.