Accelernate commited on
Commit
4600a7a
·
verified ·
1 Parent(s): d49830b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -40,7 +40,17 @@ def get_protein_image(pdbview):
40
  pdbview.zoom(0.8)
41
  pdbview.render()
42
  png = pdbview.pngImage()
43
- png_bytes = png.tostring() # Convert view to bytes
 
 
 
 
 
 
 
 
 
 
44
  return base64.b64encode(png_bytes).decode('utf-8')
45
 
46
  def perform_blast_analysis(sequence):
 
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
+ # Try to convert to bytes if possible
47
+ if hasattr(png, 'tobytes'):
48
+ png_bytes = png.tobytes()
49
+ elif hasattr(png, 'tostring'):
50
+ png_bytes = png.tostring()
51
+ else:
52
+ raise TypeError(f"Unable to convert {type(png)} to bytes")
53
+
54
  return base64.b64encode(png_bytes).decode('utf-8')
55
 
56
  def perform_blast_analysis(sequence):