Update app.py
Browse files
app.py
CHANGED
|
@@ -42,16 +42,24 @@ def get_protein_image(pdbview):
|
|
| 42 |
pdbview.zoom(0.8)
|
| 43 |
pdbview.render()
|
| 44 |
|
| 45 |
-
#
|
| 46 |
png_base64 = pdbview.js().png()
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
if isinstance(png_base64, str):
|
| 51 |
return png_base64
|
| 52 |
-
|
|
|
|
| 53 |
return base64.b64encode(png_base64).decode('utf-8')
|
| 54 |
-
|
|
|
|
|
|
|
| 55 |
def perform_blast_analysis(sequence):
|
| 56 |
st.subheader('Protein Analysis')
|
| 57 |
with st.spinner("Analyzing generated protein... This may take a few minutes."):
|
|
|
|
| 42 |
pdbview.zoom(0.8)
|
| 43 |
pdbview.render()
|
| 44 |
|
| 45 |
+
# Use the JavaScript method to get the PNG data as a base64 encoded string
|
| 46 |
png_base64 = pdbview.js().png()
|
| 47 |
|
| 48 |
+
print(f"Type of png_base64: {type(png_base64)}")
|
| 49 |
+
print(f"Length of png_base64: {len(png_base64) if png_base64 else 'N/A'}")
|
| 50 |
+
|
| 51 |
+
if png_base64 is None:
|
| 52 |
+
raise ValueError("Failed to capture image data")
|
| 53 |
+
|
| 54 |
+
# If png_base64 is already a string, it's likely already base64 encoded
|
| 55 |
if isinstance(png_base64, str):
|
| 56 |
return png_base64
|
| 57 |
+
# If it's bytes, we need to encode it
|
| 58 |
+
elif isinstance(png_base64, bytes):
|
| 59 |
return base64.b64encode(png_base64).decode('utf-8')
|
| 60 |
+
else:
|
| 61 |
+
raise TypeError(f"Unexpected type for png_base64: {type(png_base64)}")
|
| 62 |
+
|
| 63 |
def perform_blast_analysis(sequence):
|
| 64 |
st.subheader('Protein Analysis')
|
| 65 |
with st.spinner("Analyzing generated protein... This may take a few minutes."):
|