TEZv commited on
Commit
b617193
·
verified ·
1 Parent(s): 8c9adaf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -20
app.py CHANGED
@@ -11,6 +11,7 @@ from datetime import datetime
11
  from pathlib import Path
12
  import plotly.graph_objects as go
13
  import plotly.express as px
 
14
 
15
  # ========== Діагностичний друк ==========
16
  print("Gradio version:", gr.__version__)
@@ -39,21 +40,24 @@ def log_entry(tab, inputs, result, note=""):
39
  w.writerow({"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"),
40
  "tab": tab, "inputs": str(inputs),
41
  "result": str(result)[:200], "note": note})
42
- except Exception: pass
 
43
 
44
  def load_journal():
45
  try:
46
- if not LOG_PATH.exists():
47
  return "No entries yet."
48
  df = pd.read_csv(LOG_PATH)
49
  if df.empty:
50
  return "No entries yet."
51
  return df.tail(20).to_markdown(index=False)
52
- except Exception:
 
53
  return "Error loading journal."
54
 
55
  def save_note(note, tab):
56
- log_entry(tab, "manual note", note, note)
 
57
  return load_journal()
58
 
59
  def clear_journal():
@@ -608,7 +612,7 @@ body, .gradio-container {{ background: {BG} !important; color: {TXT} !important;
608
  background: {BG} !important;
609
  }}
610
 
