Spaces:
Runtime error
Runtime error
Add probabilistic profile prediction
Browse files
app.py
CHANGED
@@ -92,12 +92,48 @@ def Predict_profile(sequence, header = header,rem=rem,Hash1 = Hash1):
|
|
92 |
pred_Profile=np.delete(pred_Profile,rem,1)
|
93 |
return(pred_Profile)
|
94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
title="Protein sequence profile prediction using ProtAlbert transformer"
|
97 |
|
98 |
|
99 |
|
100 |
-
iface = gr.Interface(fn=
|
101 |
inputs=["text"],
|
102 |
outputs="text",
|
103 |
description="Please enter the sequence",
|
|
|
92 |
pred_Profile=np.delete(pred_Profile,rem,1)
|
93 |
return(pred_Profile)
|
94 |
|
95 |
+
def Predict_profile1(sequence, header = header,rem=rem,Hash1 = Hash1):
|
96 |
+
f=list()
|
97 |
+
f.append("PDBNO"+"\t")
|
98 |
+
for i in range(3,23):
|
99 |
+
f.append(header[i]+"\t")
|
100 |
+
f.append("X\n")
|
101 |
+
|
102 |
+
a = (len(Hash1),len(sequence))
|
103 |
+
pred_Profile=np.zeros(a)
|
104 |
+
for i in range(len(sequence)):
|
105 |
+
if i not in rem:
|
106 |
+
T=np.copy(list(sequence))
|
107 |
+
T=" ".join(T)
|
108 |
+
T=T.split(" ")
|
109 |
+
T[i]='[MASK]'
|
110 |
+
T=" ".join(T)
|
111 |
+
l=fill_mask(T)
|
112 |
+
number=len(l)
|
113 |
+
for k in range(number):
|
114 |
+
token=l[k]['token_str']
|
115 |
+
token=token.replace("▁","")
|
116 |
+
score=l[k]['score']
|
117 |
+
if token not in Hash1:
|
118 |
+
pred_Profile['X'][i]=pred_Profile['X'][i]+score
|
119 |
+
|
120 |
+
else:
|
121 |
+
pred_Profile[Hash1[token]][i]=score
|
122 |
+
f.append(str(i+1))
|
123 |
+
for k in range(len(Hash1)): #without X
|
124 |
+
f.append("\t"+str(pred_Profile[k][i]))
|
125 |
+
f.append("\n")
|
126 |
+
print(i)
|
127 |
+
if len(rem)!=0:
|
128 |
+
pred_Profile=np.delete(pred_Profile,rem,1)
|
129 |
+
return(pred_Profile)
|
130 |
+
|
131 |
|
132 |
title="Protein sequence profile prediction using ProtAlbert transformer"
|
133 |
|
134 |
|
135 |
|
136 |
+
iface = gr.Interface(fn=Predict_profile1,
|
137 |
inputs=["text"],
|
138 |
outputs="text",
|
139 |
description="Please enter the sequence",
|