File size: 2,418 Bytes
16e4ad5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4965d2c
 
 
 
 
 
16e4ad5
 
 
4965d2c
16e4ad5
 
 
 
 
 
 
 
 
 
 
 
 
3e00bd5
16e4ad5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4965d2c
16e4ad5
 
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
"""Master Gradio layout for the Pigeon Pea Pangenome Atlas."""

import gradio as gr

from ui.theme import build_theme, CUSTOM_CSS
from ui.quest0 import build_quest0
from ui.quest1 import build_quest1
from ui.quest2 import build_quest2
from ui.quest3 import build_quest3
from ui.quest4 import build_quest4
from ui.final import build_final_tab
from ui.gene_card_ui import build_gene_card_panel


def build_app(line_choices: list[str], contig_choices: list[str],
              gene_choices: list[str]) -> tuple:
    """
    Build the full Gradio Blocks app.

    Returns (demo, components_dict, theme, css) where:
      - demo is the gr.Blocks instance
      - components_dict maps all UI elements
      - theme is the Gradio theme object (pass to launch() for Gradio >= 6.0)
      - css is the custom CSS string (pass to launch() for Gradio >= 6.0)
    """
    theme = build_theme()

    with gr.Blocks(title="Pigeon Pea Pangenome Atlas") as demo:
        # State
        state = gr.State(value=None)

        # Header
        gr.Markdown("# Pigeon Pea Pangenome Atlas")
        gr.Markdown("*An interactive exploration of 89 pigeon pea lines and their pangenome*")

        # Main content area
        with gr.Row():
            # Main tabs (left ~75%)
            with gr.Column(scale=3):
                with gr.Tabs() as tabs:
                    q0 = build_quest0(line_choices)
                    q1 = build_quest1(line_choices)
                    q2 = build_quest2()
                    q3 = build_quest3(contig_choices)
                    q4 = build_quest4(gene_choices)
                    final = build_final_tab()

            # Gene Card side panel (right ~25%)
            gc = build_gene_card_panel()

        # Data Health accordion
        with gr.Accordion("Data Health", open=False, visible=True):
            data_health_html = gr.HTML(value="<p>Loading data health report...</p>")

    components = {
        "state": state,
        "tabs": tabs,
        "data_health_html": data_health_html,
        **{f"q0_{k}": v for k, v in q0.items()},
        **{f"q1_{k}": v for k, v in q1.items()},
        **{f"q2_{k}": v for k, v in q2.items()},
        **{f"q3_{k}": v for k, v in q3.items()},
        **{f"q4_{k}": v for k, v in q4.items()},
        **{f"final_{k}": v for k, v in final.items()},
        **{f"gc_{k}": v for k, v in gc.items()},
    }

    return demo, components, theme, CUSTOM_CSS