Spaces:
Running
Running
Update
Browse files- .ipynb_checkpoints/app-checkpoint.py +13 -17
- app.py +13 -17
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -184,42 +184,38 @@ def process_pdb(pdb_id):
|
|
184 |
pdb_path = fetch_pdb(pdb_id)
|
185 |
|
186 |
if not pdb_path:
|
187 |
-
return "Failed to fetch PDB file", None
|
188 |
-
|
189 |
# Extract protein sequence and chain
|
190 |
protein_sequence, chain = extract_protein_sequence(pdb_path)
|
191 |
|
192 |
if not protein_sequence:
|
193 |
-
return "No suitable protein sequence found", None
|
194 |
|
195 |
# Predict binding sites
|
196 |
sequence, normalized_scores = predict_protein_sequence(protein_sequence)
|
197 |
|
198 |
# Prepare representations for coloring residues
|
199 |
-
reps = [
|
200 |
-
|
201 |
-
# Map score to a color gradient from blue (low) to red (high)
|
202 |
-
color_intensity = int(score * 255)
|
203 |
-
color = f'rgb({color_intensity}, 0, {255-color_intensity})'
|
204 |
-
|
205 |
-
rep = {
|
206 |
"model": 0,
|
207 |
"chain": chain.id,
|
208 |
"resname": res,
|
209 |
-
"resnum": i,
|
210 |
"style": "cartoon",
|
211 |
-
"color":
|
212 |
-
"residue_range": f"{i}-{i}",
|
213 |
"around": 0,
|
214 |
"byres": True,
|
215 |
"visible": True
|
216 |
}
|
217 |
-
|
|
|
218 |
|
219 |
# Prepare result string
|
220 |
result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
|
221 |
|
222 |
-
return result_str,
|
223 |
|
224 |
# Create Gradio interface
|
225 |
with gr.Blocks() as demo:
|
@@ -253,7 +249,7 @@ with gr.Blocks() as demo:
|
|
253 |
predict_btn.click(
|
254 |
process_pdb,
|
255 |
inputs=[pdb_input],
|
256 |
-
outputs=[predictions_output, molecule_output
|
257 |
)
|
258 |
|
259 |
# Add some example inputs
|
@@ -265,7 +261,7 @@ with gr.Blocks() as demo:
|
|
265 |
["3TJN"]
|
266 |
],
|
267 |
inputs=[pdb_input],
|
268 |
-
outputs=[predictions_output, molecule_output
|
269 |
)
|
270 |
|
271 |
demo.launch(share=True)
|
|
|
184 |
pdb_path = fetch_pdb(pdb_id)
|
185 |
|
186 |
if not pdb_path:
|
187 |
+
return "Failed to fetch PDB file", None
|
188 |
+
|
189 |
# Extract protein sequence and chain
|
190 |
protein_sequence, chain = extract_protein_sequence(pdb_path)
|
191 |
|
192 |
if not protein_sequence:
|
193 |
+
return "No suitable protein sequence found", None
|
194 |
|
195 |
# Predict binding sites
|
196 |
sequence, normalized_scores = predict_protein_sequence(protein_sequence)
|
197 |
|
198 |
# Prepare representations for coloring residues
|
199 |
+
reps = [
|
200 |
+
{
|
|
|
|
|
|
|
|
|
|
|
201 |
"model": 0,
|
202 |
"chain": chain.id,
|
203 |
"resname": res,
|
204 |
+
"resnum": i+1,
|
205 |
"style": "cartoon",
|
206 |
+
"color": f'rgb({int(score * 255)}, 0, {int(255 - score * 255)})',
|
207 |
+
"residue_range": f"{i+1}-{i+1}",
|
208 |
"around": 0,
|
209 |
"byres": True,
|
210 |
"visible": True
|
211 |
}
|
212 |
+
for i, (res, score) in enumerate(zip(sequence, normalized_scores))
|
213 |
+
]
|
214 |
|
215 |
# Prepare result string
|
216 |
result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
|
217 |
|
218 |
+
return result_str, {"root": [pdb_path]}
|
219 |
|
220 |
# Create Gradio interface
|
221 |
with gr.Blocks() as demo:
|
|
|
249 |
predict_btn.click(
|
250 |
process_pdb,
|
251 |
inputs=[pdb_input],
|
252 |
+
outputs=[predictions_output, molecule_output]
|
253 |
)
|
254 |
|
255 |
# Add some example inputs
|
|
|
261 |
["3TJN"]
|
262 |
],
|
263 |
inputs=[pdb_input],
|
264 |
+
outputs=[predictions_output, molecule_output]
|
265 |
)
|
266 |
|
267 |
demo.launch(share=True)
|
app.py
CHANGED
@@ -184,42 +184,38 @@ def process_pdb(pdb_id):
|
|
184 |
pdb_path = fetch_pdb(pdb_id)
|
185 |
|
186 |
if not pdb_path:
|
187 |
-
return "Failed to fetch PDB file", None
|
188 |
-
|
189 |
# Extract protein sequence and chain
|
190 |
protein_sequence, chain = extract_protein_sequence(pdb_path)
|
191 |
|
192 |
if not protein_sequence:
|
193 |
-
return "No suitable protein sequence found", None
|
194 |
|
195 |
# Predict binding sites
|
196 |
sequence, normalized_scores = predict_protein_sequence(protein_sequence)
|
197 |
|
198 |
# Prepare representations for coloring residues
|
199 |
-
reps = [
|
200 |
-
|
201 |
-
# Map score to a color gradient from blue (low) to red (high)
|
202 |
-
color_intensity = int(score * 255)
|
203 |
-
color = f'rgb({color_intensity}, 0, {255-color_intensity})'
|
204 |
-
|
205 |
-
rep = {
|
206 |
"model": 0,
|
207 |
"chain": chain.id,
|
208 |
"resname": res,
|
209 |
-
"resnum": i,
|
210 |
"style": "cartoon",
|
211 |
-
"color":
|
212 |
-
"residue_range": f"{i}-{i}",
|
213 |
"around": 0,
|
214 |
"byres": True,
|
215 |
"visible": True
|
216 |
}
|
217 |
-
|
|
|
218 |
|
219 |
# Prepare result string
|
220 |
result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
|
221 |
|
222 |
-
return result_str,
|
223 |
|
224 |
# Create Gradio interface
|
225 |
with gr.Blocks() as demo:
|
@@ -253,7 +249,7 @@ with gr.Blocks() as demo:
|
|
253 |
predict_btn.click(
|
254 |
process_pdb,
|
255 |
inputs=[pdb_input],
|
256 |
-
outputs=[predictions_output, molecule_output
|
257 |
)
|
258 |
|
259 |
# Add some example inputs
|
@@ -265,7 +261,7 @@ with gr.Blocks() as demo:
|
|
265 |
["3TJN"]
|
266 |
],
|
267 |
inputs=[pdb_input],
|
268 |
-
outputs=[predictions_output, molecule_output
|
269 |
)
|
270 |
|
271 |
demo.launch(share=True)
|
|
|
184 |
pdb_path = fetch_pdb(pdb_id)
|
185 |
|
186 |
if not pdb_path:
|
187 |
+
return "Failed to fetch PDB file", None
|
188 |
+
|
189 |
# Extract protein sequence and chain
|
190 |
protein_sequence, chain = extract_protein_sequence(pdb_path)
|
191 |
|
192 |
if not protein_sequence:
|
193 |
+
return "No suitable protein sequence found", None
|
194 |
|
195 |
# Predict binding sites
|
196 |
sequence, normalized_scores = predict_protein_sequence(protein_sequence)
|
197 |
|
198 |
# Prepare representations for coloring residues
|
199 |
+
reps = [
|
200 |
+
{
|
|
|
|
|
|
|
|
|
|
|
201 |
"model": 0,
|
202 |
"chain": chain.id,
|
203 |
"resname": res,
|
204 |
+
"resnum": i+1,
|
205 |
"style": "cartoon",
|
206 |
+
"color": f'rgb({int(score * 255)}, 0, {int(255 - score * 255)})',
|
207 |
+
"residue_range": f"{i+1}-{i+1}",
|
208 |
"around": 0,
|
209 |
"byres": True,
|
210 |
"visible": True
|
211 |
}
|
212 |
+
for i, (res, score) in enumerate(zip(sequence, normalized_scores))
|
213 |
+
]
|
214 |
|
215 |
# Prepare result string
|
216 |
result_str = "\n".join([f"{aa}: {score:.2f}" for aa, score in zip(sequence, normalized_scores)])
|
217 |
|
218 |
+
return result_str, {"root": [pdb_path]}
|
219 |
|
220 |
# Create Gradio interface
|
221 |
with gr.Blocks() as demo:
|
|
|
249 |
predict_btn.click(
|
250 |
process_pdb,
|
251 |
inputs=[pdb_input],
|
252 |
+
outputs=[predictions_output, molecule_output]
|
253 |
)
|
254 |
|
255 |
# Add some example inputs
|
|
|
261 |
["3TJN"]
|
262 |
],
|
263 |
inputs=[pdb_input],
|
264 |
+
outputs=[predictions_output, molecule_output]
|
265 |
)
|
266 |
|
267 |
demo.launch(share=True)
|