fishankhan commited on
Commit
fbdaace
·
1 Parent(s): 33603cc

Initial protein predictor

Browse files
Files changed (3) hide show
  1. README.md +3 -0
  2. app.py +41 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -11,3 +11,6 @@ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
+
15
+ # Protein Structure Predictor
16
+ Predicts protein 3D structure from amino acid sequence using Facebook's ESMFold model.
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from transformers import EsmForProteinFolding, EsmTokenizer
4
+ import py3Dmol
5
+
6
+ # Load model
7
+ model = EsmForProteinFolding.from_pretrained("facebook/esmfold_v1")
8
+ tokenizer = EsmTokenizer.from_pretrained("facebook/esmfold_v1")
9
+
10
+ def predict_structure(sequence):
11
+ # Tokenize sequence
12
+ inputs = tokenizer(sequence, return_tensors="pt", add_special_tokens=False)
13
+
14
+ # Predict structure (ML happens here)
15
+ with torch.no_grad():
16
+ output = model(**inputs)
17
+
18
+ # Extract PDB string
19
+ pdb_str = output["pdb"]
20
+
21
+ # Visualize structure
22
+ viewer = py3Dmol.view(width=400, height=400)
23
+ viewer.addModel(pdb_str, "pdb")
24
+ viewer.setStyle({"cartoon": {"color": "spectrum"}})
25
+ viewer.zoomTo()
26
+
27
+ return viewer.show(), pdb_str
28
+
29
+ # Gradio UI
30
+ iface = gr.Interface(
31
+ fn=predict_structure,
32
+ inputs=gr.Textbox(label="Enter Amino Acid Sequence", placeholder="MKTAYIAKQRQISFVK..."),
33
+ outputs=[
34
+ gr.HTML(label="3D Structure"),
35
+ gr.Textbox(label="PDB Output")
36
+ ],
37
+ title="Protein Structure Prediction",
38
+ description="Enter a protein sequence to predict its 3D structure using ESMFold."
39
+ )
40
+
41
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ transformers
2
+ torch
3
+ py3Dmol
4
+ gradio