Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,8 @@ from Bio.SeqRecord import SeqRecord
|
|
| 12 |
import time
|
| 13 |
import urllib.parse
|
| 14 |
import base64
|
|
|
|
|
|
|
| 15 |
|
| 16 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
| 17 |
|
|
@@ -40,16 +42,15 @@ def get_protein_image(pdbview):
|
|
| 40 |
pdbview.zoom(0.8)
|
| 41 |
pdbview.render()
|
| 42 |
png = pdbview.pngImage()
|
| 43 |
-
print(f"Type of png: {type(png)}")
|
| 44 |
-
print(f"Dir of png: {dir(png)}")
|
| 45 |
|
| 46 |
-
#
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
return base64.b64encode(png_bytes).decode('utf-8')
|
| 55 |
|
|
|
|
| 12 |
import time
|
| 13 |
import urllib.parse
|
| 14 |
import base64
|
| 15 |
+
from IPython.display import Image
|
| 16 |
+
import io
|
| 17 |
|
| 18 |
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
| 19 |
|
|
|
|
| 42 |
pdbview.zoom(0.8)
|
| 43 |
pdbview.render()
|
| 44 |
png = pdbview.pngImage()
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
# Convert to IPython Image
|
| 47 |
+
img = Image(png)
|
| 48 |
+
|
| 49 |
+
# Save to BytesIO
|
| 50 |
+
img_io = io.BytesIO()
|
| 51 |
+
img.save(img_io, format='PNG')
|
| 52 |
+
img_io.seek(0)
|
| 53 |
+
png_bytes = img_io.getvalue()
|
| 54 |
|
| 55 |
return base64.b64encode(png_bytes).decode('utf-8')
|
| 56 |
|