Spaces:
Sleeping
Sleeping
Retry fetching structure
Browse files- hexviz/attention.py +11 -3
hexviz/attention.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
from io import StringIO
|
2 |
from urllib import request
|
3 |
|
@@ -34,13 +35,20 @@ def get_pdb_file(pdb_code: str) -> Structure:
|
|
34 |
|
35 |
|
36 |
@st.cache
|
37 |
-
def get_pdb_from_seq(sequence: str) -> str:
|
38 |
"""
|
39 |
Get structure from sequence
|
40 |
"""
|
41 |
url = "https://api.esmatlas.com/foldSequence/v1/pdb/"
|
42 |
-
|
43 |
-
pdb_str =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
return pdb_str
|
45 |
|
46 |
|
|
|
1 |
+
import time
|
2 |
from io import StringIO
|
3 |
from urllib import request
|
4 |
|
|
|
35 |
|
36 |
|
37 |
@st.cache
|
38 |
+
def get_pdb_from_seq(sequence: str) -> str | None:
|
39 |
"""
|
40 |
Get structure from sequence
|
41 |
"""
|
42 |
url = "https://api.esmatlas.com/foldSequence/v1/pdb/"
|
43 |
+
retries = 0
|
44 |
+
pdb_str = None
|
45 |
+
while retries < 3 and pdb_str is None:
|
46 |
+
response = requests.post(url, data=sequence)
|
47 |
+
pdb_str = response.text
|
48 |
+
if pdb_str == "INTERNAL SERVER ERROR":
|
49 |
+
retries += 1
|
50 |
+
time.sleep(0.1)
|
51 |
+
pdb_str = None
|
52 |
return pdb_str
|
53 |
|
54 |
|