Accelernate commited on
Commit
c3a875f
·
verified ·
1 Parent(s): 4de56ba

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -23
app.py CHANGED
@@ -13,18 +13,15 @@ def generate_sequence_from_words(words, length):
13
  return ''.join(random.choice(amino_acids) for _ in range(length))
14
 
15
  def predict_structure(sequence):
16
- url = "https://api.colabfold.com/batch"
17
- data = {
18
- "queries": [["query", sequence]],
19
- "num_relax": 0,
20
- "use_templates": False,
21
- "num_models": 1
22
- }
23
- response = requests.post(url, json=data)
24
  if response.status_code == 200:
25
- return response.json()
26
  else:
27
- st.error(f"Error in structure prediction: {response.text}")
28
  return None
29
 
30
  def visualize_protein(pdb_string):
@@ -43,7 +40,7 @@ word3 = st.text_input("Word 3")
43
 
44
  sequence_length = st.number_input("Enter desired sequence length",
45
  min_value=50,
46
- max_value=200,
47
  value=100,
48
  step=10)
49
 
@@ -56,23 +53,15 @@ if st.button("Generate Sequence and Predict Structure"):
56
 
57
  st.header("Protein Structure Prediction")
58
  with st.spinner("Predicting protein structure... This may take a few minutes."):
59
- prediction = predict_structure(sequence)
60
- if prediction and 'pdb_string' in prediction[0]:
61
- pdb_string = prediction[0]['pdb_string']
62
  view = visualize_protein(pdb_string)
63
 
64
  st_py3dmol = py3Dmol.show3d(view, width=800, height=400)
65
  st.components.v1.html(st_py3dmol.startjs, height=400)
66
 
67
- # Display confidence scores
68
- plddt_scores = prediction[0].get('plddt', [])
69
- if plddt_scores:
70
- avg_plddt = sum(plddt_scores) / len(plddt_scores)
71
- st.write(f"Average pLDDT score: {avg_plddt:.2f}")
72
- st.write("pLDDT > 90: Very high confidence")
73
- st.write("90 > pLDDT > 70: Confident")
74
- st.write("70 > pLDDT > 50: Low confidence")
75
- st.write("pLDDT < 50: Very low confidence")
76
  else:
77
  st.error("Failed to predict structure. Please try again.")
78
  else:
 
13
  return ''.join(random.choice(amino_acids) for _ in range(length))
14
 
15
  def predict_structure(sequence):
16
+ url = "https://api.esmatlas.com/foldSequence/v1/pdb/"
17
+ headers = {"Content-Type": "application/x-www-form-urlencoded"}
18
+ data = {"sequence": sequence}
19
+
20
+ response = requests.post(url, headers=headers, data=data, timeout=300)
 
 
 
21
  if response.status_code == 200:
22
+ return response.text
23
  else:
24
+ st.error(f"Error in structure prediction: {response.status_code} - {response.text}")
25
  return None
26
 
27
  def visualize_protein(pdb_string):
 
40
 
41
  sequence_length = st.number_input("Enter desired sequence length",
42
  min_value=50,
43
+ max_value=400,
44
  value=100,
45
  step=10)
46
 
 
53
 
54
  st.header("Protein Structure Prediction")
55
  with st.spinner("Predicting protein structure... This may take a few minutes."):
56
+ pdb_string = predict_structure(sequence)
57
+ if pdb_string:
 
58
  view = visualize_protein(pdb_string)
59
 
60
  st_py3dmol = py3Dmol.show3d(view, width=800, height=400)
61
  st.components.v1.html(st_py3dmol.startjs, height=400)
62
 
63
+ st.success("Structure prediction complete!")
64
+ st.write("Note: This is a computational prediction and may not represent the actual biological structure.")
 
 
 
 
 
 
 
65
  else:
66
  st.error("Failed to predict structure. Please try again.")
67
  else: