Spaces:
Sleeping
Sleeping
Update
Browse files- .ipynb_checkpoints/app-checkpoint.py +29 -6
- app.py +29 -6
.ipynb_checkpoints/app-checkpoint.py
CHANGED
|
@@ -54,6 +54,12 @@ def fetch_pdb(pdb_id):
|
|
| 54 |
return pdb_path
|
| 55 |
return None
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
# Extract sequence and predict binding scores
|
| 58 |
def process_pdb(pdb_id, segment):
|
| 59 |
pdb_path = fetch_pdb(pdb_id)
|
|
@@ -70,9 +76,11 @@ def process_pdb(pdb_id, segment):
|
|
| 70 |
with torch.no_grad():
|
| 71 |
outputs = model(input_ids).logits.detach().cpu().numpy().squeeze()
|
| 72 |
|
| 73 |
-
scores = outputs[:, 1] - outputs[:, 0]
|
|
|
|
|
|
|
| 74 |
result_str = "\n".join([
|
| 75 |
-
f"{res.get_resname()} {res.id[1]} {sequence[i]} {
|
| 76 |
for i, res in enumerate(chain)
|
| 77 |
])
|
| 78 |
|
|
@@ -86,10 +94,14 @@ with gr.Blocks() as demo:
|
|
| 86 |
gr.Markdown("# Protein Binding Site Prediction")
|
| 87 |
|
| 88 |
with gr.Row():
|
| 89 |
-
pdb_input = gr.Textbox(
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
molecule_output = Molecule3D(label="Protein Structure", reps=reps)
|
| 95 |
predictions_output = gr.Textbox(label="Binding Site Predictions")
|
|
@@ -102,4 +114,15 @@ with gr.Blocks() as demo:
|
|
| 102 |
outputs=[predictions_output, molecule_output, download_output]
|
| 103 |
)
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
demo.launch(share=True)
|
|
|
|
| 54 |
return pdb_path
|
| 55 |
return None
|
| 56 |
|
| 57 |
+
|
| 58 |
+
def normalize_scores(scores):
|
| 59 |
+
min_score = np.min(scores)
|
| 60 |
+
max_score = np.max(scores)
|
| 61 |
+
return (scores - min_score) / (max_score - min_score) if max_score > min_score else scores
|
| 62 |
+
|
| 63 |
# Extract sequence and predict binding scores
|
| 64 |
def process_pdb(pdb_id, segment):
|
| 65 |
pdb_path = fetch_pdb(pdb_id)
|
|
|
|
| 76 |
with torch.no_grad():
|
| 77 |
outputs = model(input_ids).logits.detach().cpu().numpy().squeeze()
|
| 78 |
|
| 79 |
+
scores = expit(outputs[:, 1] - outputs[:, 0])
|
| 80 |
+
normalized_scores = normalize_scores(scores)
|
| 81 |
+
|
| 82 |
result_str = "\n".join([
|
| 83 |
+
f"{res.get_resname()} {res.id[1]} {sequence[i]} {normalized_scores[i]:.2f}"
|
| 84 |
for i, res in enumerate(chain)
|
| 85 |
])
|
| 86 |
|
|
|
|
| 94 |
gr.Markdown("# Protein Binding Site Prediction")
|
| 95 |
|
| 96 |
with gr.Row():
|
| 97 |
+
pdb_input = gr.Textbox(value="2IWI",
|
| 98 |
+
label="PDB ID",
|
| 99 |
+
placeholder="Enter PDB ID here...")
|
| 100 |
+
segment_input = gr.Textbox(value="A",
|
| 101 |
+
label="Chain ID (Segment)",
|
| 102 |
+
placeholder="Enter Chain ID here...")
|
| 103 |
+
visualize_btn = gr.Button("Visualize Sructure")
|
| 104 |
+
prediction_btn = gr.Button("Predict Ligand Binding Site")
|
| 105 |
|
| 106 |
molecule_output = Molecule3D(label="Protein Structure", reps=reps)
|
| 107 |
predictions_output = gr.Textbox(label="Binding Site Predictions")
|
|
|
|
| 114 |
outputs=[predictions_output, molecule_output, download_output]
|
| 115 |
)
|
| 116 |
|
| 117 |
+
gr.Markdown("## Examples")
|
| 118 |
+
gr.Examples(
|
| 119 |
+
examples=[
|
| 120 |
+
["2IWI"],
|
| 121 |
+
["7RPZ"],
|
| 122 |
+
["3TJN"]
|
| 123 |
+
],
|
| 124 |
+
inputs=[pdb_input, segment_input],
|
| 125 |
+
outputs=[predictions_output, molecule_output, download_output]
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
demo.launch(share=True)
|
app.py
CHANGED
|
@@ -54,6 +54,12 @@ def fetch_pdb(pdb_id):
|
|
| 54 |
return pdb_path
|
| 55 |
return None
|
| 56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
# Extract sequence and predict binding scores
|
| 58 |
def process_pdb(pdb_id, segment):
|
| 59 |
pdb_path = fetch_pdb(pdb_id)
|
|
@@ -70,9 +76,11 @@ def process_pdb(pdb_id, segment):
|
|
| 70 |
with torch.no_grad():
|
| 71 |
outputs = model(input_ids).logits.detach().cpu().numpy().squeeze()
|
| 72 |
|
| 73 |
-
scores = outputs[:, 1] - outputs[:, 0]
|
|
|
|
|
|
|
| 74 |
result_str = "\n".join([
|
| 75 |
-
f"{res.get_resname()} {res.id[1]} {sequence[i]} {
|
| 76 |
for i, res in enumerate(chain)
|
| 77 |
])
|
| 78 |
|
|
@@ -86,10 +94,14 @@ with gr.Blocks() as demo:
|
|
| 86 |
gr.Markdown("# Protein Binding Site Prediction")
|
| 87 |
|
| 88 |
with gr.Row():
|
| 89 |
-
pdb_input = gr.Textbox(
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
molecule_output = Molecule3D(label="Protein Structure", reps=reps)
|
| 95 |
predictions_output = gr.Textbox(label="Binding Site Predictions")
|
|
@@ -102,4 +114,15 @@ with gr.Blocks() as demo:
|
|
| 102 |
outputs=[predictions_output, molecule_output, download_output]
|
| 103 |
)
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
demo.launch(share=True)
|
|
|
|
| 54 |
return pdb_path
|
| 55 |
return None
|
| 56 |
|
| 57 |
+
|
| 58 |
+
def normalize_scores(scores):
|
| 59 |
+
min_score = np.min(scores)
|
| 60 |
+
max_score = np.max(scores)
|
| 61 |
+
return (scores - min_score) / (max_score - min_score) if max_score > min_score else scores
|
| 62 |
+
|
| 63 |
# Extract sequence and predict binding scores
|
| 64 |
def process_pdb(pdb_id, segment):
|
| 65 |
pdb_path = fetch_pdb(pdb_id)
|
|
|
|
| 76 |
with torch.no_grad():
|
| 77 |
outputs = model(input_ids).logits.detach().cpu().numpy().squeeze()
|
| 78 |
|
| 79 |
+
scores = expit(outputs[:, 1] - outputs[:, 0])
|
| 80 |
+
normalized_scores = normalize_scores(scores)
|
| 81 |
+
|
| 82 |
result_str = "\n".join([
|
| 83 |
+
f"{res.get_resname()} {res.id[1]} {sequence[i]} {normalized_scores[i]:.2f}"
|
| 84 |
for i, res in enumerate(chain)
|
| 85 |
])
|
| 86 |
|
|
|
|
| 94 |
gr.Markdown("# Protein Binding Site Prediction")
|
| 95 |
|
| 96 |
with gr.Row():
|
| 97 |
+
pdb_input = gr.Textbox(value="2IWI",
|
| 98 |
+
label="PDB ID",
|
| 99 |
+
placeholder="Enter PDB ID here...")
|
| 100 |
+
segment_input = gr.Textbox(value="A",
|
| 101 |
+
label="Chain ID (Segment)",
|
| 102 |
+
placeholder="Enter Chain ID here...")
|
| 103 |
+
visualize_btn = gr.Button("Visualize Sructure")
|
| 104 |
+
prediction_btn = gr.Button("Predict Ligand Binding Site")
|
| 105 |
|
| 106 |
molecule_output = Molecule3D(label="Protein Structure", reps=reps)
|
| 107 |
predictions_output = gr.Textbox(label="Binding Site Predictions")
|
|
|
|
| 114 |
outputs=[predictions_output, molecule_output, download_output]
|
| 115 |
)
|
| 116 |
|
| 117 |
+
gr.Markdown("## Examples")
|
| 118 |
+
gr.Examples(
|
| 119 |
+
examples=[
|
| 120 |
+
["2IWI"],
|
| 121 |
+
["7RPZ"],
|
| 122 |
+
["3TJN"]
|
| 123 |
+
],
|
| 124 |
+
inputs=[pdb_input, segment_input],
|
| 125 |
+
outputs=[predictions_output, molecule_output, download_output]
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
demo.launch(share=True)
|