add 3d render
Browse files
app.py
CHANGED
@@ -492,6 +492,35 @@ def pdbsummary(name):
|
|
492 |
|
493 |
return answer
|
494 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
495 |
def create_interactive_table(df):
|
496 |
if df.empty:
|
497 |
return go.Figure()
|
@@ -724,6 +753,15 @@ app_ui = ui.page_fluid(
|
|
724 |
ui.output_text("sequence_output")
|
725 |
)
|
726 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
727 |
)
|
728 |
)
|
729 |
)
|
@@ -796,6 +834,17 @@ def server(input, output, session):
|
|
796 |
|
797 |
return "\n".join(output_text)
|
798 |
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
799 |
|
800 |
app = App(app_ui, server)
|
801 |
|
|
|
492 |
|
493 |
return answer
|
494 |
|
495 |
+
def render_html(pdb_id, chain="A"):
|
496 |
+
if pdb_id is None or chain is None:
|
497 |
+
return ""
|
498 |
+
html_content = f"""
|
499 |
+
<html>
|
500 |
+
<header>
|
501 |
+
<script src="https://3Dmol.org/build/3Dmol-min.js"></script>
|
502 |
+
<script src="https://3Dmol.org/build/3Dmol.ui-min.js"></script>
|
503 |
+
</header>
|
504 |
+
<body>
|
505 |
+
<div style="height: 400px; position: relative;" class="viewer_3Dmoljs"
|
506 |
+
data-pdb="{pdb_id}"
|
507 |
+
data-backgroundalpha="0.0"
|
508 |
+
data-style="cartoon:color=white"
|
509 |
+
data-select1="chain:{chain}"
|
510 |
+
data-zoomto="chain:{chain}"
|
511 |
+
data-style1="cartoon:color=spectrum"
|
512 |
+
data-spin="axis:y;speed:0.2">
|
513 |
+
</div>
|
514 |
+
</body>
|
515 |
+
</html>
|
516 |
+
"""
|
517 |
+
iframe = f"""
|
518 |
+
<iframe style="width: 100%; height: 480px; border: none;"
|
519 |
+
srcdoc='{html_content}'>
|
520 |
+
</iframe>
|
521 |
+
"""
|
522 |
+
return iframe
|
523 |
+
|
524 |
def create_interactive_table(df):
|
525 |
if df.empty:
|
526 |
return go.Figure()
|
|
|
753 |
ui.output_text("sequence_output")
|
754 |
)
|
755 |
)
|
756 |
+
),
|
757 |
+
ui.row(
|
758 |
+
ui.column(12,
|
759 |
+
ui.div(
|
760 |
+
{"class": "3d-iframe", "id": "3d-iframe"}, # css 미설정
|
761 |
+
ui.h4("3D Render"),
|
762 |
+
ui.output_ui("output_iframe")
|
763 |
+
)
|
764 |
+
)
|
765 |
)
|
766 |
)
|
767 |
)
|
|
|
834 |
|
835 |
return "\n".join(output_text)
|
836 |
return ""
|
837 |
+
|
838 |
+
@output
|
839 |
+
@render.text
|
840 |
+
def output_iframe():
|
841 |
+
current_results = results_store.get()
|
842 |
+
if current_results["type"] == "structure":
|
843 |
+
pdb_id = current_results["results"][0]['PDB ID']
|
844 |
+
# chain 가져오는 건 아직
|
845 |
+
return render_html(pdb_id, "A")
|
846 |
+
else:
|
847 |
+
return ""
|
848 |
|
849 |
app = App(app_ui, server)
|
850 |
|