-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfunctions.py
More file actions
31 lines (27 loc) · 1019 Bytes
/
functions.py
File metadata and controls
31 lines (27 loc) · 1019 Bytes
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
import pandas as pd
import csv
import openai
import subprocess
from openai import OpenAI
client = openai.OpenAI(
api_key = "COPY-API-KEY-HERE"
)
def zero_shot_predict(protein_name):
try:
sequence = ''
with open(protein_name + '.fasta', 'r') as file:
for line in file:
if not line.startswith(">"):
sequence += line.strip()
subprocess.run(['python', 'predict.py',
'--model-location', 'esm2_t36_3B_UR50D',
'--sequence', sequence,
'--dms-input', protein_name + '.csv',
'--mutation-col', 'mutant',
'--dms-output', protein_name + '_esm.csv',
'--offset-idx', '1',
'--scoring-strategy', 'masked-marginals'])
except ValueError:
return "zero-shot prediction failed error"
if __name__ == "__main__":
zero_shot_predict('AtHMT')