Spaces:
Sleeping
Sleeping
Nazarshia2889
commited on
Commit
•
caf1c7c
1
Parent(s):
5fdf698
quick change
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import pandas as pd
|
|
7 |
st.title('Ravens AI')
|
8 |
|
9 |
# text input with label
|
10 |
-
sequence = st.text_input('Enter
|
11 |
|
12 |
model_type = st.radio(
|
13 |
"Choose Linear Epitope Classifier",
|
@@ -23,83 +23,83 @@ elif model_type == 'Linear T-Cells (MHC Class II Restriction)':
|
|
23 |
elif model_type == 'Linear B-Cell':
|
24 |
model = TFAutoModelForSequenceClassification.from_pretrained('bcell')
|
25 |
|
26 |
-
propep = st.radio(
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
if propep == 'Peptide':
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
else:
|
56 |
-
r = 18
|
57 |
-
g = 150
|
58 |
-
b = 6
|
59 |
-
|
60 |
-
return f'background-color: rgb({r}, {g}, {b})'
|
61 |
-
|
62 |
-
st.table(locations.style.applymap(color_survived, subset=['Probability']))
|
63 |
-
|
64 |
-
|
65 |
-
elif propep == 'Protein':
|
66 |
-
# windows length slider
|
67 |
-
length = st.slider('Window Length', 1, 50, 10)
|
68 |
-
threshold = st.slider('Probability Threshold', 0.0, 1.0, 0.75)
|
69 |
-
|
70 |
-
# submit button
|
71 |
-
if st.button('Submit'):
|
72 |
-
if(length > len(sequence)):
|
73 |
-
st.write("Please make sure that your window length is less than the sequence length!")
|
74 |
else:
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
7 |
st.title('Ravens AI')
|
8 |
|
9 |
# text input with label
|
10 |
+
sequence = st.text_input('Enter Peptide')
|
11 |
|
12 |
model_type = st.radio(
|
13 |
"Choose Linear Epitope Classifier",
|
|
|
23 |
elif model_type == 'Linear B-Cell':
|
24 |
model = TFAutoModelForSequenceClassification.from_pretrained('bcell')
|
25 |
|
26 |
+
# propep = st.radio(
|
27 |
+
# "Scan over an entire protein or run a peptide sequence?",
|
28 |
+
# ('Protein', 'Peptide'))
|
29 |
+
|
30 |
+
# if propep == 'Peptide':
|
31 |
+
threshold = st.slider('Probability Threshold', 0.0, 1.0, 0.5)
|
32 |
+
|
33 |
+
if st.button('Submit'):
|
34 |
+
locations = []
|
35 |
+
peptide_name = sequence
|
36 |
+
peptide = tokenizer(peptide_name, return_tensors="tf")
|
37 |
+
output = model(peptide)
|
38 |
+
locations.append([peptide_name, output.logits.numpy()[0][0]])
|
39 |
+
|
40 |
+
locations = pd.DataFrame(locations, columns = ['Peptide', 'Probability'])
|
41 |
+
|
42 |
+
# display table with sequence and probability as the headers
|
43 |
+
def color_survived(x: float): # x between 0 and 1
|
44 |
+
# red to green scale based on x
|
45 |
+
# 0 -> red
|
46 |
+
# 0.5 -> clear
|
47 |
+
# 1 -> green
|
48 |
+
|
49 |
+
# red
|
50 |
+
if x < threshold:
|
51 |
+
r = 179
|
52 |
+
g = 40
|
53 |
+
b = 2
|
54 |
+
# green
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
else:
|
56 |
+
r = 18
|
57 |
+
g = 150
|
58 |
+
b = 6
|
59 |
+
|
60 |
+
return f'background-color: rgb({r}, {g}, {b})'
|
61 |
+
|
62 |
+
st.table(locations.style.applymap(color_survived, subset=['Probability']))
|
63 |
+
|
64 |
+
|
65 |
+
# elif propep == 'Protein':
|
66 |
+
# # windows length slider
|
67 |
+
# length = st.slider('Window Length', 1, 50, 10)
|
68 |
+
# threshold = st.slider('Probability Threshold', 0.0, 1.0, 0.75)
|
69 |
+
|
70 |
+
# # submit button
|
71 |
+
# if st.button('Submit'):
|
72 |
+
# if(length > len(sequence)):
|
73 |
+
# st.write("Please make sure that your window length is less than the sequence length!")
|
74 |
+
# else:
|
75 |
+
# # run model
|
76 |
+
# locations = []
|
77 |
+
# for i in range(len(sequence) - length + 1):
|
78 |
+
# peptide_name = sequence[i:i+length]
|
79 |
+
# peptide = tokenizer(peptide_name, return_tensors="tf")
|
80 |
+
# output = model(peptide)
|
81 |
+
# locations.append([peptide_name, output.logits.numpy()[0][0]])
|
82 |
|
83 |
+
# locations = pd.DataFrame(locations, columns = ['Peptide', 'Probability'])
|
84 |
+
|
85 |
+
# # display table with sequence and probability as the headers
|
86 |
+
# def color_survived(x: float): # x between 0 and 1
|
87 |
+
# # red to green scale based on x
|
88 |
+
# # 0 -> red
|
89 |
+
# # 0.5 -> clear
|
90 |
+
# # 1 -> green
|
91 |
+
|
92 |
+
# # red
|
93 |
+
# if x < threshold:
|
94 |
+
# r = 179
|
95 |
+
# g = 40
|
96 |
+
# b = 2
|
97 |
+
# # green
|
98 |
+
# else:
|
99 |
+
# r = 18
|
100 |
+
# g = 150
|
101 |
+
# b = 6
|
102 |
+
|
103 |
+
# return f'background-color: rgb({r}, {g}, {b})'
|
104 |
+
|
105 |
+
# st.table(locations.style.applymap(color_survived, subset=['Probability']))
|