Spaces:
Sleeping
Sleeping
Fix parsing of sequences and structures
Browse files- hexviz/view.py +11 -4
hexviz/view.py
CHANGED
@@ -81,20 +81,27 @@ def select_protein(pdb_code, uploaded_file, input_sequence):
|
|
81 |
pdb_str = uploaded_file.read().decode("utf-8")
|
82 |
st.session_state["uploaded_pdb_str"] = pdb_str
|
83 |
source = f"uploaded pdb file {uploaded_file.name}"
|
|
|
84 |
elif input_sequence:
|
85 |
pdb_str = get_pdb_from_seq(str(input_sequence))
|
86 |
-
if
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
89 |
elif "uploaded_pdb_str" in st.session_state:
|
90 |
pdb_str = st.session_state.uploaded_pdb_str
|
91 |
source = "Uploaded file stored in cache"
|
|
|
92 |
else:
|
93 |
file = get_pdb_file(pdb_code)
|
94 |
pdb_str = file.read()
|
95 |
source = f"PDB ID: {pdb_code}"
|
|
|
96 |
|
97 |
-
structure = parser.get_structure(pdb_code, StringIO(pdb_str))
|
98 |
return pdb_str, structure, source
|
99 |
|
100 |
|
|
|
81 |
pdb_str = uploaded_file.read().decode("utf-8")
|
82 |
st.session_state["uploaded_pdb_str"] = pdb_str
|
83 |
source = f"uploaded pdb file {uploaded_file.name}"
|
84 |
+
structure = parser.get_structure("Userfile", StringIO(pdb_str))
|
85 |
elif input_sequence:
|
86 |
pdb_str = get_pdb_from_seq(str(input_sequence))
|
87 |
+
if not pdb_str:
|
88 |
+
st.erros("ESMfold error, unable to fold sequence")
|
89 |
+
return None, None, None
|
90 |
+
else:
|
91 |
+
structure = parser.get_structure("ESMFold", StringIO(pdb_str))
|
92 |
+
if "selected_chains" in st.session_state:
|
93 |
+
del st.session_state.selected_chains
|
94 |
+
source = "Input sequence + ESM-fold"
|
95 |
elif "uploaded_pdb_str" in st.session_state:
|
96 |
pdb_str = st.session_state.uploaded_pdb_str
|
97 |
source = "Uploaded file stored in cache"
|
98 |
+
structure = parser.get_structure("userfile", StringIO(pdb_str))
|
99 |
else:
|
100 |
file = get_pdb_file(pdb_code)
|
101 |
pdb_str = file.read()
|
102 |
source = f"PDB ID: {pdb_code}"
|
103 |
+
structure = parser.get_structure(pdb_code, StringIO(pdb_str))
|
104 |
|
|
|
105 |
return pdb_str, structure, source
|
106 |
|
107 |
|