-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle.py
44 lines (37 loc) · 1.06 KB
/
single.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import requests
from dotenv import load_dotenv
from protein_utils import generate_random_protein_sequences
load_dotenv()
# API Config
url = 'https://api.ginkgobioworks.ai/v1/transforms/run'
api_key = os.getenv('GINKGO_API_KEY')
print(api_key)
transform = [{'type': 'FILL_MASK'}]
model = 'ginkgo-aa0-650M'
# Protein Sequence
seq_number = 5
seq_length = 400
add_mask = True
# Generate N masked sequences
protein_sequences = generate_random_protein_sequences(
seq_number, seq_length, add_mask)
# Make one transform request per seq
for sequence in protein_sequences:
payload = {
'model': model,
'text': sequence,
'transforms': transform
}
headers = {
'x-api-key': api_key,
'Content-Type': 'application/json'
}
# Make the POST request
response = requests.post(url, headers=headers, json=payload)
if response.ok:
data = response.json()
print(f"Running sequence: {sequence}")
print(f"Response: {data}")
else:
print(f"Error for sequence {sequence}: {response.text}")