vivek9 commited on
Commit
6db04bb
·
verified ·
1 Parent(s): 7a9a856

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -12
app.py CHANGED
@@ -1,16 +1,84 @@
1
  import gradio as gr
2
  import pandas as pd
3
- import io
4
 
5
- def read_csv(csv_file):
6
- # Convert uploaded file data to pandas DataFrame
7
- df = pd.read_csv(csv_file.name)
8
- df.to_csv("result.csv")
9
- return df,"result.csv"
 
 
 
 
 
 
 
 
 
 
10
 
11
- iface = gr.Interface(fn=read_csv,
12
- inputs=gr.File(label="Upload CSV file"),
13
- outputs=["dataframe",gr.File(label="result")],
14
- title="CSV File Reader",
15
- description="Upload a CSV file and read its contents.")
16
- iface.launch(debug=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import pandas as pd
3
+ from utils import *
4
 
5
+ def demo(SPM_path_to_csv, SPM_identifier_column, SPM_sequence_column, SPM_sortby, SPM_sliding_window_min, SPM_sliding_window_max, SPM_min_gap, SPM_max_gap, SPM_S_support_thresh, SPM_I_support_thresh, SPM_dataset_format, DSM_path_to_csv_left, DSM_path_to_csv_right, DSM_identifier_column, DSM_sequence_column, DSM_sortby, DSM_sliding_window_min, DSM_sliding_window_max, DSM_min_gap, DSM_max_gap, DSM_S_support_thresh, DSM_I_support_thresh, DSM_threshold_pvalue, DSM_dataset_format, DSM_test_type,result_view):
6
+ # Your data processing logic here
7
+ result = {
8
+ "SPM": {"path_to_csv": SPM_path_to_csv.name, "identifier_column": SPM_identifier_column, "sequence_column": SPM_sequence_column, "sortby": SPM_sortby, "sliding_window_min": SPM_sliding_window_min, "sliding_window_max": SPM_sliding_window_max, "min_gap": SPM_min_gap, "max_gap": SPM_max_gap, "S_support_thresh": SPM_S_support_thresh, "I_support_thresh": SPM_I_support_thresh, "dataset_format": SPM_dataset_format},
9
+ "DSM": {"path_to_csv_left": DSM_path_to_csv_left.name, "path_to_csv_right": DSM_path_to_csv_right.name, "identifier_column": DSM_identifier_column, "sequence_column": DSM_sequence_column, "sortby": DSM_sortby, "sliding_window_min": DSM_sliding_window_min, "sliding_window_max": DSM_sliding_window_max, "min_gap": DSM_min_gap, "max_gap": DSM_max_gap, "S_support_thresh": DSM_S_support_thresh, "I_support_thresh": DSM_I_support_thresh, "threshold_pvalue": DSM_threshold_pvalue, "dataset_format": DSM_dataset_format, "test_type": DSM_test_type}
10
+ }
11
+ spm_result, occurrence_matrix = SPM(result["SPM"])
12
+ ptrn_left, ptrn_right, ptrn_both_left, ptrn_both_right, dsm_result = DSM(result["DSM"])
13
+ spm_result.to_csv("spm_result.csv")
14
+ dsm_result.to_csv("dsm_result.csv")
15
+ if result_view=="SPM":
16
+ re=spm_result
17
+ if result_view=="DSM":
18
+ re=dsm_result
19
+ return "spm_result.csv","dsm_result.csv",re
20
 
21
+ default_values = {
22
+ "SPM Upload CSV file": None,
23
+ "SPM_identifier_column": "Identifier",
24
+ "SPM_sequence_column": "Sequence",
25
+ "SPM_sortby": "S-Support",
26
+ "SPM_sliding_window_min": 1,
27
+ "SPM_sliding_window_max": 4,
28
+ "SPM_min_gap": 1,
29
+ "SPM_max_gap": 12,
30
+ "SPM_S_support_thresh": 0.4,
31
+ "SPM_I_support_thresh": 0,
32
+ "SPM_dataset_format": 0,
33
+ "DSM_path_to_csv_left": None,
34
+ "DSM_path_to_csv_right": None,
35
+ "DSM_identifier_column": "Identifier",
36
+ "DSM_sequence_column": "Sequence",
37
+ "DSM_sortby": "S-Support",
38
+ "DSM_sliding_window_min": 1,
39
+ "DSM_sliding_window_max": 1,
40
+ "DSM_min_gap": 1,
41
+ "DSM_max_gap": 12,
42
+ "DSM_S_support_thresh": 0.4,
43
+ "DSM_I_support_thresh": 0,
44
+ "DSM_threshold_pvalue": 0.1,
45
+ "DSM_dataset_format": 0,
46
+ "DSM_test_type": "ttest_ind",
47
+ "Select method for which you want to view result": "DSM"
48
+ }
49
+
50
+ interface = gr.Interface(
51
+ fn=process_data,
52
+ inputs=[
53
+ gr.File(label="SPM Upload CSV file"),
54
+ gr.Textbox(label="SPM identifier_column"),
55
+ gr.Textbox(label="SPM sequence_column"),
56
+ gr.Dropdown(label="SPM sortby", choices=["S-Support", "I-Support"]),
57
+ gr.Number(label="SPM sliding_window_min"),
58
+ gr.Number(label="SPM sliding_window_max"),
59
+ gr.Number(label="SPM min_gap"),
60
+ gr.Number(label="SPM max_gap"),
61
+ gr.Number(label="SPM S_support_thresh"),
62
+ gr.Number(label="SPM I_support_thresh"),
63
+ gr.Number(label="SPM dataset_format"),
64
+ gr.File(label="DSM Upload CSV file for left Dataset"),
65
+ gr.File(label="DSM Upload CSV file for right Dataset"),
66
+ gr.Textbox(label="DSM identifier_column"),
67
+ gr.Textbox(label="DSM sequence_column"),
68
+ gr.Dropdown(label="DSM sortby", choices=["S-Support", "I-Support"]),
69
+ gr.Number(label="DSM sliding_window_min"),
70
+ gr.Number(label="DSM sliding_window_max"),
71
+ gr.Number(label="DSM min_gap"),
72
+ gr.Number(label="DSM max_gap"),
73
+ gr.Number(label="DSM S_support_thresh"),
74
+ gr.Number(label="DSM I_support_thresh"),
75
+ gr.Number(label="DSM threshold_pvalue"),
76
+ gr.Number(label="DSM dataset_format"),
77
+ gr.Dropdown(label="DSM test_type", choices=["poisson_means_test", "ttest_ind", "mannwhitneyu", "bws_test", "ranksums", "brunnermunzel", "mood", "ansari", "cramervonmises_2samp", "epps_singleton_2samp", "ks_2samp", "kstest"]),
78
+ gr.Dropdown(label="Select method for which you want to view result", choices=["SPM", "DSM"])
79
+ ],
80
+ outputs=[gr.File(label="SPM result"),gr.File(label="DSM result"),"dataframe"],
81
+ title="SPM And DSM Implementation in Python",
82
+ defaults=default_values
83
+ )
84
+ interface.launch(debug=True)