Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,6 +58,7 @@ def inject_bfactors_and_save(pdb_file, scores_list, component_indices):
|
|
| 58 |
|
| 59 |
return output_paths
|
| 60 |
|
|
|
|
| 61 |
def render_structure(pdb_path):
|
| 62 |
with open(pdb_path, 'r') as f:
|
| 63 |
pdb_data = f.read()
|
|
@@ -65,14 +66,15 @@ def render_structure(pdb_path):
|
|
| 65 |
view.addModel(pdb_data, 'pdb')
|
| 66 |
view.setStyle({'cartoon': {'color': 'bfactor'}})
|
| 67 |
view.zoomTo()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
-
# Embed the 3Dmol.js script manually
|
| 70 |
-
html = f'''
|
| 71 |
-
<div id="viewer"></div>
|
| 72 |
-
<script src="https://3Dmol.org/build/3Dmol.js"></script>
|
| 73 |
-
{view._make_html().split("<script>")[1]} <!-- extracts inner viewer JS only -->
|
| 74 |
-
'''
|
| 75 |
-
return html
|
| 76 |
|
| 77 |
|
| 78 |
# Gradio UI
|
|
|
|
| 58 |
|
| 59 |
return output_paths
|
| 60 |
|
| 61 |
+
#--render the structure images
|
| 62 |
def render_structure(pdb_path):
|
| 63 |
with open(pdb_path, 'r') as f:
|
| 64 |
pdb_data = f.read()
|
|
|
|
| 66 |
view.addModel(pdb_data, 'pdb')
|
| 67 |
view.setStyle({'cartoon': {'color': 'bfactor'}})
|
| 68 |
view.zoomTo()
|
| 69 |
+
|
| 70 |
+
# Safely embed viewer + required 3Dmol.js script
|
| 71 |
+
viewer_html = view._make_html()
|
| 72 |
+
full_html = (
|
| 73 |
+
'<script src="https://3Dmol.org/build/3Dmol.js"></script>\n'
|
| 74 |
+
+ viewer_html
|
| 75 |
+
)
|
| 76 |
+
return full_html
|
| 77 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
|
| 80 |
# Gradio UI
|