add 3d render
Browse files
app.py
CHANGED
@@ -480,6 +480,37 @@ def pdbsummary(name):
|
|
480 |
|
481 |
return answer
|
482 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
def create_interactive_table(df):
|
484 |
if df.empty:
|
485 |
return go.Figure()
|
@@ -707,6 +738,15 @@ app_ui = ui.page_fluid(
|
|
707 |
ui.output_text("sequence_output")
|
708 |
)
|
709 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
710 |
)
|
711 |
)
|
712 |
)
|
@@ -779,10 +819,23 @@ def server(input, output, session):
|
|
779 |
|
780 |
return "\n".join(output_text)
|
781 |
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
782 |
|
783 |
app = App(app_ui, server)
|
784 |
|
785 |
if __name__ == "__main__":
|
786 |
import nest_asyncio
|
787 |
nest_asyncio.apply()
|
788 |
-
app.run(host="0.0.0.0", port=7862)
|
|
|
|
|
|
480 |
|
481 |
return answer
|
482 |
|
483 |
+
|
484 |
+
def render_html(pdb_id, chain="A"):
|
485 |
+
if pdb_id is None or chain is None:
|
486 |
+
return ""
|
487 |
+
html_content = f"""
|
488 |
+
<html>
|
489 |
+
<header>
|
490 |
+
<script src="https://3Dmol.org/build/3Dmol-min.js"></script>
|
491 |
+
<script src="https://3Dmol.org/build/3Dmol.ui-min.js"></script>
|
492 |
+
</header>
|
493 |
+
<body>
|
494 |
+
<div style="height: 400px; position: relative;" class="viewer_3Dmoljs"
|
495 |
+
data-pdb="{pdb_id}"
|
496 |
+
data-backgroundalpha="0.0"
|
497 |
+
data-style="cartoon:color=white"
|
498 |
+
data-select1="chain:{chain}"
|
499 |
+
data-zoomto="chain:{chain}"
|
500 |
+
data-style1="cartoon:color=spectrum"
|
501 |
+
data-spin="axis:y;speed:0.2">
|
502 |
+
</div>
|
503 |
+
</body>
|
504 |
+
</html>
|
505 |
+
"""
|
506 |
+
iframe = f"""
|
507 |
+
<iframe style="width: 100%; height: 480px; border: none;"
|
508 |
+
srcdoc='{html_content}'>
|
509 |
+
</iframe>
|
510 |
+
"""
|
511 |
+
return iframe
|
512 |
+
|
513 |
+
|
514 |
def create_interactive_table(df):
|
515 |
if df.empty:
|
516 |
return go.Figure()
|
|
|
738 |
ui.output_text("sequence_output")
|
739 |
)
|
740 |
)
|
741 |
+
),
|
742 |
+
ui.row(
|
743 |
+
ui.column(12,
|
744 |
+
ui.div(
|
745 |
+
{"class": "3d-iframe", "id": "3d-iframe"}, # css 미설정
|
746 |
+
ui.h4("3D Rendering"),
|
747 |
+
ui.output_ui("output_iframe")
|
748 |
+
)
|
749 |
+
)
|
750 |
)
|
751 |
)
|
752 |
)
|
|
|
819 |
|
820 |
return "\n".join(output_text)
|
821 |
return ""
|
822 |
+
|
823 |
+
@output
|
824 |
+
@render.text
|
825 |
+
def output_iframe():
|
826 |
+
current_results = results_store.get()
|
827 |
+
if current_results["type"] == "structure":
|
828 |
+
pdb_id = current_results["results"][0]['PDB ID']
|
829 |
+
# chain 가져오는 건 아직
|
830 |
+
return render_html(pdb_id, "A")
|
831 |
+
else:
|
832 |
+
return ""
|
833 |
|
834 |
app = App(app_ui, server)
|
835 |
|
836 |
if __name__ == "__main__":
|
837 |
import nest_asyncio
|
838 |
nest_asyncio.apply()
|
839 |
+
app.run(host="0.0.0.0", port=7862)
|
840 |
+
|
841 |
+
|