Make API Request¶
There is already a server on BioLM with ESMFold loaded into memory, so predictions should be fast. Let's import the requests library.
from IPython.display import JSON # Helpful UI for JSON display
import time
from biolmai import BioLM
import requests # Will use to make calls to BioLM.ai
import csv # To read example datalines = []
with open('data/protein/data/PLA2.csv', newline='') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
lines.append(row)
print(lines)Load the example toxin sequences from the CSV file
SEQ1 = lines[1][1]
SEQ2 = lines[2][1]print("Sequence length 1: {}".format(len(SEQ1)))
print("Sequence length 2: {}".format(len(SEQ2)))SEQ1 is https://www.uniprot.org/uniprotkb/Q45Z47/entry and SEQ2 is https://www.uniprot.org/uniprotkb/P82114/entry. Both are snake venoms
Let's make a secure REST API request to BioLM API to quickly make the prediction on GPU.
# Make the request - let's time it!
start = time.time()
result = BioLM(entity="biolmtox2", action="predict", type="sequence", items=SEQ1)
end = time.time()
print(f"BioLMTox prediction took {end - start:.4f} seconds.")
# If you wish to view the full result, you can expand the tree in the cell below
JSON(result)There are keys for each input instance containing:
label, the predicted class label either 'toxin' or 'not toxin'score, the model score for the outputed label, the closer to one the more confident the model is in its predction
The label is toxin with a high score of 0.999 which matches the true label! This sequence is infact Phospholipase A2 OS2 a venom protein from the taipan snake.
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.¶
Contact us to learn more.¶
<span></span>