Spaces:
Running
Running
File size: 5,193 Bytes
81d9b6a 2f85a76 05b255c 81d9b6a e589553 81d9b6a 05b255c 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a ef142d3 81d9b6a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
import os
import gradio as gr
from genesis.pipeline import (
run_literature_review,
run_molecule_lookup,
run_pathway_analysis,
run_funding_analysis,
run_image_analysis
)
from genesis.visualization import generate_pathway_graph, generate_funding_network
from genesis.utils.pdf_export import export_report_to_pdf
# Load custom CSS
with open("genesis/static/style.css", "r") as f:
custom_css = f.read()
# App Title
APP_TITLE = "𧬠GENESIS-AI β The Synthetic Biology OS"
APP_DESCRIPTION = """
Your **multi-modal synthetic biology intelligence suite**.
Explore molecules, pathways, funding, literature, and images β with real-time AI insights.
"""
# =========================
# TAB FUNCTIONS
# =========================
def literature_tab(query):
"""Run literature review (PubMed, ChEMBL, BioPortal, UMLS)"""
summary, citations = run_literature_review(query)
pdf_path = export_report_to_pdf(
filename="literature_report.pdf",
title="Literature Review",
summary=summary,
citations=citations
)
return summary, citations, pdf_path
def molecule_tab(molecule_name):
"""Fetch molecule data from ChEMBL/NCBI & visualize"""
mol_data, mol_img = run_molecule_lookup(molecule_name)
pdf_path = export_report_to_pdf(
filename="molecule_report.pdf",
title="Molecule Report",
summary=mol_data
)
return mol_data, mol_img, pdf_path
def pathway_tab(pathway_name):
"""Run pathway analysis & generate graph"""
analysis = run_pathway_analysis(pathway_name)
graph_fig = generate_pathway_graph(pathway_name)
pdf_path = export_report_to_pdf(
filename="pathway_report.pdf",
title="Pathway Analysis",
summary=analysis
)
return analysis, graph_fig, pdf_path
def funding_tab(keyword):
"""Run funding analysis & generate investor graph"""
funding_info = run_funding_analysis(keyword)
funding_graph = generate_funding_network(keyword)
pdf_path = export_report_to_pdf(
filename="funding_report.pdf",
title="Funding Analysis",
summary=funding_info
)
return funding_info, funding_graph, pdf_path
def image_tab(image_file):
"""Run microscopy/image analysis"""
analysis_text = run_image_analysis(image_file)
pdf_path = export_report_to_pdf(
filename="image_report.pdf",
title="Image Analysis",
summary=analysis_text
)
return analysis_text, pdf_path
# =========================
# GRADIO UI
# =========================
with gr.Blocks(css=custom_css, theme="default") as demo:
gr.HTML(f"<h1>{APP_TITLE}</h1><p>{APP_DESCRIPTION}</p>")
with gr.Tabs():
# Literature Tab
with gr.Tab("π Literature Review"):
lit_query = gr.Textbox(label="Enter research question")
lit_summary = gr.Textbox(label="Summary", lines=8)
lit_citations = gr.Textbox(label="Citations", lines=5)
lit_pdf = gr.File(label="Download PDF")
lit_btn = gr.Button("Run Literature Review", variant="primary")
lit_btn.click(literature_tab, inputs=lit_query, outputs=[lit_summary, lit_citations, lit_pdf])
# Molecule Lookup
with gr.Tab("π§ͺ Molecule Viewer"):
mol_name = gr.Textbox(label="Enter molecule name / ChEMBL ID")
mol_info = gr.Textbox(label="Molecule Information", lines=8)
mol_img = gr.Image(label="Structure")
mol_pdf = gr.File(label="Download PDF")
mol_btn = gr.Button("Lookup Molecule", variant="primary")
mol_btn.click(molecule_tab, inputs=mol_name, outputs=[mol_info, mol_img, mol_pdf])
# Pathway Analysis
with gr.Tab("π¬ Pathway Analysis"):
path_name = gr.Textbox(label="Enter pathway name")
path_analysis = gr.Textbox(label="Pathway Analysis", lines=8)
path_graph = gr.Plot(label="Pathway Graph")
path_pdf = gr.File(label="Download PDF")
path_btn = gr.Button("Analyze Pathway", variant="primary")
path_btn.click(pathway_tab, inputs=path_name, outputs=[path_analysis, path_graph, path_pdf])
# Funding Network
with gr.Tab("π° Funding Explorer"):
fund_keyword = gr.Textbox(label="Enter biotech keyword")
fund_info = gr.Textbox(label="Funding Information", lines=8)
fund_graph = gr.Plot(label="Funding Network")
fund_pdf = gr.File(label="Download PDF")
fund_btn = gr.Button("Analyze Funding", variant="primary")
fund_btn.click(funding_tab, inputs=fund_keyword, outputs=[fund_info, fund_graph, fund_pdf])
# Image Analysis
with gr.Tab("πΌοΈ Image Analysis"):
img_upload = gr.Image(type="filepath", label="Upload microscopy or bio-image")
img_analysis = gr.Textbox(label="Image Analysis", lines=8)
img_pdf = gr.File(label="Download PDF")
img_btn = gr.Button("Analyze Image", variant="primary")
img_btn.click(image_tab, inputs=img_upload, outputs=[img_analysis, img_pdf])
demo.queue().launch(server_name="0.0.0.0", server_port=7860)
|