611
- /* Контейнер вкладок всередині основної колонки */
612
  .main-tabs .tab-nav button {{
613
  color: {DIM} !important;
614
  background: {BG} !important;
@@ -633,6 +637,19 @@ body, .gradio-container {{ background: {BG} !important; color: {TXT} !important;
633
  padding: 14px !important;
634
  }}
635
 
 
 
 
 
 
 
 
 
 
 
 
 
 
636
  /* Стиль для badges */
637
  .proj-badge {{
638
  background: {CARD};
@@ -741,7 +758,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
741
  with gr.Tabs(elem_classes="main-tabs"):
742
  # R1 · Variant classification
743
  with gr.TabItem("R1 · Variant classification"):
744
- with gr.Tabs():
745
  # R1a · OpenVariant
746
  with gr.TabItem("R1a · OpenVariant"):
747
  gr.HTML(proj_badge("S1-A · R1a", "OpenVariant — SNV Pathogenicity Classifier", "AUC=0.939"))
@@ -771,7 +788,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
771
  with gr.Tabs(elem_classes="main-tabs"):
772
  # R1 · miRNA silencing
773
  with gr.TabItem("R1 · miRNA silencing"):
774
- with gr.Tabs():
775
  with gr.TabItem("R1a · BRCA2 miRNA"):
776
  gr.HTML(proj_badge("S1-B · R1a", "miRNA Silencing — BRCA1/2 · TP53"))
777
  g1 = gr.Dropdown(["BRCA2","BRCA1","TP53"], value="BRCA2", label="Gene")
@@ -781,7 +798,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
781
  b1.click(predict_mirna, [g1], o1)
782
  # R2 · siRNA SL
783
  with gr.TabItem("R2 · siRNA SL"):
784
- with gr.Tabs():
785
  with gr.TabItem("R2a · TP53 siRNA"):
786
  gr.HTML(proj_badge("S1-B · R2a", "siRNA Synthetic Lethal — TP53-null"))
787
  g2 = gr.Dropdown(["LUAD","BRCA","COAD"], value="LUAD", label="Cancer type")
@@ -791,7 +808,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
791
  b2.click(predict_sirna, [g2], o2)
792
  # R3 · lncRNA + ASO
793
  with gr.TabItem("R3 · lncRNA + ASO"):
794
- with gr.Tabs():
795
  with gr.TabItem("R3a · lncRNA-TREM2"):
796
  gr.HTML(proj_badge("S1-B · R3a", "lncRNA-TREM2 ceRNA Network"))
797
  b3a = gr.Button("Load ceRNA", variant="primary")
@@ -812,7 +829,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
812
  with gr.Tabs(elem_classes="main-tabs"):
813
  # R1 · RNA-directed drug
814
  with gr.TabItem("R1 · RNA-directed drug"):
815
- with gr.Tabs():
816
  with gr.TabItem("R1a · FGFR3 RNA Drug"):
817
  gr.HTML(proj_badge("S1-C · R1a", "FGFR3 RNA-Directed Drug Discovery", "top score 0.793"))
818
  g4 = gr.Radio(["P1 (hairpin loop)","P10 (G-quadruplex)"],
@@ -827,7 +844,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
827
  gr.Markdown("> In development. Coming soon.")
828
  # R2 · Frontier
829
  with gr.TabItem("R2 · Frontier"):
830
- with gr.Tabs():
831
  with gr.TabItem("R2a · m6A×Ferroptosis×Circadian 🔴⭐"):
832
  gr.HTML(proj_badge("S1-C · R2a", "m6A × Ferroptosis × Circadian", "🔴 Frontier"))
833
  gr.Markdown(
@@ -845,7 +862,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
845
  with gr.Tabs(elem_classes="main-tabs"):
846
  # R1 · Serum corona
847
  with gr.TabItem("R1 · Serum corona"):
848
- with gr.Tabs():
849
  with gr.TabItem("R1a · LNP Corona ML"):
850
  gr.HTML(proj_badge("S1-D · R1a", "LNP Protein Corona (Serum)", "AUC=0.791"))
851
  with gr.Row():
@@ -860,7 +877,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
860
  b6.click(predict_corona, [sz,zt,pg,lp], o6)
861
  # R2 · Flow corona
862
  with gr.TabItem("R2 · Flow corona"):
863
- with gr.Tabs():
864
  with gr.TabItem("R2a · Flow Corona"):
865
  gr.HTML(proj_badge("S1-D · R2a", "Flow Corona — Vroman Effect"))
866
  with gr.Row():
@@ -877,7 +894,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
877
  b8.click(predict_flow, [s8,z8,pg8,ch8,fl8], [o8t,o8p])
878
  # R3 · Brain BBB
879
  with gr.TabItem("R3 · Brain BBB"):
880
- with gr.Tabs():
881
  with gr.TabItem("R3a · LNP Brain"):
882
  gr.HTML(proj_badge("S1-D · R3a", "LNP Brain Delivery"))
883
  smi = gr.Textbox(label="Ionizable lipid SMILES",
@@ -892,7 +909,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
892
  b9.click(predict_bbb, [smi,pk,zt9], [o9t,o9p])
893
  # R4 · NLP
894
  with gr.TabItem("R4 · NLP"):
895
- with gr.Tabs():
896
  with gr.TabItem("R4a · AutoCorona NLP"):
897
  gr.HTML(proj_badge("S1-D · R4a", "AutoCorona NLP", "F1=0.71"))
898
  txt = gr.Textbox(lines=5,label="Paper abstract",placeholder="Paste abstract here...")
@@ -907,7 +924,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
907
  b10.click(extract_corona, txt, [o10j, o10f])
908
  # R5 · Exotic fluids
909
  with gr.TabItem("R5 · Exotic fluids 🔴⭐"):
910
- with gr.Tabs():
911
  with gr.TabItem("R5a · CSF/Vitreous/BM"):
912
  gr.HTML(proj_badge("S1-D · R5a", "LNP Corona in CSF · Vitreous · Bone Marrow", "🔴 0 prior studies"))
913
  gr.Markdown(
@@ -925,7 +942,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
925
  ))
926
  with gr.Tabs(elem_classes="main-tabs"):
927
  with gr.TabItem("R1 · Liquid biopsy"):
928
- with gr.Tabs():
929
  with gr.TabItem("R1a · Liquid Biopsy"):
930
  gr.HTML(proj_badge("S1-E · R1a", "Liquid Biopsy Classifier", "AUC=0.992*"))
931
  with gr.Row():
@@ -960,7 +977,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
960
  with gr.Tabs(elem_classes="main-tabs"):
961
  # R1 · DIPG
962
  with gr.TabItem("R1 · DIPG"):
963
- with gr.Tabs():
964
  with gr.TabItem("R1a · DIPG Toolkit"):
965
  gr.HTML(proj_badge("S1-F · R1a", "DIPG Toolkit", "PBTA · GSE126319"))
966
  gr.Markdown(
@@ -994,7 +1011,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
994
  )
995
  # R2 · UVM
996
  with gr.TabItem("R2 · UVM"):
997
- with gr.Tabs():
998
  with gr.TabItem("R2a · UVM Toolkit"):
999
  gr.HTML(proj_badge("S1-F · R2a", "UVM Toolkit", "TCGA-UVM n=80"))
1000
  gr.Markdown(
@@ -1024,7 +1041,7 @@ with gr.Blocks(css=css, title="K R&D Lab · S1 Biomedical") as demo:
1024
  )
1025
  # R3 · pAML
1026
  with gr.TabItem("R3 · pAML"):
1027
- with gr.Tabs():
1028
  with gr.TabItem("R3a · pAML Toolkit"):
1029
  gr.HTML(proj_badge("S1-F · R3a", "pAML Toolkit", "TARGET-AML n≈197"))
1030
  gr.Markdown(
 
11
  from pathlib import Path
12
  import plotly.graph_objects as go
13
  import plotly.express as px
14
+ import tabulate # для коректної роботи to_markdown()
15
 
16
  # ========== Діагностичний друк ==========
17
  print("Gradio version:", gr.__version__)
 
40
  w.writerow({"timestamp": datetime.now().strftime("%Y-%m-%d %H:%M"),
41
  "tab": tab, "inputs": str(inputs),
42
  "result": str(result)[:200], "note": note})
43
+ except Exception as e:
44
+ print(f"Log error: {e}")
45
 
46
  def load_journal():
47
  try:
48
+ if not LOG_PATH.exists() or LOG_PATH.stat().st_size == 0:
49
  return "No entries yet."
50
  df = pd.read_csv(LOG_PATH)
51
  if df.empty:
52
  return "No entries yet."
53
  return df.tail(20).to_markdown(index=False)
54
+ except Exception as e:
55
+ print(f"Journal load error: {e}")
56
  return "Error loading journal."
57
 
58
  def save_note(note, tab):
59
+ if note.strip():
60
+ log_entry(tab, "manual note", note, note)
61
  return load_journal()
62
 
63
  def clear_journal():
 
612
  background: {BG} !important;
613
  }}
614
 
615
+ /* Контейнер вкладок всередині основної колонки (R1, R2, ...) */
616
  .main-tabs .tab-nav button {{
617
  color: {DIM} !important;
618
  background: {BG} !important;
 
637
  padding: 14px !important;
638
  }}
639
 
640
+ /* Третій рівень вкладок (a, b) */
641
+ .sub-tabs .tab-nav button {{
642
+ color: {DIM} !important;
643
+ background: {CARD} !important;
644
+ font-size: 11px !important;
645
+ padding: 3px 8px !important;
646
+ border-radius: 3px 3px 0 0 !important;
647
+ }}
648
+ .sub-tabs .tab-nav button.selected {{
649
+ color: {ACC} !important;
650
+ background: {BG} !important;
651
+ }}
652
+
653
  /* Стиль для badges */
654
  .proj-badge {{
655
  background: {CARD};
 
758
  with gr.Tabs(elem_classes="main-tabs"):
759
  # R1 · Variant classification
760
  with gr.TabItem("R1 · Variant classification"):
761
+ with gr.Tabs(elem_classes="sub-tabs"):
762
  # R1a · OpenVariant
763
  with gr.TabItem("R1a · OpenVariant"):
764
  gr.HTML(proj_badge("S1-A · R1a", "OpenVariant — SNV Pathogenicity Classifier", "AUC=0.939"))
 
788
  with gr.Tabs(elem_classes="main-tabs"):
789
  # R1 · miRNA silencing
790
  with gr.TabItem("R1 · miRNA silencing"):
791
+ with gr.Tabs(elem_classes="sub-tabs"):
792
  with gr.TabItem("R1a · BRCA2 miRNA"):
793
  gr.HTML(proj_badge("S1-B · R1a", "miRNA Silencing — BRCA1/2 · TP53"))
794
  g1 = gr.Dropdown(["BRCA2","BRCA1","TP53"], value="BRCA2", label="Gene")
 
798
  b1.click(predict_mirna, [g1], o1)
799
  # R2 · siRNA SL
800
  with gr.TabItem("R2 · siRNA SL"):
801
+ with gr.Tabs(elem_classes="sub-tabs"):
802
  with gr.TabItem("R2a · TP53 siRNA"):
803
  gr.HTML(proj_badge("S1-B · R2a", "siRNA Synthetic Lethal — TP53-null"))
804
  g2 = gr.Dropdown(["LUAD","BRCA","COAD"], value="LUAD", label="Cancer type")
 
808
  b2.click(predict_sirna, [g2], o2)
809
  # R3 · lncRNA + ASO
810
  with gr.TabItem("R3 · lncRNA + ASO"):
811
+ with gr.Tabs(elem_classes="sub-tabs"):
812
  with gr.TabItem("R3a · lncRNA-TREM2"):
813
  gr.HTML(proj_badge("S1-B · R3a", "lncRNA-TREM2 ceRNA Network"))
814
  b3a = gr.Button("Load ceRNA", variant="primary")
 
829
  with gr.Tabs(elem_classes="main-tabs"):
830
  # R1 · RNA-directed drug
831
  with gr.TabItem("R1 · RNA-directed drug"):
832
+ with gr.Tabs(elem_classes="sub-tabs"):
833
  with gr.TabItem("R1a · FGFR3 RNA Drug"):
834
  gr.HTML(proj_badge("S1-C · R1a", "FGFR3 RNA-Directed Drug Discovery", "top score 0.793"))
835
  g4 = gr.Radio(["P1 (hairpin loop)","P10 (G-quadruplex)"],
 
844
  gr.Markdown("> In development. Coming soon.")
845
  # R2 · Frontier
846
  with gr.TabItem("R2 · Frontier"):
847
+ with gr.Tabs(elem_classes="sub-tabs"):
848
  with gr.TabItem("R2a · m6A×Ferroptosis×Circadian 🔴⭐"):
849
  gr.HTML(proj_badge("S1-C · R2a", "m6A × Ferroptosis × Circadian", "🔴 Frontier"))
850
  gr.Markdown(
 
862
  with gr.Tabs(elem_classes="main-tabs"):
863
  # R1 · Serum corona
864
  with gr.TabItem("R1 · Serum corona"):
865
+ with gr.Tabs(elem_classes="sub-tabs"):
866
  with gr.TabItem("R1a · LNP Corona ML"):
867
  gr.HTML(proj_badge("S1-D · R1a", "LNP Protein Corona (Serum)", "AUC=0.791"))
868
  with gr.Row():
 
877
  b6.click(predict_corona, [sz,zt,pg,lp], o6)
878
  # R2 · Flow corona
879
  with gr.TabItem("R2 · Flow corona"):
880
+ with gr.Tabs(elem_classes="sub-tabs"):
881
  with gr.TabItem("R2a · Flow Corona"):
882
  gr.HTML(proj_badge("S1-D · R2a", "Flow Corona — Vroman Effect"))
883
  with gr.Row():
 
894
  b8.click(predict_flow, [s8,z8,pg8,ch8,fl8], [o8t,o8p])
895
  # R3 · Brain BBB
896
  with gr.TabItem("R3 · Brain BBB"):
897
+ with gr.Tabs(elem_classes="sub-tabs"):
898
  with gr.TabItem("R3a · LNP Brain"):
899
  gr.HTML(proj_badge("S1-D · R3a", "LNP Brain Delivery"))
900
  smi = gr.Textbox(label="Ionizable lipid SMILES",
 
909
  b9.click(predict_bbb, [smi,pk,zt9], [o9t,o9p])
910
  # R4 · NLP
911
  with gr.TabItem("R4 · NLP"):
912
+ with gr.Tabs(elem_classes="sub-tabs"):
913
  with gr.TabItem("R4a · AutoCorona NLP"):
914
  gr.HTML(proj_badge("S1-D · R4a", "AutoCorona NLP", "F1=0.71"))
915
  txt = gr.Textbox(lines=5,label="Paper abstract",placeholder="Paste abstract here...")
 
924
  b10.click(extract_corona, txt, [o10j, o10f])
925
  # R5 · Exotic fluids
926
  with gr.TabItem("R5 · Exotic fluids 🔴⭐"):
927
+ with gr.Tabs(elem_classes="sub-tabs"):
928
  with gr.TabItem("R5a · CSF/Vitreous/BM"):
929
  gr.HTML(proj_badge("S1-D · R5a", "LNP Corona in CSF · Vitreous · Bone Marrow", "🔴 0 prior studies"))
930
  gr.Markdown(
 
942
  ))
943
  with gr.Tabs(elem_classes="main-tabs"):
944
  with gr.TabItem("R1 · Liquid biopsy"):
945
+ with gr.Tabs(elem_classes="sub-tabs"):
946
  with gr.TabItem("R1a · Liquid Biopsy"):
947
  gr.HTML(proj_badge("S1-E · R1a", "Liquid Biopsy Classifier", "AUC=0.992*"))
948
  with gr.Row():
 
977
  with gr.Tabs(elem_classes="main-tabs"):
978
  # R1 · DIPG
979
  with gr.TabItem("R1 · DIPG"):
980
+ with gr.Tabs(elem_classes="sub-tabs"):
981
  with gr.TabItem("R1a · DIPG Toolkit"):
982
  gr.HTML(proj_badge("S1-F · R1a", "DIPG Toolkit", "PBTA · GSE126319"))
983
  gr.Markdown(
 
1011
  )
1012
  # R2 · UVM
1013
  with gr.TabItem("R2 · UVM"):
1014
+ with gr.Tabs(elem_classes="sub-tabs"):
1015
  with gr.TabItem("R2a · UVM Toolkit"):
1016
  gr.HTML(proj_badge("S1-F · R2a", "UVM Toolkit", "TCGA-UVM n=80"))
1017
  gr.Markdown(
 
1041
  )
1042
  # R3 · pAML
1043
  with gr.TabItem("R3 · pAML"):
1044
+ with gr.Tabs(elem_classes="sub-tabs"):
1045
  with gr.TabItem("R3a · pAML Toolkit"):
1046
  gr.HTML(proj_badge("S1-F · R3a", "pAML Toolkit", "TARGET-AML n≈197"))
1047
  gr.Markdown(