latticetower commited on
Commit
7ac370b
·
1 Parent(s): 694c1c6

update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -4
app.py CHANGED
@@ -1,7 +1,73 @@
1
  import gradio as gr
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import pandas as pd
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
 
6
+ from constants import *
 
7
 
8
+
9
+ from mpl_data_plotter import MatplotlibDataPlotter
10
+
11
+
12
+
13
+ single_df = pd.read_csv(SINGLE_DOMAINS_FILE, compression='gzip')
14
+ single_df['biosyn_class_index'] = single_df.bgc_class.apply(lambda x: BIOSYN_CLASS_NAMES.index(x))
15
+
16
+ pair_df = pd.read_csv(PAIR_DOMAINS_FILE, compression='gzip')
17
+ pair_df['biosyn_class_index'] = pair_df.bgc_class.apply(lambda x: BIOSYN_CLASS_NAMES.index(x))
18
+ # unique_domain_lengths = single_df.dom_location_len.unique()
19
+ num_domains_in_region_df = single_df.groupby('cds_region_id', as_index=False).agg({'as_domain_id': 'count'}).rename(
20
+ columns={'as_domain_id': 'num_domains'})
21
+
22
+ unique_domain_lengths = num_domains_in_region_df.num_domains.unique()
23
+
24
+
25
+ data_plotter = MatplotlibDataPlotter(single_df, pair_df, num_domains_in_region_df)
26
+
27
+
28
+ def update_all_plots(frequency, split_name='stratified'):
29
+ return data_plotter.plot_single_domains(frequency, split_name), data_plotter.plot_pair_domains(frequency, split_name)
30
+
31
+
32
+ # Create Gradio interface
33
+ with gr.Blocks(title="Interactive Wave Plotter") as demo:
34
+ gr.Markdown("## Interactive Wave Plotter")
35
+ gr.Markdown("Adjust the slider to change the frequency of all waves simultaneously.")
36
+
37
+ with gr.Row():
38
+ frequency_slider = gr.Slider(
39
+ minimum=unique_domain_lengths.min(),
40
+ maximum=unique_domain_lengths.max(),
41
+ step=1,
42
+ value=unique_domain_lengths.min(),
43
+ label="Min number of domains"
44
+ )
45
+
46
+ with gr.Row():
47
+ with gr.Column():
48
+ single_domains_plot = gr.Plot(
49
+ label="Single domains",
50
+ container=True,
51
+ elem_id="single_domains_plot"
52
+ )
53
+ # gr.HTML("""
54
+ # <style>
55
+ # #single_domains_plot {
56
+ # height: 100% !important;
57
+ # width: 100% !important;
58
+ # }
59
+ # </style>
60
+ # """)
61
+ with gr.Column():
62
+ pair_domains_plot = gr.Plot(label="Pair domains")
63
+ # with gr.Column():
64
+ # combined_plot = gr.Plot(label="Combined Wave")
65
+
66
+ frequency_slider.release(
67
+ fn=update_all_plots,
68
+ inputs=[frequency_slider],
69
+ outputs=[single_domains_plot, pair_domains_plot]#, cosine_plot]
70
+ )
71
+
72
+ demo.launch()
73
+ # demo.load(filter_map, [min_price, max_price, boroughs], map)