Spaces:
Sleeping
Sleeping
Nazarshia2889
commited on
Commit
•
ac3d524
1
Parent(s):
3fae50d
model update
Browse files- app.py +37 -34
- bcell/tf_model.h5 +1 -1
app.py
CHANGED
@@ -4,7 +4,7 @@ from transformers import AutoTokenizer
|
|
4 |
import pandas as pd
|
5 |
|
6 |
# title
|
7 |
-
st.title('
|
8 |
|
9 |
# text input with label
|
10 |
sequence = st.text_input('Enter Amino Acid Sequence')
|
@@ -14,8 +14,8 @@ model_type = st.radio(
|
|
14 |
('Linear T-Cells (MHC Class I Restriction)', 'Linear T-Cells (MHC Class II Restriction)', 'Linear B-Cell'))
|
15 |
|
16 |
# windows length slider
|
17 |
-
length = st.slider('Window Length', 1,
|
18 |
-
threshold = st.slider('Probability Threshold', 0.0, 1.0, 0.
|
19 |
|
20 |
model_checkpoint = "facebook/esm2_t6_8M_UR50D"
|
21 |
|
@@ -29,34 +29,37 @@ elif model_type == 'Linear B-Cell':
|
|
29 |
model = TFAutoModelForSequenceClassification.from_pretrained('bcell')
|
30 |
# submit button
|
31 |
if st.button('Submit'):
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
#
|
46 |
-
# 0
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
4 |
import pandas as pd
|
5 |
|
6 |
# title
|
7 |
+
st.title('Ravens AI')
|
8 |
|
9 |
# text input with label
|
10 |
sequence = st.text_input('Enter Amino Acid Sequence')
|
|
|
14 |
('Linear T-Cells (MHC Class I Restriction)', 'Linear T-Cells (MHC Class II Restriction)', 'Linear B-Cell'))
|
15 |
|
16 |
# windows length slider
|
17 |
+
length = st.slider('Window Length', 1, 50, 10)
|
18 |
+
threshold = st.slider('Probability Threshold', 0.0, 1.0, 0.75)
|
19 |
|
20 |
model_checkpoint = "facebook/esm2_t6_8M_UR50D"
|
21 |
|
|
|
29 |
model = TFAutoModelForSequenceClassification.from_pretrained('bcell')
|
30 |
# submit button
|
31 |
if st.button('Submit'):
|
32 |
+
if(length > len(sequence)):
|
33 |
+
st.write("Please make sure that your window length is less than the sequence length!")
|
34 |
+
else:
|
35 |
+
# run model
|
36 |
+
locations = []
|
37 |
+
for i in range(len(sequence) - length + 1):
|
38 |
+
peptide_name = sequence[i:i+length]
|
39 |
+
peptide = tokenizer(peptide_name, return_tensors="tf")
|
40 |
+
output = model(peptide)
|
41 |
+
locations.append([peptide_name, output.logits.numpy()[0][0]])
|
42 |
+
|
43 |
+
locations = pd.DataFrame(locations, columns = ['Peptide', 'Probability'])
|
44 |
+
|
45 |
+
# display table with sequence and probability as the headers
|
46 |
+
def color_survived(x: float): # x between 0 and 1
|
47 |
+
# red to green scale based on x
|
48 |
+
# 0 -> red
|
49 |
+
# 0.5 -> clear
|
50 |
+
# 1 -> green
|
51 |
+
|
52 |
+
# red
|
53 |
+
if x < threshold:
|
54 |
+
r = 179
|
55 |
+
g = 40
|
56 |
+
b = 2
|
57 |
+
# green
|
58 |
+
else:
|
59 |
+
r = 18
|
60 |
+
g = 150
|
61 |
+
b = 6
|
62 |
+
|
63 |
+
return f'background-color: rgb({r}, {g}, {b})'
|
64 |
+
|
65 |
+
st.table(locations.style.applymap(color_survived, subset=['Probability']))
|
bcell/tf_model.h5
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 30211508
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4e1cffc07e744025c7efe0ae8a4e3081fbb5f68f6b9c88b3ccfe0b96979929f1
|
3 |
size 30211508
